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 27 matching lines...) Expand all Loading... |
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 try { typeof(asdf); } catch(e) { assertUnreachable(); } |
45 assertEquals(2, y); | 45 assertEquals(2, y); |
46 assertEquals('global', global_function()); | 46 assertEquals('global', global_function()); |
47 assertEquals('local', local_function()); | 47 assertEquals('local', local_function()); |
| 48 var exception = false; |
48 try { | 49 try { |
49 const_uninitialized(); | 50 const_uninitialized(); |
50 assertUnreachable(); | |
51 } catch(e) { | 51 } catch(e) { |
52 // Ignore. | 52 exception = true; |
53 } | 53 } |
| 54 assertTrue(exception); |
54 assertEquals('const_global', const_initialized()); | 55 assertEquals('const_global', const_initialized()); |
| 56 exception = false; |
55 try { | 57 try { |
56 local_const_uninitialized(); | 58 local_const_uninitialized(); |
57 assertUnreachable(); | |
58 } catch(e) { | 59 } catch(e) { |
59 // Ignore. | 60 exception = true; |
60 } | 61 } |
| 62 assertTrue(exception); |
61 assertEquals('const_local', local_const_initialized()); | 63 assertEquals('const_local', local_const_initialized()); |
62 function g() { | 64 function g() { |
63 assertEquals(1, x); | 65 assertEquals(1, x); |
64 try { typeof(asdf); } catch(e) { assertUnreachable(); } | 66 try { typeof(asdf); } catch(e) { assertUnreachable(); } |
65 assertEquals(2, y); | 67 assertEquals(2, y); |
66 assertEquals('global', global_function()); | 68 assertEquals('global', global_function()); |
67 assertEquals('local', local_function()); | 69 assertEquals('local', local_function()); |
| 70 var exception = false; |
68 try { | 71 try { |
69 const_uninitialized(); | 72 const_uninitialized(); |
70 assertUnreachable(); | |
71 } catch(e) { | 73 } catch(e) { |
72 // Ignore. | 74 exception = true; |
73 } | 75 } |
| 76 assertTrue(exception); |
74 assertEquals('const_global', const_initialized()); | 77 assertEquals('const_global', const_initialized()); |
| 78 exception = false; |
75 try { | 79 try { |
76 local_const_uninitialized(); | 80 local_const_uninitialized(); |
77 assertUnreachable(); | |
78 } catch(e) { | 81 } catch(e) { |
79 // Ignore. | 82 exception = true; |
80 } | 83 } |
| 84 assertTrue(exception); |
81 assertEquals('const_local', local_const_initialized()); | 85 assertEquals('const_local', local_const_initialized()); |
82 } | 86 } |
83 g(); | 87 g(); |
84 } | 88 } |
85 f(); | 89 f(); |
86 } | 90 } |
87 | 91 |
88 testNoShadowing(); | 92 testNoShadowing(); |
89 | 93 |
90 // Test loading across eval calls that do not shadow variables. | 94 // Test loading across eval calls that do not shadow variables. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 assertEquals(4, y); | 132 assertEquals(4, y); |
129 assertEquals('new_nonglobal', global_function()); | 133 assertEquals('new_nonglobal', global_function()); |
130 assertEquals('new_local', local_function()); | 134 assertEquals('new_local', local_function()); |
131 } | 135 } |
132 g(); | 136 g(); |
133 } | 137 } |
134 f(); | 138 f(); |
135 } | 139 } |
136 | 140 |
137 testShadowing(); | 141 testShadowing(); |
OLD | NEW |