-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexer-test-maker.js
35 lines (27 loc) · 916 Bytes
/
lexer-test-maker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
let lightningSql = require("./dist/lightning-sql").lightningSql;
let queries = [
"SELECT id, users.email FROM users, charts WHERE users.id = charts.user_id",
];
queries.forEach(query => {
let lxr = new lightningSql.Lexer(query);
console.log("query = " + JSON.stringify(query) + ";");
console.log("result = [")
lxr.readAllTokens().forEach(token => {
console.log(
" new lightningSql.Token(" +
JSON.stringify(token.line) + "," +
JSON.stringify(token.type) + "," +
JSON.stringify(token.value) + "," +
JSON.stringify(token.from) + "," +
JSON.stringify(token.to) +
"),");
})
console.log("];");
console.log("test(query, () => {");
console.log(" let lxr = new lightningSql.Lexer(query);");
console.log(" expect(lxr.readAllTokens()).toStrictEqual(result);");
console.log("});");
console.log();
console.log();
// console.log(JSON.stringify(lxr.readAllTokens(), null, 4));
})