Skip to content

Commit b53cea8

Browse files
committed
new: add recursive and either tests
1 parent 992a5e1 commit b53cea8

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

lambda-buffers-compiler/lambda-buffers-compiler.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ common common-language
8686

8787
common common-imports
8888
build-depends:
89-
, base >=4.16
90-
, lens >=5.2
89+
, base >=4.16
90+
, data-default >=0.7
91+
, lens >=5.2
9192

9293
library
9394
import: common-language
9495
import: common-imports
9596
build-depends:
9697
, containers >=0.6.5.1
97-
, data-default >=0.7
9898
, freer-simple >=1.2
9999
, generic-arbitrary
100100
, generic-lens >=2.2

lambda-buffers-compiler/test/Test/KindCheck.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ testCheck =
4343
, kcTestFailing
4444
, kcTestEither
4545
, kcTestMaybe'n'Either
46-
, kcTestFix
46+
, kcTestRec
4747
]
4848

4949
trivialKCTest :: TestTree
@@ -86,7 +86,14 @@ testFolds =
8686
"Test Folds"
8787
[ testGroup
8888
"Test Arrow Folds"
89-
[testArrowFold0, testArrowFold1, testArrowFold2, testArrowFold3HK, testArrowFold4HK, testArrowFoldHHK, testFoldWithArrowToTypeTotal]
89+
[ testArrowFold0
90+
, testArrowFold1
91+
, testArrowFold2
92+
, testArrowFold3HK
93+
, testArrowFold4HK
94+
, testArrowFoldHHK
95+
, testFoldWithArrowToTypeTotal
96+
]
9097
]
9198

9299
ty :: Kind

lambda-buffers-compiler/test/Test/Utils/Constructors.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ module Test.Utils.Constructors (
2222
_LocalRef,
2323
_LocalRef',
2424
_ForeignRef',
25+
_TyApp,
2526
) where
2627

2728
import Control.Lens ((^.))
2829
import Data.Map qualified as Map
2930
import Data.Text (Text)
3031
import LambdaBuffers.Compiler.ProtoCompat qualified as PC
3132
import LambdaBuffers.Compiler.ProtoCompat.Types (SourceInfo)
33+
import Proto.Compiler_Fields ()
34+
35+
import Data.Default (def)
3236

3337
_CompilerInput :: [PC.Module] -> PC.CompilerInput
3438
_CompilerInput ms =
@@ -116,8 +120,14 @@ _Sum cs =
116120
, sourceInfo = PC.defSourceInfo
117121
}
118122

119-
_TyApp :: PC.Ty
120-
_TyApp = PC.TyAppI
123+
_TyApp :: PC.Ty -> PC.Ty -> PC.Ty
124+
_TyApp ty1 ty2 =
125+
PC.TyAppI $
126+
PC.TyApp
127+
{ PC.tyFunc = ty1
128+
, PC.tyArgs = [ty2]
129+
, PC.sourceInfo = def
130+
}
121131

122132
_TyAbs :: [(Text, PC.KindType)] -> [(Text, PC.Product)] -> PC.TyAbs
123133
_TyAbs args body =

lambda-buffers-compiler/test/Test/Utils/TyDef.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Test.Utils.Constructors (
2020
_SourceInfo,
2121
_TupleI,
2222
_TyAbs,
23+
_TyApp,
2324
_TyDef,
2425
_TyName,
2526
_TyRefILocal,
@@ -53,14 +54,21 @@ tyDef'either =
5354
]
5455
)
5556

57+
-- data F a = Rec F (F a)
5658
tyDef'recDef :: P.TyDef
5759
tyDef'recDef =
5860
_TyDef
5961
(_TyName "F")
6062
( _TyAbs
6163
[ ("a", _Type)
6264
]
63-
[ ("Rec", _TupleI [_TyRefILocal "F"])
65+
[
66+
( "Rec"
67+
, _TupleI
68+
[ _TyApp (_TyRefILocal "F") $
69+
_TyApp (_TyRefILocal "F") (_TyVarI "a")
70+
]
71+
)
6472
]
6573
)
6674

0 commit comments

Comments
 (0)