forked from idris-lang/Idris2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ cleanup ] Do not wrap the
mainExpression
into lazy
in ES backends
- Loading branch information
Showing
5 changed files
with
50 additions
and
4 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
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,4 @@ | ||
module HelloWorld | ||
|
||
main : IO () | ||
main = putStrLn "Hello, world!" |
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,7 @@ | ||
module LazyIsStillThere | ||
|
||
topLevelConst : Nat | ||
topLevelConst = 16 + 8 | ||
|
||
main : IO () | ||
main = putStrLn "Top-level constant: \{show topLevelConst}" |
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,15 @@ | ||
# Top-level constants are lazily evaluated and strongly memoised. | ||
# This is implemented by wrapping them to the function called `__lazy`. | ||
# The only top-level function that should not be treated so is the expression for `main : IO ()`. | ||
# In this test we check this. | ||
-------------- | ||
# Running an example without any top-level constants... | ||
# We expect no usages of `__lazy` to be present, maybe only a definition. | ||
Hello, world! | ||
function __lazy(thunk) { | ||
-------------- | ||
# Running an example with some top-level constant... | ||
# We expect `__lazy` to be used on the RHS for the top-level constant called `topLevelConst`. | ||
Top-level constant: 24 | ||
function __lazy(thunk) { | ||
const LazyIsStillThere_topLevelConst = __lazy(function () { |
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,20 @@ | ||
. ../../testutils.sh | ||
|
||
echo '# Top-level constants are lazily evaluated and strongly memoised.' | ||
echo '# This is implemented by wrapping them to the function called `__lazy`.' | ||
echo '# The only top-level function that should not be treated so is the expression for `main : IO ()`.' | ||
echo '# In this test we check this.' | ||
|
||
echo '--------------' | ||
|
||
echo '# Running an example without any top-level constants...' | ||
echo '# We expect no usages of `__lazy` to be present, maybe only a definition.' | ||
run --cg node -o hw.js HelloWorld.idr | ||
grep '__lazy' build/exec/hw.js | ||
|
||
echo '--------------' | ||
|
||
echo '# Running an example with some top-level constant...' | ||
echo '# We expect `__lazy` to be used on the RHS for the top-level constant called `topLevelConst`.' | ||
run --cg node -o lsth.js LazyIsStillThere.idr | ||
grep '__lazy' build/exec/lsth.js |