Skip to content

Commit

Permalink
tests.mjs: use process.stdout.write to output dots
Browse files Browse the repository at this point in the history
  • Loading branch information
philbudne committed Dec 24, 2019
1 parent b9f8122 commit 10b701f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ function test_err(msg) {
console.log(`${caller}: ${msg}`);
}

function passed() {
ok++;
if (process && process.stdout)
process.stdout.write('.');
}

function check(m, expect) {
tests++;
if (expect && m === null) {
Expand All @@ -67,19 +73,19 @@ function check(m, expect) {
test_err(`expecting failure, but matched ${LQ}${m.matched}${RQ}`);
}
else
ok++;
passed();
}
else if (m.matched !== expect) {
test_err(`expecting ${LQ}${expect}${RQ}, but matched ${LQ}${m.matched}${RQ}`);
}
else
ok++;
passed();
}

function checkval(v, expect) {
tests++;
if (v === expect)
ok++;
passed();
else
test_err(`expecting ${LQ}${expect}${RQ} got ${LQ}${v}${RQ}`);
}
Expand All @@ -89,7 +95,7 @@ function imgcheck(p, expect) {
//spipat.print_nodes(p.p.ref_array())
let v = p.toString();
if (v === expect)
ok++;
passed();
else {
test_err(`imgcheck failed:\n expecting ${LQ}${expect}${RQ}\n got ${LQ}${v}${RQ}`);
//spipat.print_nodes(p.p.ref_array())
Expand Down Expand Up @@ -480,6 +486,7 @@ console.log(m.matched);
*/

//================
console.log('');
console.log(`${tests} tests: ${ok} ok`);
if (ok == tests)
process.exit(0);
Expand Down

0 comments on commit 10b701f

Please sign in to comment.