From 0a63f2f2b09251ad3f6b771dcf1ae1b4b9c921d7 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sun, 6 Oct 2019 11:49:39 +0800 Subject: workaround V8 RegExp bug (#3453) fixes #3434 --- test/compress/regexp.js | 137 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) (limited to 'test/compress/regexp.js') diff --git a/test/compress/regexp.js b/test/compress/regexp.js index ac834e5d..6b93faba 100644 --- a/test/compress/regexp.js +++ b/test/compress/regexp.js @@ -35,3 +35,140 @@ regexp_2: { } expect_stdout: '["PASS","pass"]' } + +issue_3434_1: { + options = { + evaluate: true, + unsafe: true, + } + beautify = { + beautify: true, + } + input: { + var o = { + "\n": RegExp("\n"), + "\r": RegExp("\r"), + "\t": RegExp("\t"), + "\b": RegExp("\b"), + "\f": RegExp("\f"), + "\0": RegExp("\0"), + "\x0B": RegExp("\x0B"), + "\u2028": RegExp("\u2028"), + "\u2029": RegExp("\u2029"), + }; + for (var c in o) + console.log(o[c].test("\\"), o[c].test(c)); + } + expect_exact: [ + "var o = {", + ' "\\n": /\\n/,', + ' "\\r": /\\r/,', + ' "\\t": /\t/,', + ' "\\b": /\b/,', + ' "\\f": /\f/,', + ' "\\0": /\0/,', + ' "\\v": /\v/,', + ' "\\u2028": /\\u2028/,', + ' "\\u2029": /\\u2029/', + "};", + "", + 'for (var c in o) console.log(o[c].test("\\\\"), o[c].test(c));', + ] + expect_stdout: [ + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + ] +} + +issue_3434_2: { + options = { + evaluate: true, + unsafe: true, + } + beautify = { + beautify: true, + } + input: { + var o = { + "\n": RegExp("\\\n"), + "\r": RegExp("\\\r"), + "\t": RegExp("\\\t"), + "\b": RegExp("\\\b"), + "\f": RegExp("\\\f"), + "\0": RegExp("\\\0"), + "\x0B": RegExp("\\\x0B"), + "\u2028": RegExp("\\\u2028"), + "\u2029": RegExp("\\\u2029"), + }; + for (var c in o) + console.log(o[c].test("\\"), o[c].test(c)); + } + expect_exact: [ + "var o = {", + ' "\\n": /\\n/,', + ' "\\r": /\\r/,', + ' "\\t": /\t/,', + ' "\\b": /\b/,', + ' "\\f": /\f/,', + ' "\\0": /\0/,', + ' "\\v": /\v/,', + ' "\\u2028": /\\u2028/,', + ' "\\u2029": /\\u2029/', + "};", + "", + 'for (var c in o) console.log(o[c].test("\\\\"), o[c].test(c));', + ] + expect_stdout: [ + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + ] +} + +issue_3434_3: { + options = { + evaluate: true, + unsafe: true, + } + input: { + RegExp("\n"); + RegExp("\r"); + RegExp("\\n"); + RegExp("\\\n"); + RegExp("\\\\n"); + RegExp("\\\\\n"); + RegExp("\\\\\\n"); + RegExp("\\\\\\\n"); + RegExp("\u2028"); + RegExp("\u2029"); + RegExp("\n\r\u2028\u2029"); + RegExp("\\\nfo\n[\n]o\\bbb"); + } + expect: { + /\n/; + /\r/; + /\n/; + /\n/; + /\\n/; + /\\\n/; + /\\\n/; + /\\\n/; + /\u2028/; + /\u2029/; + /\n\r\u2028\u2029/; + /\nfo\n[\n]o\bbb/; + } +} -- cgit v1.2.3