diff options
author | Nadrieril | 2021-04-03 14:22:32 +0000 |
---|---|---|
committer | GitHub | 2021-04-03 14:22:32 +0000 |
commit | 527194222bbdcf559cfec3aac9b43c9ea05c2d6e (patch) | |
tree | 22b4fed4105d8b0a6e4fa53c97e855542b61a8fb /dhall/tests/spec.rs | |
parent | 846c14f92bda2fb3e68c3debf940414628013574 (diff) | |
parent | c331dcfaed6177a322de50fed418aa619210e88b (diff) |
Merge pull request #215 from cstorey/remove-redundant-semicolons
Diffstat (limited to '')
-rw-r--r-- | dhall/tests/spec.rs | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/dhall/tests/spec.rs b/dhall/tests/spec.rs index a0fe583..b6eeac7 100644 --- a/dhall/tests/spec.rs +++ b/dhall/tests/spec.rs @@ -103,7 +103,9 @@ impl TestFile { TestFile::Source(_) => Parsed::parse_file(&self.path())?, TestFile::Binary(_) => Parsed::parse_binary_file(&self.path())?, TestFile::UI(_) => { - Err(TestError(format!("Can't parse a UI test file")))? + return Err( + TestError("Can't parse a UI test file".to_string()).into() + ) } }) } @@ -138,9 +140,12 @@ impl TestFile { let expr_data = binary::encode(&expr)?; file.write_all(&expr_data)?; } - TestFile::UI(_) => Err(TestError(format!( - "Can't write an expression to a UI file" - )))?, + TestFile::UI(_) => { + return Err(TestError( + "Can't write an expression to a UI file".to_string(), + ) + .into()) + } } Ok(()) } @@ -148,9 +153,12 @@ impl TestFile { fn write_ui(&self, x: impl Display) -> Result<()> { match self { TestFile::UI(_) => {} - _ => Err(TestError(format!( - "Can't write a ui string to a dhall file" - )))?, + _ => { + return Err(TestError( + "Can't write a ui string to a dhall file".to_string(), + ) + .into()) + } } let path = self.path(); create_dir_all(path.parent().unwrap())?; @@ -195,7 +203,11 @@ impl TestFile { pub fn compare_binary(&self, expr: Expr) -> Result<()> { match self { TestFile::Binary(_) => {} - _ => Err(TestError(format!("This is not a binary file")))?, + _ => { + return Err( + TestError("This is not a binary file".to_string()).into() + ) + } } if !self.path().is_file() { return self.write_expr(expr); @@ -593,17 +605,19 @@ fn run_test(test: &SpecTest) -> Result<()> { ParserFailure => { use std::io; let err = unwrap_err(expr.parse())?; - match err.downcast_ref::<DhallError>() { - Some(err) => match err.kind() { + if let Some(err) = err.downcast_ref::<DhallError>() { + match err.kind() { ErrorKind::Parse(_) => {} ErrorKind::IO(e) if e.kind() == io::ErrorKind::InvalidData => {} - e => Err(TestError(format!( - "Expected parse error, got: {:?}", - e - )))?, - }, - None => {} + e => { + return Err(TestError(format!( + "Expected parse error, got: {:?}", + e + )) + .into()) + } + } } expected.compare_ui(err)?; } |