public IntLiteral(String value) { super(checkValue(value)); }
@Test(expected=IllegalArgumentException.class) public void intLiteralRejectsFloatArg() throws Exception { Node node = new IntLiteral("1.2"); }
@Test(expected=IllegalArgumentException.class) public void intLiteralRejectsNonNumericArg() throws Exception { Node node = new IntLiteral("foo"); }
@Test public void intLiteral() throws Exception { Node node = new IntLiteral("42"); assertThat( node.toString(), is("42") ); }
public IntLiteral(String value) { super(checkValue(value)); }
@Test public void bandWithIntLiteral() throws Exception { Band b = new Band( new IntLiteral("1") ); assertThat( b.toString(), is("1") ); }
@Test public void ndvi_s2() throws Exception { Set<GetSourceValue> sourcePositions = getSourcePositions("ndvi_s2.jfl", "src"); assertThat(sourcePositions, hasSize(2)); assertThat( sourcePositions, hasItems( new GetSourceValue( "src", new ImagePos(new Band(new IntLiteral("7")), Pixel.DEFAULT)))); assertThat( sourcePositions, hasItems( new GetSourceValue( "src", new ImagePos(new Band(new IntLiteral("3")), Pixel.DEFAULT)))); }
@Override public void exitLiteral(LiteralContext ctx) { Token tok = ctx.getStart(); switch (tok.getType()) { case JiffleParser.INT_LITERAL: set(ctx, new IntLiteral(tok.getText())); break; case JiffleParser.FLOAT_LITERAL: set(ctx, new DoubleLiteral(tok.getText())); break; case JiffleParser.TRUE: set(ctx, ConstantLiteral.trueValue()); break; case JiffleParser.FALSE: set(ctx, ConstantLiteral.falseValue()); break; case JiffleParser.NULL: set(ctx, ConstantLiteral.nanValue()); break; default: throw new JiffleParserException("Unrecognized literal type: " + tok.getText()); } }
@Override public void exitLiteral(LiteralContext ctx) { Token tok = ctx.getStart(); switch (tok.getType()) { case JiffleParser.INT_LITERAL: set(ctx, new IntLiteral(tok.getText())); break; case JiffleParser.FLOAT_LITERAL: set(ctx, new DoubleLiteral(tok.getText())); break; case JiffleParser.TRUE: set(ctx, ConstantLiteral.trueValue()); break; case JiffleParser.FALSE: set(ctx, ConstantLiteral.falseValue()); break; case JiffleParser.NULL: set(ctx, ConstantLiteral.nanValue()); break; default: throw new JiffleParserException("Unrecognized literal type: " + tok.getText()); } }
@Test public void pixel() throws Exception { Expression x = new IntLiteral("42"); Expression y = FunctionCall.of("y"); Pixel p = new Pixel(x, y); String expected = Strings.commas(x, y); assertThat( p.toString(), is(expected) ); }