diff --git a/parser-typechecker/tests/Unison/Test/DataDeclaration.hs b/parser-typechecker/tests/Unison/Test/DataDeclaration.hs index 9d25c8ffb4..76cddc1760 100644 --- a/parser-typechecker/tests/Unison/Test/DataDeclaration.hs +++ b/parser-typechecker/tests/Unison/Test/DataDeclaration.hs @@ -3,9 +3,8 @@ module Unison.Test.DataDeclaration where -import Data.Map (Map, (!)) +import Data.Map ((!)) import qualified Data.Map as Map -import Data.Text.Encoding (encodeUtf8) import EasyTest import Text.RawString.QQ import qualified U.Util.Hash as Hash @@ -21,11 +20,13 @@ import qualified Unison.Type as Type import Unison.UnisonFile (UnisonFile (..)) import qualified Unison.Var as Var import qualified Unison.Var.RefNamed as Var +import Unison.Prelude +import Data.Bifunctor (second) test :: Test () test = scope "datadeclaration" $ - let Right hashes = Hashing.hashDataDecls . (snd <$>) . dataDeclarationsId $ file + let hashes = fromRight (error "Expected Right") $ Hashing.hashDataDecls . (snd <$>) . dataDeclarationsId $ file hashMap = Map.fromList $ fmap (\(a, b, _) -> (a, b)) hashes hashOf k = Map.lookup (Var.named k) hashMap in tests @@ -113,7 +114,7 @@ unhashComponentTest = component = Map.singleton listRef (Right listDecl) component' :: Map R.Id (Symbol, Decl Symbol ()) component' = DD.unhashComponent component - (listVar, Right listDecl') = component' ! listRef + (listVar, listDecl') = second (fromRight (error "Expected Right")) $ component' ! listRef listType' = var listVar constructors = Map.fromList $ DD.constructors listDecl' nilType' = constructors ! nil diff --git a/parser-typechecker/tests/Unison/Test/TermParser.hs b/parser-typechecker/tests/Unison/Test/TermParser.hs index b09b0b9366..39189b78fd 100644 --- a/parser-typechecker/tests/Unison/Test/TermParser.hs +++ b/parser-typechecker/tests/Unison/Test/TermParser.hs @@ -215,7 +215,7 @@ parses = parseWith TP.term parseWith :: P Symbol a -> String -> Test () parseWith p s = scope (join . take 1 $ lines s) $ - case Ps.parse @ Symbol p s Common.parsingEnv of + case Ps.parse @Symbol p s Common.parsingEnv of Left e -> do note $ renderParseErrorAsANSI 60 s e crash $ renderParseErrorAsANSI 60 s e diff --git a/parser-typechecker/tests/Unison/Test/Typechecker/TypeError.hs b/parser-typechecker/tests/Unison/Test/Typechecker/TypeError.hs index ed30079790..5d5cf4da22 100644 --- a/parser-typechecker/tests/Unison/Test/Typechecker/TypeError.hs +++ b/parser-typechecker/tests/Unison/Test/Typechecker/TypeError.hs @@ -54,7 +54,9 @@ noYieldsError s ex = not $ yieldsError s ex yieldsError :: forall a. String -> ErrorExtractor Symbol Ann a -> Bool yieldsError s ex = - let Result notes (Just _) = Common.parseAndSynthesizeAsFile [] "> test" s - notes' :: [C.ErrorNote Symbol Ann] - notes' = [n | Result.TypeError n <- toList notes] - in any (isJust . Ex.extract ex) notes' + case Common.parseAndSynthesizeAsFile [] "> test" s of + Result notes (Just _) -> + let notes' :: [C.ErrorNote Symbol Ann] + notes' = [n | Result.TypeError n <- toList notes] + in any (isJust . Ex.extract ex) notes' + _ -> error "yieldsError: Failed to parse file" diff --git a/parser-typechecker/tests/Unison/Test/UnisonSources.hs b/parser-typechecker/tests/Unison/Test/UnisonSources.hs index d4f62568c2..712076e253 100644 --- a/parser-typechecker/tests/Unison/Test/UnisonSources.hs +++ b/parser-typechecker/tests/Unison/Test/UnisonSources.hs @@ -146,7 +146,7 @@ resultTest rt uf filepath = do case term of Right tm -> do -- compare the the watch expression from the .u with the expr in .ur - let [watchResult] = view _5 <$> Map.elems watches + let watchResult = head (view _5 <$> Map.elems watches) tm' = Term.letRec' False bindings watchResult -- note . show $ tm' -- note . show $ Term.amap (const ()) tm diff --git a/parser-typechecker/tests/Unison/Test/Util/Bytes.hs b/parser-typechecker/tests/Unison/Test/Util/Bytes.hs index 101e238840..7049e5718a 100644 --- a/parser-typechecker/tests/Unison/Test/Util/Bytes.hs +++ b/parser-typechecker/tests/Unison/Test/Util/Bytes.hs @@ -32,7 +32,7 @@ test = b1 <- BS.pack <$> replicateM n word8 b2 <- BS.pack <$> replicateM m word8 b3 <- BS.pack <$> replicateM o word8 - let [b1s, b2s, b3s] = Bytes.fromArray <$> [b1, b2, b3] + let (b1s, b2s, b3s) = (Bytes.fromArray b1, Bytes.fromArray b2, Bytes.fromArray b3) scope "associtivity" . expect' $ b1s <> (b2s <> b3s) == (b1s <> b2s) <> b3s scope "<>" . expect' $ diff --git a/parser-typechecker/tests/Unison/Test/Util/Text.hs b/parser-typechecker/tests/Unison/Test/Util/Text.hs index 9285a57ee3..cf34ded45c 100644 --- a/parser-typechecker/tests/Unison/Test/Util/Text.hs +++ b/parser-typechecker/tests/Unison/Test/Util/Text.hs @@ -38,7 +38,7 @@ test = t1 <- T.pack <$> replicateM n ch t2 <- T.pack <$> replicateM m ch t3 <- T.pack <$> replicateM o ch - let [t1s, t2s, t3s] = Text.fromText <$> [t1, t2, t3] + let (t1s, t2s, t3s) = (Text.fromText t1, Text.fromText t2, Text.fromText t3) scope "associativity" $ do -- note $ show (t1s, t2s, t3s) expect' $ t1s <> (t2s <> t3s) == (t1s <> t2s) <> t3s