Skip to content

Commit

Permalink
Add more comprehensive tests for unnecessary string escapes
Browse files Browse the repository at this point in the history
  • Loading branch information
josephfrazier committed May 10, 2017
1 parent 15d32d8 commit f04b200
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/quotes/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,19 @@ exports[`strings.js 1`] = `
'unescaped character preceded by two escaped backslashes \\\\\\\\a'
"\\a\\a" // consecutive unnecessarily escaped characters
'\\a\\a' // consecutive unnecessarily escaped characters
'escaped \\u2030 \\‰ (should not stay escaped)'
// Meaningful escapes
"octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7"
'octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7'
"meaningfully escaped alphabetical characters \\n \\r \\v \\t \\b \\f \\u2713 \\x61"
'meaningfully escaped alphabetical characters \\n \\r \\v \\t \\b \\f \\u2713 \\x61'
'escaped newline \\
'
'escaped carriage return \\
'
'escaped \\u2028 \\
'
'escaped \\u2029 \\
'
// One of each.
"\\"'"
Expand Down Expand Up @@ -172,11 +179,18 @@ exports[`strings.js 1`] = `
"unescaped character preceded by two escaped backslashes \\\\\\\\a";
"aa"; // consecutive unnecessarily escaped characters
"aa"; // consecutive unnecessarily escaped characters
"escaped \\u2030 ‰ (should not stay escaped)";
// Meaningful escapes
"octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7";
"octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7";
"meaningfully escaped alphabetical characters \\n \\r \\v \\t \\b \\f \\u2713 \\x61";
"meaningfully escaped alphabetical characters \\n \\r \\v \\t \\b \\f \\u2713 \\x61";
"escaped newline \\
";
"escaped carriage return \\
";
"escaped \\u2028 \\
";
"escaped \\u2029 \\
";
// One of each.
"\\"'";
"\\"'";
Expand Down Expand Up @@ -259,12 +273,19 @@ exports[`strings.js 2`] = `
'unescaped character preceded by two escaped backslashes \\\\\\\\a'
"\\a\\a" // consecutive unnecessarily escaped characters
'\\a\\a' // consecutive unnecessarily escaped characters
'escaped \\u2030 \\‰ (should not stay escaped)'
// Meaningful escapes
"octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7"
'octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7'
"meaningfully escaped alphabetical characters \\n \\r \\v \\t \\b \\f \\u2713 \\x61"
'meaningfully escaped alphabetical characters \\n \\r \\v \\t \\b \\f \\u2713 \\x61'
'escaped newline \\
'
'escaped carriage return \\
'
'escaped \\u2028 \\
'
'escaped \\u2029 \\
'
// One of each.
"\\"'"
Expand Down Expand Up @@ -349,11 +370,18 @@ exports[`strings.js 2`] = `
'unescaped character preceded by two escaped backslashes \\\\\\\\a';
'aa'; // consecutive unnecessarily escaped characters
'aa'; // consecutive unnecessarily escaped characters
'escaped \\u2030 ‰ (should not stay escaped)';
// Meaningful escapes
'octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7';
'octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7';
'meaningfully escaped alphabetical characters \\n \\r \\v \\t \\b \\f \\u2713 \\x61';
'meaningfully escaped alphabetical characters \\n \\r \\v \\t \\b \\f \\u2713 \\x61';
'escaped newline \\
';
'escaped carriage return \\
';
'escaped \\u2028 \\
';
'escaped \\u2029 \\
';
// One of each.
'"\\'';
'"\\'';
Expand Down
7 changes: 7 additions & 0 deletions tests/quotes/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,19 @@
'unescaped character preceded by two escaped backslashes \\\\a'
"\a\a" // consecutive unnecessarily escaped characters
'\a\a' // consecutive unnecessarily escaped characters
'escaped \u2030 \‰ (should not stay escaped)'

// Meaningful escapes
"octal escapes \0 \1 \2 \3 \4 \5 \6 \7"
'octal escapes \0 \1 \2 \3 \4 \5 \6 \7'
"meaningfully escaped alphabetical characters \n \r \v \t \b \f \u2713 \x61"
'meaningfully escaped alphabetical characters \n \r \v \t \b \f \u2713 \x61'
'escaped newline \
'
'escaped carriage return \
'
'escaped \u2028 \
'
'escaped \u2029 \
'

// One of each.
"\"'"
Expand Down

0 comments on commit f04b200

Please sign in to comment.