test_program_parse.rs
1 // Copyright (c) 2019-2025 Alpha-Delta Network Inc. 2 // This file is part of the deltavm library. 3 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at: 7 8 // http://www.apache.org/licenses/LICENSE-2.0 9 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 mod utilities; 17 use utilities::*; 18 19 use deltavm_console::network::prelude::*; 20 use deltavm_synthesizer::program::Program; 21 22 use rayon::prelude::*; 23 24 #[test] 25 fn test_program_parse() { 26 // Load the tests. 27 let tests = load_tests::<_, FileParseTest>("./tests/parser/program", "./expectations/parser/program"); 28 // Run each test and compare it against its corresponding expectation. 29 tests.par_iter().for_each(|test| { 30 // Run the parser on the test string. 31 let test_string = test.test_string(); 32 let output = match Program::<CurrentNetwork>::from_str(test_string) { 33 Ok(_) => "Program was successfully parsed.".to_string(), 34 Err(e) => e.to_string(), 35 }; 36 // Check against the expected output. 37 test.check(&output).unwrap(); 38 // Save the output. 39 test.save(&output).unwrap(); 40 }); 41 }