61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
/**
|
|
* Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/25/19.
|
|
*/
|
|
var fs = require("fs");
|
|
var exec = require('child_process').exec;
|
|
|
|
exec("node main.js -o=lexer_test.js -t=node", function(err, stdout, stderr) {
|
|
err && console.log("ERROR: ", err);
|
|
err && process.exit(1);
|
|
|
|
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();
|
|
(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("!=")).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("Oid[1.2.3]")).search();
|
|
(new Lexer("Oid [ 2431.2.3 ]")).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 Oid[1.2.3] 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();
|
|
|
|
console.log("\nSuccess tests\n");
|
|
}; |