Skip to content

Commit

Permalink
use fully qualified names in wasm_bindgen_test for items exported f…
Browse files Browse the repository at this point in the history
…rom std prelude (#3549)

* add `#![no_implicit_prelude]` to `test-macro/ui-tests`

* prefix `Some` and `None` with `::core::option::Option`

* fix `test-macro/ui-tests/should_panic.stderr` line numbers

---------

Co-authored-by: Harry Barber <harrybarber@protonmail.com>
  • Loading branch information
hlbarber and hlbarber committed Aug 7, 2023
1 parent cd04b27 commit eb36f9d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
8 changes: 5 additions & 3 deletions crates/test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ pub fn wasm_bindgen_test(
let mut tokens = Vec::<TokenTree>::new();

let should_panic = match should_panic {
Some(Some(lit)) => quote! { Some(Some(#lit)) },
Some(None) => quote! { Some(None) },
None => quote! { None },
Some(Some(lit)) => {
quote! { ::core::option::Option::Some(::core::option::Option::Some(#lit)) }
}
Some(None) => quote! { ::core::option::Option::Some(::core::option::Option::None) },
None => quote! { ::core::option::Option::None },
};

let test_body = if r#async {
Expand Down
4 changes: 4 additions & 0 deletions crates/test-macro/ui-tests/should_panic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#![no_implicit_prelude]

extern crate wasm_bindgen_test_macro;

use wasm_bindgen_test_macro::wasm_bindgen_test;

#[wasm_bindgen_test]
Expand Down
40 changes: 20 additions & 20 deletions crates/test-macro/ui-tests/should_panic.stderr
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
error: malformed `#[should_panic = "..."]` attribute
--> ui-tests/should_panic.rs:28:15
--> ui-tests/should_panic.rs:32:15
|
28 | #[should_panic::error]
32 | #[should_panic::error]
| ^

error: malformed `#[should_panic]` attribute
--> ui-tests/should_panic.rs:32:18
--> ui-tests/should_panic.rs:36:18
|
32 | #[should_panic = 42]
36 | #[should_panic = 42]
| ^^

error: malformed `#[should_panic = "..."]` attribute
--> ui-tests/should_panic.rs:36:15
--> ui-tests/should_panic.rs:40:15
|
36 | #[should_panic[]]
40 | #[should_panic[]]
| ^^

error: malformed `#[should_panic(...)]` attribute
--> ui-tests/should_panic.rs:40:15
--> ui-tests/should_panic.rs:44:15
|
40 | #[should_panic(42)]
44 | #[should_panic(42)]
| ^^^^

error: malformed `#[should_panic(...)]` attribute
--> ui-tests/should_panic.rs:44:15
--> ui-tests/should_panic.rs:48:15
|
44 | #[should_panic(test)]
48 | #[should_panic(test)]
| ^^^^^^

error: malformed `#[should_panic(...)]` attribute
--> ui-tests/should_panic.rs:48:15
--> ui-tests/should_panic.rs:52:15
|
48 | #[should_panic(expected)]
52 | #[should_panic(expected)]
| ^^^^^^^^^^

error: malformed `#[should_panic(...)]` attribute
--> ui-tests/should_panic.rs:52:15
--> ui-tests/should_panic.rs:56:15
|
52 | #[should_panic(expected::error)]
56 | #[should_panic(expected::error)]
| ^^^^^^^^^^^^^^^^^

error: malformed `#[should_panic]` attribute
--> ui-tests/should_panic.rs:56:3
--> ui-tests/should_panic.rs:60:3
|
56 | #[should_panic(expected =)]
60 | #[should_panic(expected =)]
| ^^^^^^^^^^^^

error: malformed `#[should_panic]` attribute
--> ui-tests/should_panic.rs:60:27
--> ui-tests/should_panic.rs:64:27
|
60 | #[should_panic(expected = 5)]
64 | #[should_panic(expected = 5)]
| ^

error: duplicate `should_panic` attribute
--> ui-tests/should_panic.rs:65:3
--> ui-tests/should_panic.rs:69:3
|
65 | #[should_panic = "test"]
69 | #[should_panic = "test"]
| ^^^^^^^^^^^^

0 comments on commit eb36f9d

Please sign in to comment.