Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Mar 13, 2021
1 parent ff2f300 commit 527ca58
Show file tree
Hide file tree
Showing 12 changed files with 416 additions and 974 deletions.
428 changes: 334 additions & 94 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
"chokidar-cli": "^2.0.0",
"cpy-cli": "^2.0.0",
"gh-pages": "^2.1.1",
"glob": "^7.1.6",
"husky": "^3.0.5",
"mkdirp": "^0.5.1",
"mocha": "^6.2.0",
"mocha": "^8.3.2",
"normalize.css": "^8.0.1",
"np": "^5.2.1",
"npm-run-all": "^4.1.5",
Expand Down
2 changes: 1 addition & 1 deletion test/assembly/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function issue28(arr: Float64Array): f64 {
for (let i = 0; i < 3; ++i) {
sum += arr[i];
}
return arr.length;
return sum;
}

// Basic value Passing
Expand Down
2 changes: 1 addition & 1 deletion test/assembly/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../../.nvm/versions/node/v12.2.0/lib/node_modules/assemblyscript/std/assembly.json",
"extends": "../../node_modules/assemblyscript/std/assembly.json",
"include": ["./**/*.ts"]
}
51 changes: 51 additions & 0 deletions test/test-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const asc = require("assemblyscript/cli/asc");
const { promisify } = require("util");
const glob = promisify(require("glob"));
const Mocha = require("mocha");

async function main() {
await asc.ready;

await compileAllAsc();

await runTestsInNode();
}
main();

async function compileAllAsc() {
const ascFiles = await glob("./tests/**/*.ts");
const transformFile = require.resolve("../transform.js");
for (const ascFile of ascFiles) {
console.log(`Compiling ${ascFile}...`);
await asc.main([
"--exportRuntime",
"--transform",
transformFile,
"--binaryFile",
ascFile.replace(/\.ts$/, ".wasm"),
ascFile
]);
}
}

async function runTestsInNode() {
const mocha = new Mocha();

mocha.globalSetup(() => {
console.log("GLOBAL SETUP");
});

const testFiles = await glob("./tests/**/test.js");
for (const testFile of testFiles) {
mocha.addFile(testFile);
}

const failures = await runMochaAsync(mocha);
console.log({ failures });
}

function runMochaAsync(mocha) {
return new Promise(resolve => {
const runner = mocha.run(resolve);
});
}

0 comments on commit 527ca58

Please sign in to comment.