;;; Copies/reimplementations of cl functions.
+;; FIXME: Bug#6581 is fixed, so this should be deleted.
(defun ert-equal-including-properties (a b)
"Return t if A and B have similar structure and contents.
}
}
-/* Return true if the two intervals have the same properties. */
+/* Return true if the two intervals have the same properties.
+ If use_equal is true, use Fequal for comparisons instead of EQ. */
-bool
-intervals_equal (INTERVAL i0, INTERVAL i1)
+static bool
+intervals_equal_1 (INTERVAL i0, INTERVAL i1, bool use_equal)
{
Lisp_Object i0_cdr, i0_sym;
Lisp_Object i1_cdr, i1_val;
/* i0 and i1 both have sym, but it has different values in each. */
if (!CONSP (i1_val)
|| (i1_val = XCDR (i1_val), !CONSP (i1_val))
- || !EQ (XCAR (i1_val), XCAR (i0_cdr)))
+ || use_equal ? NILP (Fequal (XCAR (i1_val), XCAR (i0_cdr)))
+ : !EQ (XCAR (i1_val), XCAR (i0_cdr)))
return false;
i0_cdr = XCDR (i0_cdr);
/* Lengths of the two plists were equal. */
return (NILP (i0_cdr) && NILP (i1_cdr));
}
+
+/* Return true if the two intervals have the same properties. */
+
+bool
+intervals_equal (INTERVAL i0, INTERVAL i1)
+{
+ return intervals_equal_1 (i0, i1, false);
+}
\f
/* Traverse an interval tree TREE, performing FUNCTION on each node.
/* If we ever find a mismatch between the strings,
they differ. */
- if (! intervals_equal (i1, i2))
+ if (! intervals_equal_1 (i1, i2, true))
return 0;
/* Advance POS till the end of the shorter interval,
context-before "f" context-after "o"))))
(ert-deftest ert-test-equal-including-properties ()
- (should (equal-including-properties "foo" "foo"))
(should (ert-equal-including-properties "foo" "foo"))
-
- (should (equal-including-properties #("foo" 0 3 (a b))
- (propertize "foo" 'a 'b)))
(should (ert-equal-including-properties #("foo" 0 3 (a b))
(propertize "foo" 'a 'b)))
-
- (should (equal-including-properties #("foo" 0 3 (a b c d))
- (propertize "foo" 'a 'b 'c 'd)))
(should (ert-equal-including-properties #("foo" 0 3 (a b c d))
(propertize "foo" 'a 'b 'c 'd)))
-
- (should-not (equal-including-properties #("foo" 0 3 (a b c e))
- (propertize "foo" 'a 'b 'c 'd)))
(should-not (ert-equal-including-properties #("foo" 0 3 (a b c e))
(propertize "foo" 'a 'b 'c 'd)))
-
- ;; This is bug 6581.
- (should-not (equal-including-properties #("foo" 0 3 (a (t)))
- (propertize "foo" 'a (list t))))
(should (ert-equal-including-properties #("foo" 0 3 (a (t)))
(propertize "foo" 'a (list t)))))
(puthash nan t h)
(should (eq (funcall test nan -nan) (gethash -nan h))))))
+(ert-deftest fns-tests-equal-including-properties ()
+ (should (equal-including-properties "" ""))
+ (should (equal-including-properties "foo" "foo"))
+ (should (equal-including-properties #("foo" 0 3 (a b))
+ (propertize "foo" 'a 'b)))
+ (should (equal-including-properties #("foo" 0 3 (a b c d))
+ (propertize "foo" 'a 'b 'c 'd)))
+ (should (equal-including-properties #("a" 0 1 (k v))
+ #("a" 0 1 (k v))))
+ (should-not (equal-including-properties #("a" 0 1 (k v))
+ #("a" 0 1 (k x))))
+ (should-not (equal-including-properties #("a" 0 1 (k v))
+ #("b" 0 1 (k v))))
+ (should-not (equal-including-properties #("foo" 0 3 (a b c e))
+ (propertize "foo" 'a 'b 'c 'd))))
+
+(ert-deftest fns-tests-equal-including-properties/string-prop-vals ()
+ "Handle string property values. (Bug#6581)"
+ (should (equal-including-properties #("a" 0 1 (k "v"))
+ #("a" 0 1 (k "v"))))
+ (should (equal-including-properties #("foo" 0 3 (a (t)))
+ (propertize "foo" 'a (list t))))
+ (should-not (equal-including-properties #("a" 0 1 (k "v"))
+ #("a" 0 1 (k "x"))))
+ (should-not (equal-including-properties #("a" 0 1 (k "v"))
+ #("b" 0 1 (k "v")))))
+
(ert-deftest fns-tests-reverse ()
(should-error (reverse))
(should-error (reverse 1))