regexp-subclass-proto-jit-bug.js (537B)
1 // |jit-test| --enable-legacy-regexp; skip-if: !getBuildConfiguration("debug") 2 3 load(libdir + 'asserts.js'); 4 5 function testSubclassProtoJitBug() { 6 class MyRegExp extends RegExp {} 7 let real = RegExp("ab|cd"); 8 let fake = new MyRegExp("ab|cd"); 9 fake.__proto__ = RegExp.prototype; 10 11 function foo(r) { 12 return r.test("ab"); 13 } 14 15 for (var i = 0; i < 2000; i++) { 16 foo(real); 17 } 18 assertEq(RegExp.lastMatch, "ab"); 19 20 foo(fake); 21 assertThrowsInstanceOf(() => RegExp.lastMatch, TypeError); 22 } 23 24 testSubclassProtoJitBug();