Search in sources :

Example 16 with RedsInteger

use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.

the class IfTest method shouldNotExecuteThenBlockWhenExecutingIfWithFalseAndNoElseClause.

@Test
void shouldNotExecuteThenBlockWhenExecutingIfWithFalseAndNoElseClause() {
    If anIf = createIfWithAssignments("a", false, 1);
    env.putVariable("a", new RedsInteger(0));
    anIf.execute(env);
    assertEquals(new RedsInteger(0), env.getVariable("a"));
}
Also used : RedsInteger(net.taken.redsnake.lang.RedsInteger) If(net.taken.redsnake.tree.statements.If) Test(org.junit.jupiter.api.Test)

Example 17 with RedsInteger

use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.

the class IfTest method shouldExecuteTheGoodBlockWhenExecutingIfWithTrueAndElseClause.

@Test
void shouldExecuteTheGoodBlockWhenExecutingIfWithTrueAndElseClause() {
    If anIf = createIfWithAssignments("a", true, 1, 2);
    env.putVariable("a", new RedsInteger(0));
    anIf.execute(env);
    assertEquals(new RedsInteger(1), env.getVariable("a"));
}
Also used : RedsInteger(net.taken.redsnake.lang.RedsInteger) If(net.taken.redsnake.tree.statements.If) Test(org.junit.jupiter.api.Test)

Example 18 with RedsInteger

use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.

the class ArithmeticBinaryExpressionTest method shouldReturnCorrectResultWhenExecuteBinaryExprPower.

@Test
void shouldReturnCorrectResultWhenExecuteBinaryExprPower() {
    ArithmeticBinaryExpression abe = createBinaryExpression(POWER, 2, 4);
    assertEquals(new RedsInteger(16), abe.execute(env));
}
Also used : RedsInteger(net.taken.redsnake.lang.RedsInteger) Test(org.junit.jupiter.api.Test)

Example 19 with RedsInteger

use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.

the class ArithmeticBinaryExpressionTest method shouldReturnCorrectResultWhenExecuteBinaryExprMod.

@Test
void shouldReturnCorrectResultWhenExecuteBinaryExprMod() {
    ArithmeticBinaryExpression abe = createBinaryExpression(MODULUS, 4, 3);
    assertEquals(new RedsInteger(1), abe.execute(env));
}
Also used : RedsInteger(net.taken.redsnake.lang.RedsInteger) Test(org.junit.jupiter.api.Test)

Example 20 with RedsInteger

use of net.taken.redsnake.lang.RedsInteger in project redsnake by Taken0711.

the class ArithmeticBinaryExpressionTest method shouldReturnCorrectResultWhenExecuteBinaryMinus.

@Test
void shouldReturnCorrectResultWhenExecuteBinaryMinus() {
    ArithmeticBinaryExpression abe = createBinaryExpression(SUBTRACT, 4, 3);
    assertEquals(new RedsInteger(1), abe.execute(env));
}
Also used : RedsInteger(net.taken.redsnake.lang.RedsInteger) Test(org.junit.jupiter.api.Test)

Aggregations

RedsInteger (net.taken.redsnake.lang.RedsInteger)28 Test (org.junit.jupiter.api.Test)28 Statement (net.taken.redsnake.tree.statements.Statement)7 TestUtils.parseStatement (net.taken.redsnake.tree.TestUtils.parseStatement)5 If (net.taken.redsnake.tree.statements.If)3 Program (net.taken.redsnake.tree.Program)2