forked from elm/compiler
-
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.
Setup QuickCheck and add Literal Parse/Print test
Currently fails the prop tests: elm#420 Also ignore emacs backup files.
- Loading branch information
Showing
6 changed files
with
83 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ cabal-dev | |
data | ||
*/ElmFiles/* | ||
.DS_Store | ||
*~ |
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,22 @@ | ||
module Tests.Property where | ||
|
||
import Test.Framework | ||
import Test.Framework.Providers.QuickCheck2 | ||
import Test.QuickCheck | ||
|
||
import SourceSyntax.Literal (Literal) | ||
import SourceSyntax.PrettyPrint (pretty) | ||
import Parse.Helpers (iParse) | ||
import Parse.Literal (literal) | ||
import Tests.Property.Arbitrary | ||
|
||
propertyTests :: Test | ||
propertyTests = | ||
testGroup "Parse/Print Agreement Tests" | ||
[ | ||
testProperty "Literal test" prop_literal_parse_print | ||
] | ||
|
||
prop_literal_parse_print :: Literal -> Bool | ||
prop_literal_parse_print l = | ||
either (const False) (== l) . iParse literal . show . pretty $ l |
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,23 @@ | ||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
module Tests.Property.Arbitrary where | ||
|
||
import Control.Applicative ((<$>)) | ||
import Test.QuickCheck.Arbitrary | ||
import Test.QuickCheck.Gen | ||
|
||
import SourceSyntax.Literal | ||
|
||
instance Arbitrary Literal where | ||
arbitrary = oneof [ IntNum <$> arbitrary | ||
, FloatNum <$> arbitrary | ||
, Chr <$> arbitrary | ||
, Str <$> arbitrary | ||
-- Booleans aren't actually source syntax | ||
-- , Boolean <$> arbitrary | ||
] | ||
shrink l = case l of | ||
IntNum n -> IntNum <$> shrink n | ||
FloatNum f -> FloatNum <$> shrink f | ||
Chr c -> Chr <$> shrink c | ||
Str s -> Str <$> shrink s | ||
Boolean b -> Boolean <$> shrink b |