-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
82 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8" /> | ||
<title>Mocha Tests</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="/node_modules/mocha/mocha.css" /> | ||
<div id="mocha"></div> | ||
|
||
<script src="/node_modules/mocha/mocha.js"></script> | ||
<script src="/dist/as-bind.iife.js"></script> | ||
<script> | ||
self.suitePaths = []; | ||
function runScript(src) { | ||
return new Promise(resolve => { | ||
const script = document.createElement("script"); | ||
script.src = src; | ||
script.onload = resolve; | ||
document.body.append(script); | ||
}); | ||
} | ||
function runInlineScript(src) { | ||
const script = document.createElement("script"); | ||
script.innerHTML = src; | ||
document.body.append(script); | ||
} | ||
|
||
self.AsBind = AsBindIIFE; | ||
self.assert = console.assert.bind(console); | ||
mocha.setup({ | ||
ui: "bdd", | ||
reporter: "json" | ||
}); | ||
mocha.rootHooks({ | ||
async beforeEach() { | ||
// This is ugly. The Mocha Context (`this`) knows the `currentTest`, but not the *path* | ||
// of the current test suite, which we need to load the corresponding .wasm file. | ||
// So I added a bit of code that pushes the suite paths into the `suitePaths` array in the same | ||
// order as they are run. | ||
const relativeTestPath = | ||
suitePaths[ | ||
this.currentTest.parent.parent.suites.indexOf(this.currentTest.parent) | ||
]; | ||
const testPath = new URL(relativeTestPath, location.href); | ||
const wasmPath = new URL("./asc.wasm", testPath); | ||
this.rawModule = await fetch(wasmPath); | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export function exported(a: Uint8Array, b: Uint8Array): Uint8Array { | ||
const intermediate = imported(a, b); | ||
export function swapAndPad(a: Uint8Array, b: Uint8Array): Uint8Array { | ||
const intermediate = swappedConcat(a, b); | ||
const result = new Uint8Array(intermediate.length + 2); | ||
result.set(intermediate, 1); | ||
result[0] = 255; | ||
result[result.length - 1] = 255; | ||
return result; | ||
} | ||
|
||
declare function imported(a: Uint8Array, b: Uint8Array): Uint8Array; | ||
declare function swappedConcat(a: Uint8Array, b: Uint8Array): Uint8Array; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export function exported(a: string, b: string): string { | ||
return "!" + imported(a, b) + "!"; | ||
export function swapAndPad(a: string, b: string): string { | ||
return "!" + swappedConcat(a, b) + "!"; | ||
} | ||
|
||
declare function imported(a: string, b: string): string; | ||
declare function swappedConcat(a: string, b: string): string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../node_modules/assemblyscript/std/assembly.json" | ||
} |