diff options
| -rw-r--r-- | miasm2/core/interval.py | 20 | ||||
| -rw-r--r-- | test/core/interval.py | 1 |
2 files changed, 11 insertions, 10 deletions
diff --git a/miasm2/core/interval.py b/miasm2/core/interval.py index 1f6eb739..66445674 100644 --- a/miasm2/core/interval.py +++ b/miasm2/core/interval.py @@ -100,20 +100,20 @@ class interval(object): o = "[]" return o - def __contains__(self, i): - if isinstance(i, interval): - for x in self.intervals: - is_out = True - for y in i.intervals: - if cmp_interval(x, y) in [INT_EQ, INT_B_IN_A]: - is_out = False + def __contains__(self, other): + if isinstance(other, interval): + for intervalB in other.intervals: + is_in = False + for intervalA in self.intervals: + if cmp_interval(intervalA, intervalB) in [INT_EQ, INT_B_IN_A]: + is_in = True break - if is_out: + if not is_in: return False return True else: - for x in self.intervals: - if x[0] <= i <= x[1]: + for intervalA in self.intervals: + if intervalA[0] <= other <= intervalA[1]: return True return False diff --git a/test/core/interval.py b/test/core/interval.py index 34537d25..4572ac50 100644 --- a/test/core/interval.py +++ b/test/core/interval.py @@ -49,6 +49,7 @@ assert((i2 in i3) is False) assert((i3 in i2)) assert((i2 in i3) is False) +assert((i3 in i14)) assert(interval.cannon_list(i1.intervals) == i1.intervals) |