const assert = require('assert'); const {execSync} = require("child_process") const {cwd} = require('process'); const {join} = require('path'); const {readFileSync} = require('fs'); function compile(file) { const cwd = "../"; return execSync("target/debug/snakeoil compile " + file, { cwd }); } function run() { const cwd = "../"; try { return execSync("node test/run.js", { cwd }).toString(); } catch (e) { return e.stderr; } } function test(file) { compile(join("test", "fixtures", file)); return run(); } describe('Python', function() { describe('test fixtures', function() { function t(name, expected) { it(name, function() { const actual = test(name); assert(actual === expected, `expected ${expected}, given ${actual}.`); }); } t("print_string.py", "hi\n"); t("print_number.py", "11\n0\n"); t("assignment.py", "abc\n"); t("assignment_global.py", "bac\n"); t("assignment_local.py", "cab\n"); t("call_argument.py", "a\n"); t("call_arguments.py", "a\nb\nc\nd\ne\n"); t("call_arguments_stack.py", "a\nb\nc\nd\ne\nhi\nhello\n"); t("del_local.py", ""); t("tuple_number.py", "11\n22\n33\n"); t("tuple_string.py", "str1\nstr2\nstr3\n"); t("compare_number.py", "True\nFalse\n"); t("compare_static_string.py", "True\nFalse\n"); t("dict_number.py", "11\n33\n"); t("dict_string.py", "aa\nbb\n"); }); });