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
1
fn detects_keyword_as_identifier_find() {
6
1
    let source = "find find,b,c: int(1..3)";
7
    // using find keyword instead of identifier
8
1
    let diagnostics = detect_semantic_errors(source);
9

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

            
13
1
    let diag = &diagnostics[0];
14

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

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

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

            
34
1
    let diag = &diagnostics[0];
35

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

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

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

            
55
1
    let diag = &diagnostics[0];
56

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