test(eval): add test for deep force key order
This tests deep forcing happens in lexicographic key order, by comparing the returned error from the evaluator. It's not possible to observe this from inside nixlang, which is why we use one_offs.rs here. Change-Id: I73085addca3a4df20bc23f9fced458758af5b391 Reviewed-on: https://cl.snix.dev/c/snix/+/30488 Reviewed-by: Bence Nemes <nemes.bence1@gmail.com> Tested-by: besadii Autosubmit: Florian Klink <flokli@flokli.de>
This commit is contained in:
parent
e97cf628a3
commit
bbc1efdb0e
3 changed files with 26 additions and 1 deletions
|
|
@ -14281,6 +14281,7 @@ rec {
|
|||
{
|
||||
name = "pretty_assertions";
|
||||
packageId = "pretty_assertions";
|
||||
features = [ "unstable" ];
|
||||
}
|
||||
{
|
||||
name = "rstest";
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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\""
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue