mod common;
use proptest::prelude::*;
proptest! {
#![proptest_config(ProptestConfig::with_cases(256))]
#[test]
fn rnix_parse_never_panics_on_printable_ascii(s in "[\\x20-\\x7e]{0,200}") {
let result = std::panic::catch_unwind(|| rnix::Root::parse(&s));
prop_assert!(result.is_ok(), "rnix panicked on input: {s:?}");
}
#[test]
fn sui_eval_never_panics_on_printable_ascii(s in "[\\x20-\\x7e]{0,200}") {
let result = std::panic::catch_unwind(|| sui_eval::eval(&s));
prop_assert!(result.is_ok(), "sui_eval panicked on input: {s:?}");
}
#[test]
fn rnix_parse_never_panics_on_utf8(s in ".{0,200}") {
let result = std::panic::catch_unwind(|| rnix::Root::parse(&s));
prop_assert!(result.is_ok(), "rnix panicked on input: {s:?}");
}
#[test]
fn sui_eval_handles_grammar_fragments(
n in any::<u32>(),
s in "[a-z]{1,8}",
) {
for expr in [
format!("let {s} = {n}; in {s}"),
format!("{{ {s} = {n}; }}"),
format!("[ {n} {n} {n} ]"),
format!("({s}: {s} + {n}) {n}"),
] {
let result = std::panic::catch_unwind(|| sui_eval::eval(&expr));
prop_assert!(result.is_ok(), "sui_eval panicked on {expr:?}");
}
}
}