Search in sources :

Example 1 with CompileOptions

use of org.joor.CompileOptions in project jOOR by jOOQ.

the class B method testCompileWithExtraOptions.

@Test
public void testCompileWithExtraOptions() {
    assertEquals("org.joor.test.Source7OK", Reflect.compile("org.joor.test.Source7OK", "package org.joor.test; " + "public class Source7OK {" + "}", new CompileOptions().options("-source", "7")).type().getName());
    try {
        Reflect.compile("org.joor.test.Source7NOK", "package org.joor.test; " + "public interface Source7NOK {" + "    default void m() {}" + "}", new CompileOptions().options("-source", "7")).type();
        fail("Class should not compile with source level 7");
    } catch (ReflectException expected) {
    }
    assertEquals("org.joor.test.Source8OK", Reflect.compile("org.joor.test.Source8OK", "package org.joor.test; " + "public interface Source8OK {" + "    default void m() {}" + "}", new CompileOptions().options("-source", "8")).type().getName());
    try {
        Reflect.compile("org.joor.test.Source8NOK", "package org.joor.test; " + "public interface Source8NOK {" + "    private void m() {}" + "}", new CompileOptions().options("-source", "8")).create().get();
        fail("Class should not compile with source level 8");
    } catch (ReflectException expected) {
    }
    try {
        Reflect.compile("org.joor.test.Invalid", "package org.joor.test; " + "public class Invalid {" + "}", new CompileOptions().options("-invalidflag"));
        fail("Expected ReflectException for -invalidflag");
    } catch (ReflectException expected) {
        assertTrue(expected.getCause() instanceof IllegalArgumentException);
    }
}
Also used : CompileOptions(org.joor.CompileOptions) ReflectException(org.joor.ReflectException) Test(org.junit.Test)

Aggregations

CompileOptions (org.joor.CompileOptions)1 ReflectException (org.joor.ReflectException)1 Test (org.junit.Test)1