mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
testing up the tests
This commit is contained in:
parent
1d0f546a53
commit
593c7a6631
@ -635,19 +635,8 @@ object CompilationTests {
|
||||
termFor(Builtins.Stream_cons)(1, termFor(Builtins.Stream_empty)))
|
||||
},
|
||||
test("map") { implicit T =>
|
||||
// Stream.foldLeft +0 (+) (Stream.take 100 (Stream.map (\x -> x + 1) (Stream.fromInt +0)))
|
||||
equal[Term](
|
||||
eval(
|
||||
termFor(Builtins.Stream_foldLeft)(
|
||||
0,
|
||||
termFor(Builtins.Int64_add),
|
||||
termFor(Builtins.Stream_take)(
|
||||
100,
|
||||
termFor(Builtins.Stream_map)(
|
||||
termFor(Builtins.Int64_inc),
|
||||
termFor(Builtins.Stream_fromInt64)(0)))
|
||||
)
|
||||
),
|
||||
eval(Stream.foldLeft(0, Int64.+, Stream.take(100, Stream.map(Int64.inc, Stream.fromInt64(0))))),
|
||||
scala.Stream.from(0).map(1+).take(100).foldLeft(0)(_+_)
|
||||
)
|
||||
}
|
||||
@ -1017,6 +1006,18 @@ object Terms {
|
||||
val lteq = termFor(Text_lteq)
|
||||
val gteq = termFor(Text_gteq)
|
||||
}
|
||||
|
||||
object Stream {
|
||||
import Builtins._
|
||||
val empty = termFor(Stream_empty)
|
||||
val fromInt64 = termFor(Stream_fromInt64)
|
||||
val fromUInt64 = termFor(Stream_fromUInt64)
|
||||
val cons = termFor(Stream_cons)
|
||||
val drop = termFor(Stream_drop)
|
||||
val take = termFor(Stream_take)
|
||||
val map = termFor(Stream_map)
|
||||
val foldLeft = termFor(Stream_foldLeft)
|
||||
}
|
||||
|
||||
object Debug {
|
||||
import Builtins._
|
||||
|
@ -10,13 +10,10 @@ fib4 n =
|
||||
n -> loop b c d (a + b + c + d) (n - 1)
|
||||
loop 0 0 0 1 n
|
||||
|
||||
ten-simple =
|
||||
t = Stream.take 10 (Stream.map fib4 (Stream.from-uint64 0))
|
||||
p = 9000
|
||||
q = 900
|
||||
r = 90
|
||||
s = 9
|
||||
sum = Stream.fold-left 0 (+) t
|
||||
sum * 10000 + p + q + r + s
|
||||
|
||||
ten-simple
|
||||
t = Stream.take 10 (Stream.map fib4 (Stream.from-uint64 0))
|
||||
p = 9000
|
||||
q = 900
|
||||
r = 90
|
||||
s = 9
|
||||
sum = Stream.fold-left 0 (+) t
|
||||
sum * 10000 + p + q + r + s
|
||||
|
15
unison-src/tests/stream-shoudnt-damage-stack.u
Normal file
15
unison-src/tests/stream-shoudnt-damage-stack.u
Normal file
@ -0,0 +1,15 @@
|
||||
(+) = (+_UInt64)
|
||||
(-) = UInt64.drop
|
||||
(*) = (*_UInt64)
|
||||
|
||||
eat-stack n = case n of
|
||||
0 -> 0
|
||||
n -> eat-stack (n - 1) + 1
|
||||
|
||||
t = Stream.take 1 (Stream.map eat-stack (Stream.from-uint64 0))
|
||||
p = 9000
|
||||
q = 900
|
||||
r = 90
|
||||
s = 9
|
||||
sum = Stream.fold-left 0 (+) t
|
||||
sum * 10000 + p + q + r + s
|
Loading…
Reference in New Issue
Block a user