| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'switch2.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; |
| 19 |
var VERSION = 'no version'; |
| 20 |
var TITLE = 'statements: switch'; |
| 21 |
var BUGNUMBER="323626"; |
| 22 |
|
| 23 |
startTest(); |
| 24 |
writeHeaderToLog("Executing script: switch2.js"); |
| 25 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
function f0(i) { |
| 30 |
switch(i) { |
| 31 |
default: |
| 32 |
case "a": |
| 33 |
case "b": |
| 34 |
return "ab*" |
| 35 |
case "c": |
| 36 |
return "c"; |
| 37 |
case "d": |
| 38 |
return "d"; |
| 39 |
} |
| 40 |
return ""; |
| 41 |
} |
| 42 |
new TestCase(SECTION, 'switch statement', |
| 43 |
f0("a"), "ab*"); |
| 44 |
|
| 45 |
new TestCase(SECTION, 'switch statement', |
| 46 |
f0("b"), "ab*"); |
| 47 |
|
| 48 |
new TestCase(SECTION, 'switch statement', |
| 49 |
f0("*"), "ab*"); |
| 50 |
|
| 51 |
new TestCase(SECTION, 'switch statement', |
| 52 |
f0("c"), "c"); |
| 53 |
|
| 54 |
new TestCase(SECTION, 'switch statement', |
| 55 |
f0("d"), "d"); |
| 56 |
|
| 57 |
function f1(i) { |
| 58 |
switch(i) { |
| 59 |
case "a": |
| 60 |
case "b": |
| 61 |
default: |
| 62 |
return "ab*" |
| 63 |
case "c": |
| 64 |
return "c"; |
| 65 |
case "d": |
| 66 |
return "d"; |
| 67 |
} |
| 68 |
return ""; |
| 69 |
} |
| 70 |
|
| 71 |
new TestCase(SECTION, 'switch statement', |
| 72 |
f1("a"), "ab*"); |
| 73 |
|
| 74 |
new TestCase(SECTION, 'switch statement', |
| 75 |
f1("b"), "ab*"); |
| 76 |
|
| 77 |
new TestCase(SECTION, 'switch statement', |
| 78 |
f1("*"), "ab*"); |
| 79 |
|
| 80 |
new TestCase(SECTION, 'switch statement', |
| 81 |
f1("c"), "c"); |
| 82 |
|
| 83 |
new TestCase(SECTION, 'switch statement', |
| 84 |
f1("d"), "d"); |
| 85 |
|
| 86 |
|
| 87 |
function f2(i) { |
| 88 |
switch (i) { |
| 89 |
case 0: |
| 90 |
case 1: |
| 91 |
return 1; |
| 92 |
case 2: |
| 93 |
return 2; |
| 94 |
} |
| 95 |
|
| 96 |
return 3; |
| 97 |
} |
| 98 |
|
| 99 |
new TestCase(SECTION, 'switch statement', |
| 100 |
f2(0), 1); |
| 101 |
|
| 102 |
new TestCase(SECTION, 'switch statement', |
| 103 |
f2(1), 1); |
| 104 |
|
| 105 |
new TestCase(SECTION, 'switch statement', |
| 106 |
f2(2), 2); |
| 107 |
|
| 108 |
new TestCase(SECTION, 'switch statement', |
| 109 |
f2(3), 3); |
| 110 |
|
| 111 |
|
| 112 |
var se = 0; |
| 113 |
switch (se = 1) { |
| 114 |
} |
| 115 |
new TestCase(SECTION, 'switch statement', |
| 116 |
se, 1); |
| 117 |
|
| 118 |
|
| 119 |
se = 0; |
| 120 |
switch (se) { |
| 121 |
default: |
| 122 |
se = 1; |
| 123 |
} |
| 124 |
new TestCase(SECTION, 'switch statement', |
| 125 |
se, 1); |
| 126 |
|
| 127 |
|
| 128 |
se = 0; |
| 129 |
for (var i=0; i < 2; i++) { |
| 130 |
switch (i) { |
| 131 |
case 0: |
| 132 |
case 1: |
| 133 |
break; |
| 134 |
} |
| 135 |
se = 1; |
| 136 |
} |
| 137 |
new TestCase(SECTION, 'switch statement', |
| 138 |
se, 1); |
| 139 |
|
| 140 |
|
| 141 |
se = 0; |
| 142 |
i = 0; |
| 143 |
switch (i) { |
| 144 |
case 0: |
| 145 |
se++; |
| 146 |
|
| 147 |
case 1: |
| 148 |
se++; |
| 149 |
break; |
| 150 |
} |
| 151 |
new TestCase(SECTION, 'switch statement', |
| 152 |
se, 2); |
| 153 |
print("hi"); |
| 154 |
|
| 155 |
test(); |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|