Skip to content

Commit d5be991

Browse files
Slight refactor
1 parent 08bf43b commit d5be991

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/Spec/BotPlutusInterface/Contract.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Control.Lens (ix, (&), (.~), (^.), (^?))
99
import Data.Aeson (ToJSON)
1010
import Data.Aeson.Extras (encodeByteString)
1111
import Data.Default (def)
12+
import Data.Function (on)
1213
import Data.Kind (Type)
1314
import Data.Map qualified as Map
1415
import Data.Maybe (fromMaybe)
@@ -871,20 +872,20 @@ assertCommandHistory state =
871872
( \(idx, expectedCmd) ->
872873
assertCommandEqual
873874
("command at index " ++ show idx ++ " was incorrect:")
874-
(fromMaybe "" $ state ^? commandHistory . ix idx)
875875
(Text.replace "\n" " " expectedCmd)
876+
(fromMaybe "" $ state ^? commandHistory . ix idx)
876877
)
877878

878879
assertCommandEqual :: String -> Text -> Text -> Assertion
879-
assertCommandEqual err actual expected
880-
| commandEqual actual expected = return ()
880+
assertCommandEqual err expected actual
881+
| commandEqual expected actual = return ()
881882
| otherwise = assertFailure $ err ++ "\nExpected:\n" ++ show expected ++ "\nGot:\n" ++ show actual
882883

883884
commandEqual :: Text -> Text -> Bool
884885
commandEqual "" "" = True
885886
commandEqual "" _ = False
886887
commandEqual _ "" = False
887-
commandEqual actual expected = maybe False (\restAct -> commandEqual (dropToSpace restAct) (dropToSpace postExp)) mRestAct
888+
commandEqual expected actual = maybe False (on commandEqual dropToSpace postExp) mRestAct
888889
where
889890
(preExp, postExp) = Text.breakOn "?" expected
890891
mRestAct = Text.stripPrefix preExp actual

0 commit comments

Comments
 (0)