Skip to content

Commit 527ca58

Browse files
committed
WIP
1 parent ff2f300 commit 527ca58

File tree

12 files changed

+416
-974
lines changed

12 files changed

+416
-974
lines changed

package-lock.json

Lines changed: 334 additions & 94 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@
5656
"chokidar-cli": "^2.0.0",
5757
"cpy-cli": "^2.0.0",
5858
"gh-pages": "^2.1.1",
59+
"glob": "^7.1.6",
5960
"husky": "^3.0.5",
6061
"mkdirp": "^0.5.1",
61-
"mocha": "^6.2.0",
62+
"mocha": "^8.3.2",
6263
"normalize.css": "^8.0.1",
6364
"np": "^5.2.1",
6465
"npm-run-all": "^4.1.5",

test/assembly/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function issue28(arr: Float64Array): f64 {
88
for (let i = 0; i < 3; ++i) {
99
sum += arr[i];
1010
}
11-
return arr.length;
11+
return sum;
1212
}
1313

1414
// Basic value Passing

test/assembly/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"extends": "../../../.nvm/versions/node/v12.2.0/lib/node_modules/assemblyscript/std/assembly.json",
2+
"extends": "../../node_modules/assemblyscript/std/assembly.json",
33
"include": ["./**/*.ts"]
44
}

test/test-runner.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const asc = require("assemblyscript/cli/asc");
2+
const { promisify } = require("util");
3+
const glob = promisify(require("glob"));
4+
const Mocha = require("mocha");
5+
6+
async function main() {
7+
await asc.ready;
8+
9+
await compileAllAsc();
10+
11+
await runTestsInNode();
12+
}
13+
main();
14+
15+
async function compileAllAsc() {
16+
const ascFiles = await glob("./tests/**/*.ts");
17+
const transformFile = require.resolve("../transform.js");
18+
for (const ascFile of ascFiles) {
19+
console.log(`Compiling ${ascFile}...`);
20+
await asc.main([
21+
"--exportRuntime",
22+
"--transform",
23+
transformFile,
24+
"--binaryFile",
25+
ascFile.replace(/\.ts$/, ".wasm"),
26+
ascFile
27+
]);
28+
}
29+
}
30+
31+
async function runTestsInNode() {
32+
const mocha = new Mocha();
33+
34+
mocha.globalSetup(() => {
35+
console.log("GLOBAL SETUP");
36+
});
37+
38+
const testFiles = await glob("./tests/**/test.js");
39+
for (const testFile of testFiles) {
40+
mocha.addFile(testFile);
41+
}
42+
43+
const failures = await runMochaAsync(mocha);
44+
console.log({ failures });
45+
}
46+
47+
function runMochaAsync(mocha) {
48+
return new Promise(resolve => {
49+
const runner = mocha.run(resolve);
50+
});
51+
}

0 commit comments

Comments
 (0)