Search in sources :

Example 1 with Program

use of net.taken.redsnake.tree.Program 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"));
}
Also used : Program(net.taken.redsnake.tree.Program) RedsInteger(net.taken.redsnake.lang.RedsInteger) Test(org.junit.jupiter.api.Test)

Example 2 with Program

use of net.taken.redsnake.tree.Program 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"));
}
Also used : Program(net.taken.redsnake.tree.Program) RedsInteger(net.taken.redsnake.lang.RedsInteger) Test(org.junit.jupiter.api.Test)

Aggregations

RedsInteger (net.taken.redsnake.lang.RedsInteger)2 Program (net.taken.redsnake.tree.Program)2 Test (org.junit.jupiter.api.Test)2