Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
More (currently failing) tests for preprocessor stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
hdamron17 committed May 26, 2020
1 parent b8bab0a commit c58ef37
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lex/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1649,12 +1649,17 @@ int main(){}
let assert_same_stringified = |cpp: &str, cpp_src: &str| {
assert_same_exact(
&format!("#define xstr(a) #a\nxstr({})", cpp),
&format!("\n{}", cpp_src));
&format!("\n{}", cpp_src),
);
};
assert_same_stringified("a + b", r#""a + b""#);
assert_same_stringified(r#"b +"c""#, r#""b +\"c\"""#);
assert_same_stringified(r#""+\\+\n+\"+""#, r#""\"+\\\\+\\n+\\\"+\"""#);
assert_same_stringified(r#""\'""#, r#""\"\\'\""#); // TODO figure out why ' is different
// TODO test unicode chars
assert_same_stringified(r#""\'""#, r#""\"\\'\""#);
assert_same_stringified(
r#""\a+\b+\e+\f+\r+\v+\?""#,
r#""\"\\a+\\b+\\e+\\f+\\r+\\v+\\?\"""#,
);
assert_same_stringified(r#""\x3f""#, r#""\"\\x3f\"""#);
}
}

0 comments on commit c58ef37

Please sign in to comment.