Skip to content

Commit

Permalink
🧪 test: Enhance TestJavetSanitizerFridge
Browse files Browse the repository at this point in the history
  • Loading branch information
caoccao committed Jun 19, 2024
1 parent 646c5c7 commit dcd5a42
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object Config {

object Versions {
const val JAVA_VERSION = "1.8"
const val JAVET = "3.1.2"
const val JAVET = "3.1.3"
const val JUNIT = "5.10.1"
const val SWC4J = "0.10.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@

package com.caoccao.javet.sanitizer.codegen;

import com.caoccao.javet.exceptions.JavetException;
import com.caoccao.javet.interop.V8Host;
import com.caoccao.javet.interop.V8Runtime;
import com.caoccao.javet.sanitizer.options.JavetSanitizerOptions;
import com.caoccao.javet.values.reference.builtin.V8ValueBuiltInObject;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;

public class TestJavetSanitizerFridge {
@Test
public void testGenerate() {
public void testGenerate() throws JavetException {
JavetSanitizerOptions options = JavetSanitizerOptions.Default.toClone();
options.getToBeDeletedIdentifierList().clear();
options.getToBeDeletedIdentifierList().add("eval");
Expand Down Expand Up @@ -59,5 +63,12 @@ public void testGenerate() {
"Object.freeze(Array);\n" +
"Object.freeze(Array.prototype);\n\n",
codeString);
try (V8Runtime v8Runtime = V8Host.getV8Instance().createV8Runtime()) {
try (V8ValueBuiltInObject v8ValueBuiltInObject = v8Runtime.getGlobalObject().getBuiltInObject()) {
assertFalse(v8ValueBuiltInObject.isFrozen());
v8Runtime.getExecutor(codeString).executeVoid();
assertTrue(v8ValueBuiltInObject.isFrozen());
}
}
}
}

0 comments on commit dcd5a42

Please sign in to comment.