Lines
0 %
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 'COLON'");
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 'bool_expr'");
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'");
fn missing_domain_in_tuple_domain() {
let source = "find x: tuple()";
check_diagnostic(diag, 0, 14, 0, 14, "Missing 'domain'");
fn missing_operator_in_comparison() {
// Missing operator in comparison expression
find x: int
such that 5 =
check_diagnostic(
diag,
1,
13,
"Missing right operand in 'comparison' expression",
);
fn missing_right_operand_in_and_expr() {
such that x /\\
14,
"Missing right operand in 'and' expression",