Skip to content

Commit 64b65fc

Browse files
committed
Add tests
1 parent 18bf892 commit 64b65fc

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

crates/macro/ui-tests/link-to.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fn good1() -> String {
2+
wasm_bindgen::link_to!(inline_js = "console.log('Hello world!');")
3+
}
4+
5+
fn good2() -> String {
6+
wasm_bindgen::link_to!(raw_module = "package/foo.js")
7+
}
8+
9+
fn bad1() -> String {
10+
wasm_bindgen::link_to!(module = "/src/not-found.js")
11+
}
12+
13+
fn bad2() -> String {
14+
wasm_bindgen::link_to!()
15+
}
16+
17+
fn bad3() -> String {
18+
wasm_bindgen::link_to!(
19+
inline_js = "console.log('Hello world!');",
20+
js_namespace = foo
21+
)
22+
}

crates/macro/ui-tests/link-to.stderr

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: failed to read file `$WORKSPACE/target/tests/wasm-bindgen-macro/src/not-found.js`: No such file or directory (os error 2)
2+
--> ui-tests/link-to.rs:10:37
3+
|
4+
10 | wasm_bindgen::link_to!(module = "/src/not-found.js")
5+
| ^^^^^^^^^^^^^^^^^^^
6+
7+
error: `link_to!` requires a module.
8+
--> ui-tests/link-to.rs:14:5
9+
|
10+
14 | wasm_bindgen::link_to!()
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^
12+
|
13+
= note: this error originates in the macro `wasm_bindgen::link_to` (in Nightly builds, run with -Z macro-backtrace for more info)
14+
15+
error: unused #[wasm_bindgen] attribute
16+
--> ui-tests/link-to.rs:20:9
17+
|
18+
20 | js_namespace = foo
19+
| ^^^^^^^^^^^^
20+
21+
error[E0601]: `main` function not found in crate `$CRATE`
22+
--> ui-tests/link-to.rs:22:2
23+
|
24+
22 | }
25+
| ^ consider adding a `main` function to `$DIR/ui-tests/link-to.rs`

0 commit comments

Comments
 (0)