Example #1
0
def test_UnwrapMethodInClass_hello_world():
    """Test that method is extracted from a class."""
    assert java.UnwrapMethodInClass("""
public class HelloWorld {
  private static void Hello() {
    System.out.println("Hello, world!");
  }
}""") == """\
Example #2
0
def test_UnwrapMethodInClass_multiple_methods():
    """Test that error is raised if class contains multiple methods."""
    with pytest.raises(errors.BadCodeException) as e_ctx:
        java.UnwrapMethodInClass("""
public class HelloWorld {
  public static void Hello() {}
  public static void Goodbye() {}
}""")
    assert str(e_ctx.value) == "Expected 1 method, found 2"
Example #3
0
def test_UnwrapMethodInClass_no_methods():
    """Test that error is raised if class doesn't contain a method."""
    with pytest.raises(errors.BadCodeException) as e_ctx:
        java.UnwrapMethodInClass("public class HelloWorld {}")
    assert str(e_ctx.value) == "Expected 1 method, found 0"