use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.
the class AssignmentTest method shouldStoreVariableWhenParseAssignment.
@Test
void shouldStoreVariableWhenParseAssignment() {
Statement stmt = parseStatement("a = 771");
stmt.execute(env);
assertEquals(new RedsInteger(771), env.getVariable("a"));
}
use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.
the class CallDesignatorTest method shouldReturnCallValueWhenExecuteCallDesignator.
@Test
void shouldReturnCallValueWhenExecuteCallDesignator() {
CallDesignator callDesignator = createCallDesignator(new RedsInteger(211));
assertEquals(new RedsInteger(211), callDesignator.execute(env));
}
use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.
the class VariableDesignatorTest method shouldReturnVariableValueWhenExecuteVarDesignatorAndFunctionExists.
@Test
void shouldReturnVariableValueWhenExecuteVarDesignatorAndFunctionExists() {
VariableDesignator var = createVariableDesignator("testvar");
env.putVariable("testvar", new RedsInteger(96));
env.putFunction("testvar", list -> new RedsInteger(957));
assertEquals(new RedsInteger(96), var.execute(env));
}
use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.
the class IfTest method shouldExecuteElseBlockWhenExecutingIfWithoutParenthesisAndWithoutCurlyBracketsAndInline.
@Test
void shouldExecuteElseBlockWhenExecutingIfWithoutParenthesisAndWithoutCurlyBracketsAndInline() {
Program program = parseProgram("a = 0\n" + "if false a = 1 else a = 2");
program.execute(env);
assertEquals(new RedsInteger(2), env.getVariable("a"));
}
use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.
the class ArithmeticBinaryExpressionTest method shouldBeRightAssociativeWhenExecuteBinaryExprPow.
@Test
void shouldBeRightAssociativeWhenExecuteBinaryExprPow() {
Statement stmt = parseStatement("2**3**2");
assertEquals(new RedsInteger(512), stmt.execute(env));
}
Aggregations