aboutsummaryrefslogtreecommitdiffstats
path: root/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.5_Multiplicative_Operators/11.5.1_Applying_the_asterisk_Operator/S11.5.1_A2.2_T1.js
diff options
context:
space:
mode:
authorDavid Fugate <dfugate@microsoft.com>2011-06-28 10:36:30 -0700
committerDavid Fugate <dfugate@microsoft.com>2011-06-28 10:36:30 -0700
commit0005b0b87b55ee11277e414c4063ae97b3c793e1 (patch)
treefc37bea04c3ff1cf21dff9ee02f51f2757958cd9 /external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.5_Multiplicative_Operators/11.5.1_Applying_the_asterisk_Operator/S11.5.1_A2.2_T1.js
parent55855b285e67bc29e567c515459726cb1a110163 (diff)
parente69a5fa68f7b946e385786ab13981385b769db64 (diff)
Merged remote changes
Diffstat (limited to 'external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.5_Multiplicative_Operators/11.5.1_Applying_the_asterisk_Operator/S11.5.1_A2.2_T1.js')
-rw-r--r--external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.5_Multiplicative_Operators/11.5.1_Applying_the_asterisk_Operator/S11.5.1_A2.2_T1.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.5_Multiplicative_Operators/11.5.1_Applying_the_asterisk_Operator/S11.5.1_A2.2_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.5_Multiplicative_Operators/11.5.1_Applying_the_asterisk_Operator/S11.5.1_A2.2_T1.js
new file mode 100644
index 000000000..712271524
--- /dev/null
+++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.5_Multiplicative_Operators/11.5.1_Applying_the_asterisk_Operator/S11.5.1_A2.2_T1.js
@@ -0,0 +1,70 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @name: S11.5.1_A2.2_T1;
+ * @section: 11.5.1, 8.6.2.6;
+ * @assertion: Operator x * y uses [[Default Value]];
+ * @description: If Type(value) is Object, evaluate ToPrimitive(value, Number);
+ */
+
+//CHECK#1
+if ({valueOf: function() {return 1}} * 1 !== 1) {
+ $ERROR('#1: {valueOf: function() {return 1}} * 1 === 1. Actual: ' + ({valueOf: function() {return 1}} * 1));
+}
+
+//CHECK#2
+if ({valueOf: function() {return 1}, toString: function() {return 0}} * 1 !== 1) {
+ $ERROR('#2: {valueOf: function() {return 1}, toString: function() {return 0}} * 1 === 1. Actual: ' + ({valueOf: function() {return 1}, toString: function() {return 0}} * 1));
+}
+
+//CHECK#3
+if ({valueOf: function() {return 1}, toString: function() {return {}}} * 1 !== 1) {
+ $ERROR('#3: {valueOf: function() {return 1}, toString: function() {return {}}} * 1 === 1. Actual: ' + ({valueOf: function() {return 1}, toString: function() {return {}}} * 1));
+}
+
+//CHECK#4
+try {
+ if ({valueOf: function() {return 1}, toString: function() {throw "error"}} * 1 !== 1) {
+ $ERROR('#4.1: {valueOf: function() {return 1}, toString: function() {throw "error"}} * 1 === 1. Actual: ' + ({valueOf: function() {return 1}, toString: function() {throw "error"}} * 1));
+ }
+}
+catch (e) {
+ if (e === "error") {
+ $ERROR('#4.2: {valueOf: function() {return 1}, toString: function() {throw "error"}} * 1 not throw "error"');
+ } else {
+ $ERROR('#4.3: {valueOf: function() {return 1}, toString: function() {throw "error"}} * 1 not throw Error. Actual: ' + (e));
+ }
+}
+
+//CHECK#5
+if (1 * {toString: function() {return 1}} !== 1) {
+ $ERROR('#5: 1 * {toString: function() {return 1}} === 1. Actual: ' + (1 * {toString: function() {return 1}}));
+}
+
+//CHECK#6
+if (1 * {valueOf: function() {return {}}, toString: function() {return 1}} !== 1) {
+ $ERROR('#6: 1 * {valueOf: function() {return {}}, toString: function() {return 1}} === 1. Actual: ' + (1 * {valueOf: function() {return {}}, toString: function() {return 1}}));
+}
+
+//CHECK#7
+try {
+ 1 * {valueOf: function() {throw "error"}, toString: function() {return 1}};
+ $ERROR('#7.1: 1 * {valueOf: function() {throw "error"}, toString: function() {return 1}} throw "error". Actual: ' + (1 * {valueOf: function() {throw "error"}, toString: function() {return 1}}));
+}
+catch (e) {
+ if (e !== "error") {
+ $ERROR('#7.2: 1 * {valueOf: function() {throw "error"}, toString: function() {return 1}} throw "error". Actual: ' + (e));
+ }
+}
+
+//CHECK#8
+try {
+ 1 * {valueOf: function() {return {}}, toString: function() {return {}}};
+ $ERROR('#8.1: 1 * {valueOf: function() {return {}}, toString: function() {return {}}} throw TypeError. Actual: ' + (1 * {valueOf: function() {return {}}, toString: function() {return {}}}));
+}
+catch (e) {
+ if ((e instanceof TypeError) !== true) {
+ $ERROR('#8.2: 1 * {valueOf: function() {return {}}, toString: function() {return {}}} throw TypeError. Actual: ' + (e));
+ }
+}