1
use conjure_cp_essence_parser::diagnostics::error_detection::semantic_errors::detect_semantic_errors;
2
use conjure_cp_essence_parser::diagnostics::error_detection::syntactic_errors::check_diagnostic;
3

            
4
#[test]
5
fn detects_keyword_as_identifier_find() {
6
    let source = "find find,b,c: int(1..3)";
7
    // using find keyword instead of identifier
8
    let diagnostics = detect_semantic_errors(source);
9

            
10
    // Should be exactly one diagnostic
11
    assert_eq!(diagnostics.len(), 1, "Expected exactly one diagnostic");
12

            
13
    let diag = &diagnostics[0];
14

            
15
    check_diagnostic(
16
        diag,
17
        0,
18
        5,
19
        0,
20
        9,
21
        "Semantic Error: Keyword 'find' used as identifier",
22
    );
23
}
24

            
25
#[test]
26
fn detects_keyword_as_identifier_letting() {
27
    let source = "find letting,b,c: int(1..3)";
28
    // using find keyword instead of identifier
29
    let diagnostics = detect_semantic_errors(source);
30

            
31
    // Should be exactly one diagnostic
32
    assert_eq!(diagnostics.len(), 1, "Expected exactly one diagnostic");
33

            
34
    let diag = &diagnostics[0];
35

            
36
    check_diagnostic(
37
        diag,
38
        0,
39
        5,
40
        0,
41
        12,
42
        "Semantic Error: Keyword 'letting' used as identifier",
43
    );
44
}
45

            
46
#[test]
47
fn detects_keyword_as_identifier_bool() {
48
    let source = "find bool: bool";
49
    // using find keyword instead of identifier
50
    let diagnostics = detect_semantic_errors(source);
51

            
52
    // Should be exactly one diagnostic
53
    assert_eq!(diagnostics.len(), 1, "Expected exactly one diagnostic");
54

            
55
    let diag = &diagnostics[0];
56

            
57
    check_diagnostic(
58
        diag,
59
        0,
60
        5,
61
        0,
62
        9,
63
        "Semantic Error: Keyword 'bool' used as identifier",
64
    );
65
}