1
1
mirror of https://github.com/tweag/nickel.git synced 2024-11-10 10:46:49 +03:00

Fix tests

This commit is contained in:
Yann Hamdaoui 2021-02-19 14:10:12 +01:00
parent d5d20d2760
commit b3ab2bfa9d
3 changed files with 10 additions and 9 deletions

View File

@ -177,11 +177,11 @@ fn record_terms() {
);
assert_eq!(
parse_without_pos("{ a = 1; $123 = (if 4 then 5 else 6); d = 42;}"),
parse_without_pos("{ a = 1; \"#{123}\" = (if 4 then 5 else 6); d = 42;}"),
mk_app!(
mk_term::op2(
BinaryOp::DynExtend(),
Num(123.),
StrChunks(vec![StrChunk::expr(RichTerm::from(Num(123.)))]),
RecRecord(
vec![
(Ident::from("a"), Num(1.).into()),

View File

@ -501,23 +501,23 @@ Assume(#alwaysTrue, false)
);
assert_eq!(
eval_string("({ $(if true then \"foo\" else \"bar\") = false; bar = true; }).foo"),
eval_string("({ \"#{if true then \"foo\" else \"bar\"}\" = false; bar = true; }).foo"),
Ok(Term::Bool(false)),
);
assert_eq!(
eval_string("({ foo = 3; bar = true; }).$(\"bar\")"),
eval_string("({ foo = 3; bar = true; }).\"bar\""),
Ok(Term::Bool(true)),
);
assert_eq!(
eval_string(
"({ $(if true then \"foo\" else \"bar\") = false; bar = true; }).$(\"foo\")"
"({ \"#{if true then \"foo\" else \"bar\"}\" = false; bar = true; }).\"foo\""
),
Ok(Term::Bool(false)),
);
eval_string("({ $(if false then \"foo\" else \"bar\") = false; bar = true; }).foo")
eval_string("({ \"#{if false then \"foo\" else \"bar\"}\" = false; bar = true; }).foo")
.unwrap_err();
}

View File

@ -2201,13 +2201,14 @@ mod tests {
#[test]
fn dynamic_record_simple() {
parse_and_typecheck("{ $(if true then \"foo\" else \"bar\") = 2; } : {_ : Num}").unwrap();
parse_and_typecheck("{ \"#{if true then \"foo\" else \"bar\"}\" = 2; } : {_ : Num}")
.unwrap();
parse_and_typecheck("({ $(if true then \"foo\" else \"bar\") = 2; }.$(\"bla\")) : Num")
parse_and_typecheck("({ \"#{if true then \"foo\" else \"bar\"}\" = 2; }.\"bla\") : Num")
.unwrap();
parse_and_typecheck(
"({ $(if true then \"foo\" else \"bar\") = 2; $(\"foo\") = true; }.$(\"bla\")) : Num",
"({ \"#{if true then \"foo\" else \"bar\"}\" = 2; \"foo\" = true; }.\"bla\") : Num",
)
.unwrap_err();