1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 00:33:59 +03:00

Add Eq1 instances to exception types

This commit is contained in:
joshvera 2018-03-23 11:48:56 -04:00
parent 68ca81ad97
commit 173781c501
4 changed files with 22 additions and 13 deletions

View File

@ -1,4 +1,5 @@
{-# LANGUAGE MultiParamTypeClasses, Rank2Types, TypeFamilies, TypeOperators, UndecidableInstances, GADTs, StandaloneDeriving #-} {-# LANGUAGE GADTs, MultiParamTypeClasses, Rank2Types, StandaloneDeriving, TypeFamilies, TypeOperators,
UndecidableInstances #-}
module Control.Abstract.Value where module Control.Abstract.Value where
import Control.Abstract.Addressable import Control.Abstract.Addressable
@ -142,6 +143,11 @@ data ValueExc v where
ValueExc :: Prelude.String -> ValueExc Value ValueExc :: Prelude.String -> ValueExc Value
StringExc :: Prelude.String -> ValueExc ByteString StringExc :: Prelude.String -> ValueExc ByteString
instance Eq1 ValueExc where
liftEq _ (ValueExc a) (ValueExc b) = a == b
liftEq _ (StringExc a) (StringExc b) = a == b
liftEq _ _ _ = False
deriving instance Show (ValueExc v) deriving instance Show (ValueExc v)
instance Show1 ValueExc where instance Show1 ValueExc where
liftShowsPrec _ _ = showsPrec liftShowsPrec _ _ = showsPrec

View File

@ -24,6 +24,9 @@ import Prologue
data Unspecialized a b where data Unspecialized a b where
Unspecialized :: { getUnspecialized :: Prelude.String } -> Unspecialized value value Unspecialized :: { getUnspecialized :: Prelude.String } -> Unspecialized value value
instance Eq1 (Unspecialized a) where
liftEq _ (Unspecialized a) (Unspecialized b) = a == b
deriving instance Eq (Unspecialized a b) deriving instance Eq (Unspecialized a b)
deriving instance Show (Unspecialized a b) deriving instance Show (Unspecialized a b)
instance Show1 (Unspecialized a) where instance Show1 (Unspecialized a) where

View File

@ -36,11 +36,11 @@ spec = parallel $ do
it "subclasses" $ do it "subclasses" $ do
res <- evaluate' "subclass.py" res <- evaluate' "subclass.py"
join (fst res) `shouldBe` Right (injValue (String "\"bar\"")) fst res `shouldBe` Right (Right (Right (injValue (String "\"bar\""))))
it "handles multiple inheritance left-to-right" $ do it "handles multiple inheritance left-to-right" $ do
res <- evaluate' "multiple_inheritance.py" res <- evaluate' "multiple_inheritance.py"
join (fst res) `shouldBe` Right (injValue (String "\"foo!\"")) fst res `shouldBe` Right (Right (Right (injValue (String "\"foo!\""))))
where where
addr = Address . Precise addr = Address . Precise

View File

@ -28,7 +28,7 @@ spec = parallel $ do
it "subclass" $ do it "subclass" $ do
res <- evaluate' "subclass.rb" res <- evaluate' "subclass.rb"
join (fst res) `shouldBe` Right (injValue (String "\"<bar>\"")) fst res `shouldBe` Right (Right (Right (injValue (String "\"<bar>\""))))
where where
addr = Address . Precise addr = Address . Precise