diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/RegExp/prototype/test | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/test')
47 files changed, 1083 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A10.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A10.js new file mode 100644 index 0000000000..0a8d503e08 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A10.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The RegExp.prototype.test.length property has the attribute ReadOnly +es5id: 15.10.6.3_A10 +description: Checking if varying the RegExp.prototype.test.length property fails +includes: [propertyHelper.js] +---*/ +assert.sameValue( + RegExp.prototype.test.hasOwnProperty('length'), + true, + 'RegExp.prototype.test.hasOwnProperty(\'length\') must return true' +); + +var __obj = RegExp.prototype.test.length; + +verifyNotWritable(RegExp.prototype.test, "length", null, function(){return "shifted";}); + +assert.sameValue( + RegExp.prototype.test.length, + __obj, + 'The value of RegExp.prototype.test.length is expected to equal the value of __obj' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A11.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A11.js new file mode 100644 index 0000000000..3dbaa2d9ab --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A11.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of the test method is 1 +es5id: 15.10.6.3_A11 +description: Checking RegExp.prototype.test.length +---*/ +assert.sameValue( + RegExp.prototype.test.hasOwnProperty("length"), + true, + 'RegExp.prototype.test.hasOwnProperty("length") must return true' +); + +assert.sameValue(RegExp.prototype.test.length, 1, 'The value of RegExp.prototype.test.length is expected to be 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T1.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T1.js new file mode 100644 index 0000000000..6a64ab568d --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T1 +description: RegExp is /1|12/ and tested string is "123" +---*/ + +var __string = "123"; +var __re = /1|12/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test(""123"") must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T10.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T10.js new file mode 100644 index 0000000000..52d27fd635 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T10.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T10 +description: RegExp is /1|12/ and tested string is 1.01 +---*/ + +var __string = 1.01; +var __re = /1|12/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test(1.01) must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T11.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T11.js new file mode 100644 index 0000000000..3c0caf4afb --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T11.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T11 +description: RegExp is /2|12/ and tested string is new Number(1.012) +---*/ + +var __string = new Number(1.012); +var __re = /2|12/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test(new Number(1.012)) must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T12.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T12.js new file mode 100644 index 0000000000..55adc94424 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T12.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T12 +description: > + RegExp is /\.14/ and tested string is {toString:function(){return + Math.PI;}} +---*/ + +var __string = {toString:function(){return Math.PI;}}; +var __re = /\.14/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test({toString:function(){return Math.PI;}}) must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T13.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T13.js new file mode 100644 index 0000000000..93b0405274 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T13.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T13 +description: RegExp is /t[a-b|q-s]/ and tested string is true +---*/ + +var __string = true; +var __re = /t[a-b|q-s]/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test(true) must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T14.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T14.js new file mode 100644 index 0000000000..95460d84fb --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T14.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T14 +description: RegExp is /AL|se/ and tested string is new Boolean +---*/ + +var __string = new Boolean; +var __re = /AL|se/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test(new Boolean) must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T15.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T15.js new file mode 100644 index 0000000000..7017b295d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T15.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T15 +description: > + RegExp is /LS/i and tested string is {toString:function(){return + false;}} +---*/ + +var __string = {toString:function(){return false;}}; +var __re = /LS/i; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test({toString:function(){return false;}}) must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T16.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T16.js new file mode 100644 index 0000000000..5bd90f169c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T16.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T16 +description: RegExp is /undefined/ and call test() without arguments +---*/ + +var __re = /undefined/; + +assert.sameValue(__re.test(), __re.exec() !== null, '__re.test() must return __re.exec() !== null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T17.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T17.js new file mode 100644 index 0000000000..2d2f52b5cb --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T17.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T17 +description: RegExp is /ll|l/ and tested string is null +---*/ + +var __re = /ll|l/; + +assert.sameValue(__re.test(null), __re.exec(null) !== null, '__re.test(null) must return __re.exec(null) !== null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T18.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T18.js new file mode 100644 index 0000000000..0726b40eda --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T18.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T18 +description: RegExp is /nd|ne/ and tested string is undefined +---*/ + +var __re = /nd|ne/; + +assert.sameValue( + __re.test(undefined), + __re.exec(undefined) !== null, + '__re.test(undefined) must return __re.exec(undefined) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T19.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T19.js new file mode 100644 index 0000000000..a767ea20c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T19.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T19 +description: RegExp is /e{1}/ and tested string is void 0 +---*/ + +var __re = /e{1}/; + +assert.sameValue( + __re.test(void 0), + __re.exec(void 0) !== null, + '__re.test(void 0) must return __re.exec(void 0) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T2.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T2.js new file mode 100644 index 0000000000..abe89629f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T2 +description: > + RegExp is /((1)|(12))((3)|(23))/ and tested string is new + String("123") +---*/ + +var __string = new String("123"); +var __re = /((1)|(12))((3)|(23))/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test("new String("123")") must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T20.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T20.js new file mode 100644 index 0000000000..50fcf0443c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T20.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T20 +description: RegExp is /[a-f]d/ and tested string is x, where x is undefined +---*/ + +var __re = /[a-f]d/; + +assert.sameValue(__re.test(x), __re.exec(x) !== null, '__re.test() must return __re.exec(x) !== null'); + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T21.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T21.js new file mode 100644 index 0000000000..1af7dfac0c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T21.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T21 +description: > + RegExp is /[a-z]n/ and tested string is x, where x is + function(){}() +---*/ + +var __re = /[a-z]n/; + +assert.sameValue( + __re.test(function(){}()), + __re.exec(function(){}()) !== null, + '__re.test(function(){}()) must return __re.exec(function(){}()) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T22.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T22.js new file mode 100644 index 0000000000..cadeb79c93 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T22.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + RegExp.prototype.test behavior depends on the lastIndex property: + ToLength(lastIndex) is the starting point for the search, so + negative numbers result in searching from 0. +es5id: 15.10.6.3_A1_T22 +description: "Set lastIndex to -1 and call /(?:ab|cd)\\d?/g.test(\"aacd22 \")" +---*/ + +var __re = /(?:ab|cd)\d?/g; +__re.lastIndex=-1; +var __executed = __re.test("aacd22 "); + +assert(!!__executed, 'The value of !!__executed is expected to be true'); +assert.sameValue(__re.lastIndex, 5, 'The value of __re.lastIndex is expected to be 5'); + +__re.lastIndex=-100; +__executed = __re.test("aacd22 "); + +assert(!!__executed, 'The value of !!__executed is expected to be true'); +assert.sameValue(__re.lastIndex, 5, 'The value of __re.lastIndex is expected to be 5'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T3.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T3.js new file mode 100644 index 0000000000..fe59bc5001 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T3 +description: > + RegExp is /a[a-z]{2,4}/ and tested string is new + Object("abcdefghi") +---*/ + +var __string = new Object("abcdefghi"); +var __re = /a[a-z]{2,4}/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test("new Object("abcdefghi")") must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T4.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T4.js new file mode 100644 index 0000000000..e4b4a1676b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T4.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T4 +description: > + RegExp is /a[a-z]{2,4}?/ and tested string is + {toString:function(){return "abcdefghi";}} +---*/ + +var __string = {toString:function(){return "abcdefghi";}}; +var __re = /a[a-z]{2,4}?/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test({toString:function(){return "abcdefghi";}}) must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T5.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T5.js new file mode 100644 index 0000000000..d15cd52808 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T5.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T5 +description: > + RegExp is /(aa|aabaac|ba|b|c)* / and tested string is + {toString:function(){return {};}, valueOf:function(){return + "aabaac";}} +---*/ + +var __string = {toString:function(){return {};}, valueOf:function(){return "aabaac";}}; +var __re = /(aa|aabaac|ba|b|c)*/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test("{toString:function(){return {};}, valueOf:function(){return "aabaac";}}) must return __re.exec(__string) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T6.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T6.js new file mode 100644 index 0000000000..dad55d3c3a --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T6.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T6 +description: > + RegExp is /(z)((a+)?(b+)?(c))* / and tested string is + (function(){return "zaacbbbcac"})() +---*/ + +var __re = /(z)((a+)?(b+)?(c))*/; + +assert.sameValue( + __re.test((function(){return "zaacbbbcac"})()), + __re.exec((function(){return "zaacbbbcac"})()) !== null, + '__re.test((function(){return "zaacbbbcac"})()) must return __re.exec((function(){return "zaacbbbcac"})()) !== null' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T7.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T7.js new file mode 100644 index 0000000000..43abe4e04b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T7.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T7 +description: > + RegExp is /[a-z]/ and tested string is {toString:function(){throw + "intostr";}} +---*/ + +try { + throw new Test262Error('#1.1: /[a-z]/.test({toString:function(){throw "intostr";}}) throw "intostr". Actual: ' + (/[a-z]/.test({toString:function(){throw "intostr";}}))); +} catch (e) { + assert.sameValue(e, "intostr", 'The value of e is expected to be "intostr"'); +} + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T8.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T8.js new file mode 100644 index 0000000000..a068a2da63 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T8.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T8 +description: > + RegExp is /[a-z]/ and tested string is {toString:void 0, + valueOf:function(){throw "invalof";}} +---*/ + +try { + throw new Test262Error('#1.1: /[a-z]/.test({toString:void 0, valueOf:function(){throw "invalof";}}) throw "invalof". Actual: ' + (/[a-z]/.test({toString:void 0, valueOf:function(){throw "invalof";}}))); +} catch (e) { + assert.sameValue(e, "invalof", 'The value of e is expected to be "invalof"'); +} + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T9.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T9.js new file mode 100644 index 0000000000..dad72cb614 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A1_T9.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Equivalent to the expression RegExp.prototype.exec(string) != null +es5id: 15.10.6.3_A1_T9 +description: RegExp is /1|12/ and tested string is function object +---*/ + +var __string; +var __re = /1|12/; + +assert.sameValue( + __re.test(__string), + __re.exec(__string) !== null, + '__re.test() must return __re.exec(__string) !== null' +); + +function __string(){} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T1.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T1.js new file mode 100644 index 0000000000..aa7c948527 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A TypeError exception is thrown if the this value is not an object for + which the value of the internal [[Class]] property is "RegExp" +es5id: 15.10.6.3_A2_T1 +description: The tested object is new Object +---*/ + +var __instance = new Object; + +__instance.test = RegExp.prototype.test; + +try { + throw new Test262Error('#1.1: __instance = new Object; __instance.test = RegExp.prototype.test; __instance.test("message to investigate"). Actual: ' + (__instance.test("message to investigate"))); +} catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T10.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T10.js new file mode 100644 index 0000000000..d674d38ae8 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T10.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A TypeError exception is thrown if the this value is not an object for + which the value of the internal [[Class]] property is "RegExp" +es5id: 15.10.6.3_A2_T10 +description: The tested object is undefined +---*/ + +var test = RegExp.prototype.test; + +try { + throw new Test262Error('#1.1: test = RegExp.prototype.test; test("message to investigate"). Actual: ' + (test("message to investigate"))); +} catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T2.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T2.js new file mode 100644 index 0000000000..0690647f9e --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T2.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A TypeError exception is thrown if the this value is not an object for + which the value of the internal [[Class]] property is "RegExp" +es5id: 15.10.6.3_A2_T2 +description: The tested object is Math +---*/ + +var __instance = Math; + +__instance.test = RegExp.prototype.test; + +try { + __instance.test("message to investigate"); + throw new Test262Error('#1.1: __instance = Math; __instance.test = RegExp.prototype.test; __instance.test("message to investigate")'); +} catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T3.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T3.js new file mode 100644 index 0000000000..e304938ad0 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T3.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A TypeError exception is thrown if the this value is not an object for + which the value of the internal [[Class]] property is "RegExp" +es5id: 15.10.6.3_A2_T3 +description: The tested object is function object +---*/ + +__instance.test = RegExp.prototype.test; + +try { + __instance.test("message to investigate"); + throw new Test262Error('#1.1: __instance.test = RegExp.prototype.test; __instance.test("message to investigate"); function __instance(){}'); +} catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +function __instance(){}; + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T4.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T4.js new file mode 100644 index 0000000000..b22f6dc1b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T4.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A TypeError exception is thrown if the this value is not an object for + which the value of the internal [[Class]] property is "RegExp" +es5id: 15.10.6.3_A2_T4 +description: The tested object is new String("[a-b]") +---*/ + +var __instance = new String("[a-b]"); + +__instance.test = RegExp.prototype.test; + + try { + throw new Test262Error('#1.1: __instance = new String("[a-b]"); __instance.test = RegExp.prototype.test; test("message to investigate"). Actual: ' + (__instance.test("message to investigate"))); + } catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); + } + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T5.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T5.js new file mode 100644 index 0000000000..47fcde5b88 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T5.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A TypeError exception is thrown if the this value is not an object for + which the value of the internal [[Class]] property is "RegExp" +es5id: 15.10.6.3_A2_T5 +description: The tested object is new Boolean(false) +---*/ + +var __instance = new Boolean(false); + +__instance.test = RegExp.prototype.test; + + try { + throw new Test262Error('#1.1: __instance = new Boolean(false); __instance.test = RegExp.prototype.test; test("message to investigate"). Actual: ' + (__instance.test("message to investigate"))); + } catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); + } + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T6.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T6.js new file mode 100644 index 0000000000..3f72ae9523 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T6.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A TypeError exception is thrown if the this value is not an object for + which the value of the internal [[Class]] property is "RegExp" +es5id: 15.10.6.3_A2_T6 +description: The tested object is new Number(1.0) +---*/ + +var __instance = new Number(1.0); + +__instance.test = RegExp.prototype.test; + +try { + throw new Test262Error('#1.1: __instance = new Number(1.0); __instance.test = RegExp.prototype.test; __instance["test"]("message to investigate"). Actual: ' + (__instance["test"]("message to investigate"))); +} catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T7.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T7.js new file mode 100644 index 0000000000..19794986f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T7.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A TypeError exception is thrown if the this value is not an object for + which the value of the internal [[Class]] property is "RegExp" +es5id: 15.10.6.3_A2_T7 +description: The tested object is false +---*/ + +var __instance = false; + +Object.prototype.test = RegExp.prototype.test; + +try { + throw new Test262Error('#1.1: __instance = false; Object.prototype.test = RegExp.prototype.test; __instance.test("message to investigate"). Actual: ' + (__instance.test("message to investigate"))); +} catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T8.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T8.js new file mode 100644 index 0000000000..a50d1fcedd --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T8.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A TypeError exception is thrown if the this value is not an object for + which the value of the internal [[Class]] property is "RegExp" +es5id: 15.10.6.3_A2_T8 +description: The tested object is "." +---*/ + +var __instance = "."; + +Object.prototype.test = RegExp.prototype.test; + +try { + throw new Test262Error('#1.1: __instance = "."; Object.prototype.test = RegExp.prototype.test; __instance.test("message to investigate"). Actual: ' + (__instance.test("message to investigate"))); +} catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T9.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T9.js new file mode 100644 index 0000000000..0ff585e300 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A2_T9.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A TypeError exception is thrown if the this value is not an object for + which the value of the internal [[Class]] property is "RegExp" +es5id: 15.10.6.3_A2_T9 +description: The tested object is 1.0 +---*/ + +var __instance = 1.0; + +Object.prototype.test = RegExp.prototype.test; + +try { + throw new Test262Error('#1.1: __instance = 1.0; Object.prototype.test = RegExp.prototype.test; __instance.test("message to investigate"). Actual: ' + (__instance.test("message to investigate"))); +} catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A6.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A6.js new file mode 100644 index 0000000000..2888978604 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A6.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: RegExp.prototype.test has not prototype property +es5id: 15.10.6.3_A6 +description: Checking RegExp.prototype.test.prototype +---*/ +assert.sameValue( + RegExp.prototype.test.prototype, + undefined, + 'The value of RegExp.prototype.test.prototype is expected to equal undefined' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A7.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A7.js new file mode 100644 index 0000000000..db7364bd31 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A7.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: RegExp.prototype.test can't be used as constructor +es5id: 15.10.6.3_A7 +description: Checking if creating the RegExp.prototype.test object fails +---*/ + +var __FACTORY = RegExp.prototype.test; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1.1: __FACTORY = RegExp.prototype.test throw TypeError. Actual: ' + (__instance)); +} catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} + +// TODO: Convert to assert.throws() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A8.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A8.js new file mode 100644 index 0000000000..e956dacab2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A8.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The RegExp.prototype.test.length property has the attribute DontEnum +es5id: 15.10.6.3_A8 +description: > + Checking if enumerating the RegExp.prototype.test.length property + fails +---*/ +assert.sameValue( + RegExp.prototype.test.hasOwnProperty('length'), + true, + 'RegExp.prototype.test.hasOwnProperty(\'length\') must return true' +); + +assert.sameValue( + RegExp.prototype.test.propertyIsEnumerable('length'), + false, + 'RegExp.prototype.test.propertyIsEnumerable(\'length\') must return false' +); + +var count=0; + +for (var p in RegExp.prototype.test){ + if (p==="length") { + count++; + } +} + +assert.sameValue(count, 0, 'The value of count is expected to be 0'); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A9.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A9.js new file mode 100644 index 0000000000..7667d3f3a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/S15.10.6.3_A9.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The RegExp.prototype.test.length property does not have the attribute + DontDelete +es5id: 15.10.6.3_A9 +description: Checking if deleting RegExp.prototype.test.length property fails +---*/ +assert.sameValue( + RegExp.prototype.exec.hasOwnProperty('length'), + true, + 'RegExp.prototype.exec.hasOwnProperty(\'length\') must return true' +); + +assert.sameValue( + delete RegExp.prototype.exec.length, + true, + 'The value of `delete RegExp.prototype.exec.length` is expected to be true' +); + +assert.sameValue( + RegExp.prototype.exec.hasOwnProperty('length'), + false, + 'RegExp.prototype.exec.hasOwnProperty(\'length\') must return false' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/browser.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/browser.js diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js new file mode 100644 index 0000000000..7ee8a9a2e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 21.2.5.13 +description: > + RegExp.prototype.test.name is "test". +info: | + RegExp.prototype.test( S ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + 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.test.name, "test"); + +verifyNotEnumerable(RegExp.prototype.test, "name"); +verifyNotWritable(RegExp.prototype.test, "name"); +verifyConfigurable(RegExp.prototype.test, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js new file mode 100644 index 0000000000..ee6ce0aeaf --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + RegExp.prototype.test does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(RegExp.prototype.test), + false, + 'isConstructor(RegExp.prototype.test) must return false' +); + +assert.throws(TypeError, () => { + let re = new RegExp(''); new re.test(); +}, '`let re = new RegExp(\'\'); new re.test()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/shell.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/shell.js diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/y-fail-lastindex-no-write.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/y-fail-lastindex-no-write.js new file mode 100644 index 0000000000..0746d299c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/y-fail-lastindex-no-write.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: Match failure with non-writable `lastIndex` property +es6id: 21.2.5.13 +info: | + 21.2.5.13 RegExp.prototype.test( S ) + + [...] + 5. Let match be RegExpExec(R, string). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 4. Let lastIndex be ToLength(Get(R,"lastIndex")). + [...] + 8. Let sticky be ToBoolean(Get(R, "sticky")). + [...] + 15. Repeat, while matchSucceeded is false + [...] + b. Let r be matcher(S, lastIndex). + c. If r is failure, then + i. If sticky is true, then + 1. Let setStatus be Set(R, "lastIndex", 0, true). + 2. ReturnIfAbrupt(setStatus). +---*/ + +var r = /c/y; +Object.defineProperty(r, 'lastIndex', { + writable: false +}); + +assert.throws(TypeError, function() { + r.test('abc'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/y-fail-lastindex.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/y-fail-lastindex.js new file mode 100644 index 0000000000..ec9e0a51b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/y-fail-lastindex.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: Resets the `lastIndex` property to zero after a match failure +es6id: 21.2.5.13 +info: | + 21.2.5.13 RegExp.prototype.test( S ) + + [...] + 5. Let match be RegExpExec(R, string). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 4. Let lastIndex be ToLength(Get(R,"lastIndex")). + [...] + 8. Let sticky be ToBoolean(Get(R, "sticky")). + [...] + 15. Repeat, while matchSucceeded is false + [...] + b. Let r be matcher(S, lastIndex). + c. If r is failure, then + i. If sticky is true, then + 1. Let setStatus be Set(R, "lastIndex", 0, true). +---*/ + +var r = /c/y; +r.lastIndex = 1; + +r.test('abc'); + +assert.sameValue(r.lastIndex, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/y-fail-return.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/y-fail-return.js new file mode 100644 index 0000000000..17c627c804 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/y-fail-return.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Stops match execution after first match failure +es6id: 21.2.5.13 +info: | + 21.2.5.13 RegExp.prototype.test( S ) + + [...] + 5. Let match be RegExpExec(R, string). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 4. Let lastIndex be ToLength(Get(R,"lastIndex")). + [...] + 8. Let sticky be ToBoolean(Get(R, "sticky")). + [...] + 15. Repeat, while matchSucceeded is false + [...] + b. Let r be matcher(S, lastIndex). + c. If r is failure, then + i. If sticky is true, then + [...] + 3. Return null. +---*/ + +assert.sameValue(/b/y.test('ab'), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/y-init-lastindex.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/y-init-lastindex.js new file mode 100644 index 0000000000..2d66352dce --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/y-init-lastindex.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Honors initial value of the `lastIndex` property +es6id: 21.2.5.13 +info: | + 21.2.5.13 RegExp.prototype.test( S ) + + [...] + 5. Let match be RegExpExec(R, string). + + 21.2.5.2.2 Runtime Semantics: RegExpBuiltinExec ( R, S ) + + [...] + 4. Let lastIndex be ToLength(Get(R,"lastIndex")). + [...] + 8. Let sticky be ToBoolean(Get(R, "sticky")). + 9. ReturnIfAbrupt(sticky). + 10. If global is false and sticky is false, let lastIndex be 0. +---*/ + +var r = /./y; +r.lastIndex = 1; + +assert.sameValue(r.test('a'), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/y-set-lastindex.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/y-set-lastindex.js new file mode 100644 index 0000000000..17f01468a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/y-set-lastindex.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Sets the `lastIndex` property to the end index of the first match +es6id: 21.2.5.13 +info: | + 21.2.5.13 RegExp.prototype.test( S ) + + [...] + 5. Let match be RegExpExec(R, string). + + 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). +---*/ + +var r = /abc/y; + +r.test('abc'); + +assert.sameValue(r.lastIndex, 3); + +reportCompare(0, 0); |