From 62d5787b09a5c2d17630a337b3d830bb0991bef6 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Mon, 20 Jul 2015 10:40:38 -0400 Subject: [PATCH] Add tests for @@match Introduce tests for the well-known Symbol, `@@match`. This effects the behavior of `String.prototype.match` and is also used by the IsRegExp abstract operation. --- .../RegExp/from-regexp-like-flag-override.js | 67 +++++++++++++ .../RegExp/from-regexp-like-get-ctor-err.js | 51 ++++++++++ .../RegExp/from-regexp-like-get-flags-err.js | 49 ++++++++++ .../RegExp/from-regexp-like-get-source-err.js | 53 ++++++++++ .../RegExp/from-regexp-like-short-circuit.js | 38 ++++++++ test/built-ins/RegExp/from-regexp-like.js | 56 +++++++++++ .../Symbol.match/builtin-coerce-global.js | 97 +++++++++++++++++++ .../builtin-coerce-lastindex-err.js | 34 +++++++ .../Symbol.match/builtin-coerce-lastindex.js | 33 +++++++ .../Symbol.match/builtin-coerce-sticky.js | 79 +++++++++++++++ .../builtin-failure-return-val.js | 36 +++++++ .../builtin-failure-set-lastindex-err.js | 40 ++++++++ .../builtin-failure-set-lastindex.js | 39 ++++++++ .../builtin-failure-y-return-val.js | 35 +++++++ .../builtin-failure-y-set-lastindex-err.js | 42 ++++++++ .../builtin-failure-y-set-lastindex.js | 38 ++++++++ .../Symbol.match/builtin-get-global-err.js | 41 ++++++++ .../Symbol.match/builtin-get-sticky-err.js | 37 +++++++ .../Symbol.match/builtin-infer-unicode.js | 38 ++++++++ .../builtin-success-g-set-lastindex-err.js | 43 ++++++++ .../builtin-success-g-set-lastindex.js | 41 ++++++++ .../builtin-success-return-val-groups.js | 49 ++++++++++ .../builtin-success-return-val.js | 40 ++++++++ .../builtin-success-u-return-val-groups.js | 51 ++++++++++ .../builtin-success-y-set-lastindex-err.js | 36 +++++++ .../builtin-success-y-set-lastindex.js | 33 +++++++ .../prototype/Symbol.match/coerce-arg-err.js | 25 +++++ .../prototype/Symbol.match/coerce-arg.js | 25 +++++ .../prototype/Symbol.match/coerce-global.js | 68 +++++++++++++ ...{get-sticky-coerce.js => coerce-sticky.js} | 10 +- .../RegExp/prototype/Symbol.match/exec-err.js | 29 ++++++ .../prototype/Symbol.match/exec-invocation.js | 41 ++++++++ .../Symbol.match/exec-return-type-invalid.js | 56 +++++++++++ .../Symbol.match/exec-return-type-valid.js | 34 +++++++ .../Symbol.match/g-coerce-result-err.js | 35 +++++++ .../prototype/Symbol.match/g-get-exec-err.js | 37 +++++++ .../Symbol.match/g-get-result-err.js | 35 +++++++ .../Symbol.match/g-init-lastindex-err.js | 22 +++++ .../Symbol.match/g-init-lastindex.js | 20 ++++ .../g-match-empty-advance-lastindex.js | 36 +++++++ .../g-match-empty-coerce-lastindex-err.js | 50 ++++++++++ .../g-match-empty-set-lastindex-err.js | 47 +++++++++ .../g-match-no-coerce-lastindex.js | 47 +++++++++ .../Symbol.match/g-match-no-set-lastindex.js | 43 ++++++++ .../Symbol.match/g-success-return-val.js | 48 +++++++++ .../prototype/Symbol.match/g-zero-matches.js | 21 ++++ .../prototype/Symbol.match/get-exec-err.js | 30 ++++++ .../prototype/Symbol.match/get-global-err.js | 22 +++++ .../RegExp/prototype/Symbol.match/length.js | 25 +++++ .../RegExp/prototype/Symbol.match/name.js | 23 +++++ .../prototype/Symbol.match/prop-desc.js | 18 ++++ .../Symbol.match/this-val-non-obj.js | 35 +++++++ .../Symbol.match/this-val-non-regexp.js | 36 +++++++ .../String/prototype/match/S15.5.4.10_A10.js | 31 ------ .../prototype/match/cstm-matcher-get-err.js | 24 +++++ .../match/cstm-matcher-invocation.js | 34 +++++++ .../prototype/match/invoke-builtin-match.js | 37 +++++++ .../match/{S15.5.4.10_A11.js => length.js} | 18 ++++ .../{S15.5.4.10_A1_T2.js => this-val-bool.js} | 0 .../{S15.5.4.10_A1_T1.js => this-val-obj.js} | 0 test/built-ins/Symbol/match/prop-desc.js | 17 ++++ 61 files changed, 2239 insertions(+), 36 deletions(-) create mode 100644 test/built-ins/RegExp/from-regexp-like-flag-override.js create mode 100644 test/built-ins/RegExp/from-regexp-like-get-ctor-err.js create mode 100644 test/built-ins/RegExp/from-regexp-like-get-flags-err.js create mode 100644 test/built-ins/RegExp/from-regexp-like-get-source-err.js create mode 100644 test/built-ins/RegExp/from-regexp-like-short-circuit.js create mode 100644 test/built-ins/RegExp/from-regexp-like.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-global.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-lastindex-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-lastindex.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-sticky.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-return-val.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-return-val.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-get-global-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-get-sticky-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-infer-unicode.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-success-return-val-groups.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-success-return-val.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-success-u-return-val-groups.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-success-y-set-lastindex-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/builtin-success-y-set-lastindex.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/coerce-arg-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/coerce-arg.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/coerce-global.js rename test/built-ins/RegExp/prototype/Symbol.match/{get-sticky-coerce.js => coerce-sticky.js} (95%) create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/exec-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/exec-invocation.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/exec-return-type-invalid.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/exec-return-type-valid.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-coerce-result-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-get-exec-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-get-result-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-init-lastindex-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-init-lastindex.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-advance-lastindex.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-coerce-lastindex-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-set-lastindex-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-match-no-coerce-lastindex.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-match-no-set-lastindex.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-success-return-val.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/g-zero-matches.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/get-exec-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/get-global-err.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/length.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/name.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/prop-desc.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/this-val-non-obj.js create mode 100644 test/built-ins/RegExp/prototype/Symbol.match/this-val-non-regexp.js delete mode 100644 test/built-ins/String/prototype/match/S15.5.4.10_A10.js create mode 100644 test/built-ins/String/prototype/match/cstm-matcher-get-err.js create mode 100644 test/built-ins/String/prototype/match/cstm-matcher-invocation.js create mode 100644 test/built-ins/String/prototype/match/invoke-builtin-match.js rename test/built-ins/String/prototype/match/{S15.5.4.10_A11.js => length.js} (56%) rename test/built-ins/String/prototype/match/{S15.5.4.10_A1_T2.js => this-val-bool.js} (100%) rename test/built-ins/String/prototype/match/{S15.5.4.10_A1_T1.js => this-val-obj.js} (100%) create mode 100644 test/built-ins/Symbol/match/prop-desc.js diff --git a/test/built-ins/RegExp/from-regexp-like-flag-override.js b/test/built-ins/RegExp/from-regexp-like-flag-override.js new file mode 100644 index 0000000000..2051a1c58e --- /dev/null +++ b/test/built-ins/RegExp/from-regexp-like-flag-override.js @@ -0,0 +1,67 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Initialization from a RegExp-like object (with flag overrides) +es6id: 21.2.3.1 +info: > + 1. Let patternIsRegExp be IsRegExp(pattern). + [...] + 6. Else if patternIsRegExp is true, then + a. Let P be Get(pattern, "source"). + b. ReturnIfAbrupt(P). + c. If flags is undefined, then + [...] + d. Else, let F be flags. + [...] + 10. Return RegExpInitialize(O, P, F). +features: [Symbol, Symbol.match] +---*/ + +var obj = { + source: 'source text' +}; +var result; + +Object.defineProperty(obj, 'flags', { + get: function() { + $ERROR('The `flags` property value should not be referenced.'); + } +}); + +obj[Symbol.match] = true; +result = new RegExp(obj, 'g'); +assert.sameValue( + result.source, 'source text', '@@match specified as a primitive boolean' +); +assert.sameValue( + result.flags, 'g', '@@match specified as a primitive boolean' +); + +obj[Symbol.match] = 'string'; +result = new RegExp(obj, 'g'); +assert.sameValue( + result.source, 'source text', '@@match specified as a primitive string' +); +assert.sameValue(result.flags, 'g', '@@match specified as a primitive string'); + +obj[Symbol.match] = []; +result = new RegExp(obj, 'g'); +assert.sameValue( + result.source, 'source text', '@@match specified as an array' +); +assert.sameValue(result.flags, 'g', '@@match specified as an array'); + +obj[Symbol.match] = Symbol(); +result = new RegExp(obj, 'g'); +assert.sameValue( + result.source, 'source text', '@@match specified as a Symbol' +); +assert.sameValue(result.flags, 'g', '@@match specified as a Symbol'); + +obj[Symbol.match] = 86; +result = new RegExp(obj, 'g'); +assert.sameValue( + result.source, 'source text', '@@match specified as a primitive number' +); +assert.sameValue(result.flags, 'g', '@@match specified as a primitive number'); diff --git a/test/built-ins/RegExp/from-regexp-like-get-ctor-err.js b/test/built-ins/RegExp/from-regexp-like-get-ctor-err.js new file mode 100644 index 0000000000..439b824215 --- /dev/null +++ b/test/built-ins/RegExp/from-regexp-like-get-ctor-err.js @@ -0,0 +1,51 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when accessing `constructor` property of RegExp-like objects +es6id: 21.2.3.1 +info: > + 1. Let patternIsRegExp be IsRegExp(pattern). + [...] + 3. If NewTarget is not undefined, let newTarget be NewTarget. + 4. Else, + a. Let newTarget be the active function object. + b. If patternIsRegExp is true and flags is undefined, then + i. Let patternConstructor be Get(pattern, "constructor"). + ii. ReturnIfAbrupt(patternConstructor). + iii. If SameValue(newTarget, patternConstructor) is true, return + pattern. +features: [Symbol, Symbol.match] +---*/ + +var obj = Object.defineProperty({}, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); + +obj[Symbol.match] = true; +assert.throws(Test262Error, function() { + RegExp(obj); +}); + +obj[Symbol.match] = 'string'; +assert.throws(Test262Error, function() { + RegExp(obj); +}); + +obj[Symbol.match] = []; +assert.throws(Test262Error, function() { + RegExp(obj); +}); + +obj[Symbol.match] = Symbol() +assert.throws(Test262Error, function() { + RegExp(obj); +}); + +obj[Symbol.match] = 86; +assert.throws(Test262Error, function() { + RegExp(obj); +}); diff --git a/test/built-ins/RegExp/from-regexp-like-get-flags-err.js b/test/built-ins/RegExp/from-regexp-like-get-flags-err.js new file mode 100644 index 0000000000..c9c7370a8c --- /dev/null +++ b/test/built-ins/RegExp/from-regexp-like-get-flags-err.js @@ -0,0 +1,49 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error thrown from `flags` property of a RegExp-like object +es6id: 21.2.3.1 +info: > + 1. Let patternIsRegExp be IsRegExp(pattern). + [...] + 6. Else if patternIsRegExp is true, then + [...] + c. If flags is undefined, then + i. Let F be Get(pattern, "flags"). + ii. ReturnIfAbrupt(F). +features: [Symbol, Symbol.match] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'flags', { + get: function() { + throw new Test262Error(); + } +}); + +obj[Symbol.match] = true; +assert.throws(Test262Error, function() { + new RegExp(obj); +}); + +obj[Symbol.match] = 'string'; +assert.throws(Test262Error, function() { + new RegExp(obj); +}); + +obj[Symbol.match] = []; +assert.throws(Test262Error, function() { + new RegExp(obj); +}); + +obj[Symbol.match] = Symbol(); +assert.throws(Test262Error, function() { + new RegExp(obj); +}); + +obj[Symbol.match] = 86; +assert.throws(Test262Error, function() { + new RegExp(obj); +}); diff --git a/test/built-ins/RegExp/from-regexp-like-get-source-err.js b/test/built-ins/RegExp/from-regexp-like-get-source-err.js new file mode 100644 index 0000000000..cff9b3a994 --- /dev/null +++ b/test/built-ins/RegExp/from-regexp-like-get-source-err.js @@ -0,0 +1,53 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error thrown from `source` property of a RegExp-like object +es6id: 21.2.3.1 +info: > + 1. Let patternIsRegExp be IsRegExp(pattern). + [...] + 6. Else if patternIsRegExp is true, then + a. Let P be Get(pattern, "source"). + b. ReturnIfAbrupt(P). +features: [Symbol, Symbol.match] +---*/ + +var obj = {}; +function CustomError() {} +Object.defineProperty(obj, 'source', { + get: function() { + throw new CustomError(); + } +}); +Object.defineProperty(obj, 'flags', { + get: function() { + $ERROR('the `flags` property should not be referenced before `source`'); + } +}); + +obj[Symbol.match] = true; +assert.throws(CustomError, function() { + new RegExp(obj); +}); + +obj[Symbol.match] = 'string'; +assert.throws(CustomError, function() { + new RegExp(obj); +}); + +obj[Symbol.match] = []; +assert.throws(CustomError, function() { + new RegExp(obj); +}); + +obj[Symbol.match] = Symbol(); +assert.throws(CustomError, function() { + new RegExp(obj); +}); + +obj[Symbol.match] = 86; +assert.throws(CustomError, function() { + new RegExp(obj); +}); diff --git a/test/built-ins/RegExp/from-regexp-like-short-circuit.js b/test/built-ins/RegExp/from-regexp-like-short-circuit.js new file mode 100644 index 0000000000..c3407bd338 --- /dev/null +++ b/test/built-ins/RegExp/from-regexp-like-short-circuit.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Skipping construction from RegExp-like objects +es6id: 21.2.3.1 +info: > + 1. Let patternIsRegExp be IsRegExp(pattern). + [...] + 3. If NewTarget is not undefined, let newTarget be NewTarget. + 4. Else, + a. Let newTarget be the active function object. + b. If patternIsRegExp is true and flags is undefined, then + i. Let patternConstructor be Get(pattern, "constructor"). + ii. ReturnIfAbrupt(patternConstructor). + iii. If SameValue(newTarget, patternConstructor) is true, return + pattern. +features: [Symbol, Symbol.match] +---*/ + +var obj = { + constructor: RegExp +}; + +obj[Symbol.match] = true; +assert.sameValue(RegExp(obj), obj); + +obj[Symbol.match] = 'string'; +assert.sameValue(RegExp(obj), obj); + +obj[Symbol.match] = []; +assert.sameValue(RegExp(obj), obj); + +obj[Symbol.match] = Symbol(); +assert.sameValue(RegExp(obj), obj); + +obj[Symbol.match] = 86; +assert.sameValue(RegExp(obj), obj); diff --git a/test/built-ins/RegExp/from-regexp-like.js b/test/built-ins/RegExp/from-regexp-like.js new file mode 100644 index 0000000000..950f5eaac8 --- /dev/null +++ b/test/built-ins/RegExp/from-regexp-like.js @@ -0,0 +1,56 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Initialization from a RegExp-like object +es6id: 21.2.3.1 +info: > + 1. Let patternIsRegExp be IsRegExp(pattern). + [...] + 6. Else if patternIsRegExp is true, then + a. Let P be Get(pattern, "source"). + b. ReturnIfAbrupt(P). + c. If flags is undefined, then + i. Let F be Get(pattern, "flags"). + ii. ReturnIfAbrupt(F). + d. Else, let F be flags. + [...] + 10. Return RegExpInitialize(O, P, F). +features: [Symbol, Symbol.match] +---*/ + +var obj = { + source: 'source text', + flags: 'i' +}; +var result; + +obj[Symbol.match] = true; +result = new RegExp(obj); +assert.sameValue(Object.getPrototypeOf(result), RegExp.prototype); +assert.sameValue(result.source, 'source text'); +assert.sameValue(result.flags, 'i'); + +obj[Symbol.match] = 'string'; +result = new RegExp(obj); +assert.sameValue(Object.getPrototypeOf(result), RegExp.prototype); +assert.sameValue(result.source, 'source text'); +assert.sameValue(result.flags, 'i'); + +obj[Symbol.match] = []; +result = new RegExp(obj); +assert.sameValue(Object.getPrototypeOf(result), RegExp.prototype); +assert.sameValue(result.source, 'source text'); +assert.sameValue(result.flags, 'i'); + +obj[Symbol.match] = Symbol(); +result = new RegExp(obj); +assert.sameValue(Object.getPrototypeOf(result), RegExp.prototype); +assert.sameValue(result.source, 'source text'); +assert.sameValue(result.flags, 'i'); + +obj[Symbol.match] = 86; +result = new RegExp(obj); +assert.sameValue(Object.getPrototypeOf(result), RegExp.prototype); +assert.sameValue(result.source, 'source text'); +assert.sameValue(result.flags, 'i'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-global.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-global.js new file mode 100644 index 0000000000..86ac657df8 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-global.js @@ -0,0 +1,97 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Type coercion of `global` property value +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 6. Let global be ToBoolean(Get(R, "global")). +features: [Symbol.match] +---*/ + +var r = /./; +var val, result; +Object.defineProperty(r, 'global', { + get: function() { + return val; + } +}); + +val = false; +result = r[Symbol.match]('ab'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 'a'); + +val = ''; +result = r[Symbol.match]('ab'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 'a'); + +val = 0; +result = r[Symbol.match]('ab'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 'a'); + +val = null; +result = r[Symbol.match]('ab'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 'a'); + +val = undefined; +result = r[Symbol.match]('ab'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 'a'); + +val = true; +result = r[Symbol.match]('ab'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 2); +assert.sameValue(result[0], 'a'); +assert.sameValue(result[1], 'b'); + +val = 'truthy'; +result = r[Symbol.match]('ab'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 2); +assert.sameValue(result[0], 'a'); +assert.sameValue(result[1], 'b'); + +val = 86; +result = r[Symbol.match]('ab'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 2); +assert.sameValue(result[0], 'a'); +assert.sameValue(result[1], 'b'); + +val = []; +result = r[Symbol.match]('ab'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 2); +assert.sameValue(result[0], 'a'); +assert.sameValue(result[1], 'b'); + +val = Symbol.match; +result = r[Symbol.match]('ab'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 2); +assert.sameValue(result[0], 'a'); +assert.sameValue(result[1], 'b'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-lastindex-err.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-lastindex-err.js new file mode 100644 index 0000000000..9b3fd43846 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-lastindex-err.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Behavior when coercion of `lastIndex` attribute throws an error +es6id: 21.2.5.6 +info: > + [...] + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 4. Let lastIndex be ToLength(Get(R,"lastIndex")). + 5. ReturnIfAbrupt(lastIndex). +features: [Symbol.match] +---*/ + +var r = /./; +r.lastIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-lastindex.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-lastindex.js new file mode 100644 index 0000000000..a16b3261ed --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-lastindex.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Type coercion of `lastIndex` property value +es6id: 21.2.5.6 +info: > + [...] + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 4. Let lastIndex be ToLength(Get(R,"lastIndex")). +features: [Symbol.match] +---*/ + +var r = /./y; +var result; + +r.lastIndex = '1.9'; + +result = r[Symbol.match]('abc'); + +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 'b'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-sticky.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-sticky.js new file mode 100644 index 0000000000..0f6a28edf7 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-sticky.js @@ -0,0 +1,79 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Type coercion of `sticky` property value +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 8. Let sticky be ToBoolean(Get(R, "sticky")). + [...] + 18. If global is true or sticky is true, + a. Let setStatus be Set(R, "lastIndex", e, true). +features: [Symbol.match] +---*/ + +var r = /./; +var val; +Object.defineProperty(r, 'sticky', { + get: function() { + return val; + } +}); + +val = false; +r[Symbol.match]('a'); +assert.sameValue(r.lastIndex, 0, 'literal false'); + +val = ''; +r[Symbol.match]('a'); +assert.sameValue(r.lastIndex, 0, 'empty string'); + +val = 0; +r[Symbol.match]('a'); +assert.sameValue(r.lastIndex, 0, 'zero'); + +val = null; +r[Symbol.match]('a'); +assert.sameValue(r.lastIndex, 0, 'null'); + +val = undefined; +r[Symbol.match]('a'); +assert.sameValue(r.lastIndex, 0, 'undefined'); + +val = true; +r[Symbol.match]('a'); +assert.sameValue(r.lastIndex, 1, 'literal true'); + +r.lastIndex = 0; +val = 'truthy'; +r[Symbol.match]('a'); +assert.sameValue(r.lastIndex, 1, 'non-empty string'); + +r.lastIndex = 0; +val = 86; +r[Symbol.match]('a'); +assert.sameValue(r.lastIndex, 1, 'nonzero number'); + +r.lastIndex = 0; +val = []; +r[Symbol.match]('a'); +assert.sameValue(r.lastIndex, 1, 'array'); + +r.lastIndex = 0; +val = Symbol.match; +r[Symbol.match]('a'); +assert.sameValue(r.lastIndex, 1, 'symbol'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-return-val.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-return-val.js new file mode 100644 index 0000000000..522111520c --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-return-val.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. + +/*--- +description: Return value after a match failure +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 3. Let length be the number of code units in S. + 4. Let lastIndex be ToLength(Get(R,"lastIndex")). + [...] + 14. Let matchSucceeded be false. + 15. Repeat, while matchSucceeded is false + a. If lastIndex > length, then + i. Let setStatus be Set(R, "lastIndex", 0, true). + ii. ReturnIfAbrupt(setStatus). + iii. Return null. +features: [Symbol.match] +---*/ + +var r = /a/; + +assert.sameValue(r[Symbol.match]('b'), null); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex-err.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex-err.js new file mode 100644 index 0000000000..4c3261feea --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex-err.js @@ -0,0 +1,40 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error thrown while setting `lastIndex` after a match failure +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 3. Let length be the number of code units in S. + 4. Let lastIndex be ToLength(Get(R,"lastIndex")). + [...] + 14. Let matchSucceeded be false. + 15. Repeat, while matchSucceeded is false + a. If lastIndex > length, then + i. Let setStatus be Set(R, "lastIndex", 0, true). + ii. ReturnIfAbrupt(setStatus). + iii. Return null. +features: [Symbol.match] +---*/ + +var r = /a/; +Object.defineProperty(r, 'lastIndex', { writable: false }); + +assert.throws(TypeError, function() { + r[Symbol.match]('b'); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex.js new file mode 100644 index 0000000000..6caa195cb4 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex.js @@ -0,0 +1,39 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Setting `lastIndex` to `0` after a match failure +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 3. Let length be the number of code units in S. + 4. Let lastIndex be ToLength(Get(R,"lastIndex")). + [...] + 14. Let matchSucceeded be false. + 15. Repeat, while matchSucceeded is false + a. If lastIndex > length, then + i. Let setStatus be Set(R, "lastIndex", 0, true). + ii. ReturnIfAbrupt(setStatus). + iii. Return null. +features: [Symbol.match] +---*/ + +var r = /a/; +r.lastIndex = 3; + +r[Symbol.match]('b'); + +assert.sameValue(r.lastIndex, 0); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-return-val.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-return-val.js new file mode 100644 index 0000000000..b90478d936 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-return-val.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Return value after a "sticky" match failure +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 8. Let sticky be ToBoolean(Get(R, "sticky")). + [...] + 14. Let matchSucceeded be false. + 15. Repeat, while matchSucceeded is false + [...] + c. If r is failure, then + i. If sticky is true, then + 1. Let setStatus be Set(R, "lastIndex", 0, true). + 2. ReturnIfAbrupt(setStatus). + 3. Return null. +features: [Symbol.match] +---*/ + +assert.sameValue(/a/y[Symbol.match]('ba'), null); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex-err.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex-err.js new file mode 100644 index 0000000000..d7b31cfa91 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex-err.js @@ -0,0 +1,42 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error thrown while setting `lastIndex` after a "sticky" match + failure +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 8. Let sticky be ToBoolean(Get(R, "sticky")). + [...] + 14. Let matchSucceeded be false. + 15. Repeat, while matchSucceeded is false + [...] + c. If r is failure, then + i. If sticky is true, then + 1. Let setStatus be Set(R, "lastIndex", 0, true). + 2. ReturnIfAbrupt(setStatus). +features: [Symbol.match] +---*/ + +var r = /a/y; + +Object.defineProperty(r, 'lastIndex', { writable: false }); + +assert.throws(TypeError, function() { + r[Symbol.match]('ba'); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex.js new file mode 100644 index 0000000000..5e0db49845 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Setting `lastIndex` to `0` after a "sticky" match failure +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 8. Let sticky be ToBoolean(Get(R, "sticky")). + [...] + 14. Let matchSucceeded be false. + 15. Repeat, while matchSucceeded is false + [...] + c. If r is failure, then + i. If sticky is true, then + 1. Let setStatus be Set(R, "lastIndex", 0, true). +features: [Symbol.match] +---*/ + +var r = /a/y; +r.lastIndex = 1; + +r[Symbol.match]('aba'); + +assert.sameValue(r.lastIndex, 0); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-get-global-err.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-get-global-err.js new file mode 100644 index 0000000000..508560d977 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-get-global-err.js @@ -0,0 +1,41 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Behavior when error thrown by accessing the `global` property +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 6. Let global be ToBoolean(Get(R, "global")). + 7. ReturnIfAbrupt(global). +features: [Symbol.match] +---*/ + +var r = /./; +var callCount = 0; +Object.defineProperty(r, 'global', { + get: function() { + callCount += 1; + + if (callCount > 1) { + throw new Test262Error(); + } + } +}); + +assert.throws(Test262Error, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-get-sticky-err.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-get-sticky-err.js new file mode 100644 index 0000000000..4b1efa9f41 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-get-sticky-err.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Behavior when error thrown by accessing the `sticky` property +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 8. Let sticky be ToBoolean(Get(R, "sticky")). + 9. ReturnIfAbrupt(sticky). +features: [Symbol.match] +---*/ + +var r = /./; +var shouldThrow = false; +Object.defineProperty(r, 'sticky', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-infer-unicode.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-infer-unicode.js new file mode 100644 index 0000000000..a280e2ea17 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-infer-unicode.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Extended unicode support is determined by internal slot (not `unicode` + property) +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 12. Let flags be the value of R’s [[OriginalFlags]] internal slot. + 13. If flags contains "u", let fullUnicode be true, else let fullUnicode be + false. +features: [Symbol.match] +---*/ + +var r; + +r = /\udf06/; +Object.defineProperty(r, 'unicode', { value: true }); +assert.notSameValue(r[Symbol.match]('\ud834\udf06'), null); + +r = /\udf06/u; +Object.defineProperty(r, 'unicode', { value: false }); +assert.sameValue(r[Symbol.match]('\ud834\udf06'), null); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex-err.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex-err.js new file mode 100644 index 0000000000..036eed90ea --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex-err.js @@ -0,0 +1,43 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error thrown while setting `lastIndex` after a "global" match + success +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 18. If global is true or sticky is true, + a. Let setStatus be Set(R, "lastIndex", e, true). + b. ReturnIfAbrupt(setStatus). +features: [Symbol.match] +---*/ + +var r = /b/; +var callCount = 0; + +Object.defineProperty(r, 'lastIndex', { writable: false }); +Object.defineProperty(r, 'global', { + get: function() { + callCount += 1; + return callCount > 1; + } +}); + +assert.throws(TypeError, function() { + r[Symbol.match]('abc'); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex.js new file mode 100644 index 0000000000..9e95de64e4 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex.js @@ -0,0 +1,41 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Setting `lastIndex` after a "global" match success +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 16. Let e be r's endIndex value. + [...] + 18. If global is true or sticky is true, + a. Let setStatus be Set(R, "lastIndex", e, true). +features: [Symbol.match] +---*/ + +var r = /b/; +var callCount = 0; + +Object.defineProperty(r, 'global', { + get: function() { + callCount += 1; + return callCount > 1; + } +}); + +r[Symbol.match]('abc'); + +assert.sameValue(r.lastIndex, 2); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-return-val-groups.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-return-val-groups.js new file mode 100644 index 0000000000..5aa858b67d --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-return-val-groups.js @@ -0,0 +1,49 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Return value after successful match with capturing groups +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 20. Let A be ArrayCreate(n + 1). + [...] + 24. Perform CreateDataProperty(A, "index", matchIndex). + 25. Perform CreateDataProperty(A, "input", S). + 26. Let matchedSubstr be the matched substring (i.e. the portion of S + between offset lastIndex inclusive and offset e exclusive). + 27. Perform CreateDataProperty(A, "0", matchedSubstr). + 28. For each integer i such that i > 0 and i ≤ n + [...] + d. Else, fullUnicode is false, + i. Assert: captureI is a List of code units. + ii. Let capturedValue be a string consisting of the code units of + captureI. + e. Perform CreateDataProperty(A, ToString(i) , capturedValue). + [...] + 29. Return A. +features: [Symbol.match] +---*/ + +var result = /b(.).(.)./[Symbol.match]('abcdefg'); + +assert(Array.isArray(result)); +assert.sameValue(result.index, 1); +assert.sameValue(result.input, 'abcdefg'); +assert.sameValue(result.length, 3); +assert.sameValue(result[0], 'bcdef'); +assert.sameValue(result[1], 'c'); +assert.sameValue(result[2], 'e'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-return-val.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-return-val.js new file mode 100644 index 0000000000..3c310adf77 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-return-val.js @@ -0,0 +1,40 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Return value after successful match +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 20. Let A be ArrayCreate(n + 1). + [...] + 24. Perform CreateDataProperty(A, "index", matchIndex). + 25. Perform CreateDataProperty(A, "input", S). + 26. Let matchedSubstr be the matched substring (i.e. the portion of S + between offset lastIndex inclusive and offset e exclusive). + 27. Perform CreateDataProperty(A, "0", matchedSubstr). + [...] + 29. Return A. +features: [Symbol.match] +---*/ + +var result = /b./[Symbol.match]('abcd'); + +assert(Array.isArray(result)); +assert.sameValue(result.index, 1); +assert.sameValue(result.input, 'abcd'); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 'bc'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-u-return-val-groups.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-u-return-val-groups.js new file mode 100644 index 0000000000..b94f4b08c5 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-u-return-val-groups.js @@ -0,0 +1,51 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Return value after successful match with extended unicode capturing groups +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 20. Let A be ArrayCreate(n + 1). + [...] + 24. Perform CreateDataProperty(A, "index", matchIndex). + 25. Perform CreateDataProperty(A, "input", S). + 26. Let matchedSubstr be the matched substring (i.e. the portion of S + between offset lastIndex inclusive and offset e exclusive). + 27. Perform CreateDataProperty(A, "0", matchedSubstr). + 28. For each integer i such that i > 0 and i ≤ n + [...] + c. Else if fullUnicode is true, + i. Assert: captureI is a List of code points. + ii. Let capturedValue be a string whose code units are the + UTF16Encoding (10.1.1) of the code points of captureI. + [...] + e. Perform CreateDataProperty(A, ToString(i) , capturedValue). + [...] + 29. Return A. +features: [Symbol.match] +---*/ + +var result = /b(.).(.)./u[Symbol.match]('ab\ud834\udf06defg'); + +assert(Array.isArray(result)); +assert.sameValue(result.index, 1); +assert.sameValue(result.input, 'ab\ud834\udf06defg'); +assert.sameValue(result.length, 3); +assert.sameValue(result[0], 'b\ud834\udf06def'); +assert.sameValue(result[1], '\ud834\udf06'); +assert.sameValue(result[2], 'e'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-y-set-lastindex-err.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-y-set-lastindex-err.js new file mode 100644 index 0000000000..0c06c3a4e9 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-y-set-lastindex-err.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. + +/*--- +description: > + Behavior when error thrown while setting `lastIndex` after a "sticky" match + success +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 18. If global is true or sticky is true, + a. Let setStatus be Set(R, "lastIndex", e, true). + b. ReturnIfAbrupt(setStatus). +features: [Symbol.match] +---*/ + +var r = /a/y; + +Object.defineProperty(r, 'lastIndex', { writable: false }); + +assert.throws(TypeError, function() { + r[Symbol.match]('a'); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-y-set-lastindex.js b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-y-set-lastindex.js new file mode 100644 index 0000000000..d0972be11d --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/builtin-success-y-set-lastindex.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Setting `lastIndex` after a "sticky" match success +es6id: 21.2.5.6 +info: > + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 7. Return RegExpBuiltinExec(R, S). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 16. Let e be r's endIndex value. + [...] + 18. If global is true or sticky is true, + a. Let setStatus be Set(R, "lastIndex", e, true). +features: [Symbol.match] +---*/ + +var r = /a/y; + +r[Symbol.match]('a'); + +assert.sameValue(r.lastIndex, 1); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/coerce-arg-err.js b/test/built-ins/RegExp/prototype/Symbol.match/coerce-arg-err.js new file mode 100644 index 0000000000..78f1e885e6 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/coerce-arg-err.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error thrown during string coercion of first parameter +es6id: 21.2.5.6 +info: > + 21.2.5.6 RegExp.prototype [ @@match ] ( string ) + + [...] + 3. Let S be ToString(string) + 4. ReturnIfAbrupt(S). +features: [Symbol.match] +---*/ + +var str = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + /./[Symbol.match](str); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/coerce-arg.js b/test/built-ins/RegExp/prototype/Symbol.match/coerce-arg.js new file mode 100644 index 0000000000..0c3202aa29 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/coerce-arg.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: String coercion of first parameter +es6id: 21.2.5.6 +info: > + 21.2.5.6 RegExp.prototype [ @@match ] ( string ) + + [...] + 3. Let S be ToString(string) + [...] +features: [Symbol.match] +---*/ + +var obj = { + valueOf: function() { + $ERROR('This method should not be invoked.'); + }, + toString: function() { + return 'toString value'; + } +}; + +assert.notSameValue(/toString value/[Symbol.match](obj), null); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/coerce-global.js b/test/built-ins/RegExp/prototype/Symbol.match/coerce-global.js new file mode 100644 index 0000000000..ff6658a3c2 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/coerce-global.js @@ -0,0 +1,68 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Boolean coercion of `global` property +es6id: 21.2.5.6 +info: > + 21.2.5.6 RegExp.prototype [ @@match ] ( string ) + + [...] + 5. Let global be ToBoolean(Get(rx, "global")). + [...] +features: [Symbol.match] +---*/ + +var r = /a/; +var result; +Object.defineProperty(r, 'global', { writable: true }); + +r.global = undefined; +result = r[Symbol.match]('aa'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); + +r.global = null; +result = r[Symbol.match]('aa'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); + +r.global = true; +result = r[Symbol.match]('aa'); +assert.notSameValue(result, null); +assert.notSameValue(result.length, 1); + +r.global = false; +result = r[Symbol.match]('aa'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); + +r.global = NaN; +result = r[Symbol.match]('aa'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); + +r.global = 0; +result = r[Symbol.match]('aa'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); + +r.global = ''; +result = r[Symbol.match]('aa'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 1); + +r.global = 86; +result = r[Symbol.match]('aa'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 2); + +r.global = Symbol.match; +result = r[Symbol.match]('aa'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 2); + +r.global = {}; +result = r[Symbol.match]('aa'); +assert.notSameValue(result, null); +assert.sameValue(result.length, 2); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/get-sticky-coerce.js b/test/built-ins/RegExp/prototype/Symbol.match/coerce-sticky.js similarity index 95% rename from test/built-ins/RegExp/prototype/Symbol.match/get-sticky-coerce.js rename to test/built-ins/RegExp/prototype/Symbol.match/coerce-sticky.js index cf78bb1b5e..a171141603 100644 --- a/test/built-ins/RegExp/prototype/Symbol.match/get-sticky-coerce.js +++ b/test/built-ins/RegExp/prototype/Symbol.match/coerce-sticky.js @@ -17,7 +17,7 @@ info: > [...] 8. Let sticky be ToBoolean(Get(R, "sticky")). -features: [Symbol, Symbol.match] +features: [Symbol.match] ---*/ var r = /a/; @@ -41,13 +41,13 @@ assert.notSameValue(r[Symbol.match]('ba'), null); r.sticky = 0; assert.notSameValue(r[Symbol.match]('ba'), null); -r.sticky = 86; -assert.sameValue(r[Symbol.match]('ba'), null); - r.sticky = ''; assert.notSameValue(r[Symbol.match]('ba'), null); -r.sticky = Symbol(); +r.sticky = 86; +assert.sameValue(r[Symbol.match]('ba'), null); + +r.sticky = Symbol.match; assert.sameValue(r[Symbol.match]('ba'), null); r.sticky = {}; diff --git a/test/built-ins/RegExp/prototype/Symbol.match/exec-err.js b/test/built-ins/RegExp/prototype/Symbol.match/exec-err.js new file mode 100644 index 0000000000..cba4d502f6 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/exec-err.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Behavior when error is thrown by `exec` method +es6id: 21.2.5.6 +info: > + [...] + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 5. If IsCallable(exec) is true, then + a. Let result be Call(exec, R, «S»). + b. ReturnIfAbrupt(result). +features: [Symbol.match] +---*/ + +var r = /./; + +r.exec = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/exec-invocation.js b/test/built-ins/RegExp/prototype/Symbol.match/exec-invocation.js new file mode 100644 index 0000000000..06d20f9a13 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/exec-invocation.js @@ -0,0 +1,41 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Invocation of `exec` method +es6id: 21.2.5.6 +info: > + [...] + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 5. If IsCallable(exec) is true, then + a. Let result be Call(exec, R, «S»). +features: [Symbol.match] +---*/ + +var r = /./; +var callCount = 0; +var arg = { + toString: function() { + return 'string form'; + } +}; +var thisValue, args; + +r.exec = function() { + thisValue = this; + args = arguments; + callCount += 1; + return null; +}; + +r[Symbol.match](arg); + +assert.sameValue(callCount, 1); +assert.sameValue(thisValue, r); +assert.sameValue(args.length, 1); +assert.sameValue(args[0], 'string form'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/exec-return-type-invalid.js b/test/built-ins/RegExp/prototype/Symbol.match/exec-return-type-invalid.js new file mode 100644 index 0000000000..169f6e91d8 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/exec-return-type-invalid.js @@ -0,0 +1,56 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Behavior when `exec` method returns value of invalid type +es6id: 21.2.5.6 +info: > + [...] + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 5. If IsCallable(exec) is true, then + a. Let result be Call(exec, R, «S»). + b. ReturnIfAbrupt(result). + c. If Type(result) is neither Object or Null, throw a TypeError + exception. +features: [Symbol.match] +---*/ + +var r = /./; +var retValue; +r.exec = function() { + return retValue; +}; + +// Explicitly assert the method's presence to avoid false positives (i.e. +// TypeErrors thrown by invoking an undefined reference). +assert.sameValue(typeof r[Symbol.match], 'function'); + +retValue = undefined; +assert.throws(TypeError, function() { + r[Symbol.match](''); +}); + +retValue = true; +assert.throws(TypeError, function() { + r[Symbol.match](''); +}); + +retValue = 'string'; +assert.throws(TypeError, function() { + r[Symbol.match](''); +}); + +retValue = Symbol.match; +assert.throws(TypeError, function() { + r[Symbol.match](''); +}); + +retValue = 86; +assert.throws(TypeError, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/exec-return-type-valid.js b/test/built-ins/RegExp/prototype/Symbol.match/exec-return-type-valid.js new file mode 100644 index 0000000000..fd3a02e12e --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/exec-return-type-valid.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Behavior when `exec` method returns value of valid type +es6id: 21.2.5.6 +info: > + [...] + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 5. If IsCallable(exec) is true, then + a. Let result be Call(exec, R, «S»). + b. ReturnIfAbrupt(result). + c. If Type(result) is neither Object or Null, throw a TypeError + exception. + d. Return result. +features: [Symbol.match] +---*/ + +var r = /./; +var retValue; +r.exec = function() { + return retValue; +}; + +retValue = null; +assert.sameValue(r[Symbol.match](''), retValue); + +retValue = {}; +assert.sameValue(r[Symbol.match](''), retValue); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-coerce-result-err.js b/test/built-ins/RegExp/prototype/Symbol.match/g-coerce-result-err.js new file mode 100644 index 0000000000..56571ec322 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-coerce-result-err.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error is thrown while coercing `0` property of match result +es6id: 21.2.5.6 +info: > + 7. If global is false, then + [...] + 8. Else global is true, + [...] + g. Repeat, + i. Let result be RegExpExec(rx, S). + [...] + iv. Else result is not null, + 1. Let matchStr be ToString(Get(result, "0")). + 2. ReturnIfAbrupt(matchStr). +features: [Symbol.match] +---*/ + +var r = /./g; +r.exec = function() { + return { + 0: { + toString: function() { + throw new Test262Error(); + } + } + }; +}; + +assert.throws(Test262Error, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-get-exec-err.js b/test/built-ins/RegExp/prototype/Symbol.match/g-get-exec-err.js new file mode 100644 index 0000000000..8f1f165b54 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-get-exec-err.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when there is an error thrown while accessing the `exec` method of + "global" instances +es6id: 21.2.5.6 +info: > + 7. If global is false, then + [...] + 8. Else global is true, + [...] + g. Repeat, + i. Let result be RegExpExec(rx, S). + ii. ReturnIfAbrupt(result). + + ES6 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 3. Let exec be Get(R, "exec"). + 4. ReturnIfAbrupt(exec). +features: [Symbol.match] +---*/ + +var r = { global: true }; +Object.defineProperty(r, 'exec', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + RegExp.prototype[Symbol.match].call(r, ''); +}); + +assert.sameValue(r.lastIndex, 0, 'Error thrown after setting `lastIndex`'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-get-result-err.js b/test/built-ins/RegExp/prototype/Symbol.match/g-get-result-err.js new file mode 100644 index 0000000000..dd41d8df79 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-get-result-err.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error is thrown while accessing `0` property of match result +es6id: 21.2.5.6 +info: > + 7. If global is false, then + [...] + 8. Else global is true, + [...] + g. Repeat, + i. Let result be RegExpExec(rx, S). + [...] + iv. Else result is not null, + 1. Let matchStr be ToString(Get(result, "0")). + 2. ReturnIfAbrupt(matchStr). +features: [Symbol.match] +---*/ + +var r = /./g; +var poisonedZero = { + get 0() { + throw new Test262Error(); + } +}; + +r.exec = function() { + return poisonedZero; +}; + +assert.throws(Test262Error, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-init-lastindex-err.js b/test/built-ins/RegExp/prototype/Symbol.match/g-init-lastindex-err.js new file mode 100644 index 0000000000..e2d99fee19 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-init-lastindex-err.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Behavior when `lastIndex` cannot be set on "global" instances +es6id: 21.2.5.6 +info: > + 7. If global is false, then + [...] + 8. Else global is true, + [...] + c. Let setStatus be Set(rx, "lastIndex", 0, true). + d. ReturnIfAbrupt(setStatus). +features: [Symbol.match] +---*/ + +var r = /./g; +Object.defineProperty(r, 'lastIndex', { writable: false }); + +assert.throws(TypeError, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-init-lastindex.js b/test/built-ins/RegExp/prototype/Symbol.match/g-init-lastindex.js new file mode 100644 index 0000000000..ae7ded3a96 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-init-lastindex.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Initializing the value of `lastIndex` on "global" instances +es6id: 21.2.5.6 +info: > + 7. If global is false, then + [...] + 8. Else global is true, + [...] + c. Let setStatus be Set(rx, "lastIndex", 0, true). +features: [Symbol.match] +---*/ + +var r = /./g; + +r.lastIndex = 1; + +assert.notSameValue(r[Symbol.match]('a'), null); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-advance-lastindex.js b/test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-advance-lastindex.js new file mode 100644 index 0000000000..51467818b4 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-advance-lastindex.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. + +/*--- +description: > + lastIndex is explicitly advanced for zero-length matches for "global" + instances +es6id: 21.2.5.6 +info: > + 7. If global is false, then + [...] + 8. Else global is true, + [...] + g. Repeat, + i. Let result be RegExpExec(rx, S). + [...] + iv. Else result is not null, + [...] + 5. If matchStr is the empty String, then + [...] + c. Let nextIndex be AdvanceStringIndex(S, thisIndex, + fullUnicode). + d. Let setStatus be Set(rx, "lastIndex", nextIndex, true). + e. ReturnIfAbrupt(setStatus). + 6. Increment n. +features: [Symbol.match] +---*/ + +var result = /(?:)/g[Symbol.match]('abc'); + +assert.notSameValue(result, null); +assert.sameValue(result.length, 4); +assert.sameValue(result[0], ''); +assert.sameValue(result[1], ''); +assert.sameValue(result[2], ''); +assert.sameValue(result[3], ''); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-coerce-lastindex-err.js b/test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-coerce-lastindex-err.js new file mode 100644 index 0000000000..5ec59caa21 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-coerce-lastindex-err.js @@ -0,0 +1,50 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error is thrown while type coercing `lastIndex` of zero-width + match +es6id: 21.2.5.6 +info: > + 7. If global is false, then + [...] + 8. Else global is true, + [...] + g. Repeat, + i. Let result be RegExpExec(rx, S). + [...] + iv. Else result is not null, + 1. Let matchStr be ToString(Get(result, "0")). + [...] + 5. If matchStr is the empty String, then + a. Let thisIndex be ToLength(Get(rx, "lastIndex")). + b. ReturnIfAbrupt(thisIndex). +features: [Symbol.match] +---*/ + +var r = /./g; +var nextMatch; + +r.exec = function() { + var thisMatch = nextMatch; + if (thisMatch === null) { + return null; + } + nextMatch = null; + return { + get 0() { + r.lastIndex = { + valueOf: function() { + throw new Test262Error(); + } + }; + return thisMatch; + } + }; +}; + +nextMatch = ''; +assert.throws(Test262Error, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-set-lastindex-err.js b/test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-set-lastindex-err.js new file mode 100644 index 0000000000..f4fd977548 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-match-empty-set-lastindex-err.js @@ -0,0 +1,47 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error is thrown while setting `lastIndex` after a zero-width + match +es6id: 21.2.5.6 +info: > + 7. If global is false, then + [...] + 8. Else global is true, + [...] + g. Repeat, + i. Let result be RegExpExec(rx, S). + [...] + iv. Else result is not null, + 1. Let matchStr be ToString(Get(result, "0")). + [...] + 5. If matchStr is the empty String, then + [...] + d. Let setStatus be Set(rx, "lastIndex", nextIndex, true). + e. ReturnIfAbrupt(setStatus). +features: [Symbol.match] +---*/ + +var exec = function() { + var thisMatch = nextMatch; + if (thisMatch === null) { + return null; + } + nextMatch = null; + return { + get 0() { + Object.defineProperty(r, 'lastIndex', { writable: false }); + return thisMatch; + } + }; +}; +var r, nextMatch; + +r = /./g; +r.exec = exec; +nextMatch = ''; +assert.throws(TypeError, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-match-no-coerce-lastindex.js b/test/built-ins/RegExp/prototype/Symbol.match/g-match-no-coerce-lastindex.js new file mode 100644 index 0000000000..1215eca2c9 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-match-no-coerce-lastindex.js @@ -0,0 +1,47 @@ +// Copyright (C) 2015 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + The `lastIndex` property is not coerced for a non-empty string match +es6id: 21.2.5.6 +info: > + 7. If global is false, then + [...] + 8. Else global is true, + [...] + g. Repeat, + i. Let result be RegExpExec(rx, S). + [...] + iv. Else result is not null, + 1. Let matchStr be ToString(Get(result, "0")). + [...] + 5. If matchStr is the empty String, then + a. Let thisIndex be ToLength(Get(rx, "lastIndex")). + b. ReturnIfAbrupt(thisIndex). +features: [Symbol.match] +---*/ + +var r = /./g; +var nextMatch; + +r.exec = function() { + var thisMatch = nextMatch; + if (thisMatch === null) { + return null; + } + nextMatch = null; + return { + get 0() { + r.lastIndex = { + valueOf: function() { + $ERROR('This function should not be invoked.'); + } + }; + return thisMatch; + } + }; +}; + +nextMatch = 'a non-empty string'; +r[Symbol.match](''); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-match-no-set-lastindex.js b/test/built-ins/RegExp/prototype/Symbol.match/g-match-no-set-lastindex.js new file mode 100644 index 0000000000..e2840ab1e9 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-match-no-set-lastindex.js @@ -0,0 +1,43 @@ +// Copyright (C) 2015 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: The `lastIndex` is not set after a non-zero-width match +es6id: 21.2.5.6 +info: > + 7. If global is false, then + [...] + 8. Else global is true, + [...] + g. Repeat, + i. Let result be RegExpExec(rx, S). + [...] + iv. Else result is not null, + 1. Let matchStr be ToString(Get(result, "0")). + [...] + 5. If matchStr is the empty String, then + [...] + d. Let setStatus be Set(rx, "lastIndex", nextIndex, true). + e. ReturnIfAbrupt(setStatus). +features: [Symbol.match] +---*/ + +var exec = function() { + var thisMatch = nextMatch; + if (thisMatch === null) { + return null; + } + nextMatch = null; + return { + get 0() { + Object.defineProperty(r, 'lastIndex', { writable: false }); + return thisMatch; + } + }; +}; +var r, nextMatch; + +r = /./g; +r.exec = exec; +nextMatch = 'a non-empty string'; +r[Symbol.match](''); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-success-return-val.js b/test/built-ins/RegExp/prototype/Symbol.match/g-success-return-val.js new file mode 100644 index 0000000000..da5958ea7c --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-success-return-val.js @@ -0,0 +1,48 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Return value when matches occur with the `global` flag +es6id: 21.2.5.6 +info: > + [...] + 7. If global is false, then + [...] + 8. Else global is true, + [...] + e. Let A be ArrayCreate(0). + [...] + g. Repeat, + i. Let result be RegExpExec(rx, S). + ii. ReturnIfAbrupt(result). + iii. If result is null, then + 1. If n=0, return null. + 2. Else, return A. +features: [Symbol.match] +---*/ + +var result = /.(.)./g[Symbol.match]('abcdefghi'); + +assert(Array.isArray(result)); + +assert.sameValue( + Object.hasOwnProperty.call(result, 'index'), + false, + 'Does not define an `index` "own" property' +); +assert.sameValue( + result.index, undefined, 'Does not define an `index` property' +); +assert.sameValue( + Object.hasOwnProperty.call(result, 'input'), + false, + 'Does not define an `input` "own" property' +); +assert.sameValue( + result.input, undefined, 'Does not define an `input` property' +); + +assert.sameValue(result.length, 3); +assert.sameValue(result[0], 'abc'); +assert.sameValue(result[1], 'def'); +assert.sameValue(result[2], 'ghi'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/g-zero-matches.js b/test/built-ins/RegExp/prototype/Symbol.match/g-zero-matches.js new file mode 100644 index 0000000000..9d3cf6f8ea --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/g-zero-matches.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Return value when no matches occur with the `global` flag +es6id: 21.2.5.6 +info: > + [...] + 7. If global is false, then + [...] + 8. Else global is true, + [...] + g. Repeat, + i. Let result be RegExpExec(rx, S). + ii. ReturnIfAbrupt(result). + iii. If result is null, then + 1. If n=0, return null. +features: [Symbol.match] +---*/ + +assert.sameValue(/a/g[Symbol.match]('b'), null); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/get-exec-err.js b/test/built-ins/RegExp/prototype/Symbol.match/get-exec-err.js new file mode 100644 index 0000000000..813667a0f4 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/get-exec-err.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Behavior when error is thrown while accessing `exec` property +es6id: 21.2.5.6 +info: > + [...] + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 3. Let exec be Get(R, "exec"). + 4. ReturnIfAbrupt(exec). +features: [Symbol.match] +---*/ + +var r = /./; + +Object.defineProperty(r, 'exec', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + r[Symbol.match](''); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/get-global-err.js b/test/built-ins/RegExp/prototype/Symbol.match/get-global-err.js new file mode 100644 index 0000000000..32866ed630 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/get-global-err.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Behavior when error is thrown during retrieval of `global` property +es6id: 21.2.5.6 +info: > + 5. Let global be ToBoolean(Get(rx, "global")). + 6. ReturnIfAbrupt(global). +features: [Symbol.match] +---*/ + +var obj = { + get global() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + RegExp.prototype[Symbol.match].call(obj); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/length.js b/test/built-ins/RegExp/prototype/Symbol.match/length.js new file mode 100644 index 0000000000..249d60fc28 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/length.js @@ -0,0 +1,25 @@ +// 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.6 +description: RegExp.prototype[Symbol.match] `length` property +info: > + ES6 Section 17: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this value + is equal to the largest number of named arguments shown in the subclause + headings for the function description, including optional parameters. + + [...] + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(RegExp.prototype[Symbol.match].length, 1); + +verifyNotEnumerable(RegExp.prototype[Symbol.match], 'length'); +verifyNotWritable(RegExp.prototype[Symbol.match], 'length'); +verifyConfigurable(RegExp.prototype[Symbol.match], 'length'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/name.js b/test/built-ins/RegExp/prototype/Symbol.match/name.js new file mode 100644 index 0000000000..d3ceefce2e --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/name.js @@ -0,0 +1,23 @@ +// 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.6 +description: RegExp.prototype[Symbol.match] `name` property +info: > + The value of the name property of this function is "[Symbol.match]". + + ES6 Section 17: + + [...] + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(RegExp.prototype[Symbol.match].name, '[Symbol.match]'); + +verifyNotEnumerable(RegExp.prototype[Symbol.match], 'name'); +verifyNotWritable(RegExp.prototype[Symbol.match], 'name'); +verifyConfigurable(RegExp.prototype[Symbol.match], 'name'); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/prop-desc.js b/test/built-ins/RegExp/prototype/Symbol.match/prop-desc.js new file mode 100644 index 0000000000..63a08e43d0 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/prop-desc.js @@ -0,0 +1,18 @@ +// 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.6 +description: RegExp.prototype[Symbol.match] property descriptor +info: > + ES6 Section 17 + + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(RegExp.prototype, Symbol.match); +verifyWritable(RegExp.prototype, Symbol.match); +verifyConfigurable(RegExp.prototype, Symbol.match); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/this-val-non-obj.js b/test/built-ins/RegExp/prototype/Symbol.match/this-val-non-obj.js new file mode 100644 index 0000000000..79bbba3363 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/this-val-non-obj.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: The `this` value must be an object +es6id: 21.2.5.6 +info: > + 1. Let rx be the this value. + 2. If Type(rx) is not Object, throw a TypeError exception. +features: [Symbol.match] +---*/ + +assert.throws(TypeError, function() { + RegExp.prototype[Symbol.match].call(undefined); +}); + +assert.throws(TypeError, function() { + RegExp.prototype[Symbol.match].call(null); +}); + +assert.throws(TypeError, function() { + RegExp.prototype[Symbol.match].call(true); +}); + +assert.throws(TypeError, function() { + RegExp.prototype[Symbol.match].call('string'); +}); + +assert.throws(TypeError, function() { + RegExp.prototype[Symbol.match].call(Symbol.match); +}); + +assert.throws(TypeError, function() { + RegExp.prototype[Symbol.match].call(86); +}); diff --git a/test/built-ins/RegExp/prototype/Symbol.match/this-val-non-regexp.js b/test/built-ins/RegExp/prototype/Symbol.match/this-val-non-regexp.js new file mode 100644 index 0000000000..567fa59310 --- /dev/null +++ b/test/built-ins/RegExp/prototype/Symbol.match/this-val-non-regexp.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. + +/*--- +description: > + Behavior when invoked on an object without a a [[RegExpMatcher]] internal + slot +es6id: 21.2.5.6 +info: > + [...] + 7. If global is false, then + a. Return RegExpExec(rx, S). + + 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S ) + + [...] + 5. If IsCallable(exec) is true, then + [...] + d. Return result. + 6. If R does not have a [[RegExpMatcher]] internal slot, throw a TypeError + exception. +features: [Symbol.match] +---*/ + +var objWithExec = { + exec: function() { + return null; + } +}; +var objWithoutExec = {}; + +RegExp.prototype[Symbol.match].call(objWithExec); + +assert.throws(TypeError, function() { + RegExp.prototype[Symbol.match].call(objWithoutExec); +}); diff --git a/test/built-ins/String/prototype/match/S15.5.4.10_A10.js b/test/built-ins/String/prototype/match/S15.5.4.10_A10.js deleted file mode 100644 index 7febd2746f..0000000000 --- a/test/built-ins/String/prototype/match/S15.5.4.10_A10.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: The String.prototype.match.length property has the attribute ReadOnly -es5id: 15.5.4.10_A10 -description: > - Checking if varying the String.prototype.match.length property - fails -includes: [propertyHelper.js] ----*/ - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -if (!(String.prototype.match.hasOwnProperty('length'))) { - $ERROR('#1: String.prototype.match.hasOwnProperty(\'length\') return true. Actual: '+String.prototype.match.hasOwnProperty('length')); -} -// -////////////////////////////////////////////////////////////////////////////// - -var __obj = String.prototype.match.length; - -verifyNotWritable(String.prototype.match, "length", null, function(){return "shifted";}); - -////////////////////////////////////////////////////////////////////////////// -//CHECK#2 -if (String.prototype.match.length !== __obj) { - $ERROR('#2: __obj = String.prototype.match.length; String.prototype.match.length = function(){return "shifted";}; String.prototype.match.length === __obj. Actual: '+String.prototype.match.length ); -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/built-ins/String/prototype/match/cstm-matcher-get-err.js b/test/built-ins/String/prototype/match/cstm-matcher-get-err.js new file mode 100644 index 0000000000..9e01e7780f --- /dev/null +++ b/test/built-ins/String/prototype/match/cstm-matcher-get-err.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Behavior when error is thrown accessing @@match property +es6id: 21.1.3.11 +info: > + [...] + 3. If regexp is neither undefined nor null, then + a. Let matcher be GetMethod(regexp, @@match). + b. ReturnIfAbrupt(matcher). +features: [Symbol.match] +---*/ + +var obj = {}; +Object.defineProperty(obj, Symbol.match, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.match(obj); +}); diff --git a/test/built-ins/String/prototype/match/cstm-matcher-invocation.js b/test/built-ins/String/prototype/match/cstm-matcher-invocation.js new file mode 100644 index 0000000000..e2442a4398 --- /dev/null +++ b/test/built-ins/String/prototype/match/cstm-matcher-invocation.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Invocation of @@match property of user-supplied objects +es6id: 21.1.3.11 +info: > + [...] + 3. If regexp is neither undefined nor null, then + a. Let matcher be GetMethod(regexp, @@match). + b. ReturnIfAbrupt(matcher). + c. If matcher is not undefined, then + i. Return Call(matcher, regexp, «O»). +features: [Symbol.match] +---*/ + +var obj = {}; +var returnVal = {}; +var callCount = 0; +var thisVal, args; + +obj[Symbol.match] = function() { + callCount += 1; + thisVal = this; + args = arguments; + return returnVal; +}; + +assert.sameValue(''.match(obj), returnVal); +assert.sameValue(callCount, 1, 'Invokes the method exactly once'); +assert.sameValue(thisVal, obj); +assert.notSameValue(args, undefined); +assert.sameValue(args.length, 1); +assert.sameValue(args[0], ''); diff --git a/test/built-ins/String/prototype/match/invoke-builtin-match.js b/test/built-ins/String/prototype/match/invoke-builtin-match.js new file mode 100644 index 0000000000..74ccb54ab9 --- /dev/null +++ b/test/built-ins/String/prototype/match/invoke-builtin-match.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Invocation of @@match property of internally-created RegExps +es6id: 21.1.3.11 +info: > + [...] + 6. Let rx be RegExpCreate(regexp, undefined) (see 21.2.3.2.3). + 7. ReturnIfAbrupt(rx). + 8. Return Invoke(rx, @@match, «S»). +features: [Symbol.match] +---*/ + +var originalMatch = RegExp.prototype[Symbol.match]; +var returnVal = {}; +var result, thisVal, args; + +RegExp.prototype[Symbol.match] = function() { + thisVal = this; + args = arguments; + return returnVal; +}; + +try { + result = 'target'.match('string source'); + + assert(thisVal instanceof RegExp); + assert.sameValue(thisVal.source, 'string source'); + assert.sameValue(thisVal.flags, ''); + assert.sameValue(thisVal.lastIndex, 0); + assert.sameValue(args.length, 1); + assert.sameValue(args[0], 'target'); + assert.sameValue(result, returnVal); +} finally { + RegExp.prototype[Symbol.match] = originalMatch; +} diff --git a/test/built-ins/String/prototype/match/S15.5.4.10_A11.js b/test/built-ins/String/prototype/match/length.js similarity index 56% rename from test/built-ins/String/prototype/match/S15.5.4.10_A11.js rename to test/built-ins/String/prototype/match/length.js index a03266abf7..d445ce9d03 100644 --- a/test/built-ins/String/prototype/match/S15.5.4.10_A11.js +++ b/test/built-ins/String/prototype/match/length.js @@ -4,7 +4,21 @@ /*--- info: The length property of the match method is 1 es5id: 15.5.4.10_A11 +es6id: 21.1.3.11 description: Checking String.prototype.match.length +info: > + ES6 Section 17: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this value + is equal to the largest number of named arguments shown in the subclause + headings for the function description, including optional parameters. + + [...] + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] ---*/ ////////////////////////////////////////////////////////////////////////////// @@ -22,3 +36,7 @@ if (String.prototype.match.length !== 1) { } // ////////////////////////////////////////////////////////////////////////////// + +verifyNotEnumerable(String.prototype.match, 'length'); +verifyNotWritable(String.prototype.match, 'length'); +verifyConfigurable(String.prototype.match, 'length'); diff --git a/test/built-ins/String/prototype/match/S15.5.4.10_A1_T2.js b/test/built-ins/String/prototype/match/this-val-bool.js similarity index 100% rename from test/built-ins/String/prototype/match/S15.5.4.10_A1_T2.js rename to test/built-ins/String/prototype/match/this-val-bool.js diff --git a/test/built-ins/String/prototype/match/S15.5.4.10_A1_T1.js b/test/built-ins/String/prototype/match/this-val-obj.js similarity index 100% rename from test/built-ins/String/prototype/match/S15.5.4.10_A1_T1.js rename to test/built-ins/String/prototype/match/this-val-obj.js diff --git a/test/built-ins/Symbol/match/prop-desc.js b/test/built-ins/Symbol/match/prop-desc.js new file mode 100644 index 0000000000..765bc74011 --- /dev/null +++ b/test/built-ins/Symbol/match/prop-desc.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.4.2.6 +description: > + `Symbol.match` property descriptor +info: > + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: false }. +includes: [propertyHelper.js] +features: [Symbol.match] +---*/ + +assert.sameValue(typeof Symbol.match, 'symbol'); +verifyNotEnumerable(Symbol, 'match'); +verifyNotWritable(Symbol, 'match'); +verifyNotConfigurable(Symbol, 'match');