blob: 1e0d76ee949e0f5d01d0f4054490b929c04d04a8 [file] [log] [blame]
description(
'Test for ES6 RegExp construct a new RegExp from exiting RegExp pattern and new flags'
);
var re = new RegExp("Abc");
shouldBeTrue('re.test(" Abc ")');
shouldBe('re.flags', '""');
re = new RegExp(re, "i");
shouldBeTrue('re.test(" ABC ")');
shouldBe('re.flags', '"i"');
re = new RegExp(re, "");
shouldBeTrue('re.test(" Abc ")');
shouldBe('re.flags', '""');
re = new RegExp(re, "iy");
shouldBe('re.exec("abcABCAbc").toString()', '"abc"');
shouldBe('re.exec("abcABCAbc").toString()', '"ABC"');
shouldBe('re.exec("abcABCAbc").toString()', '"Abc"');
shouldBe('re.flags', '"iy"');
re = new RegExp(re, "");
shouldBeFalse('re.test("abc")');
shouldThrow('new RegExp(re, "bad flags")', '"SyntaxError: Invalid flags supplied to RegExp constructor."');