diff --git a/cli/tests/fixtures/multi-dep-thunk/Main.roc b/cli/tests/fixtures/multi-dep-thunk/Main.roc index c04b36b7d6..5559d5fc09 100644 --- a/cli/tests/fixtures/multi-dep-thunk/Main.roc +++ b/cli/tests/fixtures/multi-dep-thunk/Main.roc @@ -1,4 +1,4 @@ -app Main provides [ main ] imports [ Dep1 ] +app "test-app" provides [ main ] imports [ Dep1 ] main : Str main = Dep1.value1 {} diff --git a/compiler/load/tests/fixtures/build/app_with_deps/Primary.roc b/compiler/load/tests/fixtures/build/app_with_deps/Primary.roc index 50701ac9b4..8cf44b401d 100644 --- a/compiler/load/tests/fixtures/build/app_with_deps/Primary.roc +++ b/compiler/load/tests/fixtures/build/app_with_deps/Primary.roc @@ -1,4 +1,4 @@ -app Primary +app "primary" provides [ blah2, blah3, str, alwaysThree, identity, z, w, succeed, withDefault, yay ] imports [ Dep1, Dep2.{ two, foo }, Dep3.Blah.{ bar }, Res ] diff --git a/compiler/load/tests/fixtures/build/app_with_deps/Quicksort.roc b/compiler/load/tests/fixtures/build/app_with_deps/Quicksort.roc index 9cbf0c7e38..fc551081c9 100644 --- a/compiler/load/tests/fixtures/build/app_with_deps/Quicksort.roc +++ b/compiler/load/tests/fixtures/build/app_with_deps/Quicksort.roc @@ -1,6 +1,7 @@ -app Quicksort - provides [ swap, partition, partitionHelp, quicksort ] +app "quicksort" + packages {} imports [] + provides [ swap, partition, partitionHelp, quicksort ] to "blah" quicksort : List (Num a), Int, Int -> List (Num a) quicksort = \list, low, high -> diff --git a/compiler/load/tests/fixtures/build/app_with_deps/QuicksortOneDef.roc b/compiler/load/tests/fixtures/build/app_with_deps/QuicksortOneDef.roc index 43906df5ec..c7100377df 100644 --- a/compiler/load/tests/fixtures/build/app_with_deps/QuicksortOneDef.roc +++ b/compiler/load/tests/fixtures/build/app_with_deps/QuicksortOneDef.roc @@ -1,4 +1,4 @@ -app QuicksortOneDef provides [ quicksort ] imports [] +app "quicksort-one-def" provides [ quicksort ] imports [] quicksort = \originalList -> quicksortHelp : List (Num a), Int, Int -> List (Num a) @@ -53,5 +53,5 @@ quicksort = \originalList -> - n = List.len originalList + n = List.len originalList quicksortHelp originalList 0 (n - 1) diff --git a/compiler/load/tests/test_load.rs b/compiler/load/tests/test_load.rs index 97c6b7bbee..f62dab01a6 100644 --- a/compiler/load/tests/test_load.rs +++ b/compiler/load/tests/test_load.rs @@ -238,31 +238,31 @@ mod test_load { "RBTree", indoc!( r#" - interface RBTree exposes [ Dict, empty ] imports [] + interface RBTree exposes [ Dict, empty ] imports [] - # The color of a node. Leaves are considered Black. - NodeColor : [ Red, Black ] + # The color of a node. Leaves are considered Black. + NodeColor : [ Red, Black ] - Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ] + Dict k v : [ Node NodeColor k v (Dict k v) (Dict k v), Empty ] - # Create an empty dictionary. - empty : Dict k v - empty = - Empty - "# + # Create an empty dictionary. + empty : Dict k v + empty = + Empty + "# ), ), ( "Main", indoc!( r#" - app Test provides [ main ] imports [ RBTree ] + app "test-app" provides [ main ] imports [ RBTree ] - empty : RBTree.Dict Int Int - empty = RBTree.empty + empty : RBTree.Dict Int Int + empty = RBTree.empty - main = empty - "# + main = empty + "# ), ), ]; diff --git a/compiler/parse/src/module.rs b/compiler/parse/src/module.rs index dd82351e28..d6506967a3 100644 --- a/compiler/parse/src/module.rs +++ b/compiler/parse/src/module.rs @@ -174,7 +174,7 @@ pub fn module_name<'a>() -> impl Parser<'a, ModuleName<'a>> { } #[inline(always)] -fn app_header<'a>() -> impl Parser<'a, AppHeader<'a>> { +pub fn app_header<'a>() -> impl Parser<'a, AppHeader<'a>> { parser::map( and!( skip_first!( diff --git a/compiler/parse/src/test_helpers.rs b/compiler/parse/src/test_helpers.rs index b7a78e2354..7887ee21ac 100644 --- a/compiler/parse/src/test_helpers.rs +++ b/compiler/parse/src/test_helpers.rs @@ -12,10 +12,10 @@ pub fn parse_expr_with<'a>(arena: &'a Bump, input: &'a str) -> Result(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) diff --git a/compiler/parse/tests/test_parse.rs b/compiler/parse/tests/test_parse.rs index 3e90250eb4..ed698bd960 100644 --- a/compiler/parse/tests/test_parse.rs +++ b/compiler/parse/tests/test_parse.rs @@ -21,13 +21,13 @@ mod test_parse { use roc_parse::ast::CommentOrNewline::*; use roc_parse::ast::Expr::{self, *}; use roc_parse::ast::Pattern::{self, *}; - use roc_parse::ast::StrLiteral::*; + use roc_parse::ast::StrLiteral::{self, *}; use roc_parse::ast::StrSegment::*; use roc_parse::ast::{ self, Attempting, Def, EscapedChar, Spaceable, TypeAnnotation, WhenBranch, }; - use roc_parse::header::{InterfaceHeader, ModuleName}; - use roc_parse::module::{interface_header, module_defs}; + use roc_parse::header::{AppHeader, InterfaceHeader, ModuleName}; + use roc_parse::module::{app_header, interface_header, module_defs}; use roc_parse::parser::{Fail, FailReason, Parser, State}; use roc_parse::test_helpers::parse_expr_with; use roc_region::all::{Located, Region}; @@ -2200,7 +2200,43 @@ mod test_parse { // MODULE #[test] - fn empty_module() { + fn empty_app_header() { + let arena = Bump::new(); + let packages = Vec::new_in(&arena); + let imports = Vec::new_in(&arena); + let provides = Vec::new_in(&arena); + let module_name = StrLiteral::PlainLine("test-app"); + let expected = AppHeader { + name: Located::new(0, 0, 4, 14, module_name), + packages, + imports, + provides, + to: Located::new(0, 0, 53, 57, "blah"), + after_app_keyword: &[], + before_packages: &[], + after_packages: &[], + before_imports: &[], + after_imports: &[], + before_provides: &[], + after_provides: &[], + before_to: &[], + after_to: &[], + }; + + let src = indoc!( + r#" + app "test-app" packages {} imports [] provides [] to blah + "# + ); + let actual = app_header() + .parse(&arena, State::new(src.as_bytes(), Attempting::Module)) + .map(|tuple| tuple.0); + + assert_eq!(Ok(expected), actual); + } + + #[test] + fn empty_interface_header() { let arena = Bump::new(); let exposes = Vec::new_in(&arena); let imports = Vec::new_in(&arena);