| 1 |
# `wasm-bindgen-macro` |
| 2 |
|
| 3 |
Implementation of the `#[wasm_bindgen]` attribute. See the `wasm-bindgen` |
| 4 |
documentation for more information about what this macro does. |
| 5 |
|
| 6 |
## Testing |
| 7 |
|
| 8 |
Testing of this macro is done through "ui tests" in the `ui-tests` subdirectory |
| 9 |
of this crate. Each Rust file in this folder is compiled with the `wasm_bindgen` |
| 10 |
crate, and the `*.stderr` file sitting next to it is the asserted output of the |
| 11 |
compiler. If the output matches, the test passes, and if the output doesn't |
| 12 |
match the test fails. Note that it is also considered a failure if a test |
| 13 |
actually compiles successfully. |
| 14 |
|
| 15 |
To add a test: |
| 16 |
|
| 17 |
* Create `ui-tests/my-awesome-test.rs` |
| 18 |
* Write an invalid `#[wasm_bindgen]` invocation, testing the error you're |
| 19 |
generating |
| 20 |
* Execute `cargo test -p ui-tests`, the test will fail |
| 21 |
* From within the `ui-tests` folder, execute `./update-all-references.sh`. This |
| 22 |
should create a `my-awesome-test.stderr` file. |
| 23 |
* Inspect `my-awesome-test.stderr` to make sure it looks ok |
| 24 |
* Rerun `cargo test -p ui-tests` and your tests should pass! |
| 25 |
|
| 26 |
Testing here is a work in progress, see |
| 27 |
[#601](https://github.com/rustwasm/wasm-bindgen/issues/601) for more |
| 28 |
information. |