diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/String/prototype/match')
48 files changed, 1703 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T10.js new file mode 100644 index 0000000000..0c34ca8972 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T10.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T10 +description: Call match (regexp) function with object argument +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.match(__obj)[0] !== "AB") { + throw new Test262Error('#1: var x; var __obj = {toString:function(){return "\u0041B";}}; var __str = "ABB\u0041BABAB"; __str.match(__obj)[0] ==="AB". Actual: ' + __str.match(__obj)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T11.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T11.js new file mode 100644 index 0000000000..7ed0b42606 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T11.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T11 +description: > + Override toString function, toString throw exception, then call + match (regexp) function with this object as argument +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.match(__obj); + throw new Test262Error('#1: "var x = __str.match(__obj)" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T12.js new file mode 100644 index 0000000000..d90588e14f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T12.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: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T12 +description: > + Override toString and valueOf functions, valueOf throw exception, + then call match (regexp) function with this object as argument +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "intostr"; + } +} +var __str = new String("ABB\u0041BABAB"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.match(__obj); + throw new Test262Error('#1: "var x = __str.match(__obj)" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T13.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T13.js new file mode 100644 index 0000000000..3461822606 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T13.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T13 +description: > + Override toString and valueOf functions, then call match (regexp) + function with this object as argument +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + return 1; + } +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("ABB\u0041B\u0031ABAB\u0031BBAA".match(__obj)[0] !== "1") { + throw new Test262Error('#1: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; "ABB\\u0041B\\u0031ABAB\\u0031BBAA".match(__obj)[0] ==="1". Actual: ' + ("ABB\u0041B\u0031ABAB\u0031BBAA".match(__obj)[0])); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if ("ABB\u0041B\u0031ABAB\u0031BBAA".match(__obj).length !== 1) { + throw new Test262Error('#3: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; "ABB\\u0041B\\u0031ABAB\\u0031BBAA".match(__obj).length === 1. Actual: ' + ("ABB\u0041B\u0031ABAB\u0031BBAA".match(__obj).length)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T14.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T14.js new file mode 100644 index 0000000000..cec34fd63a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T14.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: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T14 +description: > + Call match (regexp) function with RegExp object as argument from + string +---*/ + +var __reg = new RegExp("77"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("ABB\u0041BABAB\u0037\u0037BBAA".match(__reg)[0] !== "77") { + throw new Test262Error('#1: var __reg = new RegExp("77"); "ABB\\u0041BABAB\\u0037\\u0037BBAA".match(__reg)[0] === "77". Actual: ' + ("ABB\u0041BABAB\u0037\u0037BBAA".match(__reg)[0])); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T3.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T3.js new file mode 100644 index 0000000000..e8d7c8b47a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T3.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: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T3 +description: Checking by using eval +---*/ + +var match = String.prototype.match.bind(this); + +try { + this.toString = Object.prototype.toString; +} catch (e) {; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((this.toString === Object.prototype.toString) && //Ensure we could overwrite global obj's toString + (match(eval("\"bj\""))[0] !== "bj")) { + throw new Test262Error('#1: match = String.prototype.match.bind(this); match(eval("\\"bj\\""))[0] === "bj". Actual: ' + match(eval("\"bj\""))[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T4.js new file mode 100644 index 0000000000..928aae387d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T4.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T4 +description: Call match (regexp) function without arguments of string +---*/ + +var __matched = "".match(); + +var __expected = RegExp().exec(""); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__matched.length !== __expected.length) { + throw new Test262Error('#1: __matched = "".match(); __expected = RegExp().exec(""); __matched.length === __expected.length. Actual: ' + __matched.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__matched.index !== __expected.index) { + throw new Test262Error('#2: __matched = "".match(); __expected = RegExp().exec(""); __matched.index === __expected.index. Actual: ' + __matched.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__matched.input !== __expected.input) { + throw new Test262Error('#3: __matched = "".match(); __expected = RegExp().exec(""); __matched.input === __expected.input. Actual: ' + __matched.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__matched[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __matched = "".match(); __expected = RegExp().exec(""); __matched[' + index + ']===__expected[' + index + ']. Actual: ' + __matched[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T5.js new file mode 100644 index 0000000000..7fd4c470ef --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T5 +description: Call match (regexp) function with null argument of function object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" match(null) evaluates to match("null") +if (function() { + return "gnulluna" + }().match(null)[0] !== "null") { + throw new Test262Error('#1: function(){return "gnulluna"}().match(null)[0] === "null". Actual: ' + function() { + return "gnulluna" + }().match(null)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T6.js new file mode 100644 index 0000000000..164c22a560 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T6.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T6 +description: > + Call match (regexp) function with x argument of new String object, + where x is undefined variable +---*/ + +var __matched = new String("undefined").match(x); + +var __expected = RegExp(x).exec("undefined"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__matched.length !== __expected.length) { + throw new Test262Error('#1: __matched = new String("undefined").match(x); __expected = RegExp(x).exec("undefined"); __matched.length === __expected.length. Actual: ' + __matched.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__matched.index !== __expected.index) { + throw new Test262Error('#2: __matched = new String("undefined").match(x); __expected = RegExp(x).exec("undefined"); __matched.index === __expected.index. Actual: ' + __matched.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__matched.input !== __expected.input) { + throw new Test262Error('#3: __matched = new String("undefined").match(x); __expected = RegExp(x).exec("undefined"); __matched.input === __expected.input. Actual: ' + __matched.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__matched[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __matched = new String("undefined").match(x); __expected = RegExp(x).exec("undefined"); __matched[' + index + ']===__expected[' + index + ']. Actual: ' + __matched[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T7.js new file mode 100644 index 0000000000..3af4c9c7d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T7.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T7 +description: > + Call match (regexp) function with undefined argument of string + object +---*/ + +var __matched = String("undefined").match(undefined); + +var __expected = RegExp(undefined).exec("undefined"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__matched.length !== __expected.length) { + throw new Test262Error('#1: __matched = String("undefined").match(undefined); __expected = RegExp(undefined).exec("undefined"); __matched.length === __expected.length. Actual: ' + __matched.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__matched.index !== __expected.index) { + throw new Test262Error('#2: __matched = String("undefined").match(undefined); __expected = RegExp(undefined).exec("undefined"); __matched.index === __expected.index. Actual: ' + __matched.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__matched.input !== __expected.input) { + throw new Test262Error('#3: __matched = String("undefined").match(undefined); __expected = RegExp(undefined).exec("undefined"); __matched.input === __expected.input. Actual: ' + __matched.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__matched[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __matched = String("undefined").match(undefined); __expected = RegExp(undefined).exec("undefined"); __matched[' + index + ']===__expected[' + index + ']. Actual: ' + __matched[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T8.js new file mode 100644 index 0000000000..e5c5b25a87 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T8.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T8 +description: Call match (regexp) function with void 0 argument of string object; +---*/ + +var __obj = { + toString: function() {} +}; + +var __matched = String(__obj).match(void 0); + +var __expected = RegExp(void 0).exec("undefined"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__matched.length !== __expected.length) { + throw new Test262Error('#1: __obj = {toString:function(){}}; __matched = String(__obj).match(void 0); __expected = RegExp(void 0).exec("undefined"); __matched.length === __expected.length. Actual: ' + __matched.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__matched.index !== __expected.index) { + throw new Test262Error('#2: __obj = {toString:function(){}}; __matched = String(__obj).match(void 0); __expected = RegExp(void 0).exec("undefined"); __matched.index === __expected.index. Actual: ' + __matched.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__matched.input !== __expected.input) { + throw new Test262Error('#3: __obj = {toString:function(){}}; __matched = String(__obj).match(void 0); __expected = RegExp(void 0).exec("undefined"); __matched.input === __expected.input. Actual: ' + __matched.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__matched[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __obj = {toString:function(){}}; __matched = String(__obj).match(void 0); __expected = RegExp(void 0).exec("undefined"); __matched[' + index + ']===__expected[' + index + ']. Actual: ' + __matched[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T9.js new file mode 100644 index 0000000000..5e6a56d28b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T9.js @@ -0,0 +1,55 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T9 +description: > + Call match (regexp) function with function(){}() argument of + string object +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +var __matched = new String(__obj).match(function() {}()); + +var __expected = RegExp(undefined).exec("undefined"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__matched.length !== __expected.length) { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; __matched = new String(__obj).match(function(){}()); __expected = RegExp(undefined).exec("undefined"); __matched.length === __expected.length. Actual: ' + __matched.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__matched.index !== __expected.index) { + throw new Test262Error('#2: __obj = {valueOf:function(){}, toString:void 0}; __matched = new String(__obj).match(function(){}()); __expected = RegExp(undefined).exec("undefined"); __matched.index === __expected.index. Actual: ' + __matched.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__matched.input !== __expected.input) { + throw new Test262Error('#3: __obj = {valueOf:function(){}, toString:void 0}; __matched = new String(__obj).match(function(){}()); __expected = RegExp(undefined).exec("undefined"); __matched.input === __expected.input. Actual: ' + __matched.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__matched[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __obj = {valueOf:function(){}, toString:void 0}; __matched = new String(__obj).match(function(){}()); __expected = RegExp(undefined).exec("undefined"); __matched[' + index + ']===__expected[' + index + ']. Actual: ' + __matched[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T1.js new file mode 100644 index 0000000000..2d3d430675 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T1.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T1 +description: Regular expression is 3 +---*/ + +var __string = "1234567890"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(3)[0] !== "3") { + throw new Test262Error('#1: __string = "1234567890"; __string.match(3)[0]=== "3". Actual: ' + __string.match(3)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(3).length !== 1) { + throw new Test262Error('#2: __string = "1234567890"; __string.match(3).length ===1. Actual: ' + __string.match(3).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(3).index !== 2) { + throw new Test262Error('#3: __string = "1234567890"; __string.match(3).index ===2. Actual: ' + __string.match(3).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__string.match(3).input !== __string) { + throw new Test262Error('#4: __string = "1234567890"; __string.match(3).input ===__string. Actual: ' + __string.match(3).input); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T10.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T10.js new file mode 100644 index 0000000000..a39d448e24 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T10.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T10 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. Last match is + undefined. And regular expression object have property lastIndex + = tested_string.lastIndexOf("0") +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134", "02134", undefined]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/; + +__re.lastIndex = __string.lastIndexOf("0"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== 3) { + throw new Test262Error('#1: __string.match(__re).length=== 3. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(__re).index !== __string.lastIndexOf("0")) { + throw new Test262Error('#2: __string.match(__re).index ===__string.lastIndexOf("0"). Actual: ' + __string.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(__re)[mi] !== __matches[mi]) { + throw new Test262Error('#3.' + mi + ': __string.match(__re)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(__re)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T11.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T11.js new file mode 100644 index 0000000000..12d441ea85 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T11.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T11 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. Last match is + undefined. And regular expression object have property lastIndex + = tested_string.lastIndexOf("0")+1 +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134", "02134", undefined]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/; + +__re.lastIndex = __string.lastIndexOf("0") + 1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== 3) { + throw new Test262Error('#1: __string.match(__re).length=== 3. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(__re).index !== __string.lastIndexOf("0")) { + throw new Test262Error('#2: __string.match(__re).index ===__string.lastIndexOf("0"). Actual: ' + __string.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(__re)[mi] !== __matches[mi]) { + throw new Test262Error('#3.' + mi + ': __string.match(__re)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(__re)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T12.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T12.js new file mode 100644 index 0000000000..8211a34394 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T12.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T12 +description: > + Regular expression is variable that have value /([\d]{5})([-\ + ]?[\d]{4})?$/g +---*/ + +var __matches = ["02134"]; + +var __string = "Boston, MA 02134"; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== __matches.length) { + throw new Test262Error('#1: __string.match(__re).length=== __matches.length. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(__re)[0] !== __matches[0]) { + throw new Test262Error('#2: __string.match(__re)[0]===__matches[0]. Actual: ' + __string.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T13.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T13.js new file mode 100644 index 0000000000..b7f7053dd3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T13.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T13 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/g. And regular + expression object have property lastIndex = 0 +---*/ + +var __matches = ["02134"]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/g; +__re.lastIndex = 0; + +var __string = "Boston, MA 02134"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== __matches.length) { + throw new Test262Error('#1: __string.match(__re).length=== __matches.length. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(__re)[0] !== __matches[0]) { + throw new Test262Error('#3: __string.match(__re)[0]===__matches[0]. Actual: ' + __string.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T14.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T14.js new file mode 100644 index 0000000000..6f25e2a095 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T14.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T14 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/g. And regular + expression object have property lastIndex = tested_string.length +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134"]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + +__re.lastIndex = __string.length; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== __matches.length) { + throw new Test262Error('#1: __string.match(__re).length=== __matches.length. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(__re)[0] !== __matches[0]) { + throw new Test262Error('#3: __string.match(__re)[0]===__matches[0]. Actual: ' + __string.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T15.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T15.js new file mode 100644 index 0000000000..8d4b698a0d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T15.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T15 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. And regular + expression object have property lastIndex = + tested_string.lastIndexOf("0") +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134"]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + +__re.lastIndex = __string.lastIndexOf("0"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== __matches.length) { + throw new Test262Error('#1: __string.match(__re).length=== __matches.length. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(__re)[0] !== __matches[0]) { + throw new Test262Error('#3: __string.match(__re)[0]===__matches[0]. Actual: ' + __string.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T16.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T16.js new file mode 100644 index 0000000000..6f681db068 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T16.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T16 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. And regular + expression object have property lastIndex = + tested_string.lastIndexOf("0")+1 +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134"]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + +__re.lastIndex = __string.lastIndexOf("0") + 1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== __matches.length) { + throw new Test262Error('#1: __string.match(__re).length=== __matches.length. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(__re)[0] !== __matches[0]) { + throw new Test262Error('#3: __string.match(__re)[0]===__matches[0]. Actual: ' + __string.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T17.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T17.js new file mode 100644 index 0000000000..d7b517ee21 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T17.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T17 +description: Regular expression is /0./ +---*/ + +var __re = /0./; + +var __num = 10203040506070809000; + +Number.prototype.match = String.prototype.match; + +//__matches = ["02"]; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__num.match(__re)[0] !== "02") { + throw new Test262Error('#1: __num.match(__re)[0]=== "02". Actual: ' + __num.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__num.match(__re).length !== 1) { + throw new Test262Error('#2: __num.match(__re).length ===1. Actual: ' + __num.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__num.match(__re).index !== 1) { + throw new Test262Error('#3: __num.match(__re).index ===1. Actual: ' + __num.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__num.match(__re).input !== String(__num)) { + throw new Test262Error('#4: __num.match(__re).input ===String(__num). Actual: ' + __num.match(__re).input); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T18.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T18.js new file mode 100644 index 0000000000..72c25da54e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T18.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T18 +description: > + Regular expression is /0./. And regular expression object have + property lastIndex = 0 +---*/ + +var __re = /0./; + +__re.lastIndex = 0; + +var __num = 10203040506070809000; + +Number.prototype.match = String.prototype.match; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__num.match(__re)[0] !== "02") { + throw new Test262Error('#1: __num.match(__re)[0]=== "02". Actual: ' + __num.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__num.match(__re).length !== 1) { + throw new Test262Error('#2: __num.match(__re).length ===1. Actual: ' + __num.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__num.match(__re).index !== 1) { + throw new Test262Error('#3: __num.match(__re).index ===1. Actual: ' + __num.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__num.match(__re).input !== String(__num)) { + throw new Test262Error('#4: __num.match(__re).input ===String(__num). Actual: ' + __num.match(__re).input); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T2.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T2.js new file mode 100644 index 0000000000..d9b7f16203 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T2.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T2 +description: Regular expression is /34/g +---*/ + +var __matches = ["34", "34", "34"]; + +var __string = "343443444"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/34/g).length !== 3) { + throw new Test262Error('#1: __string = "343443444"; __string.match(/34/g).length=== 3. Actual: ' + __string.match(/34/g).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(/34/g)[mi] !== __matches[mi]) { + throw new Test262Error('#2.' + mi + ': __matches=["34","34","34"]; __string = "343443444"; __string.match(/34/g)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(/34/g)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T3.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T3.js new file mode 100644 index 0000000000..9401095f72 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T3.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T3 +description: Regular expression is /\d{1}/g +---*/ + +var __matches = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]; + +var __string = "123456abcde7890"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/\d{1}/g).length !== 10) { + throw new Test262Error('#1: __string = "123456abcde7890"; __string.match(/\\d{1}/g).length=== 10. Actual: ' + __string.match(/\d{1}/g).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(/\d{1}/g)[mi] !== __matches[mi]) { + throw new Test262Error('#2.' + mi + ': __matches=["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]; __string = "123456abcde7890"; __string.match(/\\d{1}/g)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(/\d{1}/g)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T4.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T4.js new file mode 100644 index 0000000000..d13b2e87c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T4.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T4 +description: Regular expression is /\d{2}/g +---*/ + +var __matches = ["12", "34", "56", "78", "90"]; + +var __string = "123456abcde7890"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/\d{2}/g).length !== 5) { + throw new Test262Error('#1: __string = "123456abcde7890"; __string.match(/\\d{2}/g).length=== 5. Actual: ' + __string.match(/\d{2}/g).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(/\d{2}/g)[mi] !== __matches[mi]) { + throw new Test262Error('#2.' + mi + ': __matches=["12", "34", "56", "78", "90"]; __string = "123456abcde7890"; __string.match(/\\d{2}/g)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(/\d{2}/g)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T5.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T5.js new file mode 100644 index 0000000000..50285dd9b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T5.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T5 +description: Regular expression is /\D{2}/g +---*/ + +var __matches = ["ab", "cd"]; + +var __string = "123456abcde7890"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/\D{2}/g).length !== 2) { + throw new Test262Error('#1: __string = "123456abcde7890"; __string.match(/\\D{2}/g).length=== 2. Actual: ' + __string.match(/\D{2}/g).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(/\D{2}/g)[mi] !== __matches[mi]) { + throw new Test262Error('#2.' + mi + ': __matches=["ab", "cd"]; __string = "123456abcde7890"; __string.match(/\\D{2}/g)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(/\D{2}/g)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T6.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T6.js new file mode 100644 index 0000000000..697488c357 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T6.js @@ -0,0 +1,62 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T6 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. Last match is + void 0 +---*/ + +var __string = "Boston, Mass. 02134"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[0] !== "02134") { + throw new Test262Error('#1: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/)[0]=== "02134". Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[1] !== "02134") { + throw new Test262Error('#2: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/)[1]=== "02134". Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[1]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[2] !== void 0) { + throw new Test262Error('#3: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/)[2]=== void 0. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[2]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).length !== 3) { + throw new Test262Error('#4: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/).length ===3. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).index !== 14) { + throw new Test262Error('#5: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/).index ===14. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).input !== __string) { + throw new Test262Error('#6: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/).input ===__string. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).input); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T7.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T7.js new file mode 100644 index 0000000000..8798673c31 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T7.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T7 +description: Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/g +---*/ + +var __matches = ["02134"]; + +var __string = "Boston, Mass. 02134"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/g).length !== 1) { + throw new Test262Error('#1: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/g).length=== 1. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/g).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/g)[0] !== __matches[0]) { + throw new Test262Error('#2: __matches=["02134"]; __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/g)[0]===__matches[0]. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/g)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T8.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T8.js new file mode 100644 index 0000000000..c86d92b66f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T8.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T8 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. Last match is + undefined. And regular expression object have property lastIndex + = 0 +---*/ + +var __matches = ["02134", "02134", undefined]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/; +__re.lastIndex = 0; + +var __string = "Boston, MA 02134"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== 3) { + throw new Test262Error('#1: __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __string.match(__re).length=== 3. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(__re).index !== __string.lastIndexOf("0")) { + throw new Test262Error('#2: __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __re.lastIndex = 0; __string.match(__re).index ===__string.lastIndexOf("0"). Actual: ' + __string.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(__re)[mi] !== __matches[mi]) { + throw new Test262Error('#3.' + mi + ': __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __matches=["02134", "02134", undefined]; __string.match(__re)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(__re)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T9.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T9.js new file mode 100644 index 0000000000..c8060a22c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T9.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T9 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. Last match is + undefined. And regular expression object have property lastIndex + = tested_string.length +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134", "02134", undefined]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/; + +__re.lastIndex = __string.length; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== 3) { + throw new Test262Error('#1: __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __string.match(__re).length=== 3. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(__re).index !== __string.lastIndexOf("0")) { + throw new Test262Error('#2: __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __re.lastIndex = __string.length; __string.match(__re).index ===__string.lastIndexOf("0"). Actual: ' + __string.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(__re)[mi] !== __matches[mi]) { + throw new Test262Error('#3.' + mi + ': __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __matches=["02134", "02134", undefined]; __string.match(__re)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(__re)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A6.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A6.js new file mode 100644 index 0000000000..aadafa396e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A6.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: String.prototype.match has not prototype property +es5id: 15.5.4.10_A6 +description: Checking String.prototype.match.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.match.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.match.prototype === undefined. Actual: ' + String.prototype.match.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A7.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A7.js new file mode 100644 index 0000000000..7380da230d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A7.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: String.prototype.match can't be used as constructor +es5id: 15.5.4.10_A7 +description: Checking if creating "String.prototype.match object" fails +---*/ + +var __FACTORY = String.prototype.match; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.match; __FACTORY = String.prototype.match; __instance = new __FACTORY lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A8.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A8.js new file mode 100644 index 0000000000..d632dfd429 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A8.js @@ -0,0 +1,43 @@ +// 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 DontEnum +es5id: 15.5.4.10_A8 +description: > + Checking if enumerating the String.prototype.match.length property + fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.match.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.match.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.match.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.match.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.match.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.match) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.match){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A9.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A9.js new file mode 100644 index 0000000000..12c86a3a1f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A9.js @@ -0,0 +1,38 @@ +// 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 does not have the attribute + DontDelete +es5id: 15.5.4.10_A9 +description: > + Checking if deleting the String.prototype.match.length property + fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.match.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.match.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.match.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.match.length) { + throw new Test262Error('#1: delete String.prototype.match.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.match.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.match.length; String.prototype.match.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.match.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/browser.js b/js/src/tests/test262/built-ins/String/prototype/match/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-get-err.js b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-get-err.js new file mode 100644 index 0000000000..e750a05018 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-get-err.js @@ -0,0 +1,26 @@ +// 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); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-invocation.js b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-invocation.js new file mode 100644 index 0000000000..3e18b8f9eb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-invocation.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: 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], ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-is-null.js b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-is-null.js new file mode 100644 index 0000000000..96a2f9b3d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-is-null.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.match +description: > + If regexp's Symbol.match property is null, no error is thrown. +info: | + String.prototype.match ( regexp ) + + [...] + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@match). + b. If matcher is not undefined, then + [...] + [...] + 5. Return ? Invoke(rx, @@match, « S »). + + GetMethod ( V, P ) + + [...] + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. +features: [Symbol.match] +---*/ + +var regexp = {}; +regexp[Symbol.match] = null; +regexp.toString = function() { return "\\d"; }; +regexp.valueOf = function() { throw new Test262Error("should not be called"); }; + +assert.sameValue("abc".match(regexp), null); +assert.sameValue("ab3c".match(regexp)[0], "3"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-groups-properties.js b/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-groups-properties.js new file mode 100644 index 0000000000..5cf6bb7691 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-groups-properties.js @@ -0,0 +1,39 @@ +// |reftest| skip -- regexp-duplicate-named-groups is not supported +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Properties on groups object with duplicate named capture groups +esid: prod-GroupSpecifier +features: [regexp-duplicate-named-groups] +includes: [compareArray.js] +---*/ + +const matcher = /(?:(?<x>a)|(?<y>a)(?<x>b))(?:(?<z>c)|(?<z>d))/; + +const threeMatchResult = "abc".match(matcher); +assert.sameValue(threeMatchResult.groups.x, "b", "group x matches b"); +assert.sameValue(threeMatchResult.groups.y, "a", "group y matches a"); +assert.sameValue(threeMatchResult.groups.z, "c", "group z matches c"); +assert.compareArray( + Object.keys(threeMatchResult.groups), + ["x", "y", "z"], + "Properties of groups are ordered in RegExp source order despite y matching before x in this alternative" +); + +const twoMatchResult = "ad".match(matcher); +assert.sameValue(twoMatchResult.groups.x, "a", "group x matches a"); +assert.sameValue(twoMatchResult.groups.y, undefined, "group y does not match"); +assert.sameValue(twoMatchResult.groups.z, "d", "group z matches d"); +assert.compareArray( + Object.keys(twoMatchResult.groups), + ["x", "y", "z"], + "y is still present on groups object, in the right order, despite not matching" +); + +const iteratedMatcher = /(?:(?:(?<x>a)|(?<x>b)|c)\k<x>){2}/; + +const matchedInPrevIterationResult = "aac".match(iteratedMatcher); +assert.sameValue(matchedInPrevIterationResult.groups.x, undefined, "group x does not match in the last iteration"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-indices-groups-properties.js b/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-indices-groups-properties.js new file mode 100644 index 0000000000..2548e693a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-indices-groups-properties.js @@ -0,0 +1,39 @@ +// |reftest| skip -- regexp-duplicate-named-groups is not supported +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Properties on indices.groups object with duplicate named capture groups +esid: prod-GroupSpecifier +features: [regexp-duplicate-named-groups, regexp-match-indices] +includes: [compareArray.js] +---*/ + +const matcher = /(?:(?<x>a)|(?<y>a)(?<x>b))(?:(?<z>c)|(?<z>d))/d; + +const threeMatchResult = "abc".match(matcher); +assert.compareArray(threeMatchResult.indices.groups.x, [1, 2], "group x matches b"); +assert.compareArray(threeMatchResult.indices.groups.y, [0, 1], "group y matches a"); +assert.compareArray(threeMatchResult.indices.groups.z, [2, 3], "group z matches c"); +assert.compareArray( + Object.keys(threeMatchResult.indices.groups), + ["x", "y", "z"], + "Properties of groups are ordered in RegExp source order despite y matching before x in this alternative" +); + +const twoMatchResult = "ad".match(matcher); +assert.compareArray(twoMatchResult.indices.groups.x, [0, 1], "group x matches a"); +assert.sameValue(twoMatchResult.indices.groups.y, undefined, "group y does not match"); +assert.compareArray(twoMatchResult.indices.groups.z, [1, 2], "group z matches d"); +assert.compareArray( + Object.keys(twoMatchResult.indices.groups), + ["x", "y", "z"], + "y is still present on groups object, in the right order, despite not matching" +); + +const iteratedMatcher = /(?:(?:(?<x>a)|(?<x>b)|c)\k<x>){2}/d; + +const matchedInPrevIterationResult = "aac".match(iteratedMatcher); +assert.sameValue(matchedInPrevIterationResult.indices.groups.x, undefined, "group x does not match in the last iteration"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/invoke-builtin-match.js b/js/src/tests/test262/built-ins/String/prototype/match/invoke-builtin-match.js new file mode 100644 index 0000000000..f33db66deb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/invoke-builtin-match.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: 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; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/length.js b/js/src/tests/test262/built-ins/String/prototype/match/length.js new file mode 100644 index 0000000000..d3ab6c5320 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/length.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.10_A11 +es6id: 21.1.3.11 +description: Checking String.prototype.match.length +info: | + The length property of the match method is 1. + + 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] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.match.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.match.hasOwnProperty("length") return true. Actual: ' + String.prototype.match.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.match.length !== 1) { + throw new Test262Error('#2: String.prototype.match.length === 1. Actual: ' + String.prototype.match.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +verifyNotEnumerable(String.prototype.match, 'length'); +verifyNotWritable(String.prototype.match, 'length'); +verifyConfigurable(String.prototype.match, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/name.js b/js/src/tests/test262/built-ins/String/prototype/match/name.js new file mode 100644 index 0000000000..09c3133348 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/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.1.3.11 +description: > + String.prototype.match.name is "match". +info: | + String.prototype.match ( regexp ) + + 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(String.prototype.match.name, "match"); + +verifyNotEnumerable(String.prototype.match, "name"); +verifyNotWritable(String.prototype.match, "name"); +verifyConfigurable(String.prototype.match, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/match/not-a-constructor.js new file mode 100644 index 0000000000..91f5ec5a8e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/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: > + String.prototype.match 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(String.prototype.match), + false, + 'isConstructor(String.prototype.match) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.match(); +}, '`new String.prototype.match()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/shell.js b/js/src/tests/test262/built-ins/String/prototype/match/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/match/this-val-bool.js b/js/src/tests/test262/built-ins/String/prototype/match/this-val-bool.js new file mode 100644 index 0000000000..251d574705 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/this-val-bool.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: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T2 +description: > + Argument is function that return boolean, and instance is Boolean + object +---*/ + +var __instance = new Boolean; + +__instance.match = String.prototype.match; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.match(function() { + return false; + }())[0] !== "false") { + throw new Test262Error('#1: __instance = new Boolean; __instance.match = String.prototype.match; __instance.match(function(){return false;}())[0] === "false". Actual: ' + __instance.match(function() { + return false; + }())[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/this-val-obj.js b/js/src/tests/test262/built-ins/String/prototype/match/this-val-obj.js new file mode 100644 index 0000000000..aa217a541f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/this-val-obj.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: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T1 +description: Arguments is true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.match = String.prototype.match; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.match(true)[0] !== "true") { + throw new Test262Error('#1: __instance = new Object(true); __instance.match = String.prototype.match; __instance.match(true)[0] === "true". Actual: ' + __instance.match(true)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/match/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..7e7d0d64ca --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/this-value-not-obj-coercible.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.match +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var match = String.prototype.match; + +assert.sameValue(typeof match, 'function'); + +assert.throws(TypeError, function() { + match.call(undefined, /./); +}, 'undefined'); + +assert.throws(TypeError, function() { + match.call(null, /./); +}, 'null'); + +reportCompare(0, 0); |