2019-01-29 08:02:47 +00:00
|
|
|
/**
|
|
|
|
* Created by Aleksey Chichenkov <a.chichenkov@initi.ru> on 1/29/19.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var fs = require("fs");
|
|
|
|
var exec = require('child_process').exec;
|
2019-01-30 15:03:10 +00:00
|
|
|
var args = require("./libs/args-parser")(process.argv);
|
2019-01-29 08:02:47 +00:00
|
|
|
|
2019-01-29 09:00:02 +00:00
|
|
|
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) {
|
2019-01-29 08:02:47 +00:00
|
|
|
err && console.log("ERROR: ", err);
|
|
|
|
err && process.exit(1);
|
|
|
|
|
|
|
|
test();
|
|
|
|
});
|
|
|
|
|
|
|
|
var test = function() {
|
2019-01-30 11:50:02 +00:00
|
|
|
var LemonJS = require("./" + config.input_path + "/" + config.file_name + ".js");
|
2019-01-29 08:02:47 +00:00
|
|
|
|
2019-01-29 11:04:41 +00:00
|
|
|
if (!fs.existsSync("tests")) {
|
2019-01-29 08:02:47 +00:00
|
|
|
fs.mkdirSync("tests");
|
|
|
|
}
|
|
|
|
|
|
|
|
var test_and = LemonJS("abc == 1 and abc1 == 2 and (bbc == 5)").tree;
|
2019-01-29 11:04:41 +00:00
|
|
|
fs.writeFileSync("./tests/test_and.json", JSON.stringify(test_and, true, 3));
|
2019-01-29 08:02:47 +00:00
|
|
|
|
|
|
|
var test_address = LemonJS('abc == Address ["a", "b", "c"]').tree;
|
2019-01-29 11:04:41 +00:00
|
|
|
fs.writeFileSync("./tests/test_address.json", JSON.stringify(test_address, true, 3));
|
2019-01-29 08:02:47 +00:00
|
|
|
|
|
|
|
var test_float = LemonJS('abc == 23.2').tree;
|
2019-01-29 11:04:41 +00:00
|
|
|
fs.writeFileSync("./tests/test_float.json", JSON.stringify(test_float, true, 3));
|
2019-01-29 08:02:47 +00:00
|
|
|
|
|
|
|
var test_string = LemonJS('abc == "sadfasdf"').tree;
|
2019-01-29 11:04:41 +00:00
|
|
|
fs.writeFileSync("./tests/test_string.json", JSON.stringify(test_string, true, 3));
|
2019-01-29 08:02:47 +00:00
|
|
|
|
|
|
|
var test_bool = LemonJS('abc == true or cab == false').tree;
|
2019-01-29 11:04:41 +00:00
|
|
|
fs.writeFileSync("./tests/test_bool.json", JSON.stringify(test_bool, true, 3));
|
2019-01-29 08:02:47 +00:00
|
|
|
|
|
|
|
var test_not = LemonJS('not cab == false').tree;
|
2019-01-29 11:04:41 +00:00
|
|
|
fs.writeFileSync("./tests/test_not.json", JSON.stringify(test_not, true, 3));
|
2019-01-29 08:02:47 +00:00
|
|
|
|
2019-01-30 10:13:05 +00:00
|
|
|
var test_oid = LemonJS('abc == Oid[1.2.3] and abd == Oid [ 1.2.3 ]').tree;
|
2019-01-29 11:04:41 +00:00
|
|
|
fs.writeFileSync("./tests/test_oid.json", JSON.stringify(test_oid, true, 3));
|
2019-01-29 08:02:47 +00:00
|
|
|
|
|
|
|
var test_timediff = LemonJS('add == TimeDiff [17924 15:01:24 441000]').tree;
|
2019-01-29 11:04:41 +00:00
|
|
|
fs.writeFileSync("./tests/test_timediff.json", JSON.stringify(test_timediff, true, 3));
|
2019-01-29 08:02:47 +00:00
|
|
|
|
|
|
|
var test_time = LemonJS('add == Time [29/12/2019 15:01:24 441000]').tree;
|
2019-01-29 11:04:41 +00:00
|
|
|
fs.writeFileSync("./tests/test_time.json", JSON.stringify(test_time, true, 3));
|
2019-01-29 08:02:47 +00:00
|
|
|
|
2019-01-29 10:40:28 +00:00
|
|
|
var test_exp_1 = LemonJS('(add == Time [29/12/2019 15:01:24 441000]) and ddds == "sdfasdf" or a == 123 and v == 155').tree;
|
2019-01-29 11:04:41 +00:00
|
|
|
fs.writeFileSync("./tests/test_exp_1.json", JSON.stringify(test_exp_1, true, 3));
|
2019-01-29 10:40:28 +00:00
|
|
|
|
2019-01-29 08:02:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|