git.delta.rocks / jrsonnet / refs/commits / 078724755e3c

difftreelog

test(parser) merge new tests

Лач2020-05-29parents: #067b138 #3527065.patch.diff
in: master

3 files changed

modified.gitignorediffbeforeafterboth
1/target1/target
2
3.idea
4.vscode
25
added.rustfmt.tomldiffbeforeafterboth

no changes

modifiedcrates/jsonnet-parser/src/lib.rsdiffbeforeafterboth
241pub mod tests {241pub mod tests {
242 use super::{expr::*, parse};242 use super::{expr::*, parse};
243
244 mod expressions {
245 use super::*;
246
247 pub fn basic_math() -> Expr {
248 Expr::BinaryOp(
249 Box::new(Expr::Num(2.0)),
250 BinaryOpType::Add,
251 Box::new(Expr::BinaryOp(
252 Box::new(Expr::Num(2.0)),
253 BinaryOpType::Mul,
254 Box::new(Expr::Num(2.0)),
255 )),
256 )
257 }
258 }
259
243 #[test]260 #[test]
244 fn empty_object() {261 fn empty_object() {
260 );278 );
261 }279 }
280
281 #[test]
282 fn basic_math_with_indents() {
283 assert_eq!(parse("2 + 2 * 2 ").unwrap(), expressions::basic_math());
284 }
285
286 #[test]
287 fn basic_math_parened() {
288 assert_eq!(
289 parse("2+(2+2*2)").unwrap(),
290 Expr::BinaryOp(
291 Box::new(Expr::Num(2.0)),
292 BinaryOpType::Add,
293 Box::new(Expr::Parened(Box::new(expressions::basic_math()))),
294 )
295 );
296 }
262297
263 /// Comments should not affect parsing298 /// Comments should not affect parsing
264 #[test]299 #[test]