| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 return x; | 120 return x; |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 assertEquals(3, f4(0), "fallthrough-switch.0"); | 124 assertEquals(3, f4(0), "fallthrough-switch.0"); |
| 125 assertEquals(3, f4(1), "fallthrough-switch.1"); | 125 assertEquals(3, f4(1), "fallthrough-switch.1"); |
| 126 assertEquals(3, f4(2), "fallthrough-switch.2"); | 126 assertEquals(3, f4(2), "fallthrough-switch.2"); |
| 127 assertEquals(5, f4(3), "fallthrough-switch.3"); | 127 assertEquals(5, f4(3), "fallthrough-switch.3"); |
| 128 | 128 |
| 129 function f4_string(tag, x) { | |
| 130 switch(tag) { | |
| 131 case 'zero': | |
| 132 x++; | |
| 133 case 'two': | |
| 134 x++; | |
| 135 } | |
| 136 return x; | |
| 137 } | |
| 138 | |
| 139 // Symbols | |
| 140 assertEquals(2, f4_string('zero', 0), "fallthrough-string-switch.0"); | |
| 141 assertEquals(1, f4_string('one', 1), "fallthrough-string-switch.1"); | |
| 142 assertEquals(3, f4_string('two', 2), "fallthrough-string-switch.2"); | |
| 143 | |
| 144 // Strings | |
| 145 assertEquals(2, f4_string('_zero'.slice(1), 0), "fallthrough-string-switch.3"); | |
| 146 assertEquals(1, f4_string('_one'.slice(1), 1), "fallthrough-string-switch.4"); | |
| 147 assertEquals(3, f4_string('_two'.slice(1), 2), "fallthrough-string-switch.5"); | |
| 148 | |
| 149 // Oddball | |
| 150 assertEquals(3, f4_string(null, 3), "fallthrough-string-switch.6"); | |
| 151 | |
| 152 // Test for regression | |
| 153 function regress_string(value) { | |
| 154 var json = 1; | |
| 155 switch (typeof value) { | |
| 156 case 'object': | |
| 157 break; | |
| 158 | |
| 159 default: | |
| 160 | |
| 161 } | |
| 162 return json; | |
| 163 }; | |
| 164 assertEquals(1, regress_string('object'), 'regression-string'); | |
| 165 | 129 |
| 166 function f5(x) { | 130 function f5(x) { |
| 167 switch(x) { | 131 switch(x) { |
| 168 case -2: return true; | 132 case -2: return true; |
| 169 case -1: return false; | 133 case -1: return false; |
| 170 case 0: return true; | 134 case 0: return true; |
| 171 case 2: return false; | 135 case 2: return false; |
| 172 default: return 42; | 136 default: return 42; |
| 173 } | 137 } |
| 174 } | 138 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 " }\n" + | 280 " }\n" + |
| 317 " }\n" + | 281 " }\n" + |
| 318 " return res;\n" + | 282 " return res;\n" + |
| 319 "})"; | 283 "})"; |
| 320 return eval(res); | 284 return eval(res); |
| 321 } | 285 } |
| 322 var verylong_size = 1000; | 286 var verylong_size = 1000; |
| 323 var verylong = makeVeryLong(verylong_size); | 287 var verylong = makeVeryLong(verylong_size); |
| 324 | 288 |
| 325 assertEquals(verylong_size * 2 + 1, verylong()); | 289 assertEquals(verylong_size * 2 + 1, verylong()); |
| OLD | NEW |