@@ -2,10 +2,28 @@ module Test.Main where
22
33import Prelude
44
5+import Control.Monad.Error.Class (throwError)
6+import Data.Either (Either(..))
57import Effect (Effect)
8+import Effect.Aff (attempt)
9+import Effect.Exception (error)
610import ViTest (describe, test, viTest)
11+import ViTest.Expect ((===))
712import ViTest.Expect.Snapshot (expectToMatchFileSnapshot)
813
14+data Direction = North | South
15+
16+derive instance Eq Direction
17+
18+equalitySpec :: Effect Unit
19+equalitySpec = describe "ViTest.Expect equality" do
20+ test "uses PureScript Eq for nullary constructors" do
21+ North === North
22+ result <- attempt (North === South)
23+ case result of
24+ Left _ -> pure unit
25+ Right _ -> throwError (error "North === South unexpectedly passed")
26+
927snapshotSpec :: Effect Unit
1028snapshotSpec = describe "ViTest.Expect.Snapshot" do
1129 test "writes the baseline on first run and diffs it on subsequent runs"
@@ -16,3 +34,4 @@ snapshotSpec = describe "ViTest.Expect.Snapshot" do
1634main :: Unit
1735main = viTest do
1836 snapshotSpec
37+ equalitySpec