summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/set-lastindex-restore.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/set-lastindex-restore.js')
-rw-r--r--js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/set-lastindex-restore.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/set-lastindex-restore.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/set-lastindex-restore.js
new file mode 100644
index 0000000000..393d02a14e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/set-lastindex-restore.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 21.2.5.9
+description: The `lastIndex` value is restored following match execution
+info: |
+ [...]
+ 8. If SameValue(currentLastIndex, previousLastIndex) is false, then
+ a. Perform ? Set(rx, "lastIndex", previousLastIndex, true).
+ [...]
+features: [Symbol.search]
+---*/
+
+var latestValue = 86;
+var callCount = 0;
+var fakeRe = {
+ get lastIndex() {
+ return latestValue;
+ },
+ set lastIndex(_) {
+ latestValue = _;
+ },
+ exec: function() {
+ callCount++;
+ latestValue = null;
+ return null;
+ }
+};
+
+RegExp.prototype[Symbol.search].call(fakeRe);
+
+assert.sameValue(callCount, 1);
+assert.sameValue(latestValue, 86);
+
+reportCompare(0, 0);