on master help sign in
Get rid of quickcheck stuff for now
26c51bbEvan Czaplicki
tests/tests/Main.hsdeleted−54
@@ -1,54 +0,0 @@
1−{-# LANGUAGE GeneralizedNewtypeDeriving, TypeSynonymInstances, FlexibleInstances, QuasiQuotes, ExtendedDefaultRules #-}
2−
3−
4−module Main where
5−
6−import Test.Framework as TF (defaultMain, testGroup, Test)
7−import Test.Framework.Providers.QuickCheck2 (testProperty)
8−
9−import Text.InterpolatedString.Perl6 (qq)
10−import Parse.Parser
11−import Util.Arbs
12−
13−import Debug.Trace
14−
15−main :: IO ()
16−main = defaultMain tests
17−
18−parses :: String -> Bool
19−parses code = either (const False) (const True) (parseProgram code)
20−
21−parseFails :: String -> Bool
22−parseFails = not . parses
23−
24−tests :: [TF.Test]
25−tests = [
26− testGroup "String Assignments" [
27− testProperty "prop_assignString" prop_assignString
28− , testProperty "prop_invalidIdent" prop_invalidIdent
29− , testProperty "prop_emptyList" prop_emptyList
30− , testProperty "prop_record" prop_record
31− ]
32− ]
33−
34−prop_assignString :: ValidIdent -> StringLiteral -> Bool
35−prop_assignString i s = parses [qq|
36−{i} = {s}
37−|]
38−
39−prop_invalidIdent :: ValidIdent -> InvalidIdentChar -> StringLiteral -> Bool
40−prop_invalidIdent i z s = parseFails [qq|
41−{i}{z} = {s}
42−|]
43−
44−prop_emptyList :: ValidIdent -> Bool
45−prop_emptyList i = parses [qq|
46−{i}=[]
47−|]
48−
49−prop_record :: ValidIdent -> ValidIdent -> ValidIdent -> ValidIdent -> StringLiteral -> Bool
50−prop_record a b c k v = parses [qq|
51−{a} = \{{k} = {v} \}
52−{b} = .{k} {a}
53−{c} = {a}.{k}
54−|]
tests/tests/Util/Arbs.hsdeleted−45
@@ -1,45 +0,0 @@
1−module Util.Arbs where
2−
3−import Control.Applicative
4−import Test.QuickCheck
5−import Util.CharGens
6−import Util.String
7−
8−import Text.InterpolatedString.Perl6 (ShowQ(showQ))
9−
10−
11−newtype ValidIdent = ValidIdent String deriving (Eq, Show)
12−
13−instance ShowQ ValidIdent where
14− showQ (ValidIdent v) = v
15−
16−instance Arbitrary ValidIdent where
17− arbitrary = ValidIdent <$> ((:) <$> lowerAlpha <*> (listOf alphaNumUnderPrime))
18−
19−
20−newtype StringLiteral = StringLiteral String deriving (Eq, Show)
21−
22−instance ShowQ StringLiteral where
23− showQ (StringLiteral v) = v
24−
25−instance Arbitrary StringLiteral where
26− arbitrary = StringLiteral <$> (\x -> "\"" ++ x ++ "\"") <$> escape <$> arbitrary
27−
28−
29−newtype InvalidIdentChar = InvalidIdentChar Char deriving (Eq, Show)
30−
31−instance ShowQ InvalidIdentChar where
32− showQ (InvalidIdentChar c) = [c]
33−
34−instance Arbitrary InvalidIdentChar where
35− arbitrary = InvalidIdentChar <$> elements "!@#$%^&*()-=+\\|/?.>,<`~"
36−
37−
38−newtype BuiltinType = BuiltinType String deriving (Eq, Show)
39−
40−instance ShowQ BuiltinType where
41− showQ (BuiltinType v) = v
42−
43−instance Arbitrary BuiltinType where
44− -- TODO: add others
45− arbitrary = BuiltinType <$> elements ["Char", "String"]
tests/tests/Util/CharGens.hsdeleted−19
@@ -1,19 +0,0 @@
1−module Util.CharGens where
2−
3−import Test.QuickCheck
4−import Test.QuickCheck.Property
5−
6−lowerAlpha :: Gen Char
7−lowerAlpha = elements ['a'..'z']
8−
9−upperAlpha :: Gen Char
10−upperAlpha = elements ['A'..'Z']
11−
12−alpha :: Gen Char
13−alpha = oneof [lowerAlpha, upperAlpha]
14−
15−alphaNum :: Gen Char
16−alphaNum = oneof [alpha, elements ['0'..'9']]
17−
18−alphaNumUnderPrime :: Gen Char
19−alphaNumUnderPrime = oneof [alphaNum, elements ['_', '\'']]
tests/tests/Util/String.hsdeleted−13
@@ -1,13 +0,0 @@
1−module Util.String where
2−
3−import qualified Data.Text as T
4−
5−replace :: String -> String -> String -> String
6−replace a b c = T.unpack (T.replace (T.pack a) (T.pack b) (T.pack c))
7−
8−escape :: String -> String
9−escape =
10− (replace "\n" "\\n") .
11− (replace "\t" "\\t") .
12− (replace "\"" "\\\"") .
13− (replace "\\" "\\\\")