Skip to content

Instantly share code, notes, and snippets.

@mernen
Last active December 20, 2015 01:39
Show Gist options
  • Save mernen/6050329 to your computer and use it in GitHub Desktop.
Save mernen/6050329 to your computer and use it in GitHub Desktop.
Sample testcase for PhantomJS issue #11494
var re1 = /test/;
var re2 = new RegExp(re1);
assert(re1 !== re2, "new RegExp() should always return a new object");
var scanner = /foo/g;
scanner.lastIndex = 3;
var copy = new RegExp(scanner);
assert(copy.lastIndex === 0, "new RegExp(...) should never copy lastIndex");
if (phantom) phantom.exit();
function assert(value, message) {
console.log(message, value ? "[OK]" : "[FAIL]");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment