From 0d820e4c0a7a1b1eeee25fb632b9496a9780b28a Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 15 Feb 2020 05:26:48 +0000 Subject: workaround RegExp formatting bugs (#3720) --- test/compress/regexp.js | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'test') diff --git a/test/compress/regexp.js b/test/compress/regexp.js index 460ff504..defc0079 100644 --- a/test/compress/regexp.js +++ b/test/compress/regexp.js @@ -186,3 +186,72 @@ issue_3434_3: { /\nfo\n[\n]o\bbb/; } } + +issue_3434_4: { + options = { + evaluate: true, + unsafe: true, + } + input: { + [ + [ "", RegExp("") ], + [ "/", RegExp("/") ], + [ "//", RegExp("//") ], + [ "\/", RegExp("\\/") ], + [ "///", RegExp("///") ], + [ "/\/", RegExp("/\\/") ], + [ "\//", RegExp("\\//") ], + [ "\\/", RegExp("\\\\/") ], + [ "////", RegExp("////") ], + [ "//\/", RegExp("//\\/") ], + [ "/\//", RegExp("/\\//") ], + [ "/\\/", RegExp("/\\\\/") ], + [ "\///", RegExp("\\///") ], + [ "\/\/", RegExp("\\/\\/") ], + [ "\\//", RegExp("\\\\//") ], + [ "\\\/", RegExp("\\\\\\/") ], + ].forEach(function(test) { + console.log(test[1].test("\\"), test[1].test(test[0])); + }); + } + expect: { + [ + [ "", /(?:)/ ], + [ "/", /\// ], + [ "//", /\/\// ], + [ "/", /\// ], + [ "///", /\/\/\// ], + [ "//", /\/\// ], + [ "//", /\/\// ], + [ "\\/", /\\\// ], + [ "////", /\/\/\/\// ], + [ "///", /\/\/\// ], + [ "///", /\/\/\// ], + [ "/\\/", /\/\\\// ], + [ "///", /\/\/\// ], + [ "//", /\/\// ], + [ "\\//", /\\\/\// ], + [ "\\/", /\\\// ], + ].forEach(function(test) { + console.log(test[1].test("\\"), test[1].test(test[0])); + }); + } + expect_stdout: [ + "true true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + "false true", + ] +} -- cgit v1.2.3