From 78ae59ac4998ac66ff104f1ac6ef365b301feb43 Mon Sep 17 00:00:00 2001 From: Chinmay Date: Thu, 3 Sep 2020 14:01:48 -0700 Subject: Adds tests related to UIDF --- python/function.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'python/function.py') diff --git a/python/function.py b/python/function.py index bb4f817a..44c2f383 100644 --- a/python/function.py +++ b/python/function.py @@ -263,8 +263,11 @@ class ValueRange(object): return "" % (self.start, self.end) return "" % (self.start, self.end, self.step) - - + def __eq__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return self.start == other.start and self.end == other.end and self.step == other.step + @property def start(self): """ """ @@ -361,7 +364,7 @@ class PossibleValueSet(object): if self._type == RegisterValueType.ConstantPointerValue: return "" % self.value if self._type == RegisterValueType.StackFrameOffset: - return "" % self.offset + return "" % self._offset if self._type == RegisterValueType.SignedRangeValue: return "" % repr(self.ranges) if self._type == RegisterValueType.UnsignedRangeValue: @@ -377,10 +380,18 @@ class PossibleValueSet(object): return "" def __eq__(self, other): - if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantValue] and isinstance(other, numbers.Integral): + if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue] and isinstance(other, numbers.Integral): return self.value == other - if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantValue] and hasattr(other, 'type') and other.type == self.type: + if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue] and hasattr(other, 'type') and other.type == self.type: return self.value == other.value + elif self.type == RegisterValueType.StackFrameOffset and hasattr(other, 'type') and other.type == self.type: + return self.offset == other.offset + elif self.type in [RegisterValueType.SignedRangeValue, RegisterValueType.UnsignedRangeValue] and hasattr(other, 'type') and other.type == self.type: + return self.ranges == other.ranges + elif self.type in [RegisterValueType.InSetOfValues, RegisterValueType.NotInSetOfValues] and hasattr(other, 'type') and other.type == self.type: + return self.values == other.values + elif self.type == RegisterValueType.UndeterminedValue and hasattr(other, 'type'): + return self.type == other.type else: return self == other @@ -581,7 +592,7 @@ class PossibleValueSet(object): """ result = PossibleValueSet() result.type = RegisterValueType.StackFrameOffset - result.value = value + result.offset = offset return result @classmethod -- cgit v1.3.1