diff --git a/compiler/parse/fuzz/Cargo.toml b/compiler/parse/fuzz/Cargo.toml index 1503985a10..2b60a1683e 100644 --- a/compiler/parse/fuzz/Cargo.toml +++ b/compiler/parse/fuzz/Cargo.toml @@ -21,7 +21,19 @@ path = ".." members = ["."] [[bin]] -name = "fuzz_parse" -path = "fuzz_targets/fuzz_parse.rs" +name = "fuzz_expr" +path = "fuzz_targets/fuzz_expr.rs" +test = false +doc = false + +[[bin]] +name = "fuzz_defs" +path = "fuzz_targets/fuzz_defs.rs" +test = false +doc = false + +[[bin]] +name = "fuzz_header" +path = "fuzz_targets/fuzz_header.rs" test = false doc = false diff --git a/compiler/parse/fuzz/README.md b/compiler/parse/fuzz/README.md index bec691956e..c31c048a6d 100644 --- a/compiler/parse/fuzz/README.md +++ b/compiler/parse/fuzz/README.md @@ -2,5 +2,10 @@ To setup fuzzing you will need to install cargo-fuzz and run with rust nightly: ``` $ cargo install cargo-fuzz -$ cargo +nightly fuzz run -O -a fuzz_parse +$ cargo +nightly fuzz run -j -- -dict=dict.txt ``` + +The different targets can be found by running `cargo fuzz list`. + +When a bug is found, it will be reported with commands to run it again and look for a minimized version. +If you are going to file a bug, please minimize the input before filing the bug. diff --git a/compiler/parse/fuzz/dict.txt b/compiler/parse/fuzz/dict.txt new file mode 100644 index 0000000000..c22976ccb2 --- /dev/null +++ b/compiler/parse/fuzz/dict.txt @@ -0,0 +1,36 @@ +"if" +"then" +"else" +"when" +"as" +"is" +"expect" + +"app" +"platform" +"provides" +"requires" +"exposes" +"imports" +"effects" +"interface" + +"|>" +"==" +"!=" +"&&" +"||" +"+" +"*" +"-" +"//" +"/" +"<=" +"<" +">=" +">" +"^" +"%%" +"%" + +"->" \ No newline at end of file diff --git a/compiler/parse/fuzz/fuzz_targets/fuzz_parse.rs b/compiler/parse/fuzz/fuzz_targets/fuzz_defs.rs similarity index 63% rename from compiler/parse/fuzz/fuzz_targets/fuzz_parse.rs rename to compiler/parse/fuzz/fuzz_targets/fuzz_defs.rs index a47318f4b0..f02bfc587c 100644 --- a/compiler/parse/fuzz/fuzz_targets/fuzz_parse.rs +++ b/compiler/parse/fuzz/fuzz_targets/fuzz_defs.rs @@ -1,11 +1,11 @@ #![no_main] use bumpalo::Bump; use libfuzzer_sys::fuzz_target; -use roc_parse::test_helpers::parse_with; +use roc_parse::test_helpers::parse_defs_with; fuzz_target!(|data: &[u8]| { if let Ok(input) = std::str::from_utf8(data) { let arena = Bump::new(); - let _actual = parse_with(&arena, input.trim()); + let _actual = parse_defs_with(&arena, input.trim()); } }); diff --git a/compiler/parse/fuzz/fuzz_targets/fuzz_expr.rs b/compiler/parse/fuzz/fuzz_targets/fuzz_expr.rs new file mode 100644 index 0000000000..d130a0c621 --- /dev/null +++ b/compiler/parse/fuzz/fuzz_targets/fuzz_expr.rs @@ -0,0 +1,11 @@ +#![no_main] +use bumpalo::Bump; +use libfuzzer_sys::fuzz_target; +use roc_parse::test_helpers::parse_expr_with; + +fuzz_target!(|data: &[u8]| { + if let Ok(input) = std::str::from_utf8(data) { + let arena = Bump::new(); + let _actual = parse_expr_with(&arena, input.trim()); + } +}); diff --git a/compiler/parse/fuzz/fuzz_targets/fuzz_header.rs b/compiler/parse/fuzz/fuzz_targets/fuzz_header.rs new file mode 100644 index 0000000000..e04f338c87 --- /dev/null +++ b/compiler/parse/fuzz/fuzz_targets/fuzz_header.rs @@ -0,0 +1,11 @@ +#![no_main] +use bumpalo::Bump; +use libfuzzer_sys::fuzz_target; +use roc_parse::test_helpers::parse_header_with; + +fuzz_target!(|data: &[u8]| { + if let Ok(input) = std::str::from_utf8(data) { + let arena = Bump::new(); + let _actual = parse_header_with(&arena, input.trim()); + } +}); diff --git a/compiler/parse/src/test_helpers.rs b/compiler/parse/src/test_helpers.rs index d2d63c912f..b7a78e2354 100644 --- a/compiler/parse/src/test_helpers.rs +++ b/compiler/parse/src/test_helpers.rs @@ -1,15 +1,38 @@ use crate::ast::{self, Attempting}; use crate::blankspace::space0_before; use crate::expr::expr; +use crate::module::{header, module_defs}; use crate::parser::{loc, Fail, Parser, State}; +use bumpalo::collections::Vec; use bumpalo::Bump; use roc_region::all::Located; #[allow(dead_code)] -pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, Fail> { +pub fn parse_expr_with<'a>(arena: &'a Bump, input: &'a str) -> Result, Fail> { parse_loc_with(arena, input).map(|loc_expr| loc_expr.value) } +#[allow(dead_code)] +pub fn parse_header_with<'a>(arena: &'a Bump, input: &'a str) -> Result, Fail> { + let state = State::new(input.trim().as_bytes(), Attempting::Module); + let answer = header().parse(arena, state); + answer + .map(|(loc_expr, _)| loc_expr) + .map_err(|(fail, _)| fail) +} + +#[allow(dead_code)] +pub fn parse_defs_with<'a>( + arena: &'a Bump, + input: &'a str, +) -> Result>>, Fail> { + let state = State::new(input.trim().as_bytes(), Attempting::Module); + let answer = module_defs().parse(arena, state); + answer + .map(|(loc_expr, _)| loc_expr) + .map_err(|(fail, _)| fail) +} + #[allow(dead_code)] pub fn parse_loc_with<'a>(arena: &'a Bump, input: &'a str) -> Result>, Fail> { let state = State::new(input.trim().as_bytes(), Attempting::Module); diff --git a/compiler/parse/tests/test_parse.rs b/compiler/parse/tests/test_parse.rs index 861e163f65..8c94db8d72 100644 --- a/compiler/parse/tests/test_parse.rs +++ b/compiler/parse/tests/test_parse.rs @@ -30,20 +30,20 @@ mod test_parse { use roc_parse::header::ModuleName; use roc_parse::module::{interface_header, module_defs}; use roc_parse::parser::{Fail, FailReason, Parser, State}; - use roc_parse::test_helpers::parse_with; + use roc_parse::test_helpers::parse_expr_with; use roc_region::all::{Located, Region}; use std::{f64, i64}; fn assert_parses_to<'a>(input: &'a str, expected_expr: Expr<'a>) { let arena = Bump::new(); - let actual = parse_with(&arena, input.trim()); + let actual = parse_expr_with(&arena, input.trim()); assert_eq!(Ok(expected_expr), actual); } fn assert_parsing_fails<'a>(input: &'a str, reason: FailReason, attempting: Attempting) { let arena = Bump::new(); - let actual = parse_with(&arena, input); + let actual = parse_expr_with(&arena, input); let expected_fail = Fail { reason, attempting }; assert_eq!(Err(expected_fail), actual); @@ -51,7 +51,7 @@ mod test_parse { fn assert_segments Vec<'_, ast::StrSegment<'_>>>(input: &str, to_expected: E) { let arena = Bump::new(); - let actual = parse_with(&arena, arena.alloc(input)); + let actual = parse_expr_with(&arena, arena.alloc(input)); let expected_slice = to_expected(&arena); let expected_expr = Expr::Str(Line(&expected_slice)); @@ -75,7 +75,7 @@ mod test_parse { ("\\t", EscapedChar::Tab), ("\\\"", EscapedChar::Quote), ] { - let actual = parse_with(&arena, arena.alloc(to_input(string))); + let actual = parse_expr_with(&arena, arena.alloc(to_input(string))); let expected_slice = to_expected(*escaped, &arena); let expected_expr = Expr::Str(Line(&expected_slice)); @@ -421,7 +421,7 @@ mod test_parse { fields: &[], update: None, }; - let actual = parse_with(&arena, "{}"); + let actual = parse_expr_with(&arena, "{}"); assert_eq!(Ok(expected), actual); } @@ -453,7 +453,7 @@ mod test_parse { fields, }; - let actual = parse_with(&arena, "{ Foo.Bar.baz & x: 5, y: 0 }"); + let actual = parse_expr_with(&arena, "{ Foo.Bar.baz & x: 5, y: 0 }"); assert_eq!(Ok(expected), actual); } @@ -468,7 +468,7 @@ mod test_parse { Located::new(0, 0, 2, 3, Num("2")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "1+2"); + let actual = parse_expr_with(&arena, "1+2"); assert_eq!(Ok(expected), actual); } @@ -482,7 +482,7 @@ mod test_parse { Located::new(0, 0, 2, 3, Num("2")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "1-2"); + let actual = parse_expr_with(&arena, "1-2"); assert_eq!(Ok(expected), actual); } @@ -496,7 +496,7 @@ mod test_parse { Located::new(0, 0, 7, 8, Num("2")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "1 + 2"); + let actual = parse_expr_with(&arena, "1 + 2"); assert_eq!(Ok(expected), actual); } @@ -510,7 +510,7 @@ mod test_parse { Located::new(0, 0, 7, 8, Num("2")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "1 - 2"); + let actual = parse_expr_with(&arena, "1 - 2"); assert_eq!(Ok(expected), actual); } @@ -533,7 +533,7 @@ mod test_parse { Located::new(0, 0, 4, 5, Num("2")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "x + 2"); + let actual = parse_expr_with(&arena, "x + 2"); assert_eq!(Ok(expected), actual); } @@ -555,7 +555,7 @@ mod test_parse { Located::new(0, 0, 4, 5, Num("2")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "x - 2"); + let actual = parse_expr_with(&arena, "x - 2"); assert_eq!(Ok(expected), actual); } @@ -570,7 +570,7 @@ mod test_parse { Located::new(1, 1, 2, 3, Num("4")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "3 \n+ 4"); + let actual = parse_expr_with(&arena, "3 \n+ 4"); assert_eq!(Ok(expected), actual); } @@ -585,7 +585,7 @@ mod test_parse { Located::new(1, 1, 2, 3, Num("4")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "3 \n- 4"); + let actual = parse_expr_with(&arena, "3 \n- 4"); assert_eq!(Ok(expected), actual); } @@ -600,7 +600,7 @@ mod test_parse { Located::new(1, 1, 2, 3, spaced_int), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "3 *\n 4"); + let actual = parse_expr_with(&arena, "3 *\n 4"); assert_eq!(Ok(expected), actual); } @@ -615,7 +615,7 @@ mod test_parse { Located::new(1, 1, 2, 3, spaced_int), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "3 -\n 4"); + let actual = parse_expr_with(&arena, "3 -\n 4"); assert_eq!(Ok(expected), actual); } @@ -630,7 +630,7 @@ mod test_parse { Located::new(1, 1, 2, 3, Num("4")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "3 # 2 × 2\n+ 4"); + let actual = parse_expr_with(&arena, "3 # 2 × 2\n+ 4"); assert_eq!(Ok(expected), actual); } @@ -645,7 +645,7 @@ mod test_parse { Located::new(1, 1, 2, 3, Num("4")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "3 # test!\n+ 4"); + let actual = parse_expr_with(&arena, "3 # test!\n+ 4"); assert_eq!(Ok(expected), actual); } @@ -660,7 +660,7 @@ mod test_parse { Located::new(1, 1, 1, 3, spaced_int), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "12 * # test!\n 92"); + let actual = parse_expr_with(&arena, "12 * # test!\n 92"); assert_eq!(Ok(expected), actual); } @@ -676,7 +676,7 @@ mod test_parse { Located::new(3, 3, 2, 3, spaced_int2), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "3 \n+ \n\n 4"); + let actual = parse_expr_with(&arena, "3 \n+ \n\n 4"); assert_eq!(Ok(expected), actual); } @@ -700,7 +700,7 @@ mod test_parse { Located::new(0, 0, 3, 4, var2), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "x- y"); + let actual = parse_expr_with(&arena, "x- y"); assert_eq!(Ok(expected), actual); } @@ -714,7 +714,7 @@ mod test_parse { Located::new(0, 0, 4, 5, Num("5")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "-12-5"); + let actual = parse_expr_with(&arena, "-12-5"); assert_eq!(Ok(expected), actual); } @@ -728,7 +728,7 @@ mod test_parse { Located::new(0, 0, 3, 5, Num("11")), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "10*11"); + let actual = parse_expr_with(&arena, "10*11"); assert_eq!(Ok(expected), actual); } @@ -747,7 +747,7 @@ mod test_parse { Located::new(0, 0, 3, 9, BinOp(inner)), )); let expected = BinOp(outer); - let actual = parse_with(&arena, "31*42+534"); + let actual = parse_expr_with(&arena, "31*42+534"); assert_eq!(Ok(expected), actual); } @@ -769,7 +769,7 @@ mod test_parse { Located::new(0, 0, 3, 4, var2), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "x==y"); + let actual = parse_expr_with(&arena, "x==y"); assert_eq!(Ok(expected), actual); } @@ -791,7 +791,7 @@ mod test_parse { Located::new(0, 0, 5, 6, var2), )); let expected = BinOp(tuple); - let actual = parse_with(&arena, "x == y"); + let actual = parse_expr_with(&arena, "x == y"); assert_eq!(Ok(expected), actual); } @@ -805,7 +805,7 @@ mod test_parse { module_name: "", ident: "whee", }; - let actual = parse_with(&arena, "whee"); + let actual = parse_expr_with(&arena, "whee"); assert_eq!(Ok(expected), actual); } @@ -817,7 +817,7 @@ mod test_parse { module_name: "", ident: "whee", })); - let actual = parse_with(&arena, "(whee)"); + let actual = parse_expr_with(&arena, "(whee)"); assert_eq!(Ok(expected), actual); } @@ -829,7 +829,7 @@ mod test_parse { module_name: "One.Two", ident: "whee", }; - let actual = parse_with(&arena, "One.Two.whee"); + let actual = parse_expr_with(&arena, "One.Two.whee"); assert_eq!(Ok(expected), actual); } @@ -840,7 +840,7 @@ mod test_parse { fn basic_global_tag() { let arena = Bump::new(); let expected = Expr::GlobalTag("Whee"); - let actual = parse_with(&arena, "Whee"); + let actual = parse_expr_with(&arena, "Whee"); assert_eq!(Ok(expected), actual); } @@ -849,7 +849,7 @@ mod test_parse { fn basic_private_tag() { let arena = Bump::new(); let expected = Expr::PrivateTag("@Whee"); - let actual = parse_with(&arena, "@Whee"); + let actual = parse_expr_with(&arena, "@Whee"); assert_eq!(Ok(expected), actual); } @@ -865,7 +865,7 @@ mod test_parse { args, CalledVia::Space, ); - let actual = parse_with(&arena, "@Whee 12 34"); + let actual = parse_expr_with(&arena, "@Whee 12 34"); assert_eq!(Ok(expected), actual); } @@ -881,7 +881,7 @@ mod test_parse { args, CalledVia::Space, ); - let actual = parse_with(&arena, "Whee 12 34"); + let actual = parse_expr_with(&arena, "Whee 12 34"); assert_eq!(Ok(expected), actual); } @@ -899,7 +899,7 @@ mod test_parse { args, CalledVia::Space, ); - let actual = parse_with(&arena, "Whee (12) (34)"); + let actual = parse_expr_with(&arena, "Whee (12) (34)"); assert_eq!(Ok(expected), actual); } @@ -908,7 +908,7 @@ mod test_parse { fn qualified_global_tag() { let arena = Bump::new(); let expected = Expr::MalformedIdent("One.Two.Whee"); - let actual = parse_with(&arena, "One.Two.Whee"); + let actual = parse_expr_with(&arena, "One.Two.Whee"); assert_eq!(Ok(expected), actual); } @@ -918,7 +918,7 @@ mod test_parse { // fn qualified_private_tag() { // let arena = Bump::new(); // let expected = Expr::MalformedIdent("One.Two.@Whee"); - // let actual = parse_with(&arena, "One.Two.@Whee"); + // let actual = parse_expr_with(&arena, "One.Two.@Whee"); // assert_eq!(Ok(expected), actual); // } @@ -929,7 +929,7 @@ mod test_parse { let pattern = Located::new(0, 0, 1, 6, Pattern::GlobalTag("Thing")); let patterns = &[pattern]; let expected = Closure(patterns, arena.alloc(Located::new(0, 0, 10, 12, Num("42")))); - let actual = parse_with(&arena, "\\Thing -> 42"); + let actual = parse_expr_with(&arena, "\\Thing -> 42"); assert_eq!(Ok(expected), actual); } @@ -938,7 +938,7 @@ mod test_parse { fn private_qualified_tag() { let arena = Bump::new(); let expected = Expr::MalformedIdent("@One.Two.Whee"); - let actual = parse_with(&arena, "@One.Two.Whee"); + let actual = parse_expr_with(&arena, "@One.Two.Whee"); assert_eq!(Ok(expected), actual); } @@ -950,7 +950,7 @@ mod test_parse { let arena = Bump::new(); let elems = &[]; let expected = List(elems); - let actual = parse_with(&arena, "[]"); + let actual = parse_expr_with(&arena, "[]"); assert_eq!(Ok(expected), actual); } @@ -961,7 +961,7 @@ mod test_parse { let arena = Bump::new(); let elems = &[]; let expected = List(elems); - let actual = parse_with(&arena, "[ ]"); + let actual = parse_expr_with(&arena, "[ ]"); assert_eq!(Ok(expected), actual); } @@ -971,7 +971,7 @@ mod test_parse { let arena = Bump::new(); let elems = &[&*arena.alloc(Located::new(0, 0, 1, 2, Num("1")))]; let expected = List(elems); - let actual = parse_with(&arena, "[1]"); + let actual = parse_expr_with(&arena, "[1]"); assert_eq!(Ok(expected), actual); } @@ -981,7 +981,7 @@ mod test_parse { let arena = Bump::new(); let elems = &[&*arena.alloc(Located::new(0, 0, 2, 3, Num("1")))]; let expected = List(elems); - let actual = parse_with(&arena, "[ 1 ]"); + let actual = parse_expr_with(&arena, "[ 1 ]"); assert_eq!(Ok(expected), actual); } @@ -996,7 +996,7 @@ mod test_parse { ident: "rec", }; let expected = Access(arena.alloc(var), "field"); - let actual = parse_with(&arena, "rec.field"); + let actual = parse_expr_with(&arena, "rec.field"); assert_eq!(Ok(expected), actual); } @@ -1009,7 +1009,7 @@ mod test_parse { ident: "rec", })); let expected = Access(arena.alloc(paren_var), "field"); - let actual = parse_with(&arena, "(rec).field"); + let actual = parse_expr_with(&arena, "(rec).field"); assert_eq!(Ok(expected), actual); } @@ -1022,7 +1022,7 @@ mod test_parse { ident: "rec", })); let expected = Access(arena.alloc(paren_var), "field"); - let actual = parse_with(&arena, "(One.Two.rec).field"); + let actual = parse_expr_with(&arena, "(One.Two.rec).field"); assert_eq!(Ok(expected), actual); } @@ -1038,7 +1038,7 @@ mod test_parse { arena.alloc(Access(arena.alloc(Access(arena.alloc(var), "abc")), "def")), "ghi", ); - let actual = parse_with(&arena, "rec.abc.def.ghi"); + let actual = parse_expr_with(&arena, "rec.abc.def.ghi"); assert_eq!(Ok(expected), actual); } @@ -1054,7 +1054,7 @@ mod test_parse { arena.alloc(Access(arena.alloc(Access(arena.alloc(var), "abc")), "def")), "ghi", ); - let actual = parse_with(&arena, "One.Two.rec.abc.def.ghi"); + let actual = parse_expr_with(&arena, "One.Two.rec.abc.def.ghi"); assert_eq!(Ok(expected), actual); } @@ -1075,7 +1075,7 @@ mod test_parse { args, CalledVia::Space, ); - let actual = parse_with(&arena, "whee 1"); + let actual = parse_expr_with(&arena, "whee 1"); assert_eq!(Ok(expected), actual); } @@ -1100,7 +1100,7 @@ mod test_parse { args, CalledVia::Space, ); - let actual = parse_with(&arena, "whee 12 34"); + let actual = parse_expr_with(&arena, "whee 12 34"); assert_eq!(Ok(expected), actual); } @@ -1153,7 +1153,7 @@ mod test_parse { args, CalledVia::Space, ); - let actual = parse_with(&arena, "a b c d"); + let actual = parse_expr_with(&arena, "a b c d"); assert_eq!(Ok(expected), actual); } @@ -1172,7 +1172,7 @@ mod test_parse { args, CalledVia::Space, ); - let actual = parse_with(&arena, "(whee) 1"); + let actual = parse_expr_with(&arena, "(whee) 1"); assert_eq!(Ok(expected), actual); } @@ -1189,7 +1189,7 @@ mod test_parse { }; let loc_arg1_expr = Located::new(0, 0, 1, 4, arg1_expr); let expected = UnaryOp(arena.alloc(loc_arg1_expr), loc_op); - let actual = parse_with(&arena, "-foo"); + let actual = parse_expr_with(&arena, "-foo"); assert_eq!(Ok(expected), actual); } @@ -1204,7 +1204,7 @@ mod test_parse { }; let loc_arg1_expr = Located::new(0, 0, 1, 5, arg1_expr); let expected = UnaryOp(arena.alloc(loc_arg1_expr), loc_op); - let actual = parse_with(&arena, "!blah"); + let actual = parse_expr_with(&arena, "!blah"); assert_eq!(Ok(expected), actual); } @@ -1240,7 +1240,7 @@ mod test_parse { CalledVia::Space, ); let expected = UnaryOp(arena.alloc(Located::new(0, 0, 1, 13, apply_expr)), loc_op); - let actual = parse_with(&arena, "-whee 12 foo"); + let actual = parse_expr_with(&arena, "-whee 12 foo"); assert_eq!(Ok(expected), actual); } @@ -1276,7 +1276,7 @@ mod test_parse { CalledVia::Space, ); let expected = UnaryOp(arena.alloc(Located::new(0, 0, 1, 13, apply_expr)), loc_op); - let actual = parse_with(&arena, "!whee 12 foo"); + let actual = parse_expr_with(&arena, "!whee 12 foo"); assert_eq!(Ok(expected), actual); } @@ -1312,7 +1312,7 @@ mod test_parse { CalledVia::Space, ))); let expected = UnaryOp(arena.alloc(Located::new(0, 0, 1, 15, apply_expr)), loc_op); - let actual = parse_with(&arena, "-(whee 12 foo)"); + let actual = parse_expr_with(&arena, "-(whee 12 foo)"); assert_eq!(Ok(expected), actual); } @@ -1348,7 +1348,7 @@ mod test_parse { CalledVia::Space, ))); let expected = UnaryOp(arena.alloc(Located::new(0, 0, 1, 15, apply_expr)), loc_op); - let actual = parse_with(&arena, "!(whee 12 foo)"); + let actual = parse_expr_with(&arena, "!(whee 12 foo)"); assert_eq!(Ok(expected), actual); } @@ -1375,7 +1375,7 @@ mod test_parse { args, CalledVia::Space, ); - let actual = parse_with(&arena, "whee 12 -foo"); + let actual = parse_expr_with(&arena, "whee 12 -foo"); assert_eq!(Ok(expected), actual); } @@ -1392,7 +1392,7 @@ mod test_parse { let access = Access(arena.alloc(var), "field"); let loc_access = Located::new(0, 0, 1, 11, access); let expected = UnaryOp(arena.alloc(loc_access), loc_op); - let actual = parse_with(&arena, "-rec1.field"); + let actual = parse_expr_with(&arena, "-rec1.field"); assert_eq!(Ok(expected), actual); } @@ -1405,7 +1405,7 @@ mod test_parse { let pattern = Located::new(0, 0, 1, 2, Identifier("a")); let patterns = &[pattern]; let expected = Closure(patterns, arena.alloc(Located::new(0, 0, 6, 8, Num("42")))); - let actual = parse_with(&arena, "\\a -> 42"); + let actual = parse_expr_with(&arena, "\\a -> 42"); assert_eq!(Ok(expected), actual); } @@ -1416,7 +1416,7 @@ mod test_parse { let pattern = Located::new(0, 0, 1, 2, Underscore); let patterns = &[pattern]; let expected = Closure(patterns, arena.alloc(Located::new(0, 0, 6, 8, Num("42")))); - let actual = parse_with(&arena, "\\_ -> 42"); + let actual = parse_expr_with(&arena, "\\_ -> 42"); assert_eq!(Ok(expected), actual); } @@ -1427,7 +1427,7 @@ mod test_parse { // underscore in an argument name, it would parse as three arguments // (and would ignore the underscore as if it had been blank space). let arena = Bump::new(); - let actual = parse_with(&arena, "\\the_answer -> 42"); + let actual = parse_expr_with(&arena, "\\the_answer -> 42"); assert_eq!(Ok(MalformedClosure), actual); } @@ -1439,7 +1439,7 @@ mod test_parse { let arg2 = Located::new(0, 0, 4, 5, Identifier("b")); let patterns = &[arg1, arg2]; let expected = Closure(patterns, arena.alloc(Located::new(0, 0, 9, 11, Num("42")))); - let actual = parse_with(&arena, "\\a, b -> 42"); + let actual = parse_expr_with(&arena, "\\a, b -> 42"); assert_eq!(Ok(expected), actual); } @@ -1455,7 +1455,7 @@ mod test_parse { arena.alloc(patterns), arena.alloc(Located::new(0, 0, 12, 14, Num("42"))), ); - let actual = parse_with(&arena, "\\a, b, c -> 42"); + let actual = parse_expr_with(&arena, "\\a, b, c -> 42"); assert_eq!(Ok(expected), actual); } @@ -1470,7 +1470,7 @@ mod test_parse { arena.alloc(patterns), arena.alloc(Located::new(0, 0, 9, 11, Num("42"))), ); - let actual = parse_with(&arena, "\\_, _ -> 42"); + let actual = parse_expr_with(&arena, "\\_, _ -> 42"); assert_eq!(Ok(expected), actual); } @@ -2038,7 +2038,7 @@ mod test_parse { }; let loc_cond = Located::new(0, 0, 5, 6, var); let expected = Expr::When(arena.alloc(loc_cond), branches); - let actual = parse_with( + let actual = parse_expr_with( &arena, indoc!( r#" @@ -2082,7 +2082,7 @@ mod test_parse { }; let loc_cond = Located::new(0, 0, 5, 6, var); let expected = Expr::When(arena.alloc(loc_cond), branches); - let actual = parse_with( + let actual = parse_expr_with( &arena, indoc!( r#" @@ -2131,7 +2131,7 @@ mod test_parse { }; let loc_cond = Located::new(0, 0, 5, 6, var); let expected = Expr::When(arena.alloc(loc_cond), branches); - let actual = parse_with( + let actual = parse_expr_with( &arena, indoc!( r#" @@ -2181,7 +2181,7 @@ mod test_parse { }; let loc_cond = Located::new(0, 0, 5, 6, var); let expected = Expr::When(arena.alloc(loc_cond), branches); - let actual = parse_with( + let actual = parse_expr_with( &arena, indoc!( r#" @@ -2488,7 +2488,7 @@ mod test_parse { }; let loc_cond = Located::new(0, 0, 5, 6, var); let expected = Expr::When(arena.alloc(loc_cond), branches); - let actual = parse_with( + let actual = parse_expr_with( &arena, indoc!( r#" @@ -2533,7 +2533,7 @@ mod test_parse { }; let loc_cond = Located::new(0, 0, 5, 6, var); let expected = Expr::When(arena.alloc(loc_cond), branches); - let actual = parse_with( + let actual = parse_expr_with( &arena, indoc!( r#"