6import Data.Maybe (Maybe(..))
7import Data.Either (Either(..))
8import Data.Unfoldable (replicate)
9import Data.Foldable (and)
10import Data.Array (catMaybes, zipWith)
12import Text.Parsing.Parser (runParserT)
13import Data.ArrayBuffer.Builder (execPut)
14import Data.ArrayBuffer.DataView as DV
15import Data.Float32 as Float32
16import Data.Long.Internal as Long
17import Data.UInt as UInt
18import Data.Generic.Rep.Eq (genericEq)
20import Pack.Msg1 as Pack1
21import Pack.Msg2 as Pack2
22import Pack3.Msg3 as Pack3
23import Pack4.Msg4 as Pack4
24import Pack5.Msg5 as Pack5
26import Test.Assert (assert')
31billion = UInt.fromInt 1000000000
32billion2' :: Long.Long Long.Signed
33billion2' = Long.fromLowHighBits billion' billion'
34billion2 :: Long.Long Long.Unsigned
35billion2 = Long.fromLowHighBits 1000000000 1000000000
40 let msg4 = (Pack4.Msg2 -- this is just a compile test
41 { f1: Just $ Pack4.Msg1_Msg2 { nested: Just "nested" }
44 let msg6 = (Pack5.Msg2 -- this is just a compile test
45 { sum1: Just $ Pack5.Msg2_Sum1_F1 $ Pack5.Msg1
46 { sum1: Just $ Pack5.Msg1_Sum1_F3 billion'
50 let msg1 = (Pack1.Msg1
52 , f2: Float32.fromNumber 345.6
64 -- -- , f14 :: Maybe.Maybe ArrayBuffer.Types.ArrayBuffer
65 , f15: Just Pack1.Msg1_E1_Three
68 ab1 <- execPut $ Pack1.putMsg1 msg1
69 let dv1 = DV.whole ab1
70 parseResult1 <- runParserT dv1 $ Pack1.parseMsg1 $ DV.byteLength dv1
72 Left err -> assert' ("msg1 parse " <> show err) false
73 Right msg1' -> assert' "msg1 roundtrip" $ genericEq msg1 msg1'
75 let msg2 = (Pack2.Msg2
76 { f1: replicate 3 1234.5
77 , f2: catMaybes [Float32.fromNumber 345.6, Float32.fromNumber 345.6]
78 , f3: replicate 3 billion'
79 , f4: replicate 3 billion2'
80 , f5: replicate 3 billion
81 , f6: replicate 3 billion2
82 , f7: replicate 3 billion'
83 , f8: replicate 3 billion2'
84 , f9: replicate 3 billion
85 , f10: replicate 3 billion2
86 , f11: replicate 3 billion2'
87 , f12: replicate 3 true
88 , f13: replicate 3 "๐"
89 -- -- , f14 :: Maybe.Maybe ArrayBuffer.Types.ArrayBuffer
90 , f15: replicate 3 Pack2.Msg2_E1_Three
93 ab2 <- execPut $ Pack2.putMsg2 msg2
94 let dv2 = DV.whole ab2
95 parseResult2 <- runParserT dv2 $ Pack2.parseMsg2 $ DV.byteLength dv2
97 Left err -> assert' ("msg2 parse " <> show err) false
98 Right msg2' -> assert' "msg2 roundtrip" $ genericEq msg2 msg2'
100 let msg3 = (Pack3.Msg3
101 { f1: replicate 3 msg1
102 , f2: replicate 3 msg2
103 -- , f4: replicate 3 (TestMsgs.Msg3_Msg4 { f1: Just 1 })
106 ab3 <- execPut $ Pack3.putMsg3 msg3
107 let dv3 = DV.whole ab3
108 parseResult3 <- runParserT dv3 $ Pack3.parseMsg3 $ DV.byteLength dv3
110 Left err -> assert' ("msg3 parse " <> show err) false
111 Right (Pack3.Msg3 {f1:f1',f2:f2'}) -> assert' "msg3 roundtrip" $
112 (and $ zipWith genericEq f1 f1') && (and $ zipWith genericEq f2 f2')
114 Pack3.Msg3 {f1,f2} = msg3
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list