mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-18 16:51:51 +03:00
[ test ] Added regression tests for #2927
This commit is contained in:
parent
24fcc0b551
commit
167258b975
@ -128,7 +128,7 @@ idrisTests = MkTestPool "Misc" [] Nothing
|
||||
"import001", "import002", "import003", "import004", "import005", "import006",
|
||||
"import007", "import008", "import009",
|
||||
-- Implicit laziness, lazy evaluation
|
||||
"lazy001", "lazy002", "lazy003", "lazy004",
|
||||
"lazy001", "lazy002", "lazy003", "lazy004", "lazy005",
|
||||
-- Namespace blocks
|
||||
"namespace001", "namespace002", "namespace003", "namespace004", "namespace005",
|
||||
-- Parameters blocks
|
||||
|
28
tests/idris2/misc/lazy005/LiftedBot.idr
Normal file
28
tests/idris2/misc/lazy005/LiftedBot.idr
Normal file
@ -0,0 +1,28 @@
|
||||
import Data.List.Lazy
|
||||
|
||||
import Debug.Trace
|
||||
|
||||
showHead : Show a => LazyList a -> String
|
||||
showHead [] = "Empty"
|
||||
showHead (x::xs) = show x
|
||||
|
||||
%inline
|
||||
(::) : Maybe a -> Lazy (LazyList a) -> LazyList a
|
||||
Nothing :: xs = xs
|
||||
Just x :: xs = x :: xs
|
||||
|
||||
bot : a
|
||||
bot = bot
|
||||
|
||||
fufu : a -> Maybe a
|
||||
fufu = Just
|
||||
|
||||
g : LazyList Nat
|
||||
g = [ fufu 6
|
||||
, fufu bot
|
||||
]
|
||||
|
||||
-- Note that this should finish in finite time, as tail containing
|
||||
-- `bot` is lazy and should never be computed
|
||||
main : IO Unit
|
||||
main = printLn $ showHead g
|
22
tests/idris2/misc/lazy005/LiftedTrace.idr
Normal file
22
tests/idris2/misc/lazy005/LiftedTrace.idr
Normal file
@ -0,0 +1,22 @@
|
||||
import Data.List.Lazy
|
||||
|
||||
import Debug.Trace
|
||||
|
||||
%default total
|
||||
|
||||
%inline
|
||||
(::) : Maybe a -> Lazy (LazyList a) -> LazyList a
|
||||
Nothing :: xs = xs
|
||||
Just x :: xs = x :: xs
|
||||
|
||||
fufu : a -> Maybe a
|
||||
fufu = Just
|
||||
|
||||
g : LazyList Nat
|
||||
g = trace "--- outmost ---"
|
||||
[ fufu $ trace "pure 6" 6
|
||||
, fufu $ trace "pure 5" 5
|
||||
]
|
||||
|
||||
main : IO Unit
|
||||
main = printLn g
|
5
tests/idris2/misc/lazy005/expected
Normal file
5
tests/idris2/misc/lazy005/expected
Normal file
@ -0,0 +1,5 @@
|
||||
pure 6
|
||||
--- outmost ---
|
||||
pure 5
|
||||
[6, 5]
|
||||
"6"
|
4
tests/idris2/misc/lazy005/run
Executable file
4
tests/idris2/misc/lazy005/run
Executable file
@ -0,0 +1,4 @@
|
||||
. ../../../testutils.sh
|
||||
|
||||
idris2 -p contrib --exec main LiftedTrace.idr
|
||||
idris2 -p contrib --exec main LiftedBot.idr
|
Loading…
Reference in New Issue
Block a user