|
| 1 | +module KeywordsSpec where |
| 2 | + |
| 3 | +import qualified Data.Set as S |
| 4 | +import Keywords (keywords) |
| 5 | +import Test.Hspec (Spec, it, shouldBe, shouldContain) |
| 6 | +import Test.Hspec.Core.Spec (Expectation) |
| 7 | + |
| 8 | +spec :: Spec |
| 9 | +spec = do |
| 10 | + it "Do you have the correct number of keywords in your list?" $ do |
| 11 | + length keywords `shouldBe` 23 |
| 12 | + it "Missing a word that is used when making a family of methods that can be used with related data types" $ do |
| 13 | + keywords `shouldContainAll` ["module", "where"] |
| 14 | + it "Missing a conditional word used in pattern matching (first word of a pair)" $ do |
| 15 | + keywords `shouldContainAll` ["case"] |
| 16 | + it "Missing a word that is used when making a family of methods that can be used with related data types" $ do |
| 17 | + keywords `shouldContainAll` ["data", "type", "newtype", "instance", "class"] |
| 18 | + it "Missing a word that defines the requirements for an instance to use a fallback method" $ do |
| 19 | + keywords `shouldContainAll` ["default"] |
| 20 | + it "Missing a word that allows you to write monadic computations in a more imperative style" $ do |
| 21 | + keywords `shouldContainAll` ["do"] |
| 22 | + it "Missing a conditional word that goes at the end" $ do |
| 23 | + keywords `shouldContainAll` ["then", "else"] |
| 24 | + it "Missing a word that is used when interfacing with C code" $ do |
| 25 | + keywords `shouldContainAll` ["foreign"] |
| 26 | + it "Missing a conditional word that determines a possibility" $ do |
| 27 | + keywords `shouldContainAll` ["if"] |
| 28 | + it "Missing a word used to obtain external modules" $ do |
| 29 | + keywords `shouldContainAll` ["import"] |
| 30 | + it "Missing a word used when substituting a name for a value (second word of a pair)" $ do |
| 31 | + keywords `shouldContainAll` ["in"] |
| 32 | + it "Missing a word used for functions that can be used in-between it's arguments" $ do |
| 33 | + keywords `shouldContainAll` ["infix"] |
| 34 | + it "Missing a word used at the top level that lets other files know what the current one is called" $ do |
| 35 | + keywords `shouldContainAll` ["module"] |
| 36 | + it "Missing a word used for functions that can be used in-between it's arguments (and can chain together from left-to-right)" $ do |
| 37 | + keywords `shouldContainAll` ["infixl"] |
| 38 | + it "Missing a word used for functions that can be used in-between it's arguments (and can chain together from right-to-left)" $ do |
| 39 | + keywords `shouldContainAll` ["infixr"] |
| 40 | + it "Missing a word used as a placeholder for data that you don't care about" $ do |
| 41 | + keywords `shouldContainAll` ["_"] |
| 42 | + it "Missing a conditional word used in pattern matching (second word of a pair)" $ do |
| 43 | + keywords `shouldContainAll` ["of"] |
| 44 | + it "Missing a word that saves a lot of boilerplate when defining behavior of new data types" $ do |
| 45 | + keywords `shouldContainAll` ["deriving"] |
| 46 | + |
| 47 | +shouldContainAll :: (Show a, Ord a) => [a] -> [a] -> Expectation |
| 48 | +shouldContainAll actual expected = |
| 49 | + S.fromList expected `S.isSubsetOf` S.fromList actual `shouldBe` True |
0 commit comments