Lines
100 %
Functions
25 %
use conjure_cp_essence_parser::diagnostics::diagnostics_api::get_diagnostics;
use conjure_cp_essence_parser::diagnostics::error_detection::collect_errors::check_diagnostic;
#[test]
fn invalid_top_level_statement_expression() {
let source = " a,a,b: int(1..3)";
let diags = get_diagnostics(source);
assert_eq!(
diags.len(),
1,
"Expected a valid top-level statement, but got 'a,a,b: int(1..3)'"
);
let diag = &diags[0];
check_diagnostic(
diag,
0,
17,
"Expected a valid top-level statement, but got '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 = get_diagnostics(source);
assert_eq!(diagnostics.len(), 1, "Expected exactly one diagnostic");
let diag = &diagnostics[0];
25,
"Expected a find declaration statement, but got 'find >=lex,b,c: int(1..3)'",
fn malformed_find_3() {
let source = "find +,a,b: int(1..3)";
assert_eq!(diags.len(), 1, "Expected exactly one diagnostic");
21,
"Expected a find declaration statement, but got '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
"Expected a find declaration statement, but got 'find :,b,c: int(1..3)'",
fn missing_colon_domain_in_find_statement_1st_line() {
let source = "find x";
6,
"Expected a find declaration statement, but got 'find x'",
fn missing_colon_domain_in_find_statement_2nd_line() {
let source = "find x: int(1..3)\nfind x";
fn unexpected_print_2nd_line() {
let source = "find a,b,c: int(1..3)\nprint a";
7,
"Expected a valid top-level statement, but got 'print a'",