From d6efc316edf3339bdfa3cc1e3d96fa6996fd7d2c Mon Sep 17 00:00:00 2001 From: Leo Balter <leonardo.balter@gmail.com> Date: Mon, 24 Apr 2017 17:57:25 -0400 Subject: [PATCH] Update some tests to avoid $ERROR --- test/built-ins/Array/S15.4.1_A1.1_T1.js | 13 ++---- test/built-ins/Array/S15.4_A1.1_T1.js | 33 ------------- test/built-ins/Array/S15.4_A1.1_T2.js | 46 ------------------- .../Array/property-cast-boolean-primitive.js | 20 ++++++++ .../Array/property-cast-nan-infinity.js | 26 +++++++++++ ...5.4_A1.1_T3.js => property-cast-number.js} | 22 +++------ 6 files changed, 57 insertions(+), 103 deletions(-) delete mode 100644 test/built-ins/Array/S15.4_A1.1_T1.js delete mode 100644 test/built-ins/Array/S15.4_A1.1_T2.js create mode 100644 test/built-ins/Array/property-cast-boolean-primitive.js create mode 100644 test/built-ins/Array/property-cast-nan-infinity.js rename test/built-ins/Array/{S15.4_A1.1_T3.js => property-cast-number.js} (71%) diff --git a/test/built-ins/Array/S15.4.1_A1.1_T1.js b/test/built-ins/Array/S15.4.1_A1.1_T1.js index 156c2a242c..d74649f823 100644 --- a/test/built-ins/Array/S15.4.1_A1.1_T1.js +++ b/test/built-ins/Array/S15.4.1_A1.1_T1.js @@ -13,13 +13,8 @@ description: > ---*/ //CHECK#1 -Array.prototype.myproperty = 1; -var x = Array(); -if (x.myproperty !== 1) { - $ERROR('#1: Array.prototype.myproperty = 1; var x = Array(); x.myproperty === 1. Actual: ' + (x.myproperty)); -} +Array.prototype.myproperty = 42; +var x = Array(); +assert.sameValue(x.myproperty, 42); -//CHECK#2 -if (x.hasOwnProperty('myproperty') !== false) { - $ERROR('#2: Array.prototype.myproperty = 1; var x = Array(); x.hasOwnProperty(\'myproperty\') === false. Actual: ' + (x.hasOwnProperty('myproperty'))); -} +assert.sameValue(Object.prototype.hasOwnProperty.call(x, 'myproperty'), false); diff --git a/test/built-ins/Array/S15.4_A1.1_T1.js b/test/built-ins/Array/S15.4_A1.1_T1.js deleted file mode 100644 index d8a2b814c0..0000000000 --- a/test/built-ins/Array/S15.4_A1.1_T1.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: > - A property name P (in the form of a string value) is an array index - if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 -es5id: 15.4_A1.1_T1 -description: Checking for boolean primitive ----*/ - -//CHECK#1 -var x = []; -x[true] = 1; -if (x[1] !== undefined) { - $ERROR('#1: x = []; x[true] = 1; x[1] === undefined. Actual: ' + (x[1])); -} - -//CHECK#2 -if (x["true"] !== 1) { - $ERROR('#2: x = []; x[true] = 1; x["true"] === 1. Actual: ' + (x["true"])); -} - -//CHECK#3 -x[false] = 0; -if (x[0] !== undefined) { - $ERROR('#3: x = []; x[true] = 1; x[false] = 0; x[0] === undefined. Actual: ' + (x[0])); -} - -//CHECK#4 -if (x["false"] !== 0) { - $ERROR('#4: x = []; x[false] = 1; x["false"] === 0. Actual: ' + (x["false"])); -} diff --git a/test/built-ins/Array/S15.4_A1.1_T2.js b/test/built-ins/Array/S15.4_A1.1_T2.js deleted file mode 100644 index feeeade1b6..0000000000 --- a/test/built-ins/Array/S15.4_A1.1_T2.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: > - A property name P (in the form of a string value) is an array index - if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 -es5id: 15.4_A1.1_T2 -description: Checking for number primitive ----*/ - -//CHECK#1 -var x = []; -x[NaN] = 1; -if (x[0] !== undefined) { - $ERROR('#1: x = []; x[NaN] = 1; x[0] === undefined. Actual: ' + (x[0])); -} - -//CHECK#2 -if (x["NaN"] !== 1) { - $ERROR('#2: x = []; x[NaN] = 1; x["NaN"] === 1. Actual: ' + (x["NaN"])); -} - -//CHECK#3 -var y = []; -y[Number.POSITIVE_INFINITY] = 1; -if (y[0] !== undefined) { - $ERROR('#3: y = []; y[Number.POSITIVE_INFINITY] = 1; y[0] === undefined. Actual: ' + (y[0])); -} - -//CHECK#4 -if (y["Infinity"] !== 1) { - $ERROR('#4: y = []; y[Number.POSITIVE_INFINITY] = 1; y["Infinity"] === 1. Actual: ' + (y["Infinity"])); -} - -//CHECK#5 -var z = []; -z[Number.NEGATIVE_INFINITY] = 1; -if (z[0] !== undefined) { - $ERROR('#5: z = []; z[Number.NEGATIVE_INFINITY] = 1; z[0] === undefined. Actual: ' + (z[0])); -} - -//CHECK#6 -if (z["-Infinity"] !== 1) { - $ERROR('#6: z = []; z[Number.NEGATIVE_INFINITY] = 1; z["-Infinity"] === 1. Actual: ' + (z["-Infinity"])); -} diff --git a/test/built-ins/Array/property-cast-boolean-primitive.js b/test/built-ins/Array/property-cast-boolean-primitive.js new file mode 100644 index 0000000000..3b89dfc25d --- /dev/null +++ b/test/built-ins/Array/property-cast-boolean-primitive.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: > + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T1 +description: Checking for boolean primitive +---*/ + +var x = []; + +x[true] = 1; +assert.sameValue(x[1], undefined, "x[1]"); +assert.sameValue(x["true"], 1, "x['true']"); + +x[false] = 0; +assert.sameValue(x[0], undefined, "x[0]"); +assert.sameValue(x["false"], 0, "x['false']") diff --git a/test/built-ins/Array/property-cast-nan-infinity.js b/test/built-ins/Array/property-cast-nan-infinity.js new file mode 100644 index 0000000000..07c139669b --- /dev/null +++ b/test/built-ins/Array/property-cast-nan-infinity.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 property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T2 +description: Checking for number primitive +---*/ + +var x = []; + +x[NaN] = 1; +assert.sameValue(x[0], undefined, "x[NaN] does not cast to x[0]"); +assert.sameValue(x["NaN"], 1, "x[NaN] casts to x['NaN']"); + +var y = []; +y[Number.POSITIVE_INFINITY] = 1; +assert.sameValue(y[0], undefined, "y[Number.POSITIVE_INFINITY] !== y[0]"); +assert.sameValue(y["Infinity"], 1, "y[Number.POSITIVE_INFINITY] === y['Infinity']"); + +var z = []; +z[Number.NEGATIVE_INFINITY] = 1; +assert.sameValue(z[0], undefined, "z[Number.NEGATIVE_INFINITY] !== z[0]"); +assert.sameValue(z["-Infinity"], 1, "z[Number.NEGATIVE_INFINITY] === z['-Infinity']"); diff --git a/test/built-ins/Array/S15.4_A1.1_T3.js b/test/built-ins/Array/property-cast-number.js similarity index 71% rename from test/built-ins/Array/S15.4_A1.1_T3.js rename to test/built-ins/Array/property-cast-number.js index 9287214f1e..e6abc6516d 100644 --- a/test/built-ins/Array/S15.4_A1.1_T3.js +++ b/test/built-ins/Array/property-cast-number.js @@ -9,38 +9,30 @@ es5id: 15.4_A1.1_T3 description: Checking for number primitive ---*/ -//CHECK#1 var x = []; x[4294967296] = 1; -if (x[0] !== undefined) { - $ERROR('#1: x = []; x[4294967296] = 1; x[0] === undefined. Actual: ' + (x[0])); -} - -//CHECK#2 -if (x["4294967296"] !== 1) { - $ERROR('#2: x = []; x[4294967296] = 1; x["4294967296"] === 1. Actual: ' + (x["4294967296"])); -} +assert.sameValue(x[0], undefined, "x[0]"); +assert.sameValue(x["4294967296"], 1, "x['4294967296'] !== 1"); -//CHECK#3 var y = []; y[4294967297] = 1; if (y[1] !== undefined) { - $ERROR('#3: y = []; y[4294967297] = 1; y[1] === undefined. Actual: ' + (y[1])); -} + $ERROR('#3: y = []; y[4294967297] = 1; y[1] === undefined. Actual: ' + (y[1])); +} //CHECK#4 if (y["4294967297"] !== 1) { - $ERROR('#4: y = []; y[4294967297] = 1; y["4294967297"] === 1. Actual: ' + (y["4294967297"])); + $ERROR('#4: y = []; y[4294967297] = 1; y["4294967297"] === 1. Actual: ' + (y["4294967297"])); } //CHECK#5 var z = []; z[1.1] = 1; if (z[1] !== undefined) { - $ERROR('#5: z = []; z[1.1] = 1; z[1] === undefined. Actual: ' + (z[1])); + $ERROR('#5: z = []; z[1.1] = 1; z[1] === undefined. Actual: ' + (z[1])); } //CHECK#6 if (z["1.1"] !== 1) { - $ERROR('#6: z = []; z[1.1] = 1; z["1.1"] === 1. Actual: ' + (z["1.1"])); + $ERROR('#6: z = []; z[1.1] = 1; z["1.1"] === 1. Actual: ' + (z["1.1"])); } -- GitLab