1
1
mirror of https://github.com/tweag/nickel.git synced 2024-10-04 23:27:15 +03:00
nickel/tests/infinite_rec.rs
2022-03-06 22:27:57 +01:00

25 lines
701 B
Rust

use assert_matches::assert_matches;
use nickel_lang::error::{Error, EvalError};
use nickel_lang_utilities::eval;
#[test]
fn infinite_loops() {
assert_matches!(
eval("{x = x}.x"),
Err(Error::EvalError(EvalError::InfiniteRecursion(..)))
);
assert_matches!(
eval("{x = y, y = z, z = x }.x"),
Err(Error::EvalError(EvalError::InfiniteRecursion(..)))
);
assert_matches!(
eval("{x = y + z, y = z + x, z = 1}.x"),
Err(Error::EvalError(EvalError::InfiniteRecursion(..)))
);
assert_matches!(
eval("{x = (fun a => a + y) 0, y = (fun a => a + x) 0}.x"),
Err(Error::EvalError(EvalError::InfiniteRecursion(..)))
);
}