about summary refs log tree commit diff
path: root/scratch
diff options
context:
space:
mode:
Diffstat (limited to 'scratch')
-rw-r--r--scratch/brilliant/Spec.hs19
-rw-r--r--scratch/brilliant/shell.nix1
2 files changed, 20 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
diff --git a/scratch/brilliant/shell.nix b/scratch/brilliant/shell.nix
index 58a2e9a6a573..06fcc7979d2e 100644
--- a/scratch/brilliant/shell.nix
+++ b/scratch/brilliant/shell.nix
@@ -3,6 +3,7 @@ let
 in pkgs.mkShell {
   buildInputs = with pkgs; [
     (haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
+      hspec
       optparse-applicative
     ]))
   ];