GoVarDeclaration[] declarations =
childAt(0,
file.getGlobalVariables()
).getDeclarations();
GoLiteralFloat fl;
// x
fl =
getAs(GoLiteralFloat.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[0].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Float, fl.getType());
assertEquals(BigDecimal.valueOf(10.0), fl.getValue());
// x
fl =
getAs(GoLiteralFloat.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[1].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Float, fl.getType());
assertEquals(BigDecimal.valueOf(0.25), fl.getValue());
// y
fl =
getAs(GoLiteralFloat.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[2].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Float, fl.getType());
assertEquals(BigDecimal.ZERO, fl.getValue());
// z
fl =
getAs(GoLiteralFloat.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[3].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Float, fl.getType());
assertEquals(new BigDecimal("72.40"), fl.getValue());
// e1
fl =
getAs(GoLiteralFloat.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[4].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Float, fl.getType());
assertEquals(new BigDecimal("1.e+0"), fl.getValue());
// e2
fl =
getAs(GoLiteralFloat.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[5].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Float, fl.getType());
assertEquals(BigDecimal.valueOf(6.67428e-11), fl.getValue());
// e3
fl =
getAs(GoLiteralFloat.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[6].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Float, fl.getType());
assertEquals(1E6, fl.getValue().floatValue(), 0.000001);
}