/ synthesizer / tests / test_command_parse.rs
test_command_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::Command;
21  
22  use rayon::prelude::*;
23  
24  #[test]
25  fn test_command_parse() {
26      // Load the tests.
27      let tests = load_tests::<_, LineParseTest>("./tests/parser/command", "./expectations/parser/command");
28      // Run each test and compare it against its corresponding expectation.
29      tests.par_iter().for_each(|test| {
30          // Run the parser on each of the test strings.
31          let outputs = test
32              .test_strings()
33              .iter()
34              .map(|test_string| convert_result(Command::<CurrentNetwork>::parse(test_string), test_string))
35              .collect::<Vec<_>>();
36          // Check against the expected output.
37          test.check(&outputs).unwrap();
38          // Save the output.
39          test.save(&outputs).unwrap();
40      });
41  }