Skip to content

Commit

Permalink
feature FEATURE_HTMLUNIT_FUNCTION_DECLARED_FORWARD_IN_BLOCK is gone
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Feb 4, 2025
1 parent e1fc865 commit f6df509
Showing 1 changed file with 3 additions and 39 deletions.
42 changes: 3 additions & 39 deletions src/test/java/org/htmlunit/corejs/ScriptRuntimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import org.htmlunit.corejs.javascript.Context;
import org.htmlunit.corejs.javascript.ContextAction;
import org.htmlunit.corejs.javascript.ContextFactory;
import org.htmlunit.corejs.javascript.Scriptable;
import org.junit.jupiter.api.Test;

Expand All @@ -31,9 +30,7 @@ public void functionDeclaredForwardInBlock() {
+ "var output = '';\n"
+ "test();\n"
+ "output";
final int feature = Context.FEATURE_HTMLUNIT_FUNCTION_DECLARED_FORWARD_IN_BLOCK;
test(script, "exception", feature, false);
test(script, "function foo() {}", feature, true);
test(script, "function foo() {}");
}

@Test
Expand All @@ -52,9 +49,7 @@ public void functionDeclaredForwardInBlockAsVar() {
+ "var output = '';\n"
+ "test();\n"
+ "output";
final int feature = Context.FEATURE_HTMLUNIT_FUNCTION_DECLARED_FORWARD_IN_BLOCK;
test(script, "undefined", feature, false);
test(script, "undefined", feature, true);
test(script, "undefined");
}

@Test
Expand All @@ -70,38 +65,7 @@ public void functionDeclaredForwardInBlock2() {
+ " function foo() {}\n"
+ "}\n"
+ "output";
final int feature = Context.FEATURE_HTMLUNIT_FUNCTION_DECLARED_FORWARD_IN_BLOCK;
test(script, "exception", feature, false);
test(script, "function foo() {}", feature, true);
}

private static void test(final String script, final Object expected,
final int feature, final boolean featureValue) {
final ContextFactory cf = new ContextFactory() {
@Override
protected boolean hasFeature(Context cx, int featureIndex) {
if (featureIndex == feature) {
return featureValue;
}
return super.hasFeature(cx, featureIndex);
}
};

final ContextAction<Object> action = new ContextAction<Object>() {
@Override
public Object run(final Context cx) {
try {
Scriptable scope = cx.initSafeStandardObjects();
final Object o = cx.evaluateString(scope, script, "test_script", 1, null);
assertEquals(expected, o);
return o;
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
};

Utils.runWithOptimizationLevel(cf, action, -1);
test(script, "function foo() {}");
}

@Test
Expand Down

0 comments on commit f6df509

Please sign in to comment.