From 3527065e268dd83454ee60d3e3d42b2fbe659112 Mon Sep 17 00:00:00 2001 From: progrm_jarvis Date: Sat, 16 May 2020 14:40:29 +0000 Subject: [PATCH] test(parser): move duplicate part of tests to submodule --- --- a/crates/jsonnet-parser/src/lib.rs +++ b/crates/jsonnet-parser/src/lib.rs @@ -188,16 +188,20 @@ pub mod tests { use super::{expr::*, parse}; - fn basic_math_expression() -> Expr { - Expr::BinaryOp( - Box::new(Expr::Num(2.0)), - BinaryOp::Add, - Box::new(Expr::BinaryOp( + mod expressions { + use super::*; + + pub fn basic_math() -> Expr { + Expr::BinaryOp( Box::new(Expr::Num(2.0)), - BinaryOp::Mul, - Box::new(Expr::Num(2.0)), - )), - ) + BinaryOp::Add, + Box::new(Expr::BinaryOp( + Box::new(Expr::Num(2.0)), + BinaryOp::Mul, + Box::new(Expr::Num(2.0)), + )), + ) + } } #[test] @@ -223,7 +227,7 @@ #[test] fn basic_math_with_indents() { - assert_eq!(parse("2 + 2 * 2 ").unwrap(), basic_math_expression()); + assert_eq!(parse("2 + 2 * 2 ").unwrap(), expressions::basic_math()); } #[test] @@ -233,7 +237,7 @@ Expr::BinaryOp( Box::new(Expr::Num(2.0)), BinaryOp::Add, - Box::new(Expr::Parened(Box::new(basic_math_expression()))), + Box::new(Expr::Parened(Box::new(expressions::basic_math()))), ) ); } -- gitstuff