Lines
100 %
Functions
use conjure_cp_essence_parser::diagnostics::error_detection::syntactic_errors::{
check_diagnostic, detect_syntactic_errors,
};
#[test]
fn invalid_top_level_statement_expression() {
let source = " a,a,b: int(1..3)";
let diags = detect_syntactic_errors(source);
assert_eq!(diags.len(), 1, "Expected exactly one diagnostic");
let diag = &diags[0];
check_diagnostic(diag, 0, 0, 0, 17, "Malformed line 1: ' a,a,b: int(1..3)'");
}
fn malformed_find_2() {
let source = "find >=lex,b,c: int(1..3)";
// using >=lex operator instead of identifier
let diagnostics = detect_syntactic_errors(source);
assert_eq!(diagnostics.len(), 1, "Expected exactly one diagnostic");
let diag = &diagnostics[0];
check_diagnostic(
diag,
0,
25,
"Malformed line 1: 'find >=lex,b,c: int(1..3)'",
);
fn malformed_find_3() {
let source = "find +,a,b: int(1..3)";
21,
"Malformed line 1: 'find +,a,b: int(1..3)'",
fn unexpected_colon_used_as_identifier() {
let source = "find :,b,c: int(1..3)";
// Should be exactly one diagnostic
"Malformed line 1: 'find :,b,c: int(1..3)'",
fn missing_colon_domain_in_find_statement_1st_line() {
let source = "find x";
check_diagnostic(diag, 0, 0, 0, 6, "Malformed line 1: 'find x'");
fn missing_colon_domain_in_find_statement_2nd_line() {
let source = "find x: int(1..3)\nfind x";
check_diagnostic(diag, 1, 0, 1, 6, "Malformed line 2: 'find x'");
fn unexpected_print_2nd_line() {
let source = "find a,b,c: int(1..3)\nprint a";
check_diagnostic(diag, 1, 0, 1, 7, "Malformed line 2: 'print a'");