summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/next-iteration-global.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/next-iteration-global.js')
-rw-r--r--js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/next-iteration-global.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/next-iteration-global.js b/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/next-iteration-global.js
new file mode 100644
index 0000000000..480f4abc84
--- /dev/null
+++ b/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/next-iteration-global.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: pending
+description: Iterates over each match
+info: |
+ %RegExpStringIteratorPrototype%.next ( )
+ [...]
+ 4. If O.[[Done]] is true, then
+ a. Return ! reateIterResultObject(undefined, true).
+ [...]
+ 9. Let match be ? RegExpExec(R, S).
+ 10. If match is null, then
+ a. Set O.[[Done]] to true.
+ b. Return ! CreateIterResultObject(undefined, true).
+ 11. Else,
+ a. If global is true,
+ i. Let matchStr be ? ToString(? Get(match, "0")).
+ ii. If matchStr is the empty string,
+ 1. Let thisIndex be ? ToLength(? Get(R, "lastIndex").
+ 2. Let nextIndex be ! AdvanceStringIndex(S, thisIndex, fullUnicode).
+ 3. Perform ? Set(R, "lastIndex", nextIndex, true).
+ iii. Return ! CreateIterResultObject(match, false).
+features: [Symbol.matchAll]
+includes: [compareArray.js, compareIterator.js, regExpUtils.js]
+---*/
+
+var regexp = /\w/g;
+var str = 'a*b';
+var iter = regexp[Symbol.matchAll](str);
+
+assert.compareIterator(iter, [
+ matchValidator(['a'], 0, str),
+ matchValidator(['b'], 2, str)
+]);
+
+// Verifies %RegExpStringIteratorPrototype%.next() step 4
+var result = iter.next();
+assert.sameValue(result.value, undefined);
+assert(result.done);
+
+reportCompare(0, 0);