Skip to content

Commit

Permalink
Test coerce
Browse files Browse the repository at this point in the history
  • Loading branch information
augustss committed Dec 29, 2024
1 parent 581fb54 commit c6e8e33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/Coerce.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ toInt = coerce
toInts :: (Coercible a Int) => [a] -> [Int]
toInts = coerce

casbs :: (Coercible a b) => [a] -> [b]
casbs = coerce

main :: IO ()
main = do
print (toInt (NT 5))
print (toInts [NT 1, NT 2] :: [Int])
print (casbs [NT 1, NT 2, NT 3] :: [Int])
print (coerce (List [3::Int, 4]) :: [Int])
print (coerce (List [NT 5, NT 6]) :: [NT])
print (coerce (List [NT 7, NT 8]) :: [Int])
6 changes: 6 additions & 0 deletions tests/Coerce.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
5
[1,2]
[1,2,3]
[3,4]
[NT 5,NT 6]
[7,8]
1 change: 1 addition & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ test:
$(TMHS) OrPat && $(EVAL) > OrPat.out && diff OrPat.ref OrPat.out
$(TMHS) PartRed && $(EVAL) > PartRed.out && diff PartRed.ref PartRed.out
$(TMHS) PatSyn && $(EVAL) > PatSyn.out && diff PatSyn.ref PatSyn.out
$(TMHS) Coerce && $(EVAL) > Coerce.out && diff Coerce.ref Coerce.out

errtest:
sh errtester.sh $(MHS) < errmsg.test
Expand Down

0 comments on commit c6e8e33

Please sign in to comment.