Skip to content
Snippets Groups Projects
Commit a7b1a9ff authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Since we're doing JS tests, add the JS test suite.

Various bits needed to be hacked up a bit since it was written for
a newer JS standard, but it's at least 11 better than 42.
parent 08723665
No related branches found
No related tags found
No related merge requests found
Pipeline #5513 failed
Showing
with 117 additions and 0 deletions
var f = new File('test.crt');
f.open('r');
f.readln(65535);
var b64 = f.readln(65535);
var raw = base64_decode(b64, 819);
var c = new CryptCert(raw);
for (var i in c) {
var val = c[i];
if (val === undefined)
continue;
}
var x = JSON.stringify(c);
var x = JSON.stringify(CryptContext.ALGO);
var cc = new CryptContext(CryptContext.ALGO.SHA2);
var y = JSON.stringify(cc);
if (system.platform == 'Win32')
exit();
var f = new File("/bin/ls");
if (!f.popen("r"))
throw new Error('popen() failed! {f.error}');
while(f.is_open) {
var l = f.readln();
if (!l)
f.close();
}
alert("test");
beep();
beep(420);
beep(420, 300);
if (ctrl('C') !== String.fromCharCode(3))
throw new Error("ctrl('C') !== String.fromCharCode(3)");
if (ctrl(3) !== String.fromCharCode(3))
throw new Error("ctrl(3) !== String.fromCharCode(3)");
var x = random(256);
var scope = new function(){};
var ret = js.exec("exit_subproc.sjs", scope, x);
if (ret != x) {
print('ret: '+ret.toSource());
print('x: '+x.toSource());
throw new Error("ret is wrong");
}
exit(argv[0]);
if (file_getname("/home/cyan/thefilename").indexOf('/') !== -1)
throw new Error('slashes in filename');
const arg1 = random(256);
// First, test that let and var go into the current global
load("load_define.sjs", arg1);
if (load_var !== arg1)
throw new Error('Var failed '+load_var+' != '+arg1);
//if (load_let !== arg1)
// throw new Error('Let failed '+load_let+' != '+arg1);
// Next, test the return value
if (load("load_return.sjs", arg1) !== arg1)
throw new Error('load() return value bad.');
// Now test what happens when a scope is passed...
// Disabled for 1.8.5
//var scope = {};
//load(scope, "load_define.sjs", arg1);
//if (scope.load_var !== arg1)
// throw new Error('xVar failed '+scope.load_var+' != '+arg1);
// NOTE: When a scope is passed, it's absolutely entered then left.
// This requires let support, var won't cut it.
//if (scope.load_let === arg1)
// throw new Error('Let still in scope '+scope.load_let.toSource()+' == '+arg1.toSource());
//if (scope.get_let() !== arg1)
// throw new Error("Scope closures don't work!");
const arg2 = random(256);
const arg3 = random(256);
// Finally, test background threads...
var q = load(true, "load_background.sjs", arg1, arg2, arg3);
if (q.read(-1) !== arg1)
throw new Error('First result from queue incorrect');
if (q.read(-1) !== arg2)
throw new Error('Second result from queue incorrect');
if (q.read(-1) !== arg3)
throw new Error('Exit result from queue incorrect');
if (q.orphan)
throw new Error('q orphaned when background terminates');
parent_queue.write(argv[0]);
parent_queue.write(argv[1]);
exit(argv[2]);
var load_let = argv[0];
var load_var = argv[0];
function get_let() {
return load_let;
}
argv[0];
log("Test");
log("10");
log(1, "test");
var start = system.timer;
var slept = mswait(1000);
var end = system.timer;
if (Math.abs(end - (start + slept / 1000)) > 0.002)
throw new Error("mswait() = "+slept+" diff of "+Math.abs(end - (start + (slept / 1000))));
printf("%s", "string");
printf("%s:%d\n", "string",57);
random();
if (random() == random() == random() == random())
throw new Error("Four random() calls returned same result");
for (var i = 0; i < 1000; i++) {
var rval = random(10);
if (rval < 0 || rval >= 10)
throw new Error("random() result out of range");
}
sound("sound.wav");
File added
var d = Date()/1000;
var t = time();
if (Math.abs(t - d) > 1)
throw new Error("new Date() and time() differ by over a second");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment