summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/named-groups/non-unicode-match.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/named-groups/non-unicode-match.js')
-rw-r--r--js/src/tests/test262/built-ins/RegExp/named-groups/non-unicode-match.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/named-groups/non-unicode-match.js b/js/src/tests/test262/built-ins/RegExp/named-groups/non-unicode-match.js
new file mode 100644
index 0000000000..bc68c12bf8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/RegExp/named-groups/non-unicode-match.js
@@ -0,0 +1,44 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Basic matching cases with non-Unicode groups
+esid: prod-GroupSpecifier
+features: [regexp-named-groups]
+includes: [compareArray.js]
+---*/
+
+assert.compareArray(["a", "a"], "bab".match(/(?<a>a)/));
+assert.compareArray(["a", "a"], "bab".match(/(?<a42>a)/));
+assert.compareArray(["a", "a"], "bab".match(/(?<_>a)/));
+assert.compareArray(["a", "a"], "bab".match(/(?<$>a)/));
+assert.compareArray(["bab", "a"], "bab".match(/.(?<$>a)./));
+assert.compareArray(["bab", "a", "b"], "bab".match(/.(?<a>a)(.)/));
+assert.compareArray(["bab", "a", "b"], "bab".match(/.(?<a>a)(?<b>.)/));
+assert.compareArray(["bab", "ab"], "bab".match(/.(?<a>\w\w)/));
+assert.compareArray(["bab", "bab"], "bab".match(/(?<a>\w\w\w)/));
+assert.compareArray(["bab", "ba", "b"], "bab".match(/(?<a>\w\w)(?<b>\w)/));
+
+let {a, b, c} = /(?<a>.)(?<b>.)(?<c>.)\k<c>\k<b>\k<a>/.exec("abccba").groups;
+assert.sameValue(a, "a");
+assert.sameValue(b, "b");
+assert.sameValue(c, "c");
+
+assert.compareArray("bab".match(/(a)/), "bab".match(/(?<a>a)/));
+assert.compareArray("bab".match(/(a)/), "bab".match(/(?<a42>a)/));
+assert.compareArray("bab".match(/(a)/), "bab".match(/(?<_>a)/));
+assert.compareArray("bab".match(/(a)/), "bab".match(/(?<$>a)/));
+assert.compareArray("bab".match(/.(a)./), "bab".match(/.(?<$>a)./));
+assert.compareArray("bab".match(/.(a)(.)/), "bab".match(/.(?<a>a)(.)/));
+assert.compareArray("bab".match(/.(a)(.)/), "bab".match(/.(?<a>a)(?<b>.)/));
+assert.compareArray("bab".match(/.(\w\w)/), "bab".match(/.(?<a>\w\w)/));
+assert.compareArray("bab".match(/(\w\w\w)/), "bab".match(/(?<a>\w\w\w)/));
+assert.compareArray("bab".match(/(\w\w)(\w)/), "bab".match(/(?<a>\w\w)(?<b>\w)/));
+
+assert.compareArray(["bab", "b"], "bab".match(/(?<b>b).\1/));
+assert.compareArray(["baba", "b", "a"], "baba".match(/(.)(?<a>a)\1\2/));
+assert.compareArray(["baba", "b", "a", "b", "a"], "baba".match(/(.)(?<a>a)(?<b>\1)(\2)/));
+assert.compareArray(["<a", "<"], "<a".match(/(?<lt><)a/));
+assert.compareArray([">a", ">"], ">a".match(/(?<gt>>)a/));
+
+reportCompare(0, 0);