S12.11_A1_T4.js (2228B)
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_T4 9 description: Using case with isNaN and isNaN(value) 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 isNaN(value): 24 result += 16; 25 default: 26 result += 32; 27 break; 28 case null: 29 result += 64; 30 case isNaN: 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 var n = Number(false); 46 47 if(!(SwitchTest(n) === 6)){ 48 throw new Test262Error("#1: SwitchTest(Number(false)) === 6. Actual: SwitchTest(Number(false)) ==="+ SwitchTest(n) ); 49 } 50 51 if(!(SwitchTest(parseInt) === 32)){ 52 throw new Test262Error("#2: SwitchTest(parseInt) === 32. Actual: SwitchTest(parseInt) ==="+ SwitchTest(parseInt) ); 53 } 54 55 if(!(SwitchTest(isNaN) === 128)){ 56 throw new Test262Error("#3: SwitchTest(isNaN) === 128. Actual: SwitchTest(isNaN) ==="+ SwitchTest(isNaN) ); 57 } 58 59 if(!(SwitchTest(true) === 32)){ 60 throw new Test262Error("#6: SwitchTest(true) === 32. Actual: SwitchTest(true) ==="+ SwitchTest(true) ); 61 } 62 63 if(!(SwitchTest(false) === 48)){ 64 throw new Test262Error("#7: SwitchTest(false) === 48. Actual: SwitchTest(false) ==="+ SwitchTest(false) ); 65 } 66 67 if(!(SwitchTest(null) === 192)){ 68 throw new Test262Error("#8: SwitchTest(null) === 192. Actual: SwitchTest(null) ==="+ SwitchTest(null) ); 69 } 70 71 if(!(SwitchTest(void 0) === 1024)){ 72 throw new Test262Error("#9: SwitchTest(void 0) === 1024. Actual: SwitchTest(void 0) ==="+ SwitchTest(void 0) ); 73 } 74 75 if(!(SwitchTest(NaN) === 32)){ 76 throw new Test262Error("#10: SwitchTest(NaN) === 32. Actual: SwitchTest(NaN) ==="+ SwitchTest(NaN) ); 77 } 78 79 if(!(SwitchTest(Infinity) === 768)){ 80 throw new Test262Error("#10: SwitchTest(NaN) === 768. Actual: SwitchTest(NaN) ==="+ SwitchTest(NaN) ); 81 } 82 83 reportCompare(0, 0);