var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
var VERSION = 'no version';
startTest();
var TITLE = 'statements: switch';
var BUGNUMBER="323626";
writeHeaderToLog("Executing script: switch2.js");
writeHeaderToLog( SECTION + " "+ TITLE);
var count = 0;
var testcases = new Array();
function f0(i) {
switch(i) {
default:
case "a":
case "b":
return "ab*"
case "c":
return "c";
case "d":
return "d";
}
return "";
}
testcases[count++] = new TestCase(SECTION, 'switch statement',
f0("a"), "ab*");
testcases[count++] = new TestCase(SECTION, 'switch statement',
f0("b"), "ab*");
testcases[count++] = new TestCase(SECTION, 'switch statement',
f0("*"), "ab*");
testcases[count++] = new TestCase(SECTION, 'switch statement',
f0("c"), "c");
testcases[count++] = 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 "";
}
testcases[count++] = new TestCase(SECTION, 'switch statement',
f1("a"), "ab*");
testcases[count++] = new TestCase(SECTION, 'switch statement',
f1("b"), "ab*");
testcases[count++] = new TestCase(SECTION, 'switch statement',
f1("*"), "ab*");
testcases[count++] = new TestCase(SECTION, 'switch statement',
f1("c"), "c");
testcases[count++] = new TestCase(SECTION, 'switch statement',
f1("d"), "d");
function f2(i) {
switch (i) {
case 0:
case 1:
return 1;
case 2:
return 2;
}
return 3;
}
testcases[count++] = new TestCase(SECTION, 'switch statement',
f2(0), 1);
testcases[count++] = new TestCase(SECTION, 'switch statement',
f2(1), 1);
testcases[count++] = new TestCase(SECTION, 'switch statement',
f2(2), 2);
testcases[count++] = new TestCase(SECTION, 'switch statement',
f2(3), 3);
var se = 0;
switch (se = 1) {
}
testcases[count++] = new TestCase(SECTION, 'switch statement',
se, 1);
se = 0;
switch (se) {
default:
se = 1;
}
testcases[count++] = new TestCase(SECTION, 'switch statement',
se, 1);
se = 0;
for (var i=0; i < 2; i++) {
switch (i) {
case 0:
case 1:
break;
}
se = 1;
}
testcases[count++] = new TestCase(SECTION, 'switch statement',
se, 1);
se = 0;
i = 0;
switch (i) {
case 0:
se++;
case 1:
se++;
break;
}
testcases[count++] = new TestCase(SECTION, 'switch statement',
se, 2);
test();
function test() {
writeLineToLog("hi");
for ( tc=0; tc < testcases.length; tc++ ) {
testcases[tc].passed = writeTestCaseResult(
testcases[tc].expect,
testcases[tc].actual,
testcases[tc].description +" = "+
testcases[tc].actual );
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
}
stopTest();
return ( testcases );
}