def test_Compile_WrapMethodInClass_hello_world(): """Test output of wrapping a method in a class.""" assert java.Compile( java.WrapMethodInClass("""\ private static void Hello() { System.out.println("Hello, world!"); }""")) == """\
def test_Compile_WrapMethodInClass_undefined_symbol(): """Test that error is raised if method has undefined symbols.""" with pytest.raises(errors.BadCodeException): java.Compile(java.WrapMethodInClass(""" private static void Hello() { UndefinedMethod(5); } """))
def test_Compile_hello_world(): """Test compilation of a "hello world" Java program.""" assert java.Compile(""" public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } } """) == """
def test_Compile_class_name_whitespace(): """Test that compile can infer the class name despite whitespace.""" assert java.Compile(""" public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } } """) == """
def test_Compile_InsertShimImports_WrapMethodInClass_array_list(): """Test output of wrapping a method in a class.""" assert """\ private static void Hello() { ArrayList<Object> a = new ArrayList<>(); System.out.println("Hello, world!"); } """ in java.Compile(java.InsertShimImports(java.WrapMethodInClass("""\ private static void Hello() { ArrayList<Object> a = new ArrayList<>(); System.out.println("Hello, world!"); } """)))
def test_Compile_empty_input(): """That an empty file is rejected.""" with pytest.raises(errors.BadCodeException): java.Compile('')
def test_Compile_WrapMethodInClass_syntax_error(): """Test that error is raised if method contains a syntax error.""" with pytest.raises(errors.BadCodeException): java.Compile(java.WrapMethodInClass("!@///"))