diff --git a/README.md b/README.md index 8623181..93c84bd 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,13 @@ Expression examples look like this: ````md ```nix -assert 1 + 1 == 2; null +let n = 1 + 1; in assert n == 2; n ``` ```` They are nix expressions inside of fenced code blocks. The first word in their info string is `nix`. The expression is passed to Nix for evaluation as `nix eval --expr `. -For future compatibility, to be considered passing, -it must successfully evaluate into `null`. It is expected of the author to demonstrate and prove their points using assertions. diff --git a/src/app/state.rs b/src/app/state.rs index 0e079fa..c645dc5 100644 --- a/src/app/state.rs +++ b/src/app/state.rs @@ -2,7 +2,6 @@ pub(crate) mod expression_state; pub(crate) mod repl_state; use anyhow::bail; -use indoc::formatdoc; use crate::{ example_id::ExampleId, @@ -269,19 +268,6 @@ impl State { bail!("{example_id}\n{stderr}") } - if expression_output.stdout != b"null\n" { - let stdout = String::from_utf8_lossy(&expression_output.stdout); - let stdout = stdout.trim_end(); - - let message = formatdoc! {" - {example_id} - evaluated into non-null - note: examples must evaluate into null - value: {stdout}"}; - - bail!("{message}"); - } - self.examples.remove(&example_id)?; Ok(vec![self.eprintln(Self::fmt_pass(&example_id))]) diff --git a/tests/expression.rs b/tests/expression.rs index 32ddaa2..64c5519 100644 --- a/tests/expression.rs +++ b/tests/expression.rs @@ -1,7 +1,7 @@ mod util; use assert_fs::fixture::FileWriteStr; -use indoc::{formatdoc, indoc}; +use indoc::indoc; use predicates::{ prelude::PredicateBooleanExt, str::{contains, starts_with}, @@ -27,42 +27,25 @@ fn assertion_fail() { } #[test] -fn fail_non_null() { +fn pass() { with_eelco(|file, eelco| { file.write_str(indoc! {" ```nix - 0 + null ``` - "}) - .unwrap(); - - let file_path = file.path().to_str().unwrap(); - - eelco.assert().failure().stderr(formatdoc! {" - Error: {file_path}:1 - evaluated into non-null - note: examples must evaluate into null - value: 0 - "}); - }); -} -#[test] -fn pass() { - with_eelco(|file, eelco| { - file.write_str(indoc! {" ```nix - null + 0 ``` "}) .unwrap(); let file_path = file.path().to_str().unwrap(); - eelco - .assert() - .success() - .stderr(format!("PASS: {file_path}:1\n")); + eelco.assert().success().stderr( + predicates::str::contains(format!("PASS: {file_path}:1\n")) + .and(predicates::str::contains(format!("PASS: {file_path}:5\n"))), + ); }); }