tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / js / kde / script-tests / arguments-scope.js
1 // We can't use normal shouldBe here, since they'd eval in the wrong context...
2
3 function shouldBeOfType(msg, val, type) {
4   if (typeof(val) != type)
5     testFailed(msg + ": value has type " + typeof(val) + " , not:" + type);
6   else
7     testPassed(msg);
8 }
9
10 function test0() {
11     var arguments;
12     // var execution should not overwrite something that was 
13     // in scope beforehand -- e.g. the arguments thing
14     shouldBeOfType("test0", arguments, 'object');
15  }
16
17 function test1() {
18     // No need to undef-initialize something in scope already!
19     shouldBeOfType("test1", arguments, 'object');
20     var arguments;
21 }
22
23 function test2(arguments) {
24     // Formals OTOH can overwrite the args object
25     shouldBeOfType("test2", arguments, 'number');
26 }
27
28
29 function test3() {
30     // Ditto for functions..
31     shouldBeOfType("test3", arguments, 'function');
32     function arguments() {}
33 }
34
35 function test4() {
36     // Here, the -declaration- part of the var below should have no 
37     // effect..
38     shouldBeOfType('test4.(1)', arguments, 'object');
39     var arguments = 4;
40     // .. but the assignment shoud just happen
41     shouldBeOfType('test4.(2)', arguments, 'number');
42 }
43
44
45 test0();
46 test1();
47 test2(42);
48 test3();
49 test4();