diff options
Diffstat (limited to 'js/src/tests/test262/ch09/9.1')
-rw-r--r-- | js/src/tests/test262/ch09/9.1/S9.1_A1_T1.js | 23 | ||||
-rw-r--r-- | js/src/tests/test262/ch09/9.1/S9.1_A1_T2.js | 23 | ||||
-rw-r--r-- | js/src/tests/test262/ch09/9.1/S9.1_A1_T3.js | 23 | ||||
-rw-r--r-- | js/src/tests/test262/ch09/9.1/S9.1_A1_T4.js | 23 | ||||
-rw-r--r-- | js/src/tests/test262/ch09/9.1/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/test262/ch09/9.1/shell.js | 0 |
6 files changed, 92 insertions, 0 deletions
diff --git a/js/src/tests/test262/ch09/9.1/S9.1_A1_T1.js b/js/src/tests/test262/ch09/9.1/S9.1_A1_T1.js new file mode 100644 index 000000000..662591054 --- /dev/null +++ b/js/src/tests/test262/ch09/9.1/S9.1_A1_T1.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. + +/** + * Result of primitive conversion from object is a default value for the Object + * + * @path ch09/9.1/S9.1_A1_T1.js + * @description Using operator Number. The operator calls ToPrimitive with hint Number + */ + +// CHECK#1 +var object = {valueOf: function() {return "1"}, toString: function() {return 0}}; +if (Number(object) !== 1) { + $ERROR('#1: var object = {valueOf: function() {return "1"}, toString: function() {return 0}}; Number(object) === 1. Actual: ' + (Number(object))); +} + +// CHECK#2 +var object = {valueOf: function() {return {}}, toString: function() {return "0"}}; +if (Number(object) !== 0) { + $ERROR('#2: var object = {valueOf: function() {return {}}, toString: function() {return "0"}}; Number(object) === 0. Actual: ' + (Number(object))); +} + + diff --git a/js/src/tests/test262/ch09/9.1/S9.1_A1_T2.js b/js/src/tests/test262/ch09/9.1/S9.1_A1_T2.js new file mode 100644 index 000000000..636591dab --- /dev/null +++ b/js/src/tests/test262/ch09/9.1/S9.1_A1_T2.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. + +/** + * Result of primitive conversion from object is a default value for the Object + * + * @path ch09/9.1/S9.1_A1_T2.js + * @description Using operator Number. This operator calls ToPrimitive with hint Number + */ + +// CHECK#1 +var object = {valueOf: function() {return 0}, toString: function() {return 1}}; +if (String(object) !== "1") { + $ERROR('#1: var object = {valueOf: function() {return 0}, toString: function() {return 1}}; String(object) === "1". Actual: ' + (String(object))); +} + +// CHECK#2 +var object = {valueOf: function() {return 0}, toString: function() {return {}}}; +if (String(object) !== "0") { + $ERROR('#2: var object = {valueOf: function() {return 0}, toString: function() {return {}}}; String(object) === "0". Actual: ' + (String(object))); +} + + diff --git a/js/src/tests/test262/ch09/9.1/S9.1_A1_T3.js b/js/src/tests/test262/ch09/9.1/S9.1_A1_T3.js new file mode 100644 index 000000000..cf418eeef --- /dev/null +++ b/js/src/tests/test262/ch09/9.1/S9.1_A1_T3.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. + +/** + * Result of primitive conversion from object is a default value for the Object + * + * @path ch09/9.1/S9.1_A1_T3.js + * @description Using operator "+". This operator firstly calls ToPrimitive and then calls ToString or ToNumber + */ + +// CHECK#1 +var object = {valueOf: function() {return 1}, toString: function() {return 0}}; +if (object + "" !== "1") { + $ERROR('#1: var object = {valueOf: function() {return 1}, toString: function() {return 0}}; object + "" === "1". Actual: ' + (object + "")); +} + +// CHECK#2 +var object = {valueOf: function() {return "1"}, toString: function() {return 0}}; +if (object + 0 !== "10") { + $ERROR('#2: var object = {valueOf: function() {return "1"}, toString: function() {return 0}}; object + 0 === "10". Actual: ' + (object + 0)); +} + + diff --git a/js/src/tests/test262/ch09/9.1/S9.1_A1_T4.js b/js/src/tests/test262/ch09/9.1/S9.1_A1_T4.js new file mode 100644 index 000000000..9dcd88f50 --- /dev/null +++ b/js/src/tests/test262/ch09/9.1/S9.1_A1_T4.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. + +/** + * Result of primitive conversion from object is a default value for the Object + * + * @path ch09/9.1/S9.1_A1_T4.js + * @description Using operator "<". The operator firstly calls ToPrimitive and then calls ToString or ToNumber + */ + +// CHECK#1 +var object = {valueOf: function() {return -2}, toString: function() {return "-2"}}; +if ("-1" < object) { + $ERROR('#1: var object = {valueOf: function() {return -2}, toString: function() {return "-2"}}; "-1" < object'); +} + +// CHECK#2 +var object = {valueOf: function() {return "-2"}, toString: function() {return -2}}; +if (object < "-1") { + $ERROR('#2: var object = {valueOf: function() {return "-2"}, toString: function() {return -2}}; object < "-1"'); +} + + diff --git a/js/src/tests/test262/ch09/9.1/browser.js b/js/src/tests/test262/ch09/9.1/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch09/9.1/browser.js diff --git a/js/src/tests/test262/ch09/9.1/shell.js b/js/src/tests/test262/ch09/9.1/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/ch09/9.1/shell.js |