diff --git a/.github/workflows/corewa_rs-ci.yml b/.github/workflows/corewa_rs-ci.yml index 50e6724f..42d62e53 100644 --- a/.github/workflows/corewa_rs-ci.yml +++ b/.github/workflows/corewa_rs-ci.yml @@ -57,4 +57,4 @@ jobs: with: toolchain: ${{ matrix.toolchain }} - name: Build and run tests - run: cargo test --color=always --workspace --all-targets --all-features + run: cargo test --color=always --workspace --all-features diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d1358665..316b6374 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -43,7 +43,6 @@ "command": "test", "args": [ "--all-features", - "--all-targets", "--workspace" ], "group": { diff --git a/corewa_rs/src/testutil.rs b/corewa_rs/src/testutil.rs index 4dcf71c2..2110bbc1 100644 --- a/corewa_rs/src/testutil.rs +++ b/corewa_rs/src/testutil.rs @@ -1,37 +1,33 @@ pub use predicates; pub use predicates_tree; -/// Simple macro to panic with a prettier error message +/// Simple macro to make assertions with a better error message. /// /// # Examples /// /// ``` -/// use predicates::prelude::*; -/// use testutil::assert_that; +/// extern crate corewa_rs; +/// use corewa_rs::assert_that; /// -/// assert_that!( -/// "Hello World", -/// str::similar("Hello World"), -/// ); +/// assert_that!("Hello World", str::similar("Hello World")); /// +/// assert_that!("Hello World", str::diff("Goodbye World")); +/// +/// // Can be used with more complex predicates /// assert_that!( -/// "Hello World", -/// str::diff("Goodbye World"), +/// &1234, +/// ge(-5).and(le(i16::MAX)) /// ); -/// -/// assert_that!("Hello World", eq("Goodbye World")); /// ``` #[macro_export] macro_rules! assert_that { - ( - $value:expr, - $($pred:tt)+ ( $args:tt ) $(,)? - ) => {{ - use predicate::*; + ($value:expr, $pred:expr $(,)?) => {{ use $crate::predicates::prelude::*; use $crate::predicates_tree::CaseTreeExt; - if let Some(case) = $($pred)+ rgo ($args).find_case(false, $value) { + use predicate::*; + + if let Some(case) = $pred.find_case(false, $value) { panic!("{}", case.tree()); }; }}; diff --git a/corewa_rs/tests/dump_test.rs b/corewa_rs/tests/dump_test.rs index c7e3bd30..ce402d29 100644 --- a/corewa_rs/tests/dump_test.rs +++ b/corewa_rs/tests/dump_test.rs @@ -12,7 +12,7 @@ fn run_test(input: &str, expected_output: &'static str) { .resolve() .unwrap_or_else(|e| panic!("{}", e)); - assert_that!(&parsed_core.to_string(), str::similar(expected_output),); + assert_that!(&parsed_core.to_string(), str::similar(expected_output)); } #[test]