]> Git — Sourcephile - haskell/symantic.git/blob - symantic-lib/Language/Symantic/Lib/Map/Test.hs
Fix Inj_ConstP -> Inj_TyConstP.
[haskell/symantic.git] / symantic-lib / Language / Symantic / Lib / Map / Test.hs
1 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
2 {-# OPTIONS_GHC -O0 -fmax-simplifier-iterations=0 #-}
3 module Lib.Map.Test where
4
5 import Test.Tasty
6
7 import Data.Map.Strict (Map)
8 import qualified Data.Map.Strict as Map
9 import Data.Proxy (Proxy(..))
10 import Data.Text as Text
11 import Prelude hiding (zipWith)
12
13 import Language.Symantic.Typing
14 import Compiling.Term.Test
15
16 type Ifaces =
17 [ Proxy (->)
18 , Proxy []
19 , Proxy Int
20 , Proxy Integer
21 , Proxy Map
22 , Proxy Char
23 , Proxy (,)
24 , Proxy Num
25 , Proxy Monoid
26 ]
27 (==>) = test_compile @Ifaces
28
29 tests :: TestTree
30 tests = testGroup "Map"
31 [ "Map.fromList (zipWith (\\(x:Integer) (y:Char) -> (x, y)) [1, 2, 3] ['a', 'b', 'c'])" ==> Right
32 ( (ty @Map :$ ty @Integer) :$ ty @Char
33 , Map.fromList [(1, 'a'), (2, 'b'), (3, 'c')]
34 , "Map.fromList (((\\x0 -> (\\x1 -> zipWith (\\x2 -> (\\x3 -> (x2, x3))) x0 x1)) (1 : 2 : 3 : [])) ('a' : 'b' : 'c' : []))" )
35 , Text.concat
36 [ "Map.foldrWithKey"
37 , " (\\(k:Integer) (v:Char) (acc:(Integer,[Char])) ->"
38 , " (k + fst acc, v : snd acc))"
39 , " (0, [] @Char)"
40 , " (Map.fromList (zipWith (\\(x:Integer) (y:Char) -> (x,y)) [1, 2, 3] ['a', 'b', 'c']))"
41 ] ==> Right
42 ( (ty @(,) :$ ty @Integer) :$ (ty @[] :$ ty @Char)
43 , (6, "abc")
44 , "((\\x0 -> (\\x1 -> Map.foldrWithKey (\\x2 -> (\\x3 -> (\\x4 -> ((\\x5 -> x2 + x5) (fst x4), x3 : snd x4)))) x0 x1)) (0, [])) (Map.fromList (((\\x0 -> (\\x1 -> zipWith (\\x2 -> (\\x3 -> (x2, x3))) x0 x1)) (1 : 2 : 3 : [])) ('a' : 'b' : 'c' : [])))" )
45 ]