diff options
| Commit | fe67e5fb5ce2217a1219f0420a011487b4475761 (patch) | |
|---|---|---|
| Author | 2020-11-02 23:44:28 +0200 | |
| Committer | 2020-11-09 22:08:19 +0200 | |
| Files | f4dcb0b755047fd932b6f3528e54352e101bc092 /JSImpl | |
| IPL-fe67e5fb5ce2217a1219f0420a011487b4475761.tar IPL-fe67e5fb5ce2217a1219f0420a011487b4475761.tar.gz IPL-fe67e5fb5ce2217a1219f0420a011487b4475761.zip | ||
| Parent | 5521d5857b122699120fbd749776dea44ffaa35b (diff) | |
Add tests for comparison variant visitor
1 files changed, 19 insertions, 0 deletions
| -rw-r--r-- | JSImpl/test/ASTInterpreterTests.cpp | 19 |
diff --git a/JSImpl/test/ASTInterpreterTests.cpp b/JSImpl/test/ASTInterpreterTests.cpp index 389f53c..e8cf282 100644 --- a/JSImpl/test/ASTInterpreterTests.cpp +++ b/JSImpl/test/ASTInterpreterTests.cpp @@ -56,3 +56,22 @@ TEST_F(ASTInterpret, StringMinusString) { ASSERT_THROW(Run("var data = 'John' - 'Doe'"), std::runtime_error); } + +TEST_F(ASTInterpret, LessNumber) +{ + Run("var answer = 6 < 7"); + ASSERT_TRUE(HasVariable("answer")); + ASSERT_DOUBLE_EQ(ValueAsNumber("answer"), 1.0); +} + +TEST_F(ASTInterpret, LessString) +{ + Run("var name = 'John' < 'Doe'"); + ASSERT_TRUE(HasVariable("name")); + ASSERT_DOUBLE_EQ(ValueAsNumber("name"), 0.0); +} + +TEST_F(ASTInterpret, StringLessNumber) +{ + ASSERT_THROW(Run("var data = 'John' < 42"), std::runtime_error); +} |
