Skip to content

Commit ec73de0

Browse files
Make assert_that a little more ergonomico
Stop testing with `--all-targets` to ensure doctests run (seems like rust-lang/cargo#5178 might still exist).
1 parent dae9d3f commit ec73de0

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

.github/workflows/corewa_rs-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ jobs:
5757
with:
5858
toolchain: ${{ matrix.toolchain }}
5959
- name: Build and run tests
60-
run: cargo test --color=always --workspace --all-targets --all-features
60+
run: cargo test --color=always --workspace --all-features

.vscode/tasks.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"command": "test",
4444
"args": [
4545
"--all-features",
46-
"--all-targets",
4746
"--workspace"
4847
],
4948
"group": {

corewa_rs/src/testutil.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
11
pub use predicates;
22
pub use predicates_tree;
33

4-
/// Simple macro to panic with a prettier error message
4+
/// Simple macro to make assertions with a better error message.
55
///
66
/// # Examples
77
///
88
/// ```
9-
/// use predicates::prelude::*;
10-
/// use testutil::assert_that;
9+
/// extern crate corewa_rs;
10+
/// use corewa_rs::assert_that;
1111
///
12-
/// assert_that!(
13-
/// "Hello World",
14-
/// str::similar("Hello World"),
15-
/// );
12+
/// assert_that!("Hello World", str::similar("Hello World"));
1613
///
14+
/// assert_that!("Hello World", str::diff("Goodbye World"));
15+
///
16+
/// // Can be used with more complex predicates
1717
/// assert_that!(
18-
/// "Hello World",
19-
/// str::diff("Goodbye World"),
18+
/// &1234,
19+
/// ge(-5).and(le(i16::MAX))
2020
/// );
21-
///
22-
/// assert_that!("Hello World", eq("Goodbye World"));
2321
/// ```
2422
#[macro_export]
2523
macro_rules! assert_that {
26-
(
27-
$value:expr,
28-
$($pred:tt)+ ( $args:tt ) $(,)?
29-
) => {{
30-
use predicate::*;
24+
($value:expr, $pred:expr $(,)?) => {{
3125
use $crate::predicates::prelude::*;
3226
use $crate::predicates_tree::CaseTreeExt;
3327

34-
if let Some(case) = $($pred)+ rgo ($args).find_case(false, $value) {
28+
use predicate::*;
29+
30+
if let Some(case) = $pred.find_case(false, $value) {
3531
panic!("{}", case.tree());
3632
};
3733
}};

corewa_rs/tests/dump_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn run_test(input: &str, expected_output: &'static str) {
1212
.resolve()
1313
.unwrap_or_else(|e| panic!("{}", e));
1414

15-
assert_that!(&parsed_core.to_string(), str::similar(expected_output),);
15+
assert_that!(&parsed_core.to_string(), str::similar(expected_output));
1616
}
1717

1818
#[test]

0 commit comments

Comments
 (0)