-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UI test for missing argument in args_into (#145)
This commit introduces a compile error when using missing argument in `args_into`. Here's an example: ```rust #[swift_bridge::bridge] mod ffi { extern "Rust" { #[swift_bridge(args_into = (arg, arg_typo))] fn some_function(arg: u8); } } ``` ``` error: arg_typo: Unknown argument Could not find "arg_typo" in "fn some_function(arg : u8)". --> tests/ui/args-into-argument-not-found.rs:7:42 | 7 | #[swift_bridge(args_into = (arg, arg_typo))] | ^^^^^^^^ ```
- Loading branch information
Showing
4 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
crates/swift-bridge-macro/tests/ui/args-into-argument-not-found.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//! # To Run | ||
//! cargo test -p swift-bridge-macro -- ui trybuild=args-into-argument-not-found.rs | ||
#[swift_bridge::bridge] | ||
mod ffi { | ||
extern "Rust" { | ||
#[swift_bridge(args_into = (arg, arg_typo))] | ||
fn some_function(arg: u8); | ||
} | ||
extern "Rust" { | ||
type SomeType; | ||
|
||
#[swift_bridge(args_into = (foo, bar))] | ||
fn some_method(&self, foo: u8); | ||
} | ||
} | ||
|
||
fn some_function(arg: u8){ | ||
|
||
} | ||
|
||
struct SomeType; | ||
|
||
impl SomeType { | ||
fn some_method(&self, foo: u8){ | ||
|
||
} | ||
} | ||
|
||
fn main() { | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
crates/swift-bridge-macro/tests/ui/args-into-argument-not-found.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: Argument "arg_typo" was not found in the "fn some_function(..)" | ||
--> tests/ui/args-into-argument-not-found.rs:7:42 | ||
| | ||
7 | #[swift_bridge(args_into = (arg, arg_typo))] | ||
| ^^^^^^^^ | ||
|
||
error: Argument "bar" was not found in the "fn some_method(..)" | ||
--> tests/ui/args-into-argument-not-found.rs:13:42 | ||
| | ||
13 | #[swift_bridge(args_into = (foo, bar))] | ||
| ^^^ |