Procházet zdrojové kódy

Fixed non-equal length check issue in non--strict node comparison.

Taddeus Kroes před 14 roky
rodič
revize
95372310c1
2 změnil soubory, kde provedl 11 přidání a 0 odebrání
  1. 6 0
      src/node.py
  2. 5 0
      tests/test_node.py

+ 6 - 0
src/node.py

@@ -253,6 +253,12 @@ class ExpressionNode(Node, ExpressionBase):
         if self.op in (OP_ADD, OP_MUL):
             s0 = self.get_scope()
             s1 = set(other.get_scope())
+
+            # Scopes sould be of equal size
+            if len(s0) != len(s1):
+                return False
+
+            # Each node in one scope should have an image node in the other
             matched = set()
 
             for n0 in s0:

+ 5 - 0
tests/test_node.py

@@ -129,6 +129,11 @@ class TestNode(unittest.TestCase):
         self.assertTrue(p2.equals(p3))
         self.assertFalse(p2.equals(p4))
 
+    def test_equals_nary_mary(self):
+        m0, m1 = tree('ab,2ab')
+
+        self.assertFalse(m0.equals(m1))
+
     def test_equals_div(self):
         d0, d1, d2 = tree('a / b,a / b,b / a')