Skip to content

Commit 6bbfaf5

Browse files
committed
test(test2): Add more tests for attribute macros
These tests aim to specifically test that the macros accept various edge cases that a user might expect us to support. This includes: - No parameters - Return result (with and without context as a parameter) - Include context as a parameter, but ignore it - Include context as a parameter and pattern match on it
1 parent 56e39d2 commit 6bbfaf5

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

crates/libtest2/tests/testsuite/macros.rs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@ mod some_module {
1616
#[libtest2::test]
1717
fn foo(_context: &libtest2::TestContext) {}
1818
}
19+
20+
#[libtest2::test]
21+
fn takes_context(_context: &libtest2::TestContext) {}
22+
23+
#[libtest2::test]
24+
fn no_parameters() {}
25+
26+
#[libtest2::test]
27+
fn takes_context_return_result(_context: &libtest2::TestContext) -> libtest2::RunResult {
28+
Ok(())
29+
}
30+
31+
#[libtest2::test]
32+
fn no_parameters_return_result() -> libtest2::RunResult {
33+
Ok(())
34+
}
35+
36+
#[libtest2::test]
37+
fn ignored_context(_: &libtest2::TestContext) {}
38+
39+
#[libtest2::test]
40+
fn context_as_pattern(libtest2::TestContext { .. }: &libtest2::TestContext) {}
1941
"#,
2042
false,
2143
);
@@ -29,11 +51,17 @@ mod some_module {
2951
fn check() {
3052
let data = str![[r#"
3153
32-
running 2 tests
33-
test foo ... ok
34-
test some_module::foo ... ok
54+
running 8 tests
55+
test context_as_pattern ... ok
56+
test foo ... ok
57+
test ignored_context ... ok
58+
test no_parameters ... ok
59+
test no_parameters_return_result ... ok
60+
test some_module::foo ... ok
61+
test takes_context ... ok
62+
test takes_context_return_result ... ok
3563
36-
test result: ok. 2 passed; 0 failed; 0 ignored; 0 filtered out; finished in [..]s
64+
test result: ok. 8 passed; 0 failed; 0 ignored; 0 filtered out; finished in [..]s
3765
3866
3967
"#]];

0 commit comments

Comments
 (0)