Skip to content

Commit

Permalink
remove some use of optimization level
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Dec 21, 2024
1 parent 05c2985 commit e5f4def
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void failureStackTraceV8() {

private static void runWithExpectedStackTrace(
final String _source, final String _expectedStackTrace) {
Utils.runWithOptimizationLevel(
Utils.runWithMode(
cx -> {
final Scriptable scope = cx.initStandardObjects();
try {
Expand All @@ -130,6 +130,6 @@ private static void runWithExpectedStackTrace(
}
throw new RuntimeException("Exception expected!");
},
-1);
true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void numericAtEndOneDigit() {
/** Special Tokenizer test for numeric constant at end. */
@Test
public void numericAtEndManyDigits() {
Utils.runWithOptimizationLevel(
Utils.runWithMode(
cx -> {
cx.setLanguageVersion(Context.VERSION_ES6);
ScriptableObject scope = cx.initStandardObjects();
Expand All @@ -32,10 +32,10 @@ public void numericAtEndManyDigits() {

return null;
},
-1);
true);

// the byte code generator adds a cast to integer
Utils.runWithOptimizationLevel(
Utils.runWithMode(
cx -> {
cx.setLanguageVersion(Context.VERSION_ES6);
ScriptableObject scope = cx.initStandardObjects();
Expand All @@ -45,19 +45,7 @@ public void numericAtEndManyDigits() {

return null;
},
0);

Utils.runWithOptimizationLevel(
cx -> {
cx.setLanguageVersion(Context.VERSION_ES6);
ScriptableObject scope = cx.initStandardObjects();

Object result = cx.evaluateString(scope, "1234", "test", 1, null);
assertEquals(1234, result);

return null;
},
1);
false);
}

/** Special Tokenizer test for numeric separator constant at end. */
Expand Down
19 changes: 0 additions & 19 deletions testutils/src/main/java/org/mozilla/javascript/tests/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,11 @@ public static void runWithAllOptimizationLevels(
runWithMode(contextFactory, action, true);
}

/** Runs the provided action at the given optimization level */
public static void runWithOptimizationLevel(
final ContextAction<?> action, final int optimizationLevel) {
runWithOptimizationLevel(new ContextFactory(), action, optimizationLevel);
}

/** Runs the provided action at the given interpretation mode */
public static void runWithMode(final ContextAction<?> action, final boolean interpretedMode) {
runWithMode(new ContextFactory(), action, interpretedMode);
}

/** Runs the provided action at the given optimization level */
@SuppressWarnings("deprecation")
public static void runWithOptimizationLevel(
final ContextFactory contextFactory,
final ContextAction<?> action,
final int optimizationLevel) {

try (final Context cx = contextFactory.enterContext()) {
cx.setOptimizationLevel(optimizationLevel);
action.run(cx);
}
}

/** Runs the provided action at the given interpretation mode */
public static void runWithMode(
final ContextFactory contextFactory,
Expand Down

0 comments on commit e5f4def

Please sign in to comment.