-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
120 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
{ | ||
"type": "application", | ||
"source-directories": ["src", "codegen", "../../src"], | ||
"elm-version": "0.19.1", | ||
"dependencies": { | ||
"direct": { | ||
"Chadtech/elm-bool-extra": "2.4.2", | ||
"elm/browser": "1.0.2", | ||
"elm/core": "1.0.5", | ||
"elm/html": "1.0.0", | ||
"elm/json": "1.1.3", | ||
"elm/parser": "1.1.0", | ||
"elm/project-metadata-utils": "1.0.2", | ||
"elm-community/maybe-extra": "5.2.0", | ||
"rtfeldman/elm-hex": "1.0.0", | ||
"stil4m/elm-syntax": "7.2.4", | ||
"the-sett/elm-pretty-printer": "3.0.0" | ||
"type": "application", | ||
"source-directories": [ | ||
"src", | ||
"codegen", | ||
"../../src" | ||
], | ||
"elm-version": "0.19.1", | ||
"dependencies": { | ||
"direct": { | ||
"Chadtech/elm-bool-extra": "2.4.2", | ||
"elm/browser": "1.0.2", | ||
"elm/core": "1.0.5", | ||
"elm/html": "1.0.0", | ||
"elm/json": "1.1.3", | ||
"elm/parser": "1.1.0", | ||
"elm/project-metadata-utils": "1.0.2", | ||
"elm-community/maybe-extra": "5.2.0", | ||
"rtfeldman/elm-hex": "1.0.0", | ||
"stil4m/elm-syntax": "7.2.4", | ||
"the-sett/elm-pretty-printer": "3.0.0" | ||
}, | ||
"indirect": { | ||
"elm/time": "1.0.0", | ||
"elm/url": "1.0.0", | ||
"elm/virtual-dom": "1.0.2", | ||
"elm-community/basics-extra": "4.1.0", | ||
"elm-community/list-extra": "8.3.0", | ||
"miniBill/elm-unicode": "1.0.2", | ||
"stil4m/structured-writer": "1.0.3" | ||
} | ||
}, | ||
"indirect": { | ||
"elm/time": "1.0.0", | ||
"elm/url": "1.0.0", | ||
"elm/virtual-dom": "1.0.2", | ||
"elm-community/basics-extra": "4.1.0", | ||
"elm-community/list-extra": "8.3.0", | ||
"miniBill/elm-unicode": "1.0.2", | ||
"stil4m/structured-writer": "1.0.3" | ||
"test-dependencies": { | ||
"direct": { | ||
"elm-explorations/test": "1.2.2" | ||
}, | ||
"indirect": { | ||
"elm/random": "1.0.0" | ||
} | ||
} | ||
}, | ||
"test-dependencies": { | ||
"direct": {}, | ||
"indirect": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Generate exposing (main) | ||
module Generate exposing (main, moduleToFile, parseSources) | ||
|
||
{-| -} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
module Tests exposing (suite) | ||
|
||
import DocsFromSource | ||
import Expect | ||
import Generate | ||
import Test exposing (Test, test) | ||
|
||
|
||
source : String | ||
source = | ||
"""module Foo exposing (a) | ||
import Imported exposing (Foo(..)) | ||
type alias Foo a = | ||
Imported.Foo a | ||
a : Foo Int | ||
a = | ||
Debug.todo "" | ||
""" | ||
|
||
|
||
expected : String | ||
expected = | ||
"""module Gen.Foo exposing ( moduleName_, a, values_ ) | ||
{-| | ||
# Generated bindings for Foo | ||
@docs moduleName_, a, values_ | ||
-} | ||
import Elm | ||
import Elm.Annotation as Type | ||
{-| The name of this module. -} | ||
moduleName_ : List String | ||
moduleName_ = | ||
[ "Foo" ] | ||
{-| a: Foo.Foo Int -} | ||
a : Elm.Expression | ||
a = | ||
Elm.value | ||
{ importFrom = [ "Foo" ] | ||
, name = "a" | ||
, annotation = Just (Type.namedWith [ "Foo" ] "Foo" [ Type.int ]) | ||
} | ||
values_ : { a : Elm.Expression } | ||
values_ = | ||
{ a = | ||
Elm.value | ||
{ importFrom = [ "Foo" ] | ||
, name = "a" | ||
, annotation = Just (Type.namedWith [ "Foo" ] "Foo" [ Type.int ]) | ||
} | ||
}""" | ||
|
||
|
||
suite : Test | ||
suite = | ||
test "Aliases are codegenned properly" <| | ||
\_ -> | ||
case DocsFromSource.fromSource source of | ||
Err _ -> | ||
Expect.fail "Could not parse source" | ||
|
||
Ok file -> | ||
Generate.moduleToFile file | ||
|> Expect.equal | ||
{ path = "Gen/Foo.elm" | ||
, contents = expected | ||
, warnings = [] | ||
} |