Skip to content

Commit

Permalink
test: add test for option label
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Jan 28, 2025
1 parent c0db7c4 commit 7ad6b2e
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/ui/err/multiple-args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#[logcall::logcall("info", ok = "info")]
fn f0() {}

#[logcall::logcall("info", err = "info")]
fn f1() {}

#[logcall::logcall("info", ok = "info", err = "info")]
fn f2() {}

#[logcall::logcall("info", some = "info")]
fn f3() {}

#[logcall::logcall("info", none = "info")]
fn f4() {}

#[logcall::logcall("info", some = "info", none = "info")]
fn f5() {}

#[logcall::logcall(some = "info", ok = "info")]
fn f6() {}

#[logcall::logcall(ok = "info", some = "info")]
fn f7() {}

#[logcall::logcall(some = "info", none = "info", ok = "info", err = "info")]
fn f8() {}

#[logcall::logcall("info", some = "info", none = "info", ok = "info", err = "info")]
fn f9() {}

fn main() {}
79 changes: 79 additions & 0 deletions tests/ui/err/multiple-args.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
error: plain level cannot be specified with `ok` or `err` levels
--> tests/ui/err/multiple-args.rs:1:1
|
1 | #[logcall::logcall("info", ok = "info")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `logcall::logcall` (in Nightly builds, run with -Z macro-backtrace for more info)

error: plain level cannot be specified with `ok` or `err` levels
--> tests/ui/err/multiple-args.rs:4:1
|
4 | #[logcall::logcall("info", err = "info")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `logcall::logcall` (in Nightly builds, run with -Z macro-backtrace for more info)

error: plain level cannot be specified with `ok` or `err` levels
--> tests/ui/err/multiple-args.rs:7:1
|
7 | #[logcall::logcall("info", ok = "info", err = "info")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `logcall::logcall` (in Nightly builds, run with -Z macro-backtrace for more info)

error: plain level cannot be specified with `some` or `none` levels
--> tests/ui/err/multiple-args.rs:10:1
|
10 | #[logcall::logcall("info", some = "info")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `logcall::logcall` (in Nightly builds, run with -Z macro-backtrace for more info)

error: plain level cannot be specified with `some` or `none` levels
--> tests/ui/err/multiple-args.rs:13:1
|
13 | #[logcall::logcall("info", none = "info")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `logcall::logcall` (in Nightly builds, run with -Z macro-backtrace for more info)

error: plain level cannot be specified with `some` or `none` levels
--> tests/ui/err/multiple-args.rs:16:1
|
16 | #[logcall::logcall("info", some = "info", none = "info")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `logcall::logcall` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `some` and `none` levels cannot be specified with `ok` or `err` levels
--> tests/ui/err/multiple-args.rs:19:1
|
19 | #[logcall::logcall(some = "info", ok = "info")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `logcall::logcall` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `some` and `none` levels cannot be specified with `ok` or `err` levels
--> tests/ui/err/multiple-args.rs:22:1
|
22 | #[logcall::logcall(ok = "info", some = "info")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `logcall::logcall` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `some` and `none` levels cannot be specified with `ok` or `err` levels
--> tests/ui/err/multiple-args.rs:25:1
|
25 | #[logcall::logcall(some = "info", none = "info", ok = "info", err = "info")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `logcall::logcall` (in Nightly builds, run with -Z macro-backtrace for more info)

error: plain level cannot be specified with `ok` or `err` levels
--> tests/ui/err/multiple-args.rs:28:1
|
28 | #[logcall::logcall("info", some = "info", none = "info", ok = "info", err = "info")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `logcall::logcall` (in Nightly builds, run with -Z macro-backtrace for more info)
7 changes: 7 additions & 0 deletions tests/ui/ok/async-in-trait.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
trait MyTrait {
async fn work(&self) -> Result<usize, usize>;
async fn run(&self) -> Option<usize>;
}

struct MyStruct;
Expand All @@ -10,6 +11,12 @@ impl MyTrait for MyStruct {
async fn work(&self) -> Result<usize, usize> {
Ok(1)
}

#[logcall::logcall("debug")]
#[logcall::logcall(some = "debug", none = "error")]
async fn work(&self) -> Option<usize> {
Some(1)
}
}

fn main() {}
18 changes: 18 additions & 0 deletions tests/ui/ok/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,28 @@ async fn i(a: u32) -> Result<u32, u32> {
Ok(a)
}

#[logcall::logcall(some = "info")]
async fn j(a: u32) -> Option<u32> {
Some(a)
}

#[logcall::logcall(none = "info")]
async fn k(a: u32) -> Option<u32> {
Some(a)
}

#[logcall::logcall(some = "info", none = "info")]
async fn l(a: u32) -> Option<u32> {
Some(a)
}

#[tokio::main]
async fn main() {
f(1).await;
g(1).await.ok();
h(1).await.ok();
i(1).await.ok();
j(1).await.unwrap();
k(1).await.unwrap();
l(1).await.unwrap();
}
18 changes: 18 additions & 0 deletions tests/ui/ok/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,27 @@ fn i(a: u32) -> Result<u32, u32> {
Ok(a)
}

#[logcall::logcall(some = "info")]
fn j(a: u32) -> Option<u32> {
Some(a)
}

#[logcall::logcall(none = "info")]
fn k(a: u32) -> Option<u32> {
Some(a)
}

#[logcall::logcall(some = "info", none = "info")]
fn l(a: u32) -> Option<u32> {
Some(a)
}

fn main() {
f(1);
g(1).ok();
h(1).ok();
i(1).ok();
j(1).unwrap();
k(1).unwrap();
l(1).unwrap();
}

0 comments on commit 7ad6b2e

Please sign in to comment.