OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 23 matching lines...) Expand all Loading... |
34 | 34 |
35 // Test loading across an eval call that does not shadow variables. | 35 // Test loading across an eval call that does not shadow variables. |
36 function testNoShadowing() { | 36 function testNoShadowing() { |
37 var y = 2; | 37 var y = 2; |
38 function local_function() { return 'local'; } | 38 function local_function() { return 'local'; } |
39 const local_const_uninitialized; | 39 const local_const_uninitialized; |
40 const local_const_initialized = function() { return "const_local"; } | 40 const local_const_initialized = function() { return "const_local"; } |
41 function f() { | 41 function f() { |
42 eval('1'); | 42 eval('1'); |
43 assertEquals(1, x); | 43 assertEquals(1, x); |
| 44 try { typeof(asdf); } catch(e) { assertUnreachable(); } |
44 assertEquals(2, y); | 45 assertEquals(2, y); |
45 assertEquals('global', global_function()); | 46 assertEquals('global', global_function()); |
46 assertEquals('local', local_function()); | 47 assertEquals('local', local_function()); |
47 try { | 48 try { |
48 const_uninitialized(); | 49 const_uninitialized(); |
49 assertUnreachable(); | 50 assertUnreachable(); |
50 } catch(e) { | 51 } catch(e) { |
51 // Ignore. | 52 // Ignore. |
52 } | 53 } |
53 assertEquals('const_global', const_initialized()); | 54 assertEquals('const_global', const_initialized()); |
54 try { | 55 try { |
55 local_const_uninitialized(); | 56 local_const_uninitialized(); |
56 assertUnreachable(); | 57 assertUnreachable(); |
57 } catch(e) { | 58 } catch(e) { |
58 // Ignore. | 59 // Ignore. |
59 } | 60 } |
60 assertEquals('const_local', local_const_initialized()); | 61 assertEquals('const_local', local_const_initialized()); |
61 function g() { | 62 function g() { |
62 assertEquals(1, x); | 63 assertEquals(1, x); |
| 64 try { typeof(asdf); } catch(e) { assertUnreachable(); } |
63 assertEquals(2, y); | 65 assertEquals(2, y); |
64 assertEquals('global', global_function()); | 66 assertEquals('global', global_function()); |
65 assertEquals('local', local_function()); | 67 assertEquals('local', local_function()); |
66 try { | 68 try { |
67 const_uninitialized(); | 69 const_uninitialized(); |
68 assertUnreachable(); | 70 assertUnreachable(); |
69 } catch(e) { | 71 } catch(e) { |
70 // Ignore. | 72 // Ignore. |
71 } | 73 } |
72 assertEquals('const_global', const_initialized()); | 74 assertEquals('const_global', const_initialized()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 assertEquals(4, y); | 128 assertEquals(4, y); |
127 assertEquals('new_nonglobal', global_function()); | 129 assertEquals('new_nonglobal', global_function()); |
128 assertEquals('new_local', local_function()); | 130 assertEquals('new_local', local_function()); |
129 } | 131 } |
130 g(); | 132 g(); |
131 } | 133 } |
132 f(); | 134 f(); |
133 } | 135 } |
134 | 136 |
135 testShadowing(); | 137 testShadowing(); |
OLD | NEW |