diff options
Diffstat (limited to '')
-rw-r--r-- | dhall/src/imports.rs | 1 | ||||
-rw-r--r-- | dhall/src/normalize.rs | 2 | ||||
-rw-r--r-- | dhall/tests/tests.rs | 103 | ||||
-rw-r--r-- | dhall_core/src/parser.rs | 130 |
4 files changed, 119 insertions, 117 deletions
diff --git a/dhall/src/imports.rs b/dhall/src/imports.rs index ea3ef01..9ae66a7 100644 --- a/dhall/src/imports.rs +++ b/dhall/src/imports.rs @@ -35,6 +35,7 @@ fn resolve_import( Local(prefix, path) => { let path = match prefix { Parent => cwd.parent().unwrap().join(path), + Here => cwd.join(path), _ => unimplemented!("{:?}", import), }; load_dhall_file(&path, true) diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index c3bea05..16d670f 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -186,7 +186,7 @@ where let ys = ys.into_iter(); ListLit(t, xs.chain(ys).collect()) } - Merge(_x, _y, _t) => unimplemented!(), + // Merge(_x, _y, _t) => unimplemented!(), Field(box RecordLit(kvs), x) => match kvs.get(&x) { Some(r) => r.clone(), None => Field(bx(RecordLit(kvs)), x), diff --git a/dhall/tests/tests.rs b/dhall/tests/tests.rs index 8b910a2..16fd4e3 100644 --- a/dhall/tests/tests.rs +++ b/dhall/tests/tests.rs @@ -1,3 +1,5 @@ +#![feature(custom_inner_attributes)] +#![rustfmt::skip] mod macros; make_spec_test!(normalization, spec_normalization_success_haskell_tutorial_access_0, "normalization/success/haskell-tutorial/access/0"); @@ -15,25 +17,25 @@ make_spec_test!(normalization, spec_normalization_success_haskell_tutorial_acces // make_spec_test!(normalization, spec_normalization_success_multiline_singleLine, "normalization/success/multiline/singleLine"); // make_spec_test!(normalization, spec_normalization_success_multiline_twoLines, "normalization/success/multiline/twoLines"); make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_0, "normalization/success/prelude/Bool/and/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_1, "normalization/success/prelude/Bool/and/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_build_0, "normalization/success/prelude/Bool/build/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_build_1, "normalization/success/prelude/Bool/build/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_0, "normalization/success/prelude/Bool/even/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_1, "normalization/success/prelude/Bool/even/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_2, "normalization/success/prelude/Bool/even/2"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_3, "normalization/success/prelude/Bool/even/3"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_fold_0, "normalization/success/prelude/Bool/fold/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_fold_1, "normalization/success/prelude/Bool/fold/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_not_0, "normalization/success/prelude/Bool/not/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_not_1, "normalization/success/prelude/Bool/not/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_0, "normalization/success/prelude/Bool/odd/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_1, "normalization/success/prelude/Bool/odd/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_2, "normalization/success/prelude/Bool/odd/2"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_3, "normalization/success/prelude/Bool/odd/3"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_or_0, "normalization/success/prelude/Bool/or/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_or_1, "normalization/success/prelude/Bool/or/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_show_0, "normalization/success/prelude/Bool/show/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_show_1, "normalization/success/prelude/Bool/show/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_1, "normalization/success/prelude/Bool/and/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_build_0, "normalization/success/prelude/Bool/build/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_build_1, "normalization/success/prelude/Bool/build/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_0, "normalization/success/prelude/Bool/even/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_1, "normalization/success/prelude/Bool/even/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_2, "normalization/success/prelude/Bool/even/2"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_even_3, "normalization/success/prelude/Bool/even/3"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_fold_0, "normalization/success/prelude/Bool/fold/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_fold_1, "normalization/success/prelude/Bool/fold/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_not_0, "normalization/success/prelude/Bool/not/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_not_1, "normalization/success/prelude/Bool/not/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_0, "normalization/success/prelude/Bool/odd/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_1, "normalization/success/prelude/Bool/odd/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_2, "normalization/success/prelude/Bool/odd/2"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_odd_3, "normalization/success/prelude/Bool/odd/3"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_or_0, "normalization/success/prelude/Bool/or/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_or_1, "normalization/success/prelude/Bool/or/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_show_0, "normalization/success/prelude/Bool/show/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Bool_show_1, "normalization/success/prelude/Bool/show/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Double_show_0, "normalization/success/prelude/Double/show/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Double_show_1, "normalization/success/prelude/Double/show/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Integer_show_0, "normalization/success/prelude/Integer/show/0"); @@ -41,18 +43,18 @@ make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_0, "n // make_spec_test!(normalization, spec_normalization_success_prelude_Integer_toDouble_0, "normalization/success/prelude/Integer/toDouble/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Integer_toDouble_1, "normalization/success/prelude/Integer/toDouble/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_all_0, "normalization/success/prelude/List/all/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_all_1, "normalization/success/prelude/List/all/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_all_1, "normalization/success/prelude/List/all/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_any_0, "normalization/success/prelude/List/any/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_any_1, "normalization/success/prelude/List/any/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_build_0, "normalization/success/prelude/List/build/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_build_1, "normalization/success/prelude/List/build/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_any_1, "normalization/success/prelude/List/any/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_build_0, "normalization/success/prelude/List/build/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_build_1, "normalization/success/prelude/List/build/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_concat_0, "normalization/success/prelude/List/concat/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_concat_1, "normalization/success/prelude/List/concat/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_concat_1, "normalization/success/prelude/List/concat/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_concatMap_0, "normalization/success/prelude/List/concatMap/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_concatMap_1, "normalization/success/prelude/List/concatMap/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_concatMap_1, "normalization/success/prelude/List/concatMap/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_filter_0, "normalization/success/prelude/List/filter/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_filter_1, "normalization/success/prelude/List/filter/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_fold_0, "normalization/success/prelude/List/fold/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_fold_0, "normalization/success/prelude/List/fold/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_fold_1, "normalization/success/prelude/List/fold/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_fold_2, "normalization/success/prelude/List/fold/2"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_generate_0, "normalization/success/prelude/List/generate/0"); @@ -65,16 +67,16 @@ make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_0, "n // make_spec_test!(normalization, spec_normalization_success_prelude_List_iterate_1, "normalization/success/prelude/List/iterate/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_last_0, "normalization/success/prelude/List/last/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_last_1, "normalization/success/prelude/List/last/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_length_0, "normalization/success/prelude/List/length/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_length_1, "normalization/success/prelude/List/length/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_length_0, "normalization/success/prelude/List/length/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_length_1, "normalization/success/prelude/List/length/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_map_0, "normalization/success/prelude/List/map/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_map_1, "normalization/success/prelude/List/map/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_null_0, "normalization/success/prelude/List/null/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_null_1, "normalization/success/prelude/List/null/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_null_0, "normalization/success/prelude/List/null/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_null_1, "normalization/success/prelude/List/null/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_replicate_0, "normalization/success/prelude/List/replicate/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_replicate_1, "normalization/success/prelude/List/replicate/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_reverse_0, "normalization/success/prelude/List/reverse/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_List_reverse_1, "normalization/success/prelude/List/reverse/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_reverse_0, "normalization/success/prelude/List/reverse/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_List_reverse_1, "normalization/success/prelude/List/reverse/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_shifted_0, "normalization/success/prelude/List/shifted/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_shifted_1, "normalization/success/prelude/List/shifted/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_List_unzip_0, "normalization/success/prelude/List/unzip/0"); @@ -83,25 +85,25 @@ make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_0, "n // make_spec_test!(normalization, spec_normalization_success_prelude_Natural_build_1, "normalization/success/prelude/Natural/build/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Natural_enumerate_0, "normalization/success/prelude/Natural/enumerate/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Natural_enumerate_1, "normalization/success/prelude/Natural/enumerate/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_even_0, "normalization/success/prelude/Natural/even/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_even_1, "normalization/success/prelude/Natural/even/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_even_0, "normalization/success/prelude/Natural/even/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_even_1, "normalization/success/prelude/Natural/even/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Natural_fold_0, "normalization/success/prelude/Natural/fold/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Natural_fold_1, "normalization/success/prelude/Natural/fold/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Natural_fold_2, "normalization/success/prelude/Natural/fold/2"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_isZero_0, "normalization/success/prelude/Natural/isZero/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_isZero_1, "normalization/success/prelude/Natural/isZero/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_odd_0, "normalization/success/prelude/Natural/odd/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_odd_1, "normalization/success/prelude/Natural/odd/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_product_0, "normalization/success/prelude/Natural/product/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_product_1, "normalization/success/prelude/Natural/product/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_show_0, "normalization/success/prelude/Natural/show/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_show_1, "normalization/success/prelude/Natural/show/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_sum_0, "normalization/success/prelude/Natural/sum/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_sum_1, "normalization/success/prelude/Natural/sum/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_isZero_0, "normalization/success/prelude/Natural/isZero/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_isZero_1, "normalization/success/prelude/Natural/isZero/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_odd_0, "normalization/success/prelude/Natural/odd/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_odd_1, "normalization/success/prelude/Natural/odd/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_product_0, "normalization/success/prelude/Natural/product/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_product_1, "normalization/success/prelude/Natural/product/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_show_0, "normalization/success/prelude/Natural/show/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_show_1, "normalization/success/prelude/Natural/show/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_sum_0, "normalization/success/prelude/Natural/sum/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_sum_1, "normalization/success/prelude/Natural/sum/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Natural_toDouble_0, "normalization/success/prelude/Natural/toDouble/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Natural_toDouble_1, "normalization/success/prelude/Natural/toDouble/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_toInteger_0, "normalization/success/prelude/Natural/toInteger/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_toInteger_1, "normalization/success/prelude/Natural/toInteger/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_toInteger_0, "normalization/success/prelude/Natural/toInteger/0"); +make_spec_test!(normalization, spec_normalization_success_prelude_Natural_toInteger_1, "normalization/success/prelude/Natural/toInteger/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_all_0, "normalization/success/prelude/Optional/all/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_all_1, "normalization/success/prelude/Optional/all/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_any_0, "normalization/success/prelude/Optional/any/0"); @@ -117,10 +119,10 @@ make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_0, "n // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_fold_1, "normalization/success/prelude/Optional/fold/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_head_0, "normalization/success/prelude/Optional/head/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_head_1, "normalization/success/prelude/Optional/head/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_head_2, "normalization/success/prelude/Optional/head/2"); +make_spec_test!(normalization, spec_normalization_success_prelude_Optional_head_2, "normalization/success/prelude/Optional/head/2"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_last_0, "normalization/success/prelude/Optional/last/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_last_1, "normalization/success/prelude/Optional/last/1"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Optional_last_2, "normalization/success/prelude/Optional/last/2"); +make_spec_test!(normalization, spec_normalization_success_prelude_Optional_last_2, "normalization/success/prelude/Optional/last/2"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_length_0, "normalization/success/prelude/Optional/length/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_length_1, "normalization/success/prelude/Optional/length/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_map_0, "normalization/success/prelude/Optional/map/0"); @@ -132,9 +134,9 @@ make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_0, "n // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_unzip_0, "normalization/success/prelude/Optional/unzip/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Optional_unzip_1, "normalization/success/prelude/Optional/unzip/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Text_concat_0, "normalization/success/prelude/Text/concat/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Text_concat_1, "normalization/success/prelude/Text/concat/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Text_concat_1, "normalization/success/prelude/Text/concat/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatMap_0, "normalization/success/prelude/Text/concatMap/0"); -// make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatMap_1, "normalization/success/prelude/Text/concatMap/1"); +make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatMap_1, "normalization/success/prelude/Text/concatMap/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatMapSep_0, "normalization/success/prelude/Text/concatMapSep/0"); // make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatMapSep_1, "normalization/success/prelude/Text/concatMapSep/1"); // make_spec_test!(normalization, spec_normalization_success_prelude_Text_concatSep_0, "normalization/success/prelude/Text/concatSep/0"); @@ -218,4 +220,3 @@ make_spec_test!(parser_failure, spec_parser_failure_incompleteIf, "parser/failur make_spec_test!(parser_failure, spec_parser_failure_mandatoryNewline, "parser/failure/mandatoryNewline"); make_spec_test!(parser_failure, spec_parser_failure_missingSpace, "parser/failure/missingSpace"); make_spec_test!(parser_failure, spec_parser_failure_spaceAfterListAppend, "parser/failure/spaceAfterListAppend"); -// make_spec_test!(parser_failure, spec_parser_failure_builtins, "parser/failure/builtins"); diff --git a/dhall_core/src/parser.rs b/dhall_core/src/parser.rs index 164d410..0ba1586 100644 --- a/dhall_core/src/parser.rs +++ b/dhall_core/src/parser.rs @@ -816,68 +816,68 @@ pub fn parse_expr<'i>(s: &'i str) -> ParseResult<BoxExpr<'i>> { // Ok(bx(Expr::BoolLit(false))) } -#[test] -fn test_parse() { - use crate::core::BinOp::*; - use crate::core::Expr::*; - // let expr = r#"{ x = "foo", y = 4 }.x"#; - // let expr = r#"(1 + 2) * 3"#; - let expr = r#"if True then 1 + 3 * 5 else 2"#; - println!("{:?}", parse_expr(expr)); - use std::thread; - // I don't understand why it stack overflows even on tiny expressions... - thread::Builder::new() - .stack_size(3 * 1024 * 1024) - .spawn(move || match parse_expr(expr) { - Err(e) => { - println!("{:?}", e); - println!("{}", e); - } - ok => println!("{:?}", ok), - }) - .unwrap() - .join() - .unwrap(); - // assert_eq!(parse_expr(expr).unwrap(), parse_expr(expr).unwrap()); - // assert!(false); - - println!("test {:?}", parse_expr("3 + 5 * 10")); - assert!(parse_expr("22").is_ok()); - assert!(parse_expr("(22)").is_ok()); - assert_eq!( - parse_expr("3 + 5 * 10").ok(), - Some(Box::new(BinOp( - NaturalPlus, - Box::new(NaturalLit(3)), - Box::new(BinOp( - NaturalTimes, - Box::new(NaturalLit(5)), - Box::new(NaturalLit(10)) - )) - ))) - ); - // The original parser is apparently right-associative - assert_eq!( - parse_expr("2 * 3 * 4").ok(), - Some(Box::new(BinOp( - NaturalTimes, - Box::new(NaturalLit(2)), - Box::new(BinOp( - NaturalTimes, - Box::new(NaturalLit(3)), - Box::new(NaturalLit(4)) - )) - ))) - ); - assert!(parse_expr("((((22))))").is_ok()); - assert!(parse_expr("((22)").is_err()); - println!("{:?}", parse_expr("\\(b : Bool) -> b == False")); - assert!(parse_expr("\\(b : Bool) -> b == False").is_ok()); - println!("{:?}", parse_expr("foo.bar")); - assert!(parse_expr("foo.bar").is_ok()); - assert!(parse_expr("[] : List Bool").is_ok()); - - // println!("{:?}", parse_expr("< Left = True | Right : Natural >")); - // println!("{:?}", parse_expr(r#""bl${42}ah""#)); - // assert!(parse_expr("< Left = True | Right : Natural >").is_ok()); -} +// #[test] +// fn test_parse() { +// use crate::core::BinOp::*; +// use crate::core::Expr::*; +// // let expr = r#"{ x = "foo", y = 4 }.x"#; +// // let expr = r#"(1 + 2) * 3"#; +// let expr = r#"if True then 1 + 3 * 5 else 2"#; +// println!("{:?}", parse_expr(expr)); +// use std::thread; +// // I don't understand why it stack overflows even on tiny expressions... +// thread::Builder::new() +// .stack_size(3 * 1024 * 1024) +// .spawn(move || match parse_expr(expr) { +// Err(e) => { +// println!("{:?}", e); +// println!("{}", e); +// } +// ok => println!("{:?}", ok), +// }) +// .unwrap() +// .join() +// .unwrap(); +// // assert_eq!(parse_expr(expr).unwrap(), parse_expr(expr).unwrap()); +// // assert!(false); + +// println!("test {:?}", parse_expr("3 + 5 * 10")); +// assert!(parse_expr("22").is_ok()); +// assert!(parse_expr("(22)").is_ok()); +// assert_eq!( +// parse_expr("3 + 5 * 10").ok(), +// Some(Box::new(BinOp( +// NaturalPlus, +// Box::new(NaturalLit(3)), +// Box::new(BinOp( +// NaturalTimes, +// Box::new(NaturalLit(5)), +// Box::new(NaturalLit(10)) +// )) +// ))) +// ); +// // The original parser is apparently right-associative +// assert_eq!( +// parse_expr("2 * 3 * 4").ok(), +// Some(Box::new(BinOp( +// NaturalTimes, +// Box::new(NaturalLit(2)), +// Box::new(BinOp( +// NaturalTimes, +// Box::new(NaturalLit(3)), +// Box::new(NaturalLit(4)) +// )) +// ))) +// ); +// assert!(parse_expr("((((22))))").is_ok()); +// assert!(parse_expr("((22)").is_err()); +// println!("{:?}", parse_expr("\\(b : Bool) -> b == False")); +// assert!(parse_expr("\\(b : Bool) -> b == False").is_ok()); +// println!("{:?}", parse_expr("foo.bar")); +// assert!(parse_expr("foo.bar").is_ok()); +// assert!(parse_expr("[] : List Bool").is_ok()); + +// // println!("{:?}", parse_expr("< Left = True | Right : Natural >")); +// // println!("{:?}", parse_expr(r#""bl${42}ah""#)); +// // assert!(parse_expr("< Left = True | Right : Natural >").is_ok()); +// } |