diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2023-10-10 10:52:44 -0400 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2023-10-13 15:31:30 -0400 |
| commit | dd3986876a96f9e9fec078247d7d40b322f8fd17 (patch) | |
| tree | af033269dedfbcb978e391b59b9df145e8234319 /test | |
| parent | 1a941c70e42c1e64b961088e953ded6a148e1351 (diff) | |
[ruby/prism] Handle remaining escape sequences for character literals
https://github.com/ruby/prism/commit/ba33607034
Diffstat (limited to 'test')
| -rw-r--r-- | test/prism/unescape_test.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/test/prism/unescape_test.rb b/test/prism/unescape_test.rb index 4e631d2238..33032ee550 100644 --- a/test/prism/unescape_test.rb +++ b/test/prism/unescape_test.rb @@ -79,17 +79,20 @@ module Prism octal = [*("0".."7")] octal = octal.product(octal).map(&:join).concat(octal.product(octal).product(octal).map(&:join)) - hex = [*("a".."f"), *("A".."F"), *("0".."9")] - hex = hex.map { |h| "x#{h}" }.concat(hex.product(hex).map { |h| "x#{h.join}" }).concat(["5", "6"].product(hex.sample(4)).product(hex.sample(4)).product(hex.sample(4)).map { |h| "u#{h.join}" }) + hex2 = [*("a".."f"), *("A".."F"), *("0".."9")] + hex2 = hex2.map { |h| "x#{h}" }.concat(hex2.product(hex2).map { |h| "x#{h.join}" }) - hexes = [*("a".."f"), *("A".."F"), *("0".."9")] - hexes = ["5", "6"].product(hexes.sample(2)).product(hexes.sample(2)).product(hexes.sample(2)).map { |h| "u{00#{h.join}}" } + hex4 = [*("a".."f"), *("A".."F"), *("0".."9")] + hex4 = ["5", "6"].product(hex4.sample(4)).product(hex4.sample(4)).product(hex4.sample(4)).map { |h| "u#{h.join}" } + + hex6 = [*("a".."f"), *("A".."F"), *("0".."9")] + hex6 = ["5", "6"].product(hex6.sample(2)).product(hex6.sample(2)).product(hex6.sample(2)).map { |h| "u{00#{h.join}}" } ctrls = (ascii.grep(/[[:print:]]/) - ["\\"]).flat_map { |c| ["C-#{c}", "c#{c}", "M-#{c}", "M-\\C-#{c}", "M-\\c#{c}", "c\\M-#{c}"] } - escapes = [*ascii, *ascii8, *octal, *hex, *hexes, *ctrls] + escapes = [*ascii, *ascii8, *octal, *hex2, *hex4, *hex6, *ctrls] contexts = [ - [Context::String.new("?", ""), [*ascii, *hex, *ctrls]], + [Context::String.new("?", ""), [*ascii, *octal]], #, *hex2]], [Context::String.new("'", "'"), escapes], [Context::String.new("\"", "\""), escapes], # [Context::String.new("%q[", "]"), escapes], @@ -133,7 +136,7 @@ module Prism "Expected #{context.name} to unescape #{escape.inspect} to #{expected.inspect}, but got #{actual.inspect}" end - if expected == :error + if expected == :error || actual == :error assert_equal expected, actual, message else assert_equal expected.bytes, actual.bytes, message |
