Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslihotzki committed Sep 24, 2022
1 parent 18bf892 commit 64b65fc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
22 changes: 22 additions & 0 deletions crates/macro/ui-tests/link-to.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
fn good1() -> String {
wasm_bindgen::link_to!(inline_js = "console.log('Hello world!');")
}

fn good2() -> String {
wasm_bindgen::link_to!(raw_module = "package/foo.js")
}

fn bad1() -> String {
wasm_bindgen::link_to!(module = "/src/not-found.js")
}

fn bad2() -> String {
wasm_bindgen::link_to!()
}

fn bad3() -> String {
wasm_bindgen::link_to!(
inline_js = "console.log('Hello world!');",
js_namespace = foo
)
}
25 changes: 25 additions & 0 deletions crates/macro/ui-tests/link-to.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error: failed to read file `$WORKSPACE/target/tests/wasm-bindgen-macro/src/not-found.js`: No such file or directory (os error 2)
--> ui-tests/link-to.rs:10:37
|
10 | wasm_bindgen::link_to!(module = "/src/not-found.js")
| ^^^^^^^^^^^^^^^^^^^

error: `link_to!` requires a module.
--> ui-tests/link-to.rs:14:5
|
14 | wasm_bindgen::link_to!()
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `wasm_bindgen::link_to` (in Nightly builds, run with -Z macro-backtrace for more info)

error: unused #[wasm_bindgen] attribute
--> ui-tests/link-to.rs:20:9
|
20 | js_namespace = foo
| ^^^^^^^^^^^^

error[E0601]: `main` function not found in crate `$CRATE`
--> ui-tests/link-to.rs:22:2
|
22 | }
| ^ consider adding a `main` function to `$DIR/ui-tests/link-to.rs`

0 comments on commit 64b65fc

Please sign in to comment.