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
extern crate avm1_tree; #[macro_use] extern crate nom; pub use self::avm1::parse_action; mod avm1; mod basic_data_types; #[cfg(test)] mod parser_tests { use ::std::io::Read; use ::avm1_tree::Action; use ::test_generator::test_expand_paths; use super::*; test_expand_paths! { test_parse_action; "../tests/actions/*.avm1" } fn test_parse_action(path: &str) { let json_path: String = path.replace(".avm1", ".json"); let mut input_file = ::std::fs::File::open(path).unwrap(); let mut input: Vec<u8> = Vec::new(); input_file.read_to_end(&mut input).expect("Failed to read AVM1 file"); let (remaining_input, actual_action) = parse_action(&input).unwrap(); assert_eq!(remaining_input, &[] as &[u8]); let json_file = ::std::fs::File::open(json_path).unwrap(); let reader = ::std::io::BufReader::new(json_file); let expected_action: Action = serde_json::from_reader(reader).unwrap(); assert_eq!(actual_action, expected_action); } }