Skip to content

Commit

Permalink
test: add return eval
Browse files Browse the repository at this point in the history
  • Loading branch information
hd1fernando committed May 23, 2023
1 parent 87f5621 commit e1bc9ea
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/DotMonkey.ParserTest/EvaluatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ public void TestIfElsExpression(string input, object expected)
}
}


[Theory(DisplayName = "Return Statement")]
[InlineData("return 10;", 10)]
[InlineData("return 10; 9;", 10)]
[InlineData("return 2 * 5; 9;", 10)]
[InlineData("9; return 2 * 5; 9;", 10)]
[InlineData("if (10 > 1) { if (10 > 1) { return 10; } return 1; }", 10)]
public void TestReturnStatement(string input, int expected)
{
var evaluated = TestEval(input);
TestIntergerObject(evaluated, expected);
}

private void TestNullObject(IObject evalueated)
{
evalueated.Should().BeOfType<NULL>();
Expand Down

0 comments on commit e1bc9ea

Please sign in to comment.