Skip to content

Commit a7cab14

Browse files
committed
one more test case
1 parent 8aa12ef commit a7cab14

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

src/test/java/org/htmlunit/javascript/FunctionsTest.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,41 @@ public void boundFunction_toString() throws Exception {
125125
* @throws Exception if the test fails
126126
*/
127127
@Test
128-
@Alerts("foo = undefined")
128+
@Alerts({"foo = undefined", "1"})
129129
public void conditionallyCreatedFunction() throws Exception {
130130
final String html
131131
= "<html><head></head>\n"
132132
+ "<body>\n"
133133
+ "<script>\n"
134134
+ LOG_TITLE_FUNCTION
135135
+ " log('foo = ' + foo);\n"
136-
+ " if (false) {\n"
136+
+ " if (true) {\n"
137+
+ " log(foo());\n"
138+
+ " function foo() { return 1; }\n"
139+
+ " }\n"
140+
+ "</script>\n"
141+
+ "</body></html>";
142+
143+
loadPageVerifyTitle2(html);
144+
}
145+
146+
/**
147+
* @throws Exception if the test fails
148+
*/
149+
@Test
150+
@Alerts({"error", "1"})
151+
public void conditionallyCreatedFunctionStrict() throws Exception {
152+
final String html
153+
= "<html><head></head>\n"
154+
+ "<body>\n"
155+
+ "<script>\n"
156+
+ " 'use strict';\n"
157+
+ LOG_TITLE_FUNCTION
158+
+ " try {\n"
159+
+ " log('foo = ' + foo);\n"
160+
+ " } catch(e) { log('error ' + e); }\n"
161+
+ " if (true) {\n"
162+
+ " log(foo());\n"
137163
+ " function foo() { return 1; }\n"
138164
+ " }\n"
139165
+ "</script>\n"

0 commit comments

Comments
 (0)