diff options
Diffstat (limited to 'js/src/tests/test262/ch09/9.8')
24 files changed, 823 insertions, 0 deletions
diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A1.js b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A1.js new file mode 100644 index 000000000..b51e4cca1 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A1.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. + +/** + * If m is NaN, return the string "NaN" + * + * @path ch09/9.8/9.8.1/S9.8.1_A1.js + * @description NaN convert to String by explicit transformation + */ + +// CHECK#1 +if (String(NaN) !== "NaN") { + $ERROR('#1: String(NaN) === Not-a-Number Actual: ' + (String(NaN))); +} + +// CHECK#2 +if (String(Number.NaN) !== "NaN") { + $ERROR('#2: String(Number.NaN) === Not-a-Number Actual: ' + (String(Number.NaN))); +} + +// CHECK#3 +if (String(Number("asasa")) !== "NaN") { + $ERROR('#3: String(Number("asasa")) === Not-a-Number Actual: ' + (String(Number("asasa")))); +} + diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A10.js b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A10.js new file mode 100644 index 000000000..17fa40697 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A10.js @@ -0,0 +1,60 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Return the string consisting of the most significant + * digit of the decimal representation of s, followed by a decimal point '.', + * followed by the remaining k-1 digits of the decimal representation of s, + * followed by the lowercase character 'e', followed by a plus sign '+' or + * minus sign '-' according to whether n-1 is positive or negative, followed + * by the decimal representation of the integer abs(n-1) (with no leading zeros) + * + * @path ch09/9.8/9.8.1/S9.8.1_A10.js + * @description Various float numbers convert to String by explicit transformation + */ + +// CHECK#1 +if (String(1.2345) !== "1.2345") { + $ERROR('#1: String(1.2345) === "1.2345". Actual: ' + (String(1.2345))); +} + +// CHECK#2 +if (String(1.234567890) !== "1.23456789") { + $ERROR('#2: String(1.234567890) === "1.23456789". Actual: ' + (String(1.234567890))); +} + +// CHECK#3 +if (String(0.12345) !== "0.12345") { + $ERROR('#3: String(0.12345) === "0.12345". Actual: ' + (String(0.12345))); +} + +// CHECK#4 +if (String(.012345) !== "0.012345") { + $ERROR('#4: String(.012345) === "0.012345". Actual: ' + (String(.012345))); +} + +// CHECK#5 +if (String(.0012345) !== "0.0012345") { + $ERROR('#5: String(.0012345) === "0.0012345". Actual: ' + (String(.0012345))); +} + +// CHECK#6 +if (String(.00012345) !== "0.00012345") { + $ERROR('#6: String(.00012345) === "0.00012345". Actual: ' + (String(.00012345))); +} + +// CHECK#7 +if (String(.000012345) !== "0.000012345") { + $ERROR('#7: String(.000012345) === "0.000012345". Actual: ' + (String(.000012345))); +} + +// CHECK#8 +if (String(.0000012345) !== "0.0000012345") { + $ERROR('#8: String(.0000012345) === "0.0000012345". Actual: ' + (String(.0000012345))); +} + +// CHECK#9 +if (String(.00000012345) !== "1.2345e-7") { + $ERROR('#9: String(.00000012345) === "1.2345e-7". Actual: ' + (String(.00000012345))); +} + diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A2.js b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A2.js new file mode 100644 index 000000000..adc8e1f5e --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A2.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. + +/** + * If m is +0 or -0, return the string "0" + * + * @path ch09/9.8/9.8.1/S9.8.1_A2.js + * @description +0 and -0 convert to String by explicit transformation + */ + +// CHECK#1 +if (String(+0) !== "0") { + $ERROR('#1: String(+0) === "0". Actual: ' + (String(+0))); +} + +// CHECK#2 +if (String(-0) !== "0") { + $ERROR('#2: String(-0) === "0". Actual: ' + (String(-0))); +} + diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A3.js b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A3.js new file mode 100644 index 000000000..3945f2279 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A3.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. + +/** + * If m is less than zero, return the string concatenation of the + * string "-" and ToString(-m) + * + * @path ch09/9.8/9.8.1/S9.8.1_A3.js + * @description -1234567890 convert to String by explicit transformation + */ + +// CHECK#1 +if (String(-1234567890) !== "-1234567890") { + $ERROR('#1: String(-1234567890) === "-1234567890". Actual: ' + (String(-1234567890))); +} + +// CHECK#2 +if ("-"+String(-(-1234567890)) !== "-1234567890") { + $ERROR('#2: "-"+String(-(-1234567890)) === "-1234567890". Actual: ' + ("-"+String(-(-1234567890)))); +} + diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A4.js b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A4.js new file mode 100644 index 000000000..f71ac7557 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A4.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. + +/** + * If m is infinity, return the string "Infinity" + * + * @path ch09/9.8/9.8.1/S9.8.1_A4.js + * @description +/-Infinity convert to String by explicit transformation + */ + +// CHECK#1 +if (String(Infinity) !== "Infinity") { + $ERROR('#1: String(Infinity) === "Infinity". Actual: ' + (String(Infinity))); +} + +// CHECK#2 +if (String(Number.POSITIVE_INFINITY) !== "Infinity") { + $ERROR('#2: String(Number.POSITIVE_INFINITY) === "Infinity". Actual: ' + (String(Number.POSITIVE_INFINITY))); +} + +// CHECK#3 +if (String(-Infinity) !== "-Infinity") { + $ERROR('#3: String(-Infinity) === "-Infinity". Actual: ' + (String(-Infinity))); +} + +// CHECK#4 +if (String(Number.NEGATIVE_INFINITY) !== "-Infinity") { + $ERROR('#4: String(Number.NEGATIVE_INFINITY) === "-Infinity". Actual: ' + (String(Number.NEGATIVE_INFINITY))); +} + diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A6.js b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A6.js new file mode 100644 index 000000000..8b9ddf42e --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A6.js @@ -0,0 +1,93 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * If 1 <= s < 1e21 or -1e21 s < -1, return the string + * consisting of the k digits of the decimal representation of s (in order, + * with no leading zeroes), followed by n-k occurrences of the character '0' + * + * @path ch09/9.8/9.8.1/S9.8.1_A6.js + * @description Various integer numbers convert to String by explicit transformation + */ + +// CHECK#1 +if (String(1) !== "1") { + $ERROR('#1: String(1) === "1". Actual: ' + (String(1))); +} + +// CHECK#2 +if (String(10) !== "10") { + $ERROR('#2: String(10) === "10". Actual: ' + (String(10))); +} + +// CHECK#3 +if (String(100) !== "100") { + $ERROR('#3: String(100) === "100". Actual: ' + (String(100))); +} + +// CHECK#4 +if (String(100000000000000000000) !== "100000000000000000000") { + $ERROR('#4: String(100000000000000000000) === "100000000000000000000". Actual: ' + (String(100000000000000000000))); +} + +// CHECK#5 +if (String(1e20) !== "100000000000000000000") { + $ERROR('#5: String(1e20) === "100000000000000000000". Actual: ' + (String(1e20))); +} + +// CHECK#6 +if (String(12345) !== "12345") { + $ERROR('#6: String(12345) === "12345". Actual: ' + (String(12345))); +} + +// CHECK#7 +if (String(12345000) !== "12345000") { + $ERROR('#7: String(12345000) === "12345000". Actual: ' + (String(12345000))); +} + +// CHECK#8 +if (String(-1) !== "-1") { + $ERROR('#8: String(-1) === "-1". Actual: ' + (String(-1))); +} + +// CHECK#9 +if (String(-10) !== "-10") { + $ERROR('#9: String(-10) === "-10". Actual: ' + (String(-10))); +} + +// CHECK#10 +if (String(-100) !== "-100") { + $ERROR('#3: String(-100) === "-100". Actual: ' + (String(-100))); +} + +// CHECK#10 +if (String(-100000000000000000000) !== "-100000000000000000000") { + $ERROR('#10: String(-100000000000000000000) === "-100000000000000000000". Actual: ' + (String(-100000000000000000000))); +} + +// CHECK#11 +if (String(-1e20) !== "-100000000000000000000") { + $ERROR('#11: String(-1e20) === "-100000000000000000000". Actual: ' + (String(-1e20))); +} + +// CHECK#12 +if (String(-12345) !== "-12345") { + $ERROR('#12: String(-12345) === "-12345". Actual: ' + (String(-12345))); +} + +// CHECK#13 +if (String(-12345000) !== "-12345000") { + $ERROR('#13: String(-12345000) === "-12345000". Actual: ' + (String(-12345000))); +} + +// CHECK#14 +if (String(1E20) !== "100000000000000000000") { + $ERROR('#14: String(1E20) === "100000000000000000000". Actual: ' + (String(1E20))); +} + +// CHECK#15 +if (String(-1E20) !== "-100000000000000000000") { + $ERROR('#15: String(-1E20) === "-100000000000000000000". Actual: ' + (String(-1E20))); +} + + diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A7.js b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A7.js new file mode 100644 index 000000000..5ad14c25d --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A7.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. + +/** + * If 1 <= s < 1e21 or -1e21 s < -1 and s has a fractional + * component, return the string consisting of the most significant n digits of + * the decimal representation of s, followed by a decimal point '.', + * followed by the remaining k-n digits of the decimal representation of s + * + * @path ch09/9.8/9.8.1/S9.8.1_A7.js + * @description 1.0000001 and -1.0000001 convert to String by explicit transformation + */ + +// CHECK#1 +if (String(1.0000001) !== "1.0000001") { + $ERROR('#1: String(1.0000001) === "1.0000001". Actual: ' + (String(1.0000001))); +} + +// CHECK#2 +if (String(-1.0000001) !== "-1.0000001") { + $ERROR('#2: String(-1.0000001) === "-1.0000001". Actual: ' + (String(-1.0000001))); +} + diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A8.js b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A8.js new file mode 100644 index 000000000..91efe0b52 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A8.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * If 1 > s > -1, and -6 < n <= 0, return the string consisting of the + * character '0', followed by a decimal point '.', followed by -n occurrences + * of the character '0', followed by the k digits of the decimal + * representation of s + * + * @path ch09/9.8/9.8.1/S9.8.1_A8.js + * @description Various float numbers convert to String by explicit transformation + */ + +// CHECK#1 +if (String(0.1) !== "0.1") { + $ERROR('#1: String(0.1) === "0.1". Actual: ' + (String(0.1))); +} + +// CHECK#2 +if (String(0.000001) !== "0.000001") { + $ERROR('#2: String(0.000001) === "0.000001". Actual: ' + (String(0.000001))); +} + +// CHECK#3 +if (String(1e-6) !== "0.000001") { + $ERROR('#3: String(1e-6) === "0.000001". Actual: ' + (String(1e-6))); +} + +// CHECK#4 +if (String(1E-6) !== "0.000001") { + $ERROR('#4: String(1E-6) === "0.000001". Actual: ' + (String(1E-6))); +} + +// CHECK#5 +if (String(-0.1) !== "-0.1") { + $ERROR('#5: String(-0.1) === "-0.1". Actual: ' + (String(-0.1))); +} + +// CHECK#6 +if (String(-0.000001) !== "-0.000001") { + $ERROR('#6: String(-0.000001) === "-0.000001". Actual: ' + (String(-0.000001))); +} + +// CHECK#7 +if (String(-1e-6) !== "-0.000001") { + $ERROR('#7: String(-1e-6) === "0.000001". Actual: ' + (String(-1e-6))); +} + +// CHECK#8 +if (String(-1E-6) !== "-0.000001") { + $ERROR('#8: String(-1E-6) === "0.000001". Actual: ' + (String(-1E-6))); +} + + diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A9_T1.js b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A9_T1.js new file mode 100644 index 000000000..d4614194b --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A9_T1.js @@ -0,0 +1,73 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Return the string consisting of the single digit of s, + * followed by lowercase character 'e', followed by a plus sign '+' or minus + * sign '-' according to whether n-1 is positive or negative, followed by the + * decimal representation of the integer abs(n-1) (with no leading zeros) + * + * @path ch09/9.8/9.8.1/S9.8.1_A9_T1.js + * @description Various big numbers convert to String by explicit transformation + */ + +// CHECK#1 +if (String(1000000000000000000000) !== "1e+21") { + $ERROR('#1: String(1000000000000000000000) === "1e+21". Actual: ' + (String(1000000000000000000000))); +} + +// CHECK#2 +if (String(10000000000000000000000) !== "1e+22") { + $ERROR('#2: String(10000000000000000000000) === "1e+22". Actual: ' + (String(10000000000000000000000))); +} + +// CHECK#3 +if (String(1e21) !== "1e+21") { + $ERROR('#3: String(1e21) === "1e+21". Actual: ' + (String(1e21))); +} + +// CHECK#4 +if (String(1.0e22) !== "1e+22") { + $ERROR('#4: String(1.0e22) === "1e+22". Actual: ' + (String(1.0e22))); +} + +// CHECK#5 +if (String(1E21) !== "1e+21") { + $ERROR('#5: String(1E21) === "1e+21". Actual: ' + (String(1E21))); +} + +// CHECK#6 +if (String(1.0E22) !== "1e+22") { + $ERROR('#6: String(1.0E22) === "1e+22". Actual: ' + (String(1.0E22))); +} + +// CHECK#7 +if (String(-1000000000000000000000) !== "-1e+21") { + $ERROR('#7: String(-1000000000000000000000) === "-1e+21". Actual: ' + (String(-1000000000000000000000))); +} + +// CHECK#8 +if (String(-10000000000000000000000) !== "-1e+22") { + $ERROR('#8: String(-10000000000000000000000) === "-1e+22". Actual: ' + (String(-10000000000000000000000))); +} + +// CHECK#9 +if (String(-1e21) !== "-1e+21") { + $ERROR('#9: String(-1e21) === "-1e+21". Actual: ' + (String(-1e21))); +} + +// CHECK#10 +if (String(-1.0e22) !== "-1e+22") { + $ERROR('#10: String(-1.0e22) === "-1e+22". Actual: ' + (String(-1.0e22))); +} + +// CHECK#11 +if (String(-1E21) !== "-1e+21") { + $ERROR('#11: String(-1E21) === "-1e+21". Actual: ' + (String(-1E21))); +} + +// CHECK#12 +if (String(-1.0E22) !== "-1e+22") { + $ERROR('#12: String(-1.0E22) === "-1e+22". Actual: ' + (String(-1.0E22))); +} + diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A9_T2.js b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A9_T2.js new file mode 100644 index 000000000..79ca7873e --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/S9.8.1_A9_T2.js @@ -0,0 +1,73 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Return the string consisting of the single digit of s, + * followed by lowercase character 'e', followed by a plus sign '+' or minus + * sign '-' according to whether n-1 is positive or negative, followed by the + * decimal representation of the integer abs(n-1) (with no leading zeros) + * + * @path ch09/9.8/9.8.1/S9.8.1_A9_T2.js + * @description Various float numbers with many zeros convert to String by explicit transformation + */ + +// CHECK#1 +if (String(0.0000001) !== "1e-7") { + $ERROR('#1: String(0.0000001) === "1e-7". Actual: ' + (String(0.0000001))); +} + +// CHECK#2 +if (String(0.000000000100000000000) !== "1e-10") { + $ERROR('#2: String(0.000000000100000000000) === "1e-10". Actual: ' + (String(0.000000000100000000000))); +} + +// CHECK#3 +if (String(1e-7) !== "1e-7") { + $ERROR('#3: String(1e-7) === "1e-7". Actual: ' + (String(1e-7))); +} + +// CHECK#4 +if (String(1.0e-10) !== "1e-10") { + $ERROR('#4: String(1.0e-10) === "1e-10". Actual: ' + (String(1.0e-10))); +} + +// CHECK#5 +if (String(1E-7) !== "1e-7") { + $ERROR('#5: String(1E-7) === "1e-7". Actual: ' + (String(1E-7))); +} + +// CHECK#6 +if (String(1.0E-10) !== "1e-10") { + $ERROR('#6: String(1.0E-10) === "1e-10". Actual: ' + (String(1.0E-10))); +} + +// CHECK#7 +if (String(-0.0000001) !== "-1e-7") { + $ERROR('#7: String(-0.0000001) === "1e-7". Actual: ' + (String(-0.0000001))); +} + +// CHECK#8 +if (String(-0.000000000100000000000) !== "-1e-10") { + $ERROR('#8: String(-0.000000000100000000000) === "1e-10". Actual: ' + (String(-0.000000000100000000000))); +} + +// CHECK#9 +if (String(-1e-7) !== "-1e-7") { + $ERROR('#9: String(-1e-7) === "-1e-7". Actual: ' + (String(-1e-7))); +} + +// CHECK#10 +if (String(-1.0e-10) !== "-1e-10") { + $ERROR('#10: String(-1.0e-10) === "-1e-10". Actual: ' + (String(-1.0e-10))); +} + +// CHECK#11 +if (String(-1E-7) !== "-1e-7") { + $ERROR('#11: String(-1E-7) === "-1e-7". Actual: ' + (String(-1E-7))); +} + +// CHECK#12 +if (String(-1.0E-10) !== "-1e-10") { + $ERROR('#12: String(-1.0E-10) === "-1e-10". Actual: ' + (String(-1.0E-10))); +} + diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/browser.js b/js/src/tests/test262/ch09/9.8/9.8.1/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/browser.js diff --git a/js/src/tests/test262/ch09/9.8/9.8.1/shell.js b/js/src/tests/test262/ch09/9.8/9.8.1/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/9.8.1/shell.js diff --git a/js/src/tests/test262/ch09/9.8/S9.8_A1_T1.js b/js/src/tests/test262/ch09/9.8/S9.8_A1_T1.js new file mode 100644 index 000000000..efce3a546 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/S9.8_A1_T1.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. + +/** + * Result of ToString conversion from undefined value is "undefined" + * + * @path ch09/9.8/S9.8_A1_T1.js + * @description Undefined values is undefined, void 0 and eval("var x"). Use explicit transformation + */ + +// CHECK#1 +if (String(undefined) !== "undefined") { + $ERROR('#1: String(undefined) === "undefined". Actual: ' + (String(undefined))); +} + +// CHECK#2 +if (String(void 0) !== "undefined") { + $ERROR('#2: String(void 0) === "undefined". Actual: ' + (String(void 0))); +} + +// CHECK#3 +if (String(eval("var x")) !== "undefined") { + $ERROR('#3: String(eval("var x")) === "undefined" . Actual: ' + (String(eval("var x")))); +} + diff --git a/js/src/tests/test262/ch09/9.8/S9.8_A1_T2.js b/js/src/tests/test262/ch09/9.8/S9.8_A1_T2.js new file mode 100644 index 000000000..dd26c11b4 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/S9.8_A1_T2.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. + +/** + * Result of ToString conversion from undefined value is "undefined" + * + * @path ch09/9.8/S9.8_A1_T2.js + * @description Undefined values is undefined, void 0 and eval("var x"). Use implicit transformation + */ + +// CHECK#1 +if (undefined + "" !== "undefined") { + $ERROR('#1: undefined + "" === "undefined". Actual: ' + (undefined + "")); +} + +// CHECK#2 +if (void 0 + "" !== "undefined") { + $ERROR('#2: void 0 + "" === "undefined". Actual: ' + (void 0 + "")); +} + +// CHECK#3 +if (eval("var x") + "" !== "undefined") { + $ERROR('#3: eval("var x") + "" === "undefined". Actual: ' + (eval("var x") + "")); +} + diff --git a/js/src/tests/test262/ch09/9.8/S9.8_A2_T1.js b/js/src/tests/test262/ch09/9.8/S9.8_A2_T1.js new file mode 100644 index 000000000..0a1b982b7 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/S9.8_A2_T1.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. + +/** + * Result of ToString conversion from null value is "null" + * + * @path ch09/9.8/S9.8_A2_T1.js + * @description null convert to String by explicit transformation + */ + +// CHECK#1 +if (String(null) !== "null") { + $ERROR('#1: String(null) === "null". Actual: ' + (String(null))); +} + diff --git a/js/src/tests/test262/ch09/9.8/S9.8_A2_T2.js b/js/src/tests/test262/ch09/9.8/S9.8_A2_T2.js new file mode 100644 index 000000000..3b760909b --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/S9.8_A2_T2.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. + +/** + * Result of ToString conversion from null value is "null" + * + * @path ch09/9.8/S9.8_A2_T2.js + * @description null convert to String by implicit transformation + */ + +// CHECK#1 +if (null + "" !== "null") { + $ERROR('#1: null + "" === "null". Actual: ' + (null + "")); +} + diff --git a/js/src/tests/test262/ch09/9.8/S9.8_A3_T1.js b/js/src/tests/test262/ch09/9.8/S9.8_A3_T1.js new file mode 100644 index 000000000..cc267edc8 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/S9.8_A3_T1.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. + +/** + * Result of ToString conversion from boolean value is "true" if + * the argument is "true", else is "false" + * + * @path ch09/9.8/S9.8_A3_T1.js + * @description True and false convert to String by explicit transformation + */ + +// CHECK#1 +if (String(false) !== "false") { + $ERROR('#1: String(false) === "false". Actual: ' + (String(false))); +} + +// CHECK#2 +if (String(true) !== "true") { + $ERROR('#2: String(true) === "true". Actual: ' + (String(true))); +} + diff --git a/js/src/tests/test262/ch09/9.8/S9.8_A3_T2.js b/js/src/tests/test262/ch09/9.8/S9.8_A3_T2.js new file mode 100644 index 000000000..788bcb58d --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/S9.8_A3_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. + +/** + * Result of ToString conversion from boolean value is "true" if + * the argument is "true", else is "false" + * + * @path ch09/9.8/S9.8_A3_T2.js + * @description True and false convert to String by implicit transformation + */ + +// CHECK#1 +if (false + "" !== "false") { + $ERROR('#1: false + "" === "false". Actual: ' + (false + "")); +} + +// CHECK#2 +if (true + "" !== "true") { + $ERROR('#2: true + "" === "true". Actual: ' + (true + "")); +} + diff --git a/js/src/tests/test262/ch09/9.8/S9.8_A4_T1.js b/js/src/tests/test262/ch09/9.8/S9.8_A4_T1.js new file mode 100644 index 000000000..064458461 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/S9.8_A4_T1.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. + +/** + * Result of String conversion from string value is the input argument (no conversion) + * + * @path ch09/9.8/S9.8_A4_T1.js + * @description Some strings convert to String with explicit transformation + */ + +// CHECK#1 +var x1 = "abc"; +if (String(x1) !== x1) { + $ERROR('#1: String("abc") === "abc". Actual: ' + (String("abc"))); +} + +// CHECK#2 +var x2 = "abc"; +if (typeof String(x2) !== typeof x2) { + $ERROR('#2: typeof String("abc") === "string". Actual: ' + (typeof String("abc"))); +} + diff --git a/js/src/tests/test262/ch09/9.8/S9.8_A4_T2.js b/js/src/tests/test262/ch09/9.8/S9.8_A4_T2.js new file mode 100644 index 000000000..fdde4c38e --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/S9.8_A4_T2.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. + +/** + * Result of String conversion from string value is the input argument (no conversion) + * + * @path ch09/9.8/S9.8_A4_T2.js + * @description Some strings convert to String by implicit transformation + */ + +// CHECK#1 +var x1 = "abc"; +if (x1 + "" !== x1) { + $ERROR('#1: "abc" + "" === "abc". Actual: ' + ("abc" + "")); +} + +// CHECK#2 +var x2 = "abc"; +if (typeof x2 + "" !== typeof x2) { + $ERROR('#2: typeof "abc" + "" === "string". Actual: ' + (typeof "abc" + "")); +} + diff --git a/js/src/tests/test262/ch09/9.8/S9.8_A5_T1.js b/js/src/tests/test262/ch09/9.8/S9.8_A5_T1.js new file mode 100644 index 000000000..55d88c102 --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/S9.8_A5_T1.js @@ -0,0 +1,93 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Result of String conversion from Object value is conversion + * from primitive value + * + * @path ch09/9.8/S9.8_A5_T1.js + * @description Some objects convert to String by explicit transformation + */ + +// CHECK#1 +if (String(new Number()) !== "0") { + $ERROR('#1: String(new Number()) === "0". Actual: ' + (String(new Number()))); +} + +// CHECK#2 +if (String(new Number(0)) !== "0") { + $ERROR('#2: String(new Number(0)) === "0". Actual: ' + (String(new Number(0)))); +} + +// CHECK#3 +if (String(new Number(Number.NaN)) !== "NaN") { + $ERROR('#3: String(new Number(Number.NaN)) === Not-a-Number. Actual: ' + (String(new Number(Number.NaN)))); +} + +// CHECK#4 +if (String(new Number(null)) !== "0") { + $ERROR('#4: String(new Number(null)) === "0". Actual: ' + (String(new Number(null)))); +} + +// CHECK#5 +if (String(new Number(void 0)) !== "NaN") { + $ERROR('#5: String(new Number(void 0)) === Not-a-Number. Actual: ' + (String(new Number(void 0)))); +} + +// CHECK#6 +if (String(new Number(true)) !== "1") { + $ERROR('#6: String(new Number(true)) === "1". Actual: ' + (String(new Number(true)))); +} + +// CHECK#7 +if (String(new Number(false)) !== "0") { + $ERROR('#7: String(new Number(false)) === "0". Actual: ' + (String(new Number(false)))); +} + +// CHECK#8 +if (String(new Boolean(true)) !== "true") { + $ERROR('#8: String(new Boolean(true)) === "true". Actual: ' + (String(new Boolean(true)))); +} + +// CHECK#9 +if (String(new Boolean(false)) !== "false") { + $ERROR('#9: Number(new Boolean(false)) === "false". Actual: ' + (Number(new Boolean(false)))); +} + +// CHECK#10 +if (String(new Array(2,4,8,16,32)) !== "2,4,8,16,32") { + $ERROR('#10: String(new Array(2,4,8,16,32)) === "2,4,8,16,32". Actual: ' + (String(new Array(2,4,8,16,32)))); +} + +// CHECK#11 +var myobj1 = { + toNumber : function(){return 12345;}, + toString : function(){return 67890;}, + valueOf : function(){return "[object MyObj]";} + }; + +if (String(myobj1) !== "67890"){ + $ERROR("#11: String(myobj) calls ToPrimitive with hint String"); +} + +// CHECK#12 +var myobj2 = { + toNumber : function(){return 12345;}, + toString : function(){return {}}, + valueOf : function(){return "[object MyObj]";} + }; + +if (String(myobj2) !== "[object MyObj]"){ + $ERROR("#12: String(myobj) calls ToPrimitive with hint String"); +} + +// CHECK#13 +var myobj3 = { + toNumber : function(){return 12345;}, + valueOf : function(){return "[object MyObj]";} + }; + +if (String(myobj3) !== "[object Object]"){ + $ERROR("#13: String(myobj) calls ToPrimitive with hint String"); +} + diff --git a/js/src/tests/test262/ch09/9.8/S9.8_A5_T2.js b/js/src/tests/test262/ch09/9.8/S9.8_A5_T2.js new file mode 100644 index 000000000..7911adaee --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/S9.8_A5_T2.js @@ -0,0 +1,92 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * Result of String conversion from Object value is conversion + * from primitive value + * + * @path ch09/9.8/S9.8_A5_T2.js + * @description Some objects convert to String by implicit transformation + */ + +// CHECK#1 +if (new Number() + "" !== "0") { + $ERROR('#1: new Number() + "" === "0". Actual: ' + (new Number() + "")); +} + +// CHECK#2 +if (new Number(0) + "" !== "0") { + $ERROR('#2: new Number(0) + "" === "0". Actual: ' + (new Number(0) + "")); +} + +// CHECK#3 +if (new Number(Number.NaN) + "" !== "NaN") { + $ERROR('#3: new Number(Number.NaN) + "" === "NaN". Actual: ' + (new Number(Number.NaN) + "")); +} + +// CHECK#4 +if (new Number(null) + "" !== "0") { + $ERROR('#4: new Number(null) + "" === "0". Actual: ' + (new Number(null) + "")); +} + +// CHECK#5 +if (new Number(void 0) + "" !== "NaN") { + $ERROR('#5: new Number(void 0) + "" === "NaN. Actual: ' + (new Number(void 0) + "")); +} + +// CHECK#6 +if (new Number(true) + "" !== "1") { + $ERROR('#6: new Number(true) + "" === "1". Actual: ' + (new Number(true) + "")); +} + +// CHECK#7 +if (new Number(false) + "" !== "0") { + $ERROR('#7: new Number(false) + "" === "0". Actual: ' + (new Number(false) + "")); +} + +// CHECK#8 +if (new Boolean(true) + "" !== "true") { + $ERROR('#8: new Boolean(true) + "" === "true". Actual: ' + (new Boolean(true) + "")); +} + +// CHECK#9 +if (new Boolean(false) + "" !== "false") { + $ERROR('#9: Number(new Boolean(false)) === "false". Actual: ' + (Number(new Boolean(false)))); +} + +// CHECK#10 +if (new Array(2,4,8,16,32) + "" !== "2,4,8,16,32") { + $ERROR('#10: new Array(2,4,8,16,32) + "" === "2,4,8,16,32". Actual: ' + (new Array(2,4,8,16,32) + "")); +} + +// CHECK#11 +var myobj1 = { + toNumber : function(){return 12345;}, + toString : function(){return 67890;}, + valueOf : function(){return "[object MyObj]";} + }; + +if (myobj1 + "" !== "[object MyObj]"){ + $ERROR('#11: myobj1 + "" calls ToPrimitive with hint Number. Exptected: "[object MyObj]". Actual: ' + (myobj1 + "")); +} + +// CHECK#12 +var myobj2 = { + toNumber : function(){return 12345;}, + toString : function(){return 67890}, + valueOf : function(){return {}} + }; + +if (myobj2 + "" !== "67890"){ + $ERROR('#12: myobj2 + "" calls ToPrimitive with hint Number. Exptected: "67890". Actual: ' + (myobj2 + "")); +} + +// CHECK#13 +var myobj3 = { + toNumber : function(){return 12345;} + }; + +if (myobj3 + "" !== "[object Object]"){ + $ERROR('#13: myobj3 + "" calls ToPrimitive with hint Number. Exptected: "[object Object]". Actual: ' + (myobj3 + "")); +} + diff --git a/js/src/tests/test262/ch09/9.8/browser.js b/js/src/tests/test262/ch09/9.8/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/browser.js diff --git a/js/src/tests/test262/ch09/9.8/shell.js b/js/src/tests/test262/ch09/9.8/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch09/9.8/shell.js |