MCPcopy Create free account
hub / github.com/GCMiner/GCMiner / CompilerTest

Class CompilerTest

src/test/java/examples/CompilerTest.java:19–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17import static org.junit.Assume.*;
18
19@RunWith(JQF.class)
20public class CompilerTest {
21
22 static {
23 // Disable all logging by Closure passes, to speed up fuzzing
24 java.util.logging.LogManager.getLogManager().reset();
25 }
26
27 // Compiler, options, and predefined JS environment
28 private Compiler compiler = new Compiler(new PrintStream(new ByteArrayOutputStream(), false));
29 private CompilerOptions options = new CompilerOptions();
30 private SourceFile externs = SourceFile.fromCode("externs", "");
31
32 @Before // Runs before tests are executed
33 public void initCompiler() {
34 // Don't use threads
35 compiler.disableThreads();
36 // Don't print things
37 options.setPrintConfig(false);
38 // Enable all safe optimizations
39 CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
40 }
41
42 /** Compiles an input and returns its result */
43 private Result compile(SourceFile input) {
44 Result result = compiler.compile(externs, input, options);
45 assumeTrue(result.success); // Semantic validity check
46 return result;
47 }
48
49 /** Entry point for fuzzing with default (arbitrary) string generator */
50 @Fuzz
51 public void testWithGenerator(@From(JavaScriptCodeGenerator.class) String code) {
52 SourceFile input = SourceFile.fromCode("input", code);
53 compile(input);
54 }
55}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected