/** * Created by Aleksey Chichenkov on 1/29/19. */ var fs = require("fs"); var exec = require('child_process').exec; var args = require("args-parser")(process.argv); var cfg_path = "config.js"; var config; if(args["c"] !== undefined) { config = require("./" + args["c"]); cfg_path = args["c"]; } else { config = require("./config.js"); } exec("node main.js -o=" + cfg_path + " -t=node", function(err, stdout, stderr) { err && console.log("ERROR: ", err); err && process.exit(1); test(); }); var test = function() { var LemonJS = require("./parsers/filters/parser.js"); if(!fs.existsSync("tests")) { fs.mkdirSync("tests"); } var test_and = LemonJS("abc == 1 and abc1 == 2 and (bbc == 5)").tree; fs.writeFileSync("tests/test_and.json", JSON.stringify(test_and, true, 3)); var test_address = LemonJS('abc == Address ["a", "b", "c"]').tree; fs.writeFileSync("tests/test_address.json", JSON.stringify(test_address, true, 3)); var test_float = LemonJS('abc == 23.2').tree; fs.writeFileSync("tests/test_float.json", JSON.stringify(test_float, true, 3)); var test_string = LemonJS('abc == "sadfasdf"').tree; fs.writeFileSync("tests/test_string.json", JSON.stringify(test_string, true, 3)); var test_bool = LemonJS('abc == true or cab == false').tree; fs.writeFileSync("tests/test_bool.json", JSON.stringify(test_bool, true, 3)); var test_not = LemonJS('not cab == false').tree; fs.writeFileSync("tests/test_not.json", JSON.stringify(test_not, true, 3)); var test_oid = LemonJS('abc == Oid [a.b.d]').tree; fs.writeFileSync("tests/test_oid.json", JSON.stringify(test_oid, true, 3)); var test_timediff = LemonJS('add == TimeDiff [17924 15:01:24 441000]').tree; fs.writeFileSync("tests/test_timediff.json", JSON.stringify(test_timediff, true, 3)); var test_time = LemonJS('add == Time [29/12/2019 15:01:24 441000]').tree; fs.writeFileSync("tests/test_time.json", JSON.stringify(test_time, true, 3)); };