S12.11_A1_T3.js (2519B)
1 // Copyright 2009 the Sputnik authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 info: | 6 If Result.type is break and Result.target is in the current 7 label set, return (normal, Result.value, empty) 8 es5id: 12.11_A1_T3 9 description: Using case with null, NaN, Infinity 10 ---*/ 11 12 function SwitchTest(value){ 13 var result = 0; 14 15 switch(value) { 16 case 0: 17 result += 2; 18 case 1: 19 result += 4; 20 break; 21 case 2: 22 result += 8; 23 case 3: 24 result += 16; 25 default: 26 result += 32; 27 break; 28 case null: 29 result += 64; 30 case NaN: 31 result += 128; 32 break; 33 case Infinity: 34 result += 256; 35 case 2+3: 36 result += 512; 37 break; 38 case undefined: 39 result += 1024; 40 } 41 42 return result; 43 } 44 45 if(!(SwitchTest(0) === 6)){ 46 throw new Test262Error("#1: SwitchTest(0) === 6. Actual: SwitchTest(0) ==="+ SwitchTest(0) ); 47 } 48 49 if(!(SwitchTest(1) === 4)){ 50 throw new Test262Error("#2: SwitchTest(1) === 4. Actual: SwitchTest(1) ==="+ SwitchTest(1) ); 51 } 52 53 if(!(SwitchTest(2) === 56)){ 54 throw new Test262Error("#3: SwitchTest(2) === 56. Actual: SwitchTest(2) ==="+ SwitchTest(2) ); 55 } 56 57 if(!(SwitchTest(3) === 48)){ 58 throw new Test262Error("#4: SwitchTest(3) === 48. Actual: SwitchTest(3) ==="+ SwitchTest(3) ); 59 } 60 61 if(!(SwitchTest(4) === 32)){ 62 throw new Test262Error("#5: SwitchTest(4) === 32. Actual: SwitchTest(4) ==="+ SwitchTest(4) ); 63 } 64 65 if(!(SwitchTest(5) === 512)){ 66 throw new Test262Error("#5: SwitchTest(5) === 512. Actual: SwitchTest(5) ==="+ SwitchTest(5) ); 67 } 68 69 if(!(SwitchTest(true) === 32)){ 70 throw new Test262Error("#6: SwitchTest(true) === 32. Actual: SwitchTest(true) ==="+ SwitchTest(true) ); 71 } 72 73 if(!(SwitchTest(false) === 32)){ 74 throw new Test262Error("#7: SwitchTest(false) === 32. Actual: SwitchTest(false) ==="+ SwitchTest(false) ); 75 } 76 77 if(!(SwitchTest(null) === 192)){ 78 throw new Test262Error("#8: SwitchTest(null) === 192. Actual: SwitchTest(null) ==="+ SwitchTest(null) ); 79 } 80 81 if(!(SwitchTest(void 0) === 1024)){ 82 throw new Test262Error("#9: SwitchTest(void 0) === 1024. Actual: SwitchTest(void 0) ==="+ SwitchTest(void 0) ); 83 } 84 85 if(!(SwitchTest(NaN) === 32)){ 86 throw new Test262Error("#10: SwitchTest(NaN) === 32. Actual: SwitchTest(NaN) ==="+ SwitchTest(NaN) ); 87 } 88 89 if(!(SwitchTest(Infinity) === 768)){ 90 throw new Test262Error("#10: SwitchTest(NaN) === 768. Actual: SwitchTest(NaN) ==="+ SwitchTest(NaN) ); 91 } 92 93 reportCompare(0, 0);