| Index: test/mjsunit/regexp-not-sticky-yet.js
|
| diff --git a/test/mjsunit/regress/regress-392114.js b/test/mjsunit/regexp-not-sticky-yet.js
|
| similarity index 54%
|
| copy from test/mjsunit/regress/regress-392114.js
|
| copy to test/mjsunit/regexp-not-sticky-yet.js
|
| index e5cf1cde372f13c72262855b35f4a00390d3b057..4186a63fefbe5fd95f7a9cb3e5157939c2a04d3e 100644
|
| --- a/test/mjsunit/regress/regress-392114.js
|
| +++ b/test/mjsunit/regexp-not-sticky-yet.js
|
| @@ -25,42 +25,41 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -// Flags: --expose-debug-as debug --allow-natives-syntax
|
| +// Test that sticky regexp support is not affecting V8 when the
|
| +// --harmony-regexps flag is not on.
|
|
|
| -Debug = debug.Debug;
|
| +assertThrows(function() { eval("/foo.bar/y"); }, SyntaxError);
|
| +assertThrows(function() { eval("/foobar/y"); }, SyntaxError);
|
| +assertThrows(function() { eval("/foo.bar/gy"); }, SyntaxError);
|
| +assertThrows(function() { eval("/foobar/gy"); }, SyntaxError);
|
| +assertThrows(function() { new RegExp("foo.bar", "y"); }, SyntaxError);
|
| +assertThrows(function() { new RegExp("foobar", "y"); }, SyntaxError);
|
| +assertThrows(function() { new RegExp("foo.bar", "gy"); }, SyntaxError);
|
| +assertThrows(function() { new RegExp("foobar", "gy"); }, SyntaxError);
|
|
|
| -function dummy(x) {
|
| - return x + 100;
|
| -}
|
| +var re = /foo.bar/;
|
| +assertEquals("/foo.bar/", "" + re);
|
| +var plain = /foobar/;
|
| +assertEquals("/foobar/", "" + plain);
|
|
|
| -function create_closure() {
|
| - var f = function(arg) {
|
| - if (arg) { %DeoptimizeFunction(f); }
|
| - var a = Array(10);
|
| - for (var i = 0; i < a.length; i++) {
|
| - a[i] = i;
|
| - }
|
| - }
|
| - return f;
|
| -}
|
| +re.compile("foo.bar");
|
| +assertEquals(void 0, re.sticky);
|
|
|
| -var c = create_closure();
|
| -c();
|
| +var global = /foo.bar/g;
|
| +assertEquals("/foo.bar/g", "" + global);
|
| +var plainglobal = /foobar/g;
|
| +assertEquals("/foobar/g", "" + plainglobal);
|
|
|
| -// c CallIC state now has custom Array handler installed.
|
| +assertEquals(void 0, re.sticky);
|
| +re.sticky = true; // Has no effect on the regexp, just sets a property.
|
| +assertTrue(re.sticky);
|
|
|
| -// Turn on the debugger.
|
| -Debug.setListener(function () {});
|
| +assertTrue(re.test("..foo.bar"));
|
|
|
| -var d = create_closure();
|
| -%OptimizeFunctionOnNextCall(d);
|
| -// Thanks to the debugger, we recreate the full code too. We deopt and run
|
| -// it, stomping on the unexpected AllocationSite in the type vector slot.
|
| -d(true);
|
| +re.lastIndex = -1; // Ignored for non-global, non-sticky.
|
| +assertTrue(re.test("..foo.bar"));
|
| +assertEquals(-1, re.lastIndex);
|
|
|
| -// CallIC in c misinterprets type vector slot contents as an AllocationSite,
|
| -// corrupting the heap.
|
| -c();
|
| -
|
| -// CallIC MISS - crash due to corruption.
|
| -dummy();
|
| +re.lastIndex = -1; // Ignored for non-global, non-sticky.
|
| +assertTrue(!!re.exec("..foo.bar"));
|
| +assertEquals(-1, re.lastIndex);
|
|
|