summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/ch12/12.11
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/ch12/12.11')
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A1_T1.js74
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A1_T2.js88
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A1_T3.js92
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A1_T4.js80
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A2_T1.js30
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A3_T1.js27
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A3_T2.js27
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A3_T3.js13
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A3_T4.js27
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A3_T5.js28
-rw-r--r--js/src/tests/test262/ch12/12.11/S12.11_A4_T1.js36
-rw-r--r--js/src/tests/test262/ch12/12.11/browser.js0
-rw-r--r--js/src/tests/test262/ch12/12.11/shell.js0
13 files changed, 522 insertions, 0 deletions
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A1_T1.js b/js/src/tests/test262/ch12/12.11/S12.11_A1_T1.js
new file mode 100644
index 000000000..0d637da55
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A1_T1.js
@@ -0,0 +1,74 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * If Result.type is break and Result.target is in the current
+ * label set, return (normal, Result.value, empty)
+ *
+ * @path ch12/12.11/S12.11_A1_T1.js
+ * @description Simple test using switch statement
+ */
+
+function SwitchTest(value){
+ var result = 0;
+
+ switch(value) {
+ case 0:
+ result += 2;
+ case 1:
+ result += 4;
+ break;
+ case 2:
+ result += 8;
+ case 3:
+ result += 16;
+ default:
+ result += 32;
+ break;
+ case 4:
+ result += 64;
+ }
+
+ return result;
+}
+
+if(!(SwitchTest(0) === 6)){
+ $ERROR("#1: SwitchTest(0) === 6. Actual: SwitchTest(0) ==="+ SwitchTest(0) );
+}
+
+if(!(SwitchTest(1) === 4)){
+ $ERROR("#2: SwitchTest(1) === 4. Actual: SwitchTest(1) ==="+ SwitchTest(1) );
+}
+
+if(!(SwitchTest(2) === 56)){
+ $ERROR("#3: SwitchTest(2) === 56. Actual: SwitchTest(2) ==="+ SwitchTest(2) );
+}
+
+if(!(SwitchTest(3) === 48)){
+ $ERROR("#4: SwitchTest(3) === 48. Actual: SwitchTest(3) ==="+ SwitchTest(3) );
+}
+
+if(!(SwitchTest(4) === 64)){
+ $ERROR("#5: SwitchTest(4) === 64. Actual: SwitchTest(4) ==="+ SwitchTest(4) );
+}
+
+if(!(SwitchTest(true) === 32)){
+ $ERROR("#6: SwitchTest(true) === 32. Actual: SwitchTest(true) ==="+ SwitchTest(true) );
+}
+
+if(!(SwitchTest(false) === 32)){
+ $ERROR("#7: SwitchTest(false) === 32. Actual: SwitchTest(false) ==="+ SwitchTest(false) );
+}
+
+if(!(SwitchTest(null) === 32)){
+ $ERROR("#8: SwitchTest(null) === 32. Actual: SwitchTest(null) ==="+ SwitchTest(null) );
+}
+
+if(!(SwitchTest(void 0) === 32)){
+ $ERROR("#9: SwitchTest(void 0) === 32. Actual: SwitchTest(void 0) ==="+ SwitchTest(void 0) );
+}
+
+if(!(SwitchTest('0') === 32)){
+ $ERROR("#10: SwitchTest('0') === 32. Actual: SwitchTest('0') ==="+ SwitchTest('0') );
+}
+
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A1_T2.js b/js/src/tests/test262/ch12/12.11/S12.11_A1_T2.js
new file mode 100644
index 000000000..a7b4abc59
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A1_T2.js
@@ -0,0 +1,88 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * If Result.type is break and Result.target is in the current
+ * label set, return (normal, Result.value, empty)
+ *
+ * @path ch12/12.11/S12.11_A1_T2.js
+ * @description Switch with different types of variables
+ */
+
+var x = new Number(2);
+
+function SwitchTest(value){
+ var result = 0;
+
+ switch(value) {
+ case 0:
+ result += 2;
+ case '1':
+ result += 4;
+ break;
+ case new Number(2):
+ result += 8;
+ case 3:
+ result += 16;
+ default:
+ result += 32;
+ break;
+ case 4:
+ result += 64;
+ break;
+ case x:
+ result += 128;
+ break;
+ case 0:
+ result += 256;
+ case 1:
+ result += 512;
+ }
+
+ return result;
+}
+
+if(!(SwitchTest(0) === 6)){
+ $ERROR("#1: SwitchTest(0) === 6. Actual: SwitchTest(0) ==="+ SwitchTest(0) );
+}
+
+if(!(SwitchTest(1) === 512)){
+ $ERROR("#2: SwitchTest(1) === 512. Actual: SwitchTest(1) ==="+ SwitchTest(1) );
+}
+
+if(!(SwitchTest(2) === 32)){
+ $ERROR("#3: SwitchTest(2) === 32. Actual: SwitchTest(2) ==="+ SwitchTest(2) );
+}
+
+if(!(SwitchTest(3) === 48)){
+ $ERROR("#4: SwitchTest(3) === 48. Actual: SwitchTest(3) ==="+ SwitchTest(3) );
+}
+
+if(!(SwitchTest(4) === 64)){
+ $ERROR("#5: SwitchTest(4) === 64. Actual: SwitchTest(4) ==="+ SwitchTest(4) );
+}
+
+if(!(SwitchTest(true) === 32)){
+ $ERROR("#6: SwitchTest(true) === 32. Actual: SwitchTest(true) ==="+ SwitchTest(true) );
+}
+
+if(!(SwitchTest(false) === 32)){
+ $ERROR("#7: SwitchTest(false) === 32. Actual: SwitchTest(false) ==="+ SwitchTest(false) );
+}
+
+if(!(SwitchTest(null) === 32)){
+ $ERROR("#8: SwitchTest(null) === 32. Actual: SwitchTest(null) ==="+ SwitchTest(null) );
+}
+
+if(!(SwitchTest(void 0) === 32)){
+ $ERROR("#9: SwitchTest(void 0) === 32. Actual: SwitchTest(void 0) ==="+ SwitchTest(void 0) );
+}
+
+if(!(SwitchTest('0') === 32)){
+ $ERROR("#10: SwitchTest('0') === 32. Actual: SwitchTest('0') ==="+ SwitchTest('0') );
+}
+
+if(!(SwitchTest(x) === 128)){
+ $ERROR("#10: SwitchTest(x) === 128. Actual: SwitchTest(x) ==="+ SwitchTest(x) );
+}
+
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A1_T3.js b/js/src/tests/test262/ch12/12.11/S12.11_A1_T3.js
new file mode 100644
index 000000000..3171a6661
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A1_T3.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.
+
+/**
+ * If Result.type is break and Result.target is in the current
+ * label set, return (normal, Result.value, empty)
+ *
+ * @path ch12/12.11/S12.11_A1_T3.js
+ * @description Using case with null, NaN, Infinity
+ */
+
+function SwitchTest(value){
+ var result = 0;
+
+ switch(value) {
+ case 0:
+ result += 2;
+ case 1:
+ result += 4;
+ break;
+ case 2:
+ result += 8;
+ case 3:
+ result += 16;
+ default:
+ result += 32;
+ break;
+ case null:
+ result += 64;
+ case NaN:
+ result += 128;
+ break;
+ case Infinity:
+ result += 256;
+ case 2+3:
+ result += 512;
+ break;
+ case undefined:
+ result += 1024;
+ }
+
+ return result;
+}
+
+if(!(SwitchTest(0) === 6)){
+ $ERROR("#1: SwitchTest(0) === 6. Actual: SwitchTest(0) ==="+ SwitchTest(0) );
+}
+
+if(!(SwitchTest(1) === 4)){
+ $ERROR("#2: SwitchTest(1) === 4. Actual: SwitchTest(1) ==="+ SwitchTest(1) );
+}
+
+if(!(SwitchTest(2) === 56)){
+ $ERROR("#3: SwitchTest(2) === 56. Actual: SwitchTest(2) ==="+ SwitchTest(2) );
+}
+
+if(!(SwitchTest(3) === 48)){
+ $ERROR("#4: SwitchTest(3) === 48. Actual: SwitchTest(3) ==="+ SwitchTest(3) );
+}
+
+if(!(SwitchTest(4) === 32)){
+ $ERROR("#5: SwitchTest(4) === 32. Actual: SwitchTest(4) ==="+ SwitchTest(4) );
+}
+
+if(!(SwitchTest(5) === 512)){
+ $ERROR("#5: SwitchTest(5) === 512. Actual: SwitchTest(5) ==="+ SwitchTest(5) );
+}
+
+if(!(SwitchTest(true) === 32)){
+ $ERROR("#6: SwitchTest(true) === 32. Actual: SwitchTest(true) ==="+ SwitchTest(true) );
+}
+
+if(!(SwitchTest(false) === 32)){
+ $ERROR("#7: SwitchTest(false) === 32. Actual: SwitchTest(false) ==="+ SwitchTest(false) );
+}
+
+if(!(SwitchTest(null) === 192)){
+ $ERROR("#8: SwitchTest(null) === 192. Actual: SwitchTest(null) ==="+ SwitchTest(null) );
+}
+
+if(!(SwitchTest(void 0) === 1024)){
+ $ERROR("#9: SwitchTest(void 0) === 1024. Actual: SwitchTest(void 0) ==="+ SwitchTest(void 0) );
+}
+
+if(!(SwitchTest(NaN) === 32)){
+ $ERROR("#10: SwitchTest(NaN) === 32. Actual: SwitchTest(NaN) ==="+ SwitchTest(NaN) );
+}
+
+if(!(SwitchTest(Infinity) === 768)){
+ $ERROR("#10: SwitchTest(NaN) === 768. Actual: SwitchTest(NaN) ==="+ SwitchTest(NaN) );
+}
+
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A1_T4.js b/js/src/tests/test262/ch12/12.11/S12.11_A1_T4.js
new file mode 100644
index 000000000..0182397fe
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A1_T4.js
@@ -0,0 +1,80 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * If Result.type is break and Result.target is in the current
+ * label set, return (normal, Result.value, empty)
+ *
+ * @path ch12/12.11/S12.11_A1_T4.js
+ * @description Using case with isNaN and isNaN(value)
+ */
+
+function SwitchTest(value){
+ var result = 0;
+
+ switch(value) {
+ case 0:
+ result += 2;
+ case 1:
+ result += 4;
+ break;
+ case 2:
+ result += 8;
+ case isNaN(value):
+ result += 16;
+ default:
+ result += 32;
+ break;
+ case null:
+ result += 64;
+ case isNaN:
+ result += 128;
+ break;
+ case Infinity:
+ result += 256;
+ case 2+3:
+ result += 512;
+ break;
+ case undefined:
+ result += 1024;
+ }
+
+ return result;
+}
+
+if(!(SwitchTest(eval('Number(false)')) === 6)){
+ $ERROR("#1: SwitchTest(0) === 6. Actual: SwitchTest(0) ==="+ SwitchTest(0) );
+}
+
+if(!(SwitchTest(parseInt) === 32)){
+ $ERROR("#2: SwitchTest(parseInt) === 32. Actual: SwitchTest(parseInt) ==="+ SwitchTest(parseInt) );
+}
+
+if(!(SwitchTest(isNaN) === 128)){
+ $ERROR("#3: SwitchTest(isNaN) === 128. Actual: SwitchTest(isNaN) ==="+ SwitchTest(isNaN) );
+}
+
+if(!(SwitchTest(true) === 32)){
+ $ERROR("#6: SwitchTest(true) === 32. Actual: SwitchTest(true) ==="+ SwitchTest(true) );
+}
+
+if(!(SwitchTest(false) === 48)){
+ $ERROR("#7: SwitchTest(false) === 48. Actual: SwitchTest(false) ==="+ SwitchTest(false) );
+}
+
+if(!(SwitchTest(null) === 192)){
+ $ERROR("#8: SwitchTest(null) === 192. Actual: SwitchTest(null) ==="+ SwitchTest(null) );
+}
+
+if(!(SwitchTest(void 0) === 1024)){
+ $ERROR("#9: SwitchTest(void 0) === 1024. Actual: SwitchTest(void 0) ==="+ SwitchTest(void 0) );
+}
+
+if(!(SwitchTest(NaN) === 32)){
+ $ERROR("#10: SwitchTest(NaN) === 32. Actual: SwitchTest(NaN) ==="+ SwitchTest(NaN) );
+}
+
+if(!(SwitchTest(Infinity) === 768)){
+ $ERROR("#10: SwitchTest(NaN) === 768. Actual: SwitchTest(NaN) ==="+ SwitchTest(NaN) );
+}
+
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A2_T1.js b/js/src/tests/test262/ch12/12.11/S12.11_A2_T1.js
new file mode 100644
index 000000000..247437638
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A2_T1.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.
+
+/**
+ * There can be only one DefaultClause
+ *
+ * @path ch12/12.11/S12.11_A2_T1.js
+ * @description Duplicate DefaultClause
+ * @negative
+ */
+
+function SwitchTest(value){
+ var result = 0;
+
+ switch(value) {
+ case 0:
+ result += 2;
+ default:
+ result += 32;
+ break;
+ default:
+ result += 32;
+ break;
+ }
+
+ return result;
+}
+
+var x = SwitchTest(0);
+
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A3_T1.js b/js/src/tests/test262/ch12/12.11/S12.11_A3_T1.js
new file mode 100644
index 000000000..feab32852
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A3_T1.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.
+
+/**
+ * Syntax constructions of switch statement
+ *
+ * @path ch12/12.11/S12.11_A3_T1.js
+ * @description Checking if execution of "switch() {}" fails
+ * @negative
+ */
+
+function SwitchTest(value){
+ var result = 0;
+
+ switch() {
+ case 0:
+ result += 2;
+ default:
+ result += 32;
+ break;
+ }
+
+ return result;
+}
+
+var x = SwitchTest(0);
+
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A3_T2.js b/js/src/tests/test262/ch12/12.11/S12.11_A3_T2.js
new file mode 100644
index 000000000..d879d6028
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A3_T2.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.
+
+/**
+ * Syntax constructions of switch statement
+ *
+ * @path ch12/12.11/S12.11_A3_T2.js
+ * @description Checking if execution of "switch {}" fails
+ * @negative
+ */
+
+function SwitchTest(value){
+ var result = 0;
+
+ switch {
+ case 0:
+ result += 2;
+ default:
+ result += 32;
+ break;
+ }
+
+ return result;
+}
+
+var x = SwitchTest(0);
+
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A3_T3.js b/js/src/tests/test262/ch12/12.11/S12.11_A3_T3.js
new file mode 100644
index 000000000..03d3898dc
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A3_T3.js
@@ -0,0 +1,13 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * Syntax constructions of switch statement
+ *
+ * @path ch12/12.11/S12.11_A3_T3.js
+ * @description Checking if execution of "switch(value)" fails
+ * @negative
+ */
+
+switch(value);
+
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A3_T4.js b/js/src/tests/test262/ch12/12.11/S12.11_A3_T4.js
new file mode 100644
index 000000000..00def2926
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A3_T4.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.
+
+/**
+ * Syntax constructions of switch statement
+ *
+ * @path ch12/12.11/S12.11_A3_T4.js
+ * @description Using "case" that has no Expresson after it. "CaseClause: case Expression : [StatementList]"
+ * @negative
+ */
+
+function SwitchTest(value){
+ var result = 0;
+
+ switch(value) {
+ case:
+ result += 2;
+ default:
+ result += 32;
+ break;
+ }
+
+ return result;
+}
+
+var x = SwitchTest(0);
+
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A3_T5.js b/js/src/tests/test262/ch12/12.11/S12.11_A3_T5.js
new file mode 100644
index 000000000..02cd94bd9
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A3_T5.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.
+
+/**
+ * Syntax constructions of switch statement
+ *
+ * @path ch12/12.11/S12.11_A3_T5.js
+ * @description Introducing statement not followed by "case" keyword
+ * @negative
+ */
+
+function SwitchTest(value){
+ var result = 0;
+
+ switch(value) {
+ result =2;
+ case 0:
+ result += 2;
+ default:
+ result += 32;
+ break;
+ }
+
+ return result;
+}
+
+var x = SwitchTest(0);
+
diff --git a/js/src/tests/test262/ch12/12.11/S12.11_A4_T1.js b/js/src/tests/test262/ch12/12.11/S12.11_A4_T1.js
new file mode 100644
index 000000000..8fbafbc81
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/S12.11_A4_T1.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.
+
+/**
+ * Embedded syntax constructions of switch statement
+ *
+ * @path ch12/12.11/S12.11_A4_T1.js
+ * @description Nesting one "switch" statement into StatementList of the other's
+ */
+
+function SwitchTest(value){
+ var result = 0;
+
+ switch(value) {
+ case 0:
+ switch(value) {
+ case 0:
+ result += 3;
+ break;
+ default:
+ result += 32;
+ break;
+ }
+ result *= 2;
+ break;
+ result=3;
+ default:
+ result += 32;
+ break;
+ }
+ return result;
+}
+
+var x = SwitchTest(0);
+if(x!==6) $ERROR("#1: SwitchTest(0) === 6. Actual: SwitchTest(0) ==="+ SwitchTest(0) );
+
diff --git a/js/src/tests/test262/ch12/12.11/browser.js b/js/src/tests/test262/ch12/12.11/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/browser.js
diff --git a/js/src/tests/test262/ch12/12.11/shell.js b/js/src/tests/test262/ch12/12.11/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/ch12/12.11/shell.js