blob: 8d3f928f42c6a1c8af713414fc072a52d3b7b037 (
plain)
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
|
pub mod modelica_parser;
pub mod modelica_ast;
#[test]
fn test_lexical() {
assert_eq!(&format!("{:?}", modelica_parser::parse_integer("+123").unwrap()),
"123");
assert_eq!(&format!("{:?}", modelica_parser::parse_integer("-9").unwrap()),
"-9");
assert_eq!(&format!("{:?}", modelica_parser::parse_float("-1.0e0").unwrap()),
"-1");
assert_eq!(&format!("{:?}", modelica_parser::parse_float("123.456").unwrap()),
"123.456");
}
#[test]
fn test_parse() {
let example1 =
r#"model MinimalModel
Real x;
equation
x = 1;
end MinimalModel;
"#;
assert_eq!(&format!("{:?}", modelica_parser::parse_model(example1).unwrap()), example1);
let example2 =
r#"model MinimalModel
parameter Real a;
Real b;
equation
connect(a, b);
a = 1;
b = ((abs(a) + 2) / 4);
end MinimalModel;
"#;
assert_eq!(&format!("{:?}", modelica_parser::parse_model(example2).unwrap()), example2);
}
|