OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 TestLocalDoesNotThrow("if (true) var x;"); | 102 TestLocalDoesNotThrow("if (true) var x;"); |
103 TestLocalDoesNotThrow("if (true) {} else var x;"); | 103 TestLocalDoesNotThrow("if (true) {} else var x;"); |
104 TestLocalDoesNotThrow("do var x; while (false)"); | 104 TestLocalDoesNotThrow("do var x; while (false)"); |
105 TestLocalDoesNotThrow("while (false) var x;"); | 105 TestLocalDoesNotThrow("while (false) var x;"); |
106 TestLocalDoesNotThrow("label: var x;"); | 106 TestLocalDoesNotThrow("label: var x;"); |
107 TestLocalDoesNotThrow("for (;false;) var x;"); | 107 TestLocalDoesNotThrow("for (;false;) var x;"); |
108 TestLocalDoesNotThrow("switch (true) { case true: var x; }"); | 108 TestLocalDoesNotThrow("switch (true) { case true: var x; }"); |
109 TestLocalDoesNotThrow("switch (true) { default: var x; }"); | 109 TestLocalDoesNotThrow("switch (true) { default: var x; }"); |
110 | 110 |
111 // Test function declarations in source element and | 111 // Test function declarations in source element and |
112 // non-strict statement positions. | 112 // sloppy statement positions. |
113 function f() { | 113 function f() { |
114 // Non-strict source element positions. | 114 // Sloppy source element positions. |
115 function g0() { | 115 function g0() { |
116 "use strict"; | 116 "use strict"; |
117 // Strict source element positions. | 117 // Strict source element positions. |
118 function h() { } | 118 function h() { } |
119 { | 119 { |
120 function h1() { } | 120 function h1() { } |
121 } | 121 } |
122 } | 122 } |
123 { | 123 { |
124 function g1() { } | 124 function g1() { } |
125 } | 125 } |
126 } | 126 } |
127 f(); | 127 f(); |
128 | 128 |
129 // Test function declarations in statement position in strict mode. | 129 // Test function declarations in statement position in strict mode. |
130 TestLocalThrows("function f() { if (true) function g() {}", SyntaxError); | 130 TestLocalThrows("function f() { if (true) function g() {}", SyntaxError); |
131 TestLocalThrows("function f() { if (true) {} else function g() {}", SyntaxError)
; | 131 TestLocalThrows("function f() { if (true) {} else function g() {}", SyntaxError)
; |
132 TestLocalThrows("function f() { do function g() {} while (false)", SyntaxError); | 132 TestLocalThrows("function f() { do function g() {} while (false)", SyntaxError); |
133 TestLocalThrows("function f() { while (false) function g() {}", SyntaxError); | 133 TestLocalThrows("function f() { while (false) function g() {}", SyntaxError); |
134 TestLocalThrows("function f() { label: function g() {}", SyntaxError); | 134 TestLocalThrows("function f() { label: function g() {}", SyntaxError); |
135 TestLocalThrows("function f() { for (;false;) function g() {}", SyntaxError); | 135 TestLocalThrows("function f() { for (;false;) function g() {}", SyntaxError); |
136 TestLocalThrows("function f() { switch (true) { case true: function g() {} }", S
yntaxError); | 136 TestLocalThrows("function f() { switch (true) { case true: function g() {} }", S
yntaxError); |
137 TestLocalThrows("function f() { switch (true) { default: function g() {} }", Syn
taxError); | 137 TestLocalThrows("function f() { switch (true) { default: function g() {} }", Syn
taxError); |
OLD | NEW |