forked from joxa/joxa
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support implicit do in case/let/defn body's
- Loading branch information
1 parent
2edd6a7
commit 2787f37
Showing
3 changed files
with
68 additions
and
24 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Feature: Joxa should support mulitple expressions in the body of let, defn and case | ||
In order to allow a developer to do side effect code easily | ||
As an Joxa Developer | ||
I want to Joxa to be able have mulitple expressions in bodies without having a do | ||
|
||
Scenario: Support implicit do | ||
Given a module that has an anonymous function | ||
When joxa is called on this module | ||
Then a beam binary is produced | ||
And the described function can be called and works correctly |
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
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,37 @@ | ||
-module(jxat_implicit_do). | ||
|
||
-export([given/3, 'when'/3, then/3]). | ||
-include_lib("eunit/include/eunit.hrl"). | ||
|
||
given([a,module,that,has,an,anonymous,function], _State, _) -> | ||
Source = <<"(module jxat-implicit-do-test | ||
(require io)) | ||
(defn t1 () | ||
(let ((a 1)) | ||
(io/format \"~p\" [a]) | ||
:booha)) | ||
(defn+ do-test () | ||
(case (t1) | ||
(:booha | ||
(io/format \"did it\") | ||
:return-it))) | ||
(defn+ do-test2 () | ||
(t1) | ||
(do-test))">>, | ||
{ok, Source}. | ||
|
||
|
||
'when'([joxa,is,called,on,this,module], Source, _) -> | ||
Result = joxa.compiler:forms("", Source, []), | ||
{ok, Result}. | ||
|
||
then([a,beam,binary,is,produced], State = {_, Binary}, _) -> | ||
?assertMatch(true, is_binary(Binary)), | ||
{ok, State}; | ||
then([the,described,function,can,be,called,'and',works,correctly], State, _) -> | ||
?assertMatch([{'do-test',0},{'do-test2',0},{module_info,0},{module_info,1}], | ||
lists:sort('jxat-implicit-do-test':module_info(exports))), | ||
{ok, State}. | ||
|