4
4
5
5
import org .htmlunit .corejs .javascript .Context ;
6
6
import org .htmlunit .corejs .javascript .ContextAction ;
7
- import org .htmlunit .corejs .javascript .ContextFactory ;
8
7
import org .htmlunit .corejs .javascript .Scriptable ;
9
8
import org .junit .jupiter .api .Test ;
10
9
@@ -31,9 +30,7 @@ public void functionDeclaredForwardInBlock() {
31
30
+ "var output = '';\n "
32
31
+ "test();\n "
33
32
+ "output" ;
34
- final int feature = Context .FEATURE_HTMLUNIT_FUNCTION_DECLARED_FORWARD_IN_BLOCK ;
35
- test (script , "exception" , feature , false );
36
- test (script , "function foo() {}" , feature , true );
33
+ test (script , "function foo() {}" );
37
34
}
38
35
39
36
@ Test
@@ -52,9 +49,7 @@ public void functionDeclaredForwardInBlockAsVar() {
52
49
+ "var output = '';\n "
53
50
+ "test();\n "
54
51
+ "output" ;
55
- final int feature = Context .FEATURE_HTMLUNIT_FUNCTION_DECLARED_FORWARD_IN_BLOCK ;
56
- test (script , "undefined" , feature , false );
57
- test (script , "undefined" , feature , true );
52
+ test (script , "undefined" );
58
53
}
59
54
60
55
@ Test
@@ -70,38 +65,7 @@ public void functionDeclaredForwardInBlock2() {
70
65
+ " function foo() {}\n "
71
66
+ "}\n "
72
67
+ "output" ;
73
- final int feature = Context .FEATURE_HTMLUNIT_FUNCTION_DECLARED_FORWARD_IN_BLOCK ;
74
- test (script , "exception" , feature , false );
75
- test (script , "function foo() {}" , feature , true );
76
- }
77
-
78
- private static void test (final String script , final Object expected ,
79
- final int feature , final boolean featureValue ) {
80
- final ContextFactory cf = new ContextFactory () {
81
- @ Override
82
- protected boolean hasFeature (Context cx , int featureIndex ) {
83
- if (featureIndex == feature ) {
84
- return featureValue ;
85
- }
86
- return super .hasFeature (cx , featureIndex );
87
- }
88
- };
89
-
90
- final ContextAction <Object > action = new ContextAction <Object >() {
91
- @ Override
92
- public Object run (final Context cx ) {
93
- try {
94
- Scriptable scope = cx .initSafeStandardObjects ();
95
- final Object o = cx .evaluateString (scope , script , "test_script" , 1 , null );
96
- assertEquals (expected , o );
97
- return o ;
98
- } catch (final Exception e ) {
99
- throw new RuntimeException (e );
100
- }
101
- }
102
- };
103
-
104
- Utils .runWithOptimizationLevel (cf , action , -1 );
68
+ test (script , "function foo() {}" );
105
69
}
106
70
107
71
@ Test
0 commit comments