Lines
100 %
Functions
use conjure_cp_essence_parser::diagnostics::error_detection::syntactic_errors::{
check_diagnostic, detect_syntactic_errors,
};
#[test]
fn missing_identifier() {
let source = "find: bool";
let diagnostics = detect_syntactic_errors(source);
assert_eq!(diagnostics.len(), 1, "Expected exactly one diagnostic");
let diag = &diagnostics[0];
check_diagnostic(diag, 0, 4, 0, 4, "Missing Variable List");
}
fn missing_colon() {
let source = "find x bool";
// Should be exactly one diagnostic
check_diagnostic(diag, 0, 6, 0, 6, "Missing :");
fn missing_domain() {
// not indented because have to avoid leading spaces for accurate character counr
let source = "\
find x: bool
find y:
";
check_diagnostic(diag, 1, 7, 1, 7, "Missing Domain");
fn missing_contraint() {
such that
check_diagnostic(diag, 1, 9, 1, 9, "Missing Expression");
fn multiple_missing_tokens() {
find x: int(1..3
letting x be
assert_eq!(diagnostics.len(), 2, "Expected two diagnostics");
let diag1 = &diagnostics[0];
let diag2 = &diagnostics[1];
check_diagnostic(diag1, 0, 16, 0, 16, "Missing )");
check_diagnostic(diag2, 1, 12, 1, 12, "Missing Expression or Domain");