parent
634f1f3d9a
commit
8285625156
|
@ -368,6 +368,8 @@ Extra-Source-Files:
|
|||
dhall-lang/tests/typecheck/success/prelude/Text/concatSep/*.dhall
|
||||
dhall-lang/tests/typecheck/success/simple/access/*.dhall
|
||||
dhall-lang/tests/typecheck/success/simple/*.dhall
|
||||
dhall-lang/tests/type-inference/success/simple/*.dhall
|
||||
dhall-lang/tests/type-inference/success/unit/*.dhall
|
||||
tests/format/*.dhall
|
||||
tests/lint/success/*.dhall
|
||||
tests/diff/*.dhall
|
||||
|
@ -533,6 +535,7 @@ Test-Suite tasty
|
|||
Dhall.Test.Regression
|
||||
Dhall.Test.Tutorial
|
||||
Dhall.Test.TypeCheck
|
||||
Dhall.Test.TypeInference
|
||||
Dhall.Test.Util
|
||||
Build-Depends:
|
||||
base >= 4 && < 5 ,
|
||||
|
|
|
@ -14,6 +14,7 @@ import qualified Dhall.Test.QuickCheck
|
|||
import qualified Dhall.Test.Regression
|
||||
import qualified Dhall.Test.Tutorial
|
||||
import qualified Dhall.Test.TypeCheck
|
||||
import qualified Dhall.Test.TypeInference
|
||||
import qualified GHC.IO.Encoding
|
||||
import qualified System.Directory
|
||||
import qualified System.Environment
|
||||
|
@ -30,6 +31,8 @@ getAllTests = do
|
|||
|
||||
typecheckingTests <- Dhall.Test.TypeCheck.getTests
|
||||
|
||||
typeinferenceTests <- Dhall.Test.TypeInference.getTests
|
||||
|
||||
importingTests <- Dhall.Test.Import.getTests
|
||||
|
||||
lintTests <- Dhall.Test.Lint.getTests
|
||||
|
@ -42,6 +45,7 @@ getAllTests = do
|
|||
, parsingTests
|
||||
, importingTests
|
||||
, typecheckingTests
|
||||
, typeinferenceTests
|
||||
, formattingTests
|
||||
, lintTests
|
||||
, diffTests
|
||||
|
|
49
dhall/tests/Dhall/Test/TypeInference.hs
Normal file
49
dhall/tests/Dhall/Test/TypeInference.hs
Normal file
|
@ -0,0 +1,49 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Dhall.Test.TypeInference where
|
||||
|
||||
import Data.Monoid (mempty, (<>))
|
||||
import Data.Text (Text)
|
||||
import Prelude hiding (FilePath)
|
||||
import Test.Tasty (TestTree)
|
||||
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.Text.IO as Text.IO
|
||||
import qualified Dhall.Core as Core
|
||||
import qualified Dhall.Import as Import
|
||||
import qualified Dhall.Parser as Parser
|
||||
import qualified Dhall.Test.Util as Test.Util
|
||||
import qualified Dhall.TypeCheck as TypeCheck
|
||||
import qualified Test.Tasty as Tasty
|
||||
import qualified Test.Tasty.HUnit as Tasty.HUnit
|
||||
import qualified Turtle
|
||||
|
||||
getTests :: IO TestTree
|
||||
getTests = do
|
||||
successTests <- Test.Util.discover (Turtle.chars <* "A.dhall") successTest (Turtle.lstree "./dhall-lang/tests/type-inference/success")
|
||||
|
||||
let testTree = Tasty.testGroup "type-inference tests"
|
||||
[ successTests
|
||||
]
|
||||
|
||||
return testTree
|
||||
|
||||
successTest :: Text -> TestTree
|
||||
successTest prefix = do
|
||||
Tasty.HUnit.testCase (Text.unpack prefix) $ do
|
||||
value <- expr "A.dhall"
|
||||
|
||||
expectedType <- expr "B.dhall"
|
||||
|
||||
inferredType <- Core.throws (TypeCheck.typeOf value)
|
||||
|
||||
let message = "The inferred type did not match the expected type"
|
||||
|
||||
Tasty.HUnit.assertEqual message expectedType inferredType
|
||||
where
|
||||
expr suffix = do
|
||||
code <- Text.IO.readFile (Text.unpack prefix <> suffix)
|
||||
|
||||
e <- Core.throws (Parser.exprFromText mempty code)
|
||||
|
||||
Import.assertNoImports (Core.denote e)
|
Loading…
Reference in New Issue
Block a user