diff options
author | Nadrieril Feneanar | 2019-08-07 23:12:47 +0200 |
---|---|---|
committer | GitHub | 2019-08-07 23:12:47 +0200 |
commit | 674fbdc33c788156f76d263b044dccc48c810870 (patch) | |
tree | 725eaa49a4f2236d44470279296969b66ba0bbc8 /dhall/src/tests.rs | |
parent | 8ec422f2319360f986950fcb9aae4bcf65a9c1e2 (diff) | |
parent | e81ab9a553bf82f20fa0b0344926258176a21dac (diff) |
Merge pull request #95 from Nadrieril/catchup-spec
A lot more catching up on the spec
Diffstat (limited to 'dhall/src/tests.rs')
-rw-r--r-- | dhall/src/tests.rs | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index 2f68dac..9784eec 100644 --- a/dhall/src/tests.rs +++ b/dhall/src/tests.rs @@ -45,6 +45,7 @@ pub enum Feature { Parser, Printer, BinaryEncoding, + BinaryDecoding, Import, Normalization, AlphaNormalization, @@ -80,20 +81,27 @@ pub fn run_test( ) -> Result<()> { use self::Feature::*; use self::Status::*; - let feature_prefix = match feature { - Parser => "parser/", - Printer => "parser/", - BinaryEncoding => "parser/", - Import => "import/", - Normalization => "normalization/", - AlphaNormalization => "alpha-normalization/", - Typecheck => "typecheck/", - TypeInference => "type-inference/", - }; - let base_path = - "../dhall-lang/tests/".to_owned() + feature_prefix + base_path; + let base_path = base_path.to_owned(); match status { Success => { + match feature { + BinaryDecoding => { + let expr_file_path = base_path.clone() + "A.dhallb"; + let expr_file_path = PathBuf::from(&expr_file_path); + let mut expr_data = Vec::new(); + { + File::open(&expr_file_path)? + .read_to_end(&mut expr_data)?; + } + let expr = Parsed::parse_binary(&expr_data)?; + let expected_file_path = base_path + "B.dhall"; + let expected = parse_file_str(&expected_file_path)?; + assert_eq_pretty!(expr, expected); + + return Ok(()); + } + _ => {} + } let expr_file_path = base_path.clone() + "A.dhall"; let expr = parse_file_str(&expr_file_path)?; @@ -164,7 +172,9 @@ pub fn run_test( .normalize(); match feature { - Parser | Printer | BinaryEncoding => unreachable!(), + Parser | Printer | BinaryEncoding | BinaryDecoding => { + unreachable!() + } Import => { let expr = expr.skip_typecheck().normalize(); assert_eq_display!(expr, expected); @@ -195,10 +205,21 @@ pub fn run_test( let err = parse_file_str(&file_path).unwrap_err(); match err { Error::Parse(_) => {} + Error::IO(e) + if e.kind() == std::io::ErrorKind::InvalidData => {} e => panic!("Expected parse error, got: {:?}", e), } } Printer | BinaryEncoding => unreachable!(), + BinaryDecoding => { + let expr_file_path = file_path + "b"; + let mut expr_data = Vec::new(); + { + File::open(&PathBuf::from(&expr_file_path))? + .read_to_end(&mut expr_data)?; + } + Parsed::parse_binary(&expr_data).unwrap_err(); + } Import => { parse_file_str(&file_path)?.resolve().unwrap_err(); } |