Skip to content

Commit

Permalink
test for hacked const handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jun 26, 2024
1 parent e1937ec commit 0eedbca
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/java/org/htmlunit/javascript/JavaScriptEngine2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,33 @@ public void constInOfLoop() throws Exception {
loadPageVerifyTitle2(html);
}

/**
* @throws Exception if the test fails
*/
@Test
@Alerts("seven")
public void constInIfElse() throws Exception {
final String html = "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ "function test() {\n"
+ " let abcd = '1234';"
+ " if('abcd' === abcd) {\n"
+ " const constant = 7;\n"
+ " log(constant);\n"
+ " } else {\n"
+ " const constant = 'seven';\n"
+ " log(constant);\n"
+ " }\n"
+ "}\n"
+ "</script>\n"
+ "</head>\n"
+ "<body onload='test()'>\n"
+ "</body></html>";

loadPageVerifyTitle2(html);
}

/**
* @throws Exception if the test fails
*/
Expand Down

0 comments on commit 0eedbca

Please sign in to comment.