-
Notifications
You must be signed in to change notification settings - Fork 0
[wip] Integration tests #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vic
wants to merge
8
commits into
master
Choose a base branch
from
integration_tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cc2231e
Add elmer_runtime to test deps and sample test
davoclavo 7181f04
Generate and load binary code generated from elm
davoclavo 44d5d7b
Resolve core deps and add native module
davoclavo 98405e1
Add missing load_binary for compiled test module
davoclavo 91636e1
Pattern match in Funs is kind of cool
davoclavo 8e5f7b3
Add beam dump
davoclavo 2b98d82
Prefix local names with ?MODULE
vic 5f242ec
Handle TailDef in let
davoclavo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,11 @@ | ||
| {erl_opts, [debug_info]}. | ||
| {deps, [ | ||
| {jsx, "2.8.0"} | ||
| ]}. | ||
| {profiles, [ | ||
| {test, [ | ||
| {deps, [ | ||
| {elmer_runtime, {git, "git://github.com/elmer-compiler/elmer_runtime.git", {branch, "master"}}} | ||
| ]} | ||
| ]} | ||
| ]}. |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| -module('Elm.LetInTailDef'). |
This file contains hidden or 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,8 @@ | ||
| -module('Elm.Native.Utils'). | ||
|
|
||
| -export([ append/0 ]). | ||
|
|
||
| append() -> | ||
| elmer_runtime:partial(fun (Xs, Ys) when is_binary(Xs) -> erlang:iolist_to_binary([Xs, Ys]); | ||
| (Xs, Ys) when is_list(Xs) -> lists:append(Xs, Ys) | ||
| end, 2). | ||
This file contains hidden or 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,12 @@ | ||
| module LetInTailDef exposing (foo) | ||
|
|
||
| foo = | ||
| let | ||
| sum x y = | ||
| if y == 0 then | ||
| x | ||
| else | ||
| sum (x + y) 0 | ||
| val = sum 2 3 | ||
| in | ||
| val |
This file contains hidden or 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,4 @@ | ||
| module RunExample exposing (greet) | ||
|
|
||
| greet name = | ||
| "Howdy, " ++ name |
This file contains hidden or 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,50 @@ | ||
| -module(native_elmer_test). | ||
|
|
||
| -ifdef(TEST). | ||
|
|
||
| -include_lib("eunit/include/eunit.hrl"). | ||
|
|
||
| -define(ELINE, 0). | ||
| -define(USER_BUILD_DIR, "elm-stuff/build-artifacts/0.17.1/user/project/1.0.0"). | ||
| -define(CORE_BUILD_DIR, "elm-stuff/build-artifacts/0.17.1/elm-lang/core/4.0.5"). | ||
|
|
||
| on_cwd(Cwd, Fun) -> | ||
| {ok, OldDir} = file:get_cwd(), | ||
| try file:set_cwd(Cwd) of | ||
| ok -> Fun() | ||
| after | ||
| ok = file:set_cwd(OldDir) | ||
| end. | ||
|
|
||
| elm_compile(ElmModuleName, Format) -> | ||
| ElmFileName = ElmModuleName ++ ".elm", | ||
| on_cwd("test/files", fun () -> elmer_compiler:compile([ElmFileName], Format, []) end). | ||
|
|
||
|
|
||
| user_build_filepath(ElmModuleName) -> | ||
| ?USER_BUILD_DIR ++ "/" ++ ElmModuleName ++ ".elmo". | ||
|
|
||
| core_build_filepath(ElmModuleName) -> | ||
| ?CORE_BUILD_DIR ++ "/" ++ ElmModuleName ++ ".elmo". | ||
|
|
||
| elm_load_module(ElmModuleName, CoreModuleName) -> | ||
| Compiled = elm_compile(ElmModuleName, {beam, "build"}), | ||
| UserElmoFileName = user_build_filepath(ElmModuleName), | ||
| {ok, Module, CompiledBinary} = proplists:get_value(UserElmoFileName, Compiled, elm_not_compiled), | ||
| {module, Module} = code:load_binary(Module, ElmModuleName, CompiledBinary), | ||
| %% TODO Resolve many core module dependencies | ||
| CoreElmoFileName = core_build_filepath(CoreModuleName), | ||
| {ok, CoreModule, CoreCompiledBinary} = proplists:get_value(CoreElmoFileName, Compiled, elm_not_compiled), | ||
| {module, CoreModule} = code:load_binary(CoreModule, CoreModuleName, CoreCompiledBinary), | ||
| Module. | ||
|
|
||
| runs_RunExample_test() -> | ||
| elm_load_module("RunExample", "Basics"), | ||
| %% TODO Figure out where to put Native modules | ||
| Result = ('Elm.RunExample':greet())([<<"doodie">>]), | ||
| ?assertEqual(<<"Howdy, doodie">>, Result), | ||
| Result2 = ('Elm.Native.Utils':append())([[1,2],[3,4]]), | ||
| ?assertEqual([1,2,3,4], Result2). | ||
|
|
||
| -endif. %% TEST | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elm.Native.*should not be implemented here, I'm thinking of having a new repo on the elmer-compiler organization that mirror those from elm-lang, for example one repo for core, one for html, etc, and they MUST use the same semantic version than the package from elm. So for example,Elm.Native.Utilsshould be onelmer-coreetc. IIRC the elm-compiler just concatenates those Native javascript modules when everything is compiled to javascript. But we must require the user to list each elmer-* native package as another erlang dependency at runtime.