Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / test / ParserTests.cpp
diff options
context:
space:
mode:
Commite89ae67ea4d71912caef286d3b4dcc3a5a64d134 (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-10-28 18:47:12 +0200
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-10-28 18:47:12 +0200
Files51bc62f8df96e4df48934ece5502855cb448f2d2 /JSImpl/test/ParserTests.cpp
IPL-e89ae67ea4d71912caef286d3b4dcc3a5a64d134.tar
IPL-e89ae67ea4d71912caef286d3b4dcc3a5a64d134.tar.gz
IPL-e89ae67ea4d71912caef286d3b4dcc3a5a64d134.zip
Parent2bb25db66a044f8c489ab6449386a32f31de1256 (diff)
Moved lexer and parser tests to the test app
1 files changed, 22 insertions, 0 deletions
-rw-r--r--JSImpl/test/ParserTests.cpp22
diff --git a/JSImpl/test/ParserTests.cpp b/JSImpl/test/ParserTests.cpp
new file mode 100644
index 0000000..a884f37
--- /dev/null
+++ b/JSImpl/test/ParserTests.cpp
@@ -0,0 +1,22 @@
+#include <src/CommonTypes.h>
+#include <src/Lexer.h>
+#include <src/Parser.h>
+#include <src/ASTPrinter.h>
+
+#include <gtest/gtest.h>
+
+#include <sstream>
+
+TEST(Parser, ParseUnaryExpr)
+{
+ IPLVector<Token> tokens;
+ Tokenize("function pesho() { var a = 0; return a; } var a = \"3\";", tokens);
+
+ // TODO make actual test :D
+ auto expr = Parse(tokens);
+ std::ostringstream output;
+ ASTPrinter p(output);
+ expr->Accept(p);
+ ASSERT_TRUE(!output.str().empty());
+}
+