Cezar Andrei has proposed merging lp:~zorba-coders/zorba/bug1090083-deepEqual 
into lp:zorba.

Commit message:
Fix deep-equal bug 1090083.

Requested reviews:
  Cezar Andrei (cezar-andrei)
  Sorin Marian Nasoi (sorin.marian.nasoi)
Related bugs:
  Bug #1090083 in Zorba: "deep-equal doesn't check type annotations"
  https://bugs.launchpad.net/zorba/+bug/1090083

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug1090083-deepEqual/+merge/158509

Fix deep-equal bug 1090083.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug1090083-deepEqual/+merge/158509
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/sequences/sequences_impl.cpp'
--- src/runtime/sequences/sequences_impl.cpp	2013-03-26 18:10:32 +0000
+++ src/runtime/sequences/sequences_impl.cpp	2013-04-11 23:41:34 +0000
@@ -926,6 +926,17 @@
       if (! item1->getNodeName()->equals(item2->getNodeName()))
         return false;
 
+      TypeManager* tm = sctx->get_typemanager();
+
+      xqtref_t type1 = tm->create_value_type(item1.getp());
+      xqtref_t type2 = tm->create_value_type(item2.getp());
+
+      const NodeXQType* nodeType1 = static_cast<const NodeXQType *>(type1.getp());
+      const NodeXQType* nodeType2 = static_cast<const NodeXQType *>(type2.getp());
+
+      if ( nodeType1->get_content_type()->content_kind() != nodeType2->get_content_type()->content_kind() )
+        return false;
+
       return (DeepEqualAttributes(loc,
                                   sctx,
                                   dctx,
@@ -1093,6 +1104,13 @@
       item1->isJSONArray() != item2->isJSONArray())
     return false;
 
+
+  xqtref_t type1 = tm->create_value_type(item1.getp());
+  xqtref_t type2 = tm->create_value_type(item2.getp());
+
+  if ( type1->content_kind() != type2->content_kind() )
+    return false;
+
   if (item1->isAtomic())
   {
     assert(item2->isAtomic());
@@ -1102,9 +1120,6 @@
       collator = sctx->get_default_collator(QueryLoc::null);
 
     // check NaN
-    xqtref_t type1 = tm->create_value_type(item1.getp());
-    xqtref_t type2 = tm->create_value_type(item2.getp());
-
     if (((TypeOps::is_subtype(tm, *type1, *rtm.FLOAT_TYPE_ONE)
           &&
           item1->getFloatValue().isNaN())

=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt	2013-04-11 18:13:48 +0000
+++ test/fots/CMakeLists.txt	2013-04-11 23:41:34 +0000
@@ -130,8 +130,6 @@
 EXPECTED_FOTS_FAILURE (fn-available-environment-variables fn-available-environment-variables-011 0)
 EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-36 0)
 EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-37 0)
-EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-38 0)
-EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-39 0)
 EXPECTED_FOTS_FAILURE (fn-distinct-values cbcl-distinct-values-002 0)
 EXPECTED_FOTS_FAILURE (fn-distinct-values cbcl-distinct-values-002b 0)
 EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-005 0)

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to