diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/js1_2/statements | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/js1_2/statements')
-rw-r--r-- | js/src/tests/js1_2/statements/break.js | 130 | ||||
-rw-r--r-- | js/src/tests/js1_2/statements/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/js1_2/statements/continue.js | 143 | ||||
-rw-r--r-- | js/src/tests/js1_2/statements/do_while.js | 35 | ||||
-rw-r--r-- | js/src/tests/js1_2/statements/shell.js | 0 | ||||
-rw-r--r-- | js/src/tests/js1_2/statements/switch.js | 96 | ||||
-rw-r--r-- | js/src/tests/js1_2/statements/switch2.js | 158 |
7 files changed, 562 insertions, 0 deletions
diff --git a/js/src/tests/js1_2/statements/break.js b/js/src/tests/js1_2/statements/break.js new file mode 100644 index 000000000..77c4983d0 --- /dev/null +++ b/js/src/tests/js1_2/statements/break.js @@ -0,0 +1,130 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + Filename: break.js + Description: 'Tests the break statement' + + Author: Nick Lerissa + Date: March 18, 1998 +*/ + +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'statements: break'; + +writeHeaderToLog("Executing script: break.js"); +writeHeaderToLog( SECTION + " "+ TITLE); + +var i,j; + +for (i = 0; i < 1000; i++) +{ + if (i == 100) break; +} + +// 'breaking out of "for" loop' +new TestCase ( SECTION, 'breaking out of "for" loop', + 100, i); + +j = 2000; + +out1: +for (i = 0; i < 1000; i++) +{ + if (i == 100) + { + out2: + for (j = 0; j < 1000; j++) + { + if (j == 500) break out1; + } + j = 2001; + } + j = 2002; +} + +// 'breaking out of a "for" loop with a "label"' +new TestCase ( SECTION, 'breaking out of a "for" loop with a "label"', + 500, j); + +i = 0; + +while (i < 1000) +{ + if (i == 100) break; + i++; +} + +// 'breaking out of a "while" loop' +new TestCase ( SECTION, 'breaking out of a "while" loop', + 100, i ); + + +j = 2000; +i = 0; + +out3: +while (i < 1000) +{ + if (i == 100) + { + j = 0; + out4: + while (j < 1000) + { + if (j == 500) break out3; + j++; + } + j = 2001; + } + j = 2002; + i++; +} + +// 'breaking out of a "while" loop with a "label"' +new TestCase ( SECTION, 'breaking out of a "while" loop with a "label"', + 500, j); + +i = 0; + +do +{ + if (i == 100) break; + i++; +} while (i < 1000); + +// 'breaking out of a "do" loop' +new TestCase ( SECTION, 'breaking out of a "do" loop', + 100, i ); + +j = 2000; +i = 0; + +out5: +do +{ + if (i == 100) + { + j = 0; + out6: + do + { + if (j == 500) break out5; + j++; + }while (j < 1000); + j = 2001; + } + j = 2002; + i++; +}while (i < 1000); + +// 'breaking out of a "do" loop with a "label"' +new TestCase ( SECTION, 'breaking out of a "do" loop with a "label"', + 500, j); + +test(); diff --git a/js/src/tests/js1_2/statements/browser.js b/js/src/tests/js1_2/statements/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_2/statements/browser.js diff --git a/js/src/tests/js1_2/statements/continue.js b/js/src/tests/js1_2/statements/continue.js new file mode 100644 index 000000000..0017ba88d --- /dev/null +++ b/js/src/tests/js1_2/statements/continue.js @@ -0,0 +1,143 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + Filename: continue.js + Description: 'Tests the continue statement' + + Author: Nick Lerissa + Date: March 18, 1998 +*/ + +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'statements: continue'; + +writeHeaderToLog("Executing script: continue.js"); +writeHeaderToLog( SECTION + " "+ TITLE); + +var i,j; + +j = 0; +for (i = 0; i < 200; i++) +{ + if (i == 100) + continue; + j++; +} + +// '"continue" in a "for" loop' +new TestCase ( SECTION, '"continue" in "for" loop', + 199, j); + + +j = 0; +out1: +for (i = 0; i < 1000; i++) +{ + if (i == 100) + { + out2: + for (var k = 0; k < 1000; k++) + { + if (k == 500) continue out1; + } + j = 3000; + } + j++; +} + +// '"continue" in a "for" loop with a "label"' +new TestCase ( SECTION, '"continue" in "for" loop with a "label"', + 999, j); + +i = 0; +j = 1; + +while (i != j) +{ + i++; + if (i == 100) continue; + j++; +} + +// '"continue" in a "while" loop' +new TestCase ( SECTION, '"continue" in a "while" loop', + 100, j ); + +j = 0; +i = 0; +out3: +while (i < 1000) +{ + if (i == 100) + { + var k = 0; + out4: + while (k < 1000) + { + if (k == 500) + { + i++; + continue out3; + } + k++; + } + j = 3000; + } + j++; + i++; +} + +// '"continue" in a "while" loop with a "label"' +new TestCase ( SECTION, '"continue" in a "while" loop with a "label"', + 999, j); + +i = 0; +j = 1; + +do +{ + i++; + if (i == 100) continue; + j++; +} while (i != j); + + +// '"continue" in a "do" loop' +new TestCase ( SECTION, '"continue" in a "do" loop', + 100, j ); + +j = 0; +i = 0; +out5: +do +{ + if (i == 100) + { + var k = 0; + out6: + do + { + if (k == 500) + { + i++; + continue out5; + } + k++; + }while (k < 1000); + j = 3000; + } + j++; + i++; +}while (i < 1000); + +// '"continue" in a "do" loop with a "label"' +new TestCase ( SECTION, '"continue" in a "do" loop with a "label"', + 999, j); + +test(); diff --git a/js/src/tests/js1_2/statements/do_while.js b/js/src/tests/js1_2/statements/do_while.js new file mode 100644 index 000000000..90ad5117e --- /dev/null +++ b/js/src/tests/js1_2/statements/do_while.js @@ -0,0 +1,35 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + Filename: do_while.js + Description: 'This tests the new do_while loop' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 +*/ + +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'statements: do_while'; + +writeHeaderToLog('Executing script: do_while.js'); +writeHeaderToLog( SECTION + " "+ TITLE); + +var done = false; +var x = 0; +do +{ + if (x++ == 3) done = true; +} while (!done); + +new TestCase( SECTION, "do_while ", + 4, x); + +//load('d:/javascript/tests/output/statements/do_while.js') +test(); + diff --git a/js/src/tests/js1_2/statements/shell.js b/js/src/tests/js1_2/statements/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_2/statements/shell.js diff --git a/js/src/tests/js1_2/statements/switch.js b/js/src/tests/js1_2/statements/switch.js new file mode 100644 index 000000000..c7d3548de --- /dev/null +++ b/js/src/tests/js1_2/statements/switch.js @@ -0,0 +1,96 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + Filename: switch.js + Description: 'Tests the switch statement' + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696 + + Author: Nick Lerissa + Date: March 19, 1998 +*/ + +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +var TITLE = 'statements: switch'; +var BUGNUMBER="323696"; + +startTest(); +writeHeaderToLog("Executing script: switch.js"); +writeHeaderToLog( SECTION + " "+ TITLE); + + +var var1 = "match string"; +var match1 = false; +var match2 = false; +var match3 = false; + +switch (var1) +{ +case "match string": + match1 = true; +case "bad string 1": + match2 = true; + break; +case "bad string 2": + match3 = true; +} + +new TestCase ( SECTION, 'switch statement', + true, match1); + +new TestCase ( SECTION, 'switch statement', + true, match2); + +new TestCase ( SECTION, 'switch statement', + false, match3); + +var var2 = 3; + +var match1 = false; +var match2 = false; +var match3 = false; +var match4 = false; +var match5 = false; + +switch (var2) +{ +case 1: +/* switch (var1) + { + case "foo": + match1 = true; + break; + case 3: + match2 = true; + break; + }*/ + match3 = true; + break; +case 2: + match4 = true; + break; +case 3: + match5 = true; + break; +} +new TestCase ( SECTION, 'switch statement', + false, match1); + +new TestCase ( SECTION, 'switch statement', + false, match2); + +new TestCase ( SECTION, 'switch statement', + false, match3); + +new TestCase ( SECTION, 'switch statement', + false, match4); + +new TestCase ( SECTION, 'switch statement', + true, match5); + +test(); diff --git a/js/src/tests/js1_2/statements/switch2.js b/js/src/tests/js1_2/statements/switch2.js new file mode 100644 index 000000000..86b2251fa --- /dev/null +++ b/js/src/tests/js1_2/statements/switch2.js @@ -0,0 +1,158 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + Filename: switch2.js + Description: 'Tests the switch statement' + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696 + + Author: Norris Boyd + Date: July 31, 1998 +*/ + +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +var TITLE = 'statements: switch'; +var BUGNUMBER="323626"; + +startTest(); +writeHeaderToLog("Executing script: switch2.js"); +writeHeaderToLog( SECTION + " "+ TITLE); + +// test defaults not at the end; regression test for a bug that +// nearly made it into 4.06 +function f0(i) { + switch(i) { + default: + case "a": + case "b": + return "ab*" + case "c": + return "c"; + case "d": + return "d"; + } + return ""; +} +new TestCase(SECTION, 'switch statement', + f0("a"), "ab*"); + +new TestCase(SECTION, 'switch statement', + f0("b"), "ab*"); + +new TestCase(SECTION, 'switch statement', + f0("*"), "ab*"); + +new TestCase(SECTION, 'switch statement', + f0("c"), "c"); + +new TestCase(SECTION, 'switch statement', + f0("d"), "d"); + +function f1(i) { + switch(i) { + case "a": + case "b": + default: + return "ab*" + case "c": + return "c"; + case "d": + return "d"; + } + return ""; +} + +new TestCase(SECTION, 'switch statement', + f1("a"), "ab*"); + +new TestCase(SECTION, 'switch statement', + f1("b"), "ab*"); + +new TestCase(SECTION, 'switch statement', + f1("*"), "ab*"); + +new TestCase(SECTION, 'switch statement', + f1("c"), "c"); + +new TestCase(SECTION, 'switch statement', + f1("d"), "d"); + +// Switch on integer; will use TABLESWITCH opcode in C engine +function f2(i) { + switch (i) { + case 0: + case 1: + return 1; + case 2: + return 2; + } + // with no default, control will fall through + return 3; +} + +new TestCase(SECTION, 'switch statement', + f2(0), 1); + +new TestCase(SECTION, 'switch statement', + f2(1), 1); + +new TestCase(SECTION, 'switch statement', + f2(2), 2); + +new TestCase(SECTION, 'switch statement', + f2(3), 3); + +// empty switch: make sure expression is evaluated +var se = 0; +switch (se = 1) { +} +new TestCase(SECTION, 'switch statement', + se, 1); + +// only default +se = 0; +switch (se) { +default: + se = 1; +} +new TestCase(SECTION, 'switch statement', + se, 1); + +// in loop, break should only break out of switch +se = 0; +for (var i=0; i < 2; i++) { + switch (i) { + case 0: + case 1: + break; + } + se = 1; +} +new TestCase(SECTION, 'switch statement', + se, 1); + +// test "fall through" +se = 0; +i = 0; +switch (i) { +case 0: + se++; + /* fall through */ +case 1: + se++; + break; +} +new TestCase(SECTION, 'switch statement', + se, 2); +print("hi"); + +test(); + +// Needed: tests for evaluation time of case expressions. +// This issue was under debate at ECMA, so postponing for now. + |