1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use super::ParseTest;
// TODO: clean up this test file
// IDENTIFIERS
// ================================================================================================
#[test]
fn error_invalid_int() {
let num: u128 = u64::MAX as u128 + 1;
let source = format!(
r#"
def test
trace_columns {{
main: [clk],
}}
integrity_constraints {{
enf clk' = clk + {num}
}}
"#,
);
// Integers can only be of type u64.
ParseTest::new().expect_program_diagnostic(&source, "value is too big");
}
// UNRECOGNIZED TOKEN ERRORS
// ================================================================================================
#[test]
fn error_constraint_without_section() {
// Constraints outside of valid sections are not allowed.
let source = r#"
def test
enf clk' = clk + 1
"#;
ParseTest::new().expect_unrecognized_token(source);
}
#[test]
fn error_identifier_starting_with_int() {
// Identifiers cannot start with numeric characters.
// lexer considers the integer 1 and alphabetic clk' to be separate tokens
// hence this fails at parser level since a valid identifier is expected
// at that position which 1 is not.
let source = r#"
def test
trace_columns {
main: [clk]
}
integrity_constraints {
enf 1clk' = clk + 1
}
"#;
ParseTest::new().expect_unrecognized_token(source);
}