Commits

Stephen Turnbull committed 37479d8

Fix subsetp based on patch by Benson and Steven Mitchell.
Add appropriate short-circuits for null set arguments.
Add tests (mostly from Steven Mitchell) to test suite.

Comments (0)

Files changed (4)

+2012-12-24  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	Based on patch by Benson and Steven Mitchell on XEmacs Beta
+	<50D16FF7.4090708@bnin.net>.
+
+	* sequence.c (venn): Fix bug in handling null arguments.
+	Add null set short circuits, conditional on caller is `subsetp'.
+
 2012-10-18  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* fontcolor-xlike-inc.c (xft_find_charset_font):
   CHECK_LIST (liszt2);
 
   CHECK_KEY_ARGUMENT (key);
+ 
+  /* #### Consider refactoring these tests into callers, and/or optimizing
+     tests. */
+  if (EQ (caller, Qsubsetp))
+    {
+      if (NILP (liszt1))
+	{
+	  return Qt;
+	}
+      if (NILP (liszt2))
+        {
+	  return Qnil;
+        }
+    }
 
   if (NILP (liszt1) && intersectionp)
     {
+2012-12-19  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* automated/lisp-tests.el: Add tests of #'subsetp.
+	Thanks Steven and Benson Mitchell <smitchell@bnin.net>.
+
 2012-12-14  Mats Lidell  <matsl@xemacs.org>
 
 	* automated/register-tests.el: New. Test for register.el. Test

tests/automated/lisp-tests.el

 	       (gethash hashed-bignum hashing))
 	      "checking hashing works correctly with #'eql tests and bignums"))))
 
+;; #'subsetp tests.
+;; Return non-nil if every element of LIST1 also appears in LIST2.
+;; A couple of non-nondegenerate false cases.
+(Assert (not (subsetp (list ?a ?b) (list ?c ?d))))
+(Assert (not (subsetp (list ?a ?b) (list ?b ?c ?d))))
+;; Next five thanks to Steven and Benson Mitchell on XEmacs Beta
+;; <50D16FF7.4090708@bnin.net>.
+;; Two non-degenerate true cases.
+(Assert (subsetp (list ?a) (list ?a ?b ?c ?d)))
+(Assert (subsetp (list ?a ?b) (list ?a ?b ?c ?d)))
+;; The three degenerate cases involving nil.
+(Assert (not (subsetp (list ?a) nil)))
+(Assert (subsetp nil (list ?a ?b ?c ?d)))
+(Assert (subsetp nil nil))
+;; #### We should also test the keywords.
+;; #### We should also test the error conditions.
+
 ;; 
 (when (decode-char 'ucs #x0192)
   (Check-Error