From d5c3e8f2ef7438b7ac84be34cfe019ce365ae529 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 7 Aug 2019 16:22:00 +0200 Subject: Forbid surrogate pairs and non-characters --- dhall/src/tests.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'dhall/src/tests.rs') diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index 2f68dac..8b32fb4 100644 --- a/dhall/src/tests.rs +++ b/dhall/src/tests.rs @@ -195,6 +195,8 @@ 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), } } -- cgit v1.2.3 From 6654d441e5741013a8618907773ac54101e3fdf2 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 7 Aug 2019 21:38:01 +0200 Subject: Add binary-decode tests --- dhall/src/tests.rs | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'dhall/src/tests.rs') diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index 8b32fb4..da48d15 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, @@ -84,6 +85,7 @@ pub fn run_test( Parser => "parser/", Printer => "parser/", BinaryEncoding => "parser/", + BinaryDecoding => "binary-decode/", Import => "import/", Normalization => "normalization/", AlphaNormalization => "alpha-normalization/", @@ -94,6 +96,24 @@ pub fn run_test( "../dhall-lang/tests/".to_owned() + feature_prefix + base_path; 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 +184,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); @@ -201,6 +223,15 @@ pub fn run_test( } } 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(); } -- cgit v1.2.3 From a01cf8ad53a3839d13aa99a589ba0f2aa796d511 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 7 Aug 2019 21:57:51 +0200 Subject: Remove an annoying redundancy in the test harness --- dhall/src/tests.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'dhall/src/tests.rs') diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index da48d15..9784eec 100644 --- a/dhall/src/tests.rs +++ b/dhall/src/tests.rs @@ -81,19 +81,7 @@ pub fn run_test( ) -> Result<()> { use self::Feature::*; use self::Status::*; - let feature_prefix = match feature { - Parser => "parser/", - Printer => "parser/", - BinaryEncoding => "parser/", - BinaryDecoding => "binary-decode/", - 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 { -- cgit v1.2.3 From 071ba528cd8c6a222be345ddec7560bb45cca6be Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 8 Aug 2019 19:33:07 +0200 Subject: Add support for dependent types --- dhall/src/tests.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'dhall/src/tests.rs') diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index 9784eec..15bc97a 100644 --- a/dhall/src/tests.rs +++ b/dhall/src/tests.rs @@ -107,6 +107,7 @@ pub fn run_test( match feature { Parser => { + // This exercices both parsing and binary decoding // Compare parse/decoded let expected_file_path = base_path + "B.dhallb"; let expected_file_path = PathBuf::from(&expected_file_path); -- cgit v1.2.3