use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.
the class ArithmeticBinaryExpressionTest method shouldReturnCorrectResultWhenExecuteBinaryExprMult.
@Test
void shouldReturnCorrectResultWhenExecuteBinaryExprMult() {
ArithmeticBinaryExpression abe = createBinaryExpression(MULTIPLY, 4, 2);
assertEquals(new RedsInteger(8), abe.execute(env));
}
use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.
the class ArithmeticBinaryExpressionTest method shouldReturnCorrectResultWhenExecuteBinaryPlus.
@Test
void shouldReturnCorrectResultWhenExecuteBinaryPlus() {
ArithmeticBinaryExpression abe = createBinaryExpression(ADD, 4, 3);
assertEquals(new RedsInteger(7), abe.execute(env));
}
use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.
the class ArithmeticBinaryExpressionTest method shouldPrioritizeUnaryMinusOverMultiplyDivideAndModulo.
@Test
void shouldPrioritizeUnaryMinusOverMultiplyDivideAndModulo() {
Statement stmt = parseStatement("2*-1/-1*(1%-(-2))");
assertEquals(new RedsInteger(2), stmt.execute(env));
}
use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.
the class IfTest method shouldExecuteThenBlockWhenExecutingIfWithParenthesisAndCurlyBracketsAndNotInline.
@Test
void shouldExecuteThenBlockWhenExecutingIfWithParenthesisAndCurlyBracketsAndNotInline() {
Program program = parseProgram("a = 0\n" + "if(true) {\n" + " a = 1\n" + "} else {\n" + " a = 2\n" + "}");
program.execute(env);
assertEquals(new RedsInteger(1), env.getVariable("a"));
}
use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.
the class IfTest method shouldNotExecuteElseBlockWhenExecutingIfWithFalseAndElseClause.
@Test
void shouldNotExecuteElseBlockWhenExecutingIfWithFalseAndElseClause() {
If anIf = createIfWithAssignments("a", false, 1, 2);
env.putVariable("a", new RedsInteger(0));
anIf.execute(env);
assertEquals(new RedsInteger(2), env.getVariable("a"));
}
Aggregations