File indexing completed on 2024-04-28 15:28:37
0001 // We can't use normal shouldBe here, since they'd eval in the wrong context... 0002 0003 function shouldBeOfType(msg, val, type) { 0004 if (typeof(val) != type) 0005 testFailed(msg + ": value has type " + typeof(val) + " , not:" + type); 0006 else 0007 testPassed(msg); 0008 } 0009 0010 function test0() { 0011 var arguments; 0012 // var execution should not overwrite something that was 0013 // in scope beforehand -- e.g. the arguments thing 0014 shouldBeOfType("test0", arguments, 'object'); 0015 } 0016 0017 function test1() { 0018 // No need to undef-initialize something in scope already! 0019 shouldBeOfType("test1", arguments, 'object'); 0020 var arguments; 0021 } 0022 0023 function test2(arguments) { 0024 // Formals OTOH can overwrite the args object 0025 shouldBeOfType("test2", arguments, 'number'); 0026 } 0027 0028 0029 function test3() { 0030 // Ditto for functions.. 0031 shouldBeOfType("test3", arguments, 'function'); 0032 function arguments() {} 0033 } 0034 0035 function test4() { 0036 // Here, the -declaration- part of the var below should have no 0037 // effect.. 0038 shouldBeOfType('test4.(1)', arguments, 'object'); 0039 var arguments = 4; 0040 // .. but the assignment shoud just happen 0041 shouldBeOfType('test4.(2)', arguments, 'number'); 0042 } 0043 0044 0045 test0(); 0046 test1(); 0047 test2(42); 0048 test3(); 0049 test4();