re2-js-generator/test.js

62 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-01-25 12:15:41 +00:00
/**
* Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/25/19.
*/
var fs = require("fs");
var exec = require('child_process').exec;
2019-01-25 13:30:02 +00:00
exec("node main.js -o=lexer_test.js -t=node", function(err, stdout, stderr) {
2019-01-25 12:15:41 +00:00
err && console.log("ERROR: ", err);
err && process.exit(1);
var file = fs.readFileSync("lexer_test.js", "utf8");
file += "\n module.exports = Lexer";
fs.writeFileSync("lexer_test.js", file);
test();
fs.unlinkSync("lexer_test.js");
});
var test = function() {
var Lexer = require("./lexer_test");
console.log("TEST SINGLE");
(new Lexer("[")).search();
(new Lexer("]")).search();
(new Lexer("(")).search();
2019-01-25 13:30:02 +00:00
(new Lexer(")")).search();
2019-01-25 12:15:41 +00:00
(new Lexer(":")).search();
(new Lexer(",")).search();
(new Lexer(".")).search();
(new Lexer("%")).search();
(new Lexer(">")).search();
(new Lexer(">=")).search();
(new Lexer("<")).search();
(new Lexer("<=")).search();
(new Lexer("==")).search();
(new Lexer("!=")).search();
(new Lexer("AND")).search();
(new Lexer("and")).search();
(new Lexer("OR")).search();
(new Lexer("or")).search();
(new Lexer("NOT")).search();
(new Lexer("not")).search();
(new Lexer("LIKE")).search();
(new Lexer("like")).search();
(new Lexer("NLIKE")).search();
(new Lexer("nlike")).search();
(new Lexer("Address")).search();
(new Lexer("Time")).search();
(new Lexer("TimeDiff")).search();
var lex_test_all = new Lexer("[ ] ( ) : , . % > >= < <= == != AND and OR or NOT not LIKE like NLIKE nlike Address Time TimeDiff 'sdfadfasdf' \"asdfasfd\" ")
var _lex;
console.log("start search");
while (_lex = lex_test_all.next());
console.log("TEST STRING LITERAL");
(new Lexer(' "111\\\"11\\\"1" "222222" ')).search();
(new Lexer(" '111\\\'11\\\'1' '222222' ")).search();
};