Skip to content

Commit ffbfa8a

Browse files
committed
Adding tests
1 parent 697593b commit ffbfa8a

5 files changed

+85
-0
lines changed

test/AllTests.agda

+6
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ import Issue286
7575
import NonClassInstance
7676
import Issue218
7777
import Issue251
78+
import HaskellDataOpenImport
79+
import HaskellDataQualifiedImport
80+
import Map
7881

7982
{-# FOREIGN AGDA2HS
8083
import Issue14
@@ -149,4 +152,7 @@ import Issue286
149152
import NonClassInstance
150153
import Issue218
151154
import Issue251
155+
import HaskellDataOpenImport
156+
import HaskellDataQualifiedImport
157+
import Map
152158
#-}

test/HaskellDataOpenImport.agda

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{-# OPTIONS --erasure #-}
2+
3+
module HaskellDataOpenImport where
4+
5+
open import Agda.Builtin.Int
6+
open import Haskell.Data.Map
7+
8+
map : Map Int Int
9+
map = empty
10+
{-# COMPILE AGDA2HS map #-}

test/HaskellDataQualifiedImport.agda

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{-# OPTIONS --erasure #-}
2+
3+
module HaskellDataQualifiedImport where
4+
5+
open import Agda.Builtin.Int
6+
import Haskell.Data.Map as Map
7+
8+
map : Map.Map Int Int
9+
map = Map.empty
10+
{-# COMPILE AGDA2HS map #-}

test/Map.agda

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
-- A test pack for Data.Map.
2+
module Map where
3+
4+
open import Agda.Builtin.Equality
5+
open import Agda.Builtin.Nat
6+
open import Agda.Builtin.List
7+
open import Haskell.Prim.Maybe
8+
open import Haskell.Prim.Ord
9+
open import Haskell.Prim.Tuple
10+
open import Haskell.Law.Equality
11+
import Haskell.Data.Map as Map
12+
open Map using (Map)
13+
14+
firstMap : Map Nat Nat
15+
firstMap = Map.fromList ((50 , 5) ∷ (40 , 4) ∷ (100 , 10) ∷ [])
16+
{-# COMPILE AGDA2HS firstMap #-}
17+
18+
val1 : Maybe Nat
19+
val1 = Map.lookup 100 firstMap
20+
{-# COMPILE AGDA2HS val1 #-}
21+
22+
@0 test1 : val1 ≡ Just 10
23+
test1 = trans (Map.insertNotChangingOthers 100 50 5 (Map.fromList ((40 , 4) ∷ (100 , 10) ∷ [])))
24+
(trans (Map.insertNotChangingOthers 100 40 4 (Map.fromList ((100 , 10) ∷ [])))
25+
(Map.memberAfterInsertion 100 10 Map.empty))
26+
27+
val2 : Maybe Nat
28+
val2 = Map.lookup 15 firstMap
29+
{-# COMPILE AGDA2HS val2 #-}
30+
31+
@0 test2 : val2 ≡ Nothing
32+
test2 = trans (Map.insertNotChangingOthers 15 50 5 (Map.fromList ((40 , 4) ∷ (100 , 10) ∷ [])))
33+
(trans (Map.insertNotChangingOthers 15 40 4 (Map.fromList ((100 , 10) ∷ [])))
34+
(trans (Map.insertNotChangingOthers 15 100 10 Map.empty)
35+
(fst (Map.notMember↔Nothing 15 Map.empty)
36+
(Map.nullHasNoMembers Map.empty Map.emptyIsNull 15))))
37+
38+
secondMap : Map Nat Nat
39+
secondMap = Map.delete 50 firstMap
40+
{-# COMPILE AGDA2HS secondMap #-}
41+
42+
val3 : Maybe Nat
43+
val3 = Map.lookup 50 secondMap
44+
{-# COMPILE AGDA2HS val3 #-}
45+
46+
@0 test3 : val3 ≡ Nothing
47+
test3 = fst (Map.notMember↔Nothing 50 secondMap)
48+
(Map.notMemberAfterDeletion 50 firstMap)
49+
50+
val4 : Maybe Nat
51+
val4 = Map.lookup 100 secondMap
52+
{-# COMPILE AGDA2HS val4 #-}
53+
54+
@0 test4 : val4 ≡ Just 10
55+
test4 = trans (Map.deleteNotChangingOthers 100 50 firstMap)
56+
test1

test/golden/AllTests.hs

+3
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,7 @@ import Issue286
7272
import NonClassInstance
7373
import Issue218
7474
import Issue251
75+
import HaskellDataOpenImport
76+
import HaskellDataQualifiedImport
77+
import Map
7578

0 commit comments

Comments
 (0)