-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support top-level resources (#525)
- Loading branch information
1 parent
9e784e2
commit dc01f95
Showing
7 changed files
with
126 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
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
Binary file not shown.
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,57 @@ | ||
// Flags: --map testwasi=../helpers.js --map r=../resource_borrow_simple.js#R test=../resource_borrow_simple.js#test | ||
|
||
// @ts-nocheck | ||
import * as assert from "assert"; | ||
|
||
/* | ||
WIT definition (for reference): | ||
package root:component; | ||
world root { | ||
import wasi:cli/[email protected]; | ||
import wasi:cli/[email protected]; | ||
import wasi:io/[email protected]; | ||
import wasi:io/[email protected]; | ||
import wasi:cli/[email protected]; | ||
import wasi:cli/[email protected]; | ||
import wasi:cli/[email protected]; | ||
import wasi:clocks/[email protected]; | ||
import wasi:filesystem/[email protected]; | ||
import wasi:filesystem/[email protected]; | ||
import test: func(r: borrow<r>); | ||
resource r { | ||
constructor(); | ||
} | ||
export test-imports: func(); | ||
} | ||
*/ | ||
|
||
// Imports | ||
let constructed = false; | ||
export class R { | ||
constructor() { | ||
constructed = true; | ||
} | ||
} | ||
|
||
let tested = false; | ||
export function test(r) { | ||
assert.ok(r instanceof R); | ||
tested = true; | ||
} | ||
|
||
export async function run() { | ||
const wasm = await import( | ||
"../output/resource_borrow_simple/resource_borrow_simple.js" | ||
); | ||
|
||
wasm.testImports(); | ||
assert.ok(constructed); | ||
assert.ok(tested); | ||
} | ||
|
||
// TLA cycle avoidance | ||
setTimeout(run); |
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