@@ -4,6 +4,7 @@ import BitParser
4import BitWriter
4import BitWriter
5import Bytes exposing (Bytes)
5import Bytes exposing (Bytes)
6import Bytes.Extra as Bytes
6import Bytes.Extra as Bytes
7+import Expect exposing (Expectation)
7import Fuzz exposing (Fuzzer)
8import Fuzz exposing (Fuzzer)
8import List.Extra as List
9import List.Extra as List
9import Test exposing (..)
10import Test exposing (..)
@@ -19,9 +20,37 @@ tests =
20 maybeBytesEq (Just a) (BitWriter.run (mat a BitWriter.empty) |> BitParser.run rub)
21 maybeBytesEq (Just a) (BitWriter.run (mat a BitWriter.empty) |> BitParser.run rub)
26+ maybeNounEq (Just n) (BitWriter.run (jam n BitWriter.empty) |> BitParser.run cue)
31+maybeNounEq : Maybe Noun -> Maybe Noun -> Expectation
34+ ( Just x, Just y ) ->
41+nounEq : Noun -> Noun -> Expectation
44+ ( Atom x, Atom y ) ->
47+ ( Cell ( x1, y1 ), Cell ( x2, y2 ) ) ->
48+ Expect.all [ nounEq x1 x2 |> always, nounEq y1 y2 |> always ] ()
51+ Expect.fail (Debug.toString a ++ " /= " ++ Debug.toString b)
25atom : Fuzzer Bytes
54atom : Fuzzer Bytes
@@ -29,12 +58,9 @@ atom =
29 (\a -> a |> Bytes.toByteValues |> List.dropWhileRight (\x -> x == 0) |> Bytes.fromByteValues)
58 (\a -> a |> Bytes.toByteValues |> List.dropWhileRight (\x -> x == 0) |> Bytes.fromByteValues)
32−noun : Fuzzer Noun
61+noun : () -> Fuzzer Noun
34− (\() ->
63+ Fuzz.frequency
36− [ bytes |> Fuzz.map Atom
64+ [ ( 0.6, atom |> Fuzz.map Atom )
37− , Fuzz.map2 (\a b -> Cell ( a, b )) noun noun
65+ , ( 0.4, Fuzz.map2 (\a b -> Cell ( a, b )) (Fuzz.lazy noun) (Fuzz.lazy noun) )