Search in sources :

Example 26 with RedsInteger

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

the class AssignmentTest method shouldPrioritizePlusAndMinusOverEquals.

@Test
void shouldPrioritizePlusAndMinusOverEquals() {
    Statement stmt = parseStatement("a = 5+2-1");
    stmt.execute(env);
    assertEquals(new RedsInteger(6), env.getVariable("a"));
}
Also used : Statement(net.taken.redsnake.tree.statements.Statement) RedsInteger(net.taken.redsnake.lang.RedsInteger) Test(org.junit.jupiter.api.Test)

Example 27 with RedsInteger

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

the class VariableDesignatorTest method shouldReturnVariableValueWhenExecuteVarDesignator.

@Test
void shouldReturnVariableValueWhenExecuteVarDesignator() {
    VariableDesignator var = createVariableDesignator("testvar");
    env.putVariable("testvar", new RedsInteger(223));
    assertEquals(new RedsInteger(223), var.execute(env));
}
Also used : RedsInteger(net.taken.redsnake.lang.RedsInteger) Test(org.junit.jupiter.api.Test)

Example 28 with RedsInteger

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

the class VariableDesignatorTest method shouldCallFunctionWhenExecuteVarDesignatorAndVarDoesntExist.

@Test
void shouldCallFunctionWhenExecuteVarDesignatorAndVarDoesntExist() {
    VariableDesignator var = createVariableDesignator("testFunction");
    env.putFunction("testFunction", list -> new RedsInteger(22));
    assertEquals(new RedsInteger(22), var.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