5c1ef6ac82
In the ES2015 spec, RegExp uses ToLength, not ToInteger, on lastIndex to coerce it to an integer. This patch switches to ToLength when the --harmony-tolength flag is on, and adds some tests to verify the new behavior. BUG=v8:4244 LOG=Y R=adamk Review URL: https://codereview.chromium.org/1394023005 Cr-Commit-Position: refs/heads/master@{#31306}
20 lines
426 B
JavaScript
20 lines
426 B
JavaScript
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --harmony-tolength
|
|
|
|
'use strict';
|
|
|
|
let regexp = /x/g;
|
|
|
|
regexp.lastIndex = -1;
|
|
|
|
assertTrue(regexp.test("axb"));
|
|
assertEquals(2, regexp.lastIndex);
|
|
|
|
regexp.lastIndex = -1;
|
|
|
|
assertEquals("x", regexp.exec("axb")[0]);
|
|
assertEquals(2, regexp.lastIndex);
|