about summary refs log tree commit diff
path: root/scratch/brilliant/Spec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'scratch/brilliant/Spec.hs')
-rw-r--r--scratch/brilliant/Spec.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/scratch/brilliant/Spec.hs b/scratch/brilliant/Spec.hs
new file mode 100644
index 000000000000..f348dd0669a1
--- /dev/null
+++ b/scratch/brilliant/Spec.hs
@@ -0,0 +1,19 @@
+--------------------------------------------------------------------------------
+module Spec where
+--------------------------------------------------------------------------------
+import Test.Hspec
+import Test.QuickCheck
+import Control.Exception (evaluate)
+--------------------------------------------------------------------------------
+
+main :: IO ()
+main = hspec $ do
+  describe "Prelude.head" $ do
+    it "returns the first element of a list" $ do
+      head [23 ..] `shouldBe` (23 :: Integer)
+
+    it "returns the first element of an arbitrary list" $
+      property $ \x xs -> head (x:xs) == (x :: Integer)
+
+    it "throws an exception if used with an empty list" $ do
+      evaluate (head []) `shouldThrow` anyException