GoVarDeclaration[] declarations =
childAt(0,
file.getGlobalVariables()
).getDeclarations();
GoLiteralInteger integer;
// x
integer =
getAs(GoLiteralInteger.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[0].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Int, integer.getType());
assertEquals(BigInteger.valueOf(10), integer.getValue());
// y
integer =
getAs(GoLiteralInteger.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[1].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Int, integer.getType());
assertEquals(BigInteger.ZERO, integer.getValue());
// z
integer =
getAs(GoLiteralInteger.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[2].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Int, integer.getType());
assertEquals(BigInteger.valueOf(0120), integer.getValue());
// h1
integer =
getAs(GoLiteralInteger.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[3].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Int, integer.getType());
assertEquals(BigInteger.valueOf(0xEF), integer.getValue());
// h1
integer =
getAs(GoLiteralInteger.class,
getAs(GoLiteralExpression.class,
childAt(0,
declarations[4].getExpressions()
)
).getLiteral()
);
assertEquals(GoLiteral.Type.Int, integer.getType());
assertEquals(BigInteger.valueOf(0xAB), integer.getValue());
}