@@ -3,6 +3,7 @@ import Test.HUnit
33import ProjectM36.Tupleable
44import ProjectM36.Atomable
55import ProjectM36.Attribute
6+import ProjectM36.Error
67import Data.Binary
78import ProjectM36.Base
89import Control.DeepSeq (NFData)
@@ -10,6 +11,7 @@ import GHC.Generics
1011import qualified Data.Vector as V
1112import qualified Data.Map as M
1213import qualified Data.Text as T
14+import qualified Data.Set as S
1315import System.Exit
1416import Data.Proxy
1517
@@ -151,7 +153,7 @@ testDefineExpr = TestCase $ assertEqual "define expr" expected actual
151153
152154testUpdateExpr :: Test
153155testUpdateExpr = TestCase $ do
154− let expected = Update "rv" updateMap restriction
156+ let expected = Right (Update "rv" updateMap restriction)
155157 updateMap = M.fromList [("attr9B", NakedAtomExpr (TextAtom "b")),
156158 ("attr9C", NakedAtomExpr (DoubleAtom 5.5))]
157159 restriction = AttributeEqualityPredicate "attr9A" (NakedAtomExpr (IntegerAtom 5))
@@ -163,10 +165,7 @@ testUpdateExpr = TestCase $ do
163165
164166testUpdateExprEmptyAttrs :: Test
165167testUpdateExprEmptyAttrs = TestCase $ do
166− let expected = Update "rv" updateMap TruePredicate
167− updateMap = M.fromList [("attr9B", NakedAtomExpr (TextAtom "b")),
168− ("attr9C", NakedAtomExpr (DoubleAtom 5.5)),
169− ("attr9A", NakedAtomExpr (IntegerAtom 5))]
168+ let expected = Left EmptyAttributesError
170169 actual = toUpdateExpr "rv" [] (Test9C {attr9A = 5,
171170 attr9B = "b",
172171 attr9C = 5.5})
@@ -175,12 +174,7 @@ testUpdateExprEmptyAttrs = TestCase $ do
175174testUpdateExprWrongAttr :: Test
176175testUpdateExprWrongAttr = TestCase $ do
177176 --currently, passing in the wrong attribute replaces the whole relvar with a single tuple- is this what we want?
178− let expected = Update "rv" updateMap TruePredicate
179− updateMap = M.fromList [
180− ("attr9A", NakedAtomExpr (IntegerAtom 5)),
181− ("attr9B", NakedAtomExpr (TextAtom "b")),
182− ("attr9C", NakedAtomExpr (DoubleAtom 5.5))
183− ]
177+ let expected = Left (NoSuchAttributeNamesError (S.singleton "nonexistentattr"))
184178 actual = toUpdateExpr "rv" ["nonexistentattr"] (Test9C {attr9A = 5,
185179 attr9B = "b",
186180 attr9C = 5.5})
@@ -188,10 +182,10 @@ testUpdateExprWrongAttr = TestCase $ do
188182
189183testDeleteExpr :: Test
190184testDeleteExpr = TestCase $ do
191− let expected = Delete "rv" (AndPredicate (AttributeEqualityPredicate "attr9A"
185+ let expected = Right (Delete "rv" (AndPredicate (AttributeEqualityPredicate "attr9A"
192186 (NakedAtomExpr (IntegerAtom 5)))
193187 (AttributeEqualityPredicate "attr9B"
194− (NakedAtomExpr (TextAtom "b"))))
188+ (NakedAtomExpr (TextAtom "b")))))
195189 actual = toDeleteExpr "rv" ["attr9A", "attr9B"] (Test9C {attr9A = 5,
196190 attr9B = "b",
197191 attr9C = 5.5})