-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module HM.InterpretSpec where | ||
|
||
import Test.Hspec | ||
import Control.Monad (forM_) | ||
import HM.Interpret | ||
|
||
isSuccess :: Result -> Bool | ||
isSuccess Success{} = True | ||
isSuccess _ = False | ||
|
||
isTypeError :: Result -> Bool | ||
isTypeError (Failure TypecheckingError _) = True | ||
isTypeError _ = False | ||
|
||
wellTypedPaths :: [FilePath] | ||
wellTypedPaths = ["well-typed/1.lam", "well-typed/2.lam"] | ||
|
||
illTypedPaths :: [FilePath] | ||
illTypedPaths = ["ill-typed/1.lam", "ill-typed/2.lam"] | ||
|
||
spec :: Spec | ||
spec = do | ||
|
||
describe "well-typed expressions" $ do | ||
forM_ wellTypedPaths $ \path -> it path $ do | ||
contents <- readFile ("test/files/" ++ path) | ||
interpret contents `shouldSatisfy` isSuccess | ||
|
||
describe "ill-typed expressions" $ do | ||
forM_ illTypedPaths $ \path -> it path $ do | ||
contents <- readFile ("test/files/" ++ path) | ||
interpret contents `shouldSatisfy` isTypeError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{-# OPTIONS_GHC -F -pgmF hspec-discover #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
let x = true in (if iszero x then 1 else 0) | ||
let x = true in (if iszero(x) then 1 else 0) |