Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / test / ASTInterpreterTests.cpp
diff options
context:
space:
mode:
Commitfe67e5fb5ce2217a1219f0420a011487b4475761 (patch)
Author
 Dimitar Trendafilov <trendafilov.dn@gmail.com>
2020-11-02 23:44:28 +0200
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-11-09 22:08:19 +0200
Filesf4dcb0b755047fd932b6f3528e54352e101bc092 /JSImpl/test/ASTInterpreterTests.cpp
IPL-fe67e5fb5ce2217a1219f0420a011487b4475761.tar
IPL-fe67e5fb5ce2217a1219f0420a011487b4475761.tar.gz
IPL-fe67e5fb5ce2217a1219f0420a011487b4475761.zip
Parent5521d5857b122699120fbd749776dea44ffaa35b (diff)
Add tests for comparison variant visitor
1 files changed, 19 insertions, 0 deletions
-rw-r--r--JSImpl/test/ASTInterpreterTests.cpp19
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);
+}