diff --git a/snix/Cargo.nix b/snix/Cargo.nix index 8074f37ab..d3c65be17 100644 --- a/snix/Cargo.nix +++ b/snix/Cargo.nix @@ -14281,6 +14281,7 @@ rec { { name = "pretty_assertions"; packageId = "pretty_assertions"; + features = [ "unstable" ]; } { name = "rstest"; diff --git a/snix/eval/Cargo.toml b/snix/eval/Cargo.toml index 2e41bf477..d16971332 100644 --- a/snix/eval/Cargo.toml +++ b/snix/eval/Cargo.toml @@ -41,7 +41,7 @@ thiserror.workspace = true criterion.workspace = true itertools.workspace = true mimalloc.workspace = true -pretty_assertions.workspace = true +pretty_assertions = { workspace = true, features = ["unstable"] } rstest.workspace = true tempfile.workspace = true diff --git a/snix/eval/src/tests/one_offs.rs b/snix/eval/src/tests/one_offs.rs index 49ed713fc..7550f4e7a 100644 --- a/snix/eval/src/tests/one_offs.rs +++ b/snix/eval/src/tests/one_offs.rs @@ -1,4 +1,5 @@ use crate::*; +use pretty_assertions::assert_matches; #[test] fn test_source_builtin() { @@ -37,3 +38,26 @@ fn skip_broken_bytecode() { ErrorKind::UnknownStaticVariable )); } + +/// Checks that deep forcing happens in lexicographic key order +/// See https://cl.snix.dev/c/snix/+/30309/comment/a7c9c6d5_bacf7332/ for +/// details. +#[test] +fn key_order_deep_force() { + let result = Evaluation::builder_pure().build().evaluate( + /* code = */ + r#"builtins.toXML { + c = throw "ccc"; + a = throw "aaa"; + b = throw "bbb"; + d = throw "dd"; + }"#, + None, + ); + assert_eq!(result.errors.len(), 1); + + assert_matches!( + &result.errors[0].kind, + ErrorKind::CatchableError(CatchableErrorKind::Throw(s)) if s.as_ref() == "\"aaa\"" + ); +}