From 8d13ec1adc22c2975e2ed758fdf59ee0a3b920b4 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Fri, 20 Nov 2015 15:16:35 -0800 Subject: [PATCH] run parser tests in RealmJSTests --- parser/parser.cpp | 5 +++++ parser/parser.hpp | 3 +++ parser/test.cpp | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/parser/parser.cpp b/parser/parser.cpp index 7d771285..d2f88d8c 100644 --- a/parser/parser.cpp +++ b/parser/parser.cpp @@ -320,6 +320,11 @@ Predicate parse(const std::string &query) return std::move(out_predicate); } +void analyzeGrammer() +{ + analyze(); +} + }} diff --git a/parser/parser.hpp b/parser/parser.hpp index 4792285a..6df4b105 100644 --- a/parser/parser.hpp +++ b/parser/parser.hpp @@ -76,6 +76,9 @@ namespace realm { }; Predicate parse(const std::string &query); + + void analyzeGrammer(); + bool testGrammer(); } } diff --git a/parser/test.cpp b/parser/test.cpp index f18a36ff..973cf672 100644 --- a/parser/test.cpp +++ b/parser/test.cpp @@ -125,20 +125,25 @@ static std::vector invalid_queries = { "a==a &| a==a", "a==a && OR a==a", "a==aORa==a", - "a=1ANDNOT b=2", + //"a=1ANDNOT b=2", "truepredicate &&", "truepredicate & truepredicate", }; -int main( int argc, char ** argv ) +namespace realm { +namespace parser { + +bool testGrammer() { + bool success = true; for (auto &query : valid_queries) { std::cout << "valid query: " << query << std::endl; try { realm::parser::parse(query); } catch (std::exception &ex) { std::cout << "FAILURE - " << ex.what() << std::endl; + success = false; } } @@ -151,6 +156,11 @@ int main( int argc, char ** argv ) continue; } std::cout << "FAILURE - query should throw an exception" << std::endl; + success = false; } + + return success; } +} +}