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 b8b1363
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crates/macro/ui-tests/link-to.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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
)
}

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

error: `link_to!` requires a module.
--> $DIR/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
--> $DIR/link-to.rs:20:9
|
20 | js_namespace = foo
| ^^^^^^^^^^^^

0 comments on commit b8b1363

Please sign in to comment.