2012-07-04 16:53:12 -05:00
|
|
|
//! Escapes text sequences
|
2012-03-16 14:20:29 -05:00
|
|
|
|
|
|
|
export mk_pass;
|
|
|
|
|
|
|
|
fn mk_pass() -> pass {
|
|
|
|
text_pass::mk_pass("escape", escape)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn escape(s: str) -> str {
|
|
|
|
str::replace(s, "\\", "\\\\")
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn should_escape_backslashes() {
|
|
|
|
let s = "\\n";
|
|
|
|
let r = escape(s);
|
|
|
|
assert r == "\\\\n";
|
|
|
|
}
|