aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/tests/examples.rs.WIP
blob: a206ac6a61f01b61c143389f7514e4e269888260 (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

extern crate modelica_parser;

use std::io::Read;
use std::fs::{File, read_dir};
use std::path::Path;
use modelica_parser::parser::parse_model;

fn do_file(p: &Path) {
    let mut s = String::new();
    File::open(p).and_then(|mut f| f.read_to_string(&mut s)).unwrap();
    modelica_parser::parser::parse_model(&s).unwrap();
}

#[test]
fn test_example_files() {

    let files: Vec<&Path> = read_dir(Path::new("./examples/modelica_models/"))
        .unwrap()
        .map(|x| x.unwrap())
        .filter(|x| x.metadata().unwrap().is_file())
        .filter(|x| x.path().suffix().equals(".mo"))
        .map(|x| x.path())
        .collect();

    for p in &files {
        do_file(p);
    }
}