public static StatementEnd throw_(final Class<? extends Throwable> throwableType, final Object... parameters) { return StatementBuilder.create().throw_(throwableType, parameters); }
public static StatementEnd throw_(final String exceptionVarName) { return StatementBuilder.create().throw_(exceptionVarName); }
public static StatementEnd throw_(final Class<? extends Throwable> throwableType, final Object... parameters) { return StatementBuilder.create().throw_(throwableType, parameters); }
public static StatementEnd throw_(final String exceptionVarName) { return StatementBuilder.create().throw_(exceptionVarName); }
@Test public void testThrowExceptionUsingUndefinedVariable() { try { StatementBuilder.create() .throw_("t") .toJavaString(); fail("expected OutOfScopeException"); } catch (OutOfScopeException e) { // expected } }
@Test public void testThrowExceptionUsingNewInstanceWithParameters() { final Context c = Context.create().autoImport(); final String s = StatementBuilder.create(c).throw_(InvalidTypeException.class, "message").toJavaString(); assertEquals("failed to generate throw statement using a new instance", "throw new InvalidTypeException(\"message\")", s); }
@Test public void testThrowExceptionUsingNewInstance() { final Context c = Context.create().autoImport(); final String s = StatementBuilder.create(c).throw_(InvalidTypeException.class).toJavaString(); assertEquals("failed to generate throw statement using a new instance", "throw new InvalidTypeException()", s); }