mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-27 14:54:55 +00:00
run parser tests in RealmJSTests
This commit is contained in:
parent
40f0e5f274
commit
df7474feb3
@ -64,6 +64,8 @@
|
||||
02D8D1F71B601984006DB49D /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02B58CCD1AE99D4D009B348C /* JavaScriptCore.framework */; };
|
||||
02E9A9F11BFA84F100939F86 /* QueryTests.js in Resources */ = {isa = PBXBuildFile; fileRef = 02E9A9F01BFA84F100939F86 /* QueryTests.js */; };
|
||||
02EF76761BFFD41F000D5BAD /* queryTests.json in Resources */ = {isa = PBXBuildFile; fileRef = 02EF76751BFFD41F000D5BAD /* queryTests.json */; };
|
||||
02EF76861BFFDE37000D5BAD /* test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02EF76851BFFDE37000D5BAD /* test.cpp */; };
|
||||
02EF76881BFFDE9E000D5BAD /* GrammerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 02EF76871BFFDE9E000D5BAD /* GrammerTests.mm */; };
|
||||
F636F6C81BCDB3570023F35C /* RealmReact.h in Headers */ = {isa = PBXBuildFile; fileRef = 0270BCCF1B7D067300010E03 /* RealmReact.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F64426C51BCDB1E200A81210 /* RealmJS.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 02B58CB11AE99CEC009B348C /* RealmJS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
F64E1EF11BC3510E00E0E150 /* util.js in Resources */ = {isa = PBXBuildFile; fileRef = F64E1EF01BC3510E00E0E150 /* util.js */; };
|
||||
@ -225,6 +227,8 @@
|
||||
02E9A9F01BFA84F100939F86 /* QueryTests.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = QueryTests.js; path = tests/QueryTests.js; sourceTree = SOURCE_ROOT; };
|
||||
02EE6D781BD87E310016A82E /* ReactTests.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactTests.xcodeproj; path = tests/ReactTests/ios/ReactTests.xcodeproj; sourceTree = "<group>"; };
|
||||
02EF76751BFFD41F000D5BAD /* queryTests.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = queryTests.json; path = "src/object-store/parser/queryTests.json"; sourceTree = SOURCE_ROOT; };
|
||||
02EF76851BFFDE37000D5BAD /* test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = test.cpp; path = "src/object-store/parser/test.cpp"; sourceTree = SOURCE_ROOT; };
|
||||
02EF76871BFFDE9E000D5BAD /* GrammerTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = GrammerTests.mm; path = tests/GrammerTests.mm; sourceTree = SOURCE_ROOT; };
|
||||
F64E1EF01BC3510E00E0E150 /* util.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = util.js; path = tests/util.js; sourceTree = SOURCE_ROOT; };
|
||||
F68A278A1BC2722A0063D40A /* RJSModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RJSModuleLoader.h; path = tests/RJSModuleLoader.h; sourceTree = SOURCE_ROOT; };
|
||||
F68A278B1BC2722A0063D40A /* RJSModuleLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RJSModuleLoader.m; path = tests/RJSModuleLoader.m; sourceTree = SOURCE_ROOT; };
|
||||
@ -378,6 +382,8 @@
|
||||
02409DC11BCF11D6005F3B3E /* RealmJSCoreTests.m */,
|
||||
F68A278A1BC2722A0063D40A /* RJSModuleLoader.h */,
|
||||
F68A278B1BC2722A0063D40A /* RJSModuleLoader.m */,
|
||||
02EF76871BFFDE9E000D5BAD /* GrammerTests.mm */,
|
||||
02EF76851BFFDE37000D5BAD /* test.cpp */,
|
||||
);
|
||||
path = RealmJSTests;
|
||||
sourceTree = "<group>";
|
||||
@ -700,6 +706,8 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F68A278C1BC2722A0063D40A /* RJSModuleLoader.m in Sources */,
|
||||
02EF76881BFFDE9E000D5BAD /* GrammerTests.mm in Sources */,
|
||||
02EF76861BFFDE37000D5BAD /* test.cpp in Sources */,
|
||||
0270BC821B7D020100010E03 /* RealmJSTests.mm in Sources */,
|
||||
02409DC21BCF11D6005F3B3E /* RealmJSCoreTests.m in Sources */,
|
||||
);
|
||||
|
@ -320,6 +320,11 @@ Predicate parse(const std::string &query)
|
||||
return std::move(out_predicate);
|
||||
}
|
||||
|
||||
void analyzeGrammer()
|
||||
{
|
||||
analyze<pred>();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
@ -76,6 +76,9 @@ namespace realm {
|
||||
};
|
||||
|
||||
Predicate parse(const std::string &query);
|
||||
|
||||
void analyzeGrammer();
|
||||
bool testGrammer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,20 +125,25 @@ static std::vector<std::string> 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
19
tests/GrammerTests.mm
Normal file
19
tests/GrammerTests.mm
Normal file
@ -0,0 +1,19 @@
|
||||
/* Copyright 2015 Realm Inc - All Rights Reserved
|
||||
* Proprietary and Confidential
|
||||
*/
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <RealmJS/RealmJS.h>
|
||||
#import "parser.hpp"
|
||||
|
||||
@interface GrammerTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation GrammerTests
|
||||
|
||||
- (void)testGrammer {
|
||||
realm::parser::analyzeGrammer();
|
||||
XCTAssertTrue(realm::parser::testGrammer());
|
||||
}
|
||||
|
||||
@end
|
@ -62,3 +62,5 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user