Mercurial > hg > xemacs-beta
diff tests/automated/lisp-tests.el @ 4906:6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
-------------------- ChangeLog entries follow: --------------------
lisp/ChangeLog addition:
2010-02-01 Ben Wing <ben@xemacs.org>
* cl-extra.el:
* cl-extra.el (cl-string-vector-equalp): Removed.
* cl-extra.el (cl-bit-vector-vector-equalp): Removed.
* cl-extra.el (cl-vector-array-equalp): Removed.
* cl-extra.el (cl-hash-table-contents-equalp): Removed.
* cl-extra.el (equalp): Removed.
* cl-extra.el (cl-mapcar-many):
Comment out the whole `equalp' implementation for the moment;
remove once we're sure the C implementation works.
* cl-macs.el:
* cl-macs.el (equalp):
Simplify the compiler-macro for `equalp' -- once it's in C,
we don't need to try so hard to expand it.
src/ChangeLog addition:
2010-02-01 Ben Wing <ben@xemacs.org>
* abbrev.c (abbrev_match_mapper):
* buffer.h (CANON_TABLE_OF):
* buffer.h:
* editfns.c (Fchar_equal):
* minibuf.c (scmp_1):
* text.c (qxestrcasecmp_i18n):
* text.c (qxestrncasecmp_i18n):
* text.c (qxetextcasecmp):
* text.c (qxetextcasecmp_matching):
Create new macro CANONCASE that converts to a canonical mapping
and use it to do caseless comparisons instead of DOWNCASE.
* alloc.c:
* alloc.c (cons_equal):
* alloc.c (vector_equal):
* alloc.c (string_equal):
* bytecode.c (compiled_function_equal):
* chartab.c (char_table_entry_equal):
* chartab.c (char_table_equal):
* data.c (weak_list_equal):
* data.c (weak_box_equal):
* data.c (ephemeron_equal):
* device-msw.c (equal_devmode):
* elhash.c (hash_table_equal):
* events.c (event_equal):
* extents.c (properties_equal):
* extents.c (extent_equal):
* faces.c:
* faces.c (face_equal):
* faces.c (face_hash):
* floatfns.c (float_equal):
* fns.c:
* fns.c (bit_vector_equal):
* fns.c (plists_differ):
* fns.c (Fplists_eq):
* fns.c (Fplists_equal):
* fns.c (Flax_plists_eq):
* fns.c (Flax_plists_equal):
* fns.c (internal_equal):
* fns.c (internal_equalp):
* fns.c (internal_equal_0):
* fns.c (syms_of_fns):
* glyphs.c (image_instance_equal):
* glyphs.c (glyph_equal):
* glyphs.c (glyph_hash):
* gui.c (gui_item_equal):
* lisp.h:
* lrecord.h (struct lrecord_implementation):
* marker.c (marker_equal):
* number.c (bignum_equal):
* number.c (ratio_equal):
* number.c (bigfloat_equal):
* objects.c (color_instance_equal):
* objects.c (font_instance_equal):
* opaque.c (equal_opaque):
* opaque.c (equal_opaque_ptr):
* rangetab.c (range_table_equal):
* specifier.c (specifier_equal):
Add a `foldcase' param to the equal() method and use it to implement
`equalp' comparisons. Also add to plists_differ(), although we
don't currently use it here.
Rewrite internal_equalp(). Implement cross-type vector comparisons.
Don't implement our own handling of numeric promotion -- just use
the `=' primitive.
Add internal_equal_0(), which takes a `foldcase' param and calls
either internal_equal() or internal_equalp().
* buffer.h:
When given a 0 for buffer (which is the norm when functions don't
have a specific buffer available), use the current buffer's table,
not `standard-case-table'; otherwise the current settings are
ignored.
* casetab.c:
* casetab.c (set_case_table):
When handling old-style vectors of 256 in `set-case-table' don't
overwrite the existing table! Instead create a new table and
populate.
* device-msw.c (sync_printer_with_devmode):
* lisp.h:
* text.c (lisp_strcasecmp_ascii):
Rename lisp_strcasecmp to lisp_strcasecmp_ascii and use
lisp_strcasecmp_i18n for caseless comparisons in some places.
* elhash.c:
Delete unused lisp_string_hash and lisp_string_equal().
* events.h:
* keymap-buttons.h:
* keymap.h:
* keymap.c (keymap_lookup_directly):
* keymap.c (keymap_store):
* keymap.c (FROB):
* keymap.c (key_desc_list_to_event):
* keymap.c (describe_map_mapper):
* keymap.c (INCLUDE_BUTTON_ZERO):
New file keymap-buttons.h; use to handle buttons 1-26 in place of
duplicating code 26 times.
* frame-gtk.c (allocate_gtk_frame_struct):
* frame-msw.c (mswindows_init_frame_1):
Fix some comments about internal_equal() in redisplay that don't
apply any more.
* keymap-slots.h:
* keymap.c:
New file keymap-slots.h. Use it to notate the slots in a keymap
structure, similar to frameslots.h or coding-system-slots.h.
* keymap.c (MARKED_SLOT):
* keymap.c (keymap_equal):
* keymap.c (keymap_hash):
Implement.
tests/ChangeLog addition:
2010-02-01 Ben Wing <ben@xemacs.org>
* automated/case-tests.el:
* automated/case-tests.el (uni-mappings):
* automated/search-tests.el:
Delete old pristine-case-table code. Rewrite the Unicode torture
test to take into account whether overlapping mappings exist for
more than one character, and not doing the upcase/downcase
comparisons in such cases.
* automated/lisp-tests.el (foo):
* automated/lisp-tests.el (string-variable):
* automated/lisp-tests.el (featurep):
Replace Assert (equal ... with Assert-equal; same for other types
of equality. Replace some awkward equivalents of Assert-equalp
with Assert-equalp. Add lots of equalp tests.
* automated/case-tests.el:
* automated/regexp-tests.el:
* automated/search-tests.el:
Fix up the comments at the top of the files. Move rules about where
to put tests into case-tests.el.
* automated/test-harness.el:
* automated/test-harness.el (test-harness-aborted-summary-template): New.
* automated/test-harness.el (test-harness-from-buffer):
* automated/test-harness.el (batch-test-emacs):
Fix Assert-test-not. Create Assert-not-equal and variants.
Delete the doc strings from all these convenience functions to avoid
excessive repetition; instead use one copy in a comment.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 01 Feb 2010 01:02:40 -0600 |
parents | 91a023144e72 |
children | 1b96882bdf37 |
line wrap: on
line diff
--- a/tests/automated/lisp-tests.el Sat Jan 30 20:34:23 2010 -0600 +++ b/tests/automated/lisp-tests.el Mon Feb 01 01:02:40 2010 -0600 @@ -1957,35 +1957,28 @@ (foo-zero 400 (1+ most-positive-fixnum))))) "Checking multiple values are discarded correctly when forced") (Check-Error setting-constant (setq multiple-values-limit 20)) - (Assert - (equal '(-1 1) - (multiple-value-list (floor -3 4))) + (Assert-equal '(-1 1) + (multiple-value-list (floor -3 4)) "Checking #'multiple-value-list gives a sane result") (let ((ey 40000) (bee "this is a string") (cee #s(hash-table size 256 data (969 ?\xF9)))) - (Assert - (equal - (multiple-value-list (values ey bee cee)) - (multiple-value-list (values-list (list ey bee cee)))) + (Assert-equal + (multiple-value-list (values ey bee cee)) + (multiple-value-list (values-list (list ey bee cee))) "Checking that #'values and #'values-list are correctly related") - (Assert - (equal - (multiple-value-list (values-list (list ey bee cee))) - (multiple-value-list (apply #'values (list ey bee cee)))) + (Assert-equal + (multiple-value-list (values-list (list ey bee cee))) + (multiple-value-list (apply #'values (list ey bee cee))) "Checking #'values-list and #'apply with #values are correctly related")) - (Assert - (= (multiple-value-call #'+ (floor 5 3) (floor 19 4)) 10) + (Assert= (multiple-value-call #'+ (floor 5 3) (floor 19 4)) 10 "Checking #'multiple-value-call gives reasonable results.") - (Assert - (= (multiple-value-call (values '+ '*) (floor 5 3) (floor 19 4)) 10) + (Assert= (multiple-value-call (values '+ '*) (floor 5 3) (floor 19 4)) 10 "Checking #'multiple-value-call correct when first arg multiple.") - (Assert - (= 1 (length (multiple-value-list (prog1 (floor pi) "hi there")))) + (Assert= 1 (length (multiple-value-list (prog1 (floor pi) "hi there"))) "Checking #'prog1 does not pass back multiple values") - (Assert - (= 2 (length (multiple-value-list - (multiple-value-prog1 (floor pi) "hi there")))) + (Assert= 2 (length (multiple-value-list + (multiple-value-prog1 (floor pi) "hi there"))) "Checking #'multiple-value-prog1 passes back multiple values") (multiple-value-bind (floored remainder this-is-nil) (floor pi 1.0) @@ -2003,75 +1996,59 @@ (Assert-eql 2.0 ey "Checking ey set correctly") (Assert-eql bee (- e 2.0) "Checking bee set correctly") (Assert (null cee) "Checking cee set to nil correctly")) - (Assert - (= 3 (length (multiple-value-list (eval '(values nil t pi))))) + (Assert= 3 (length (multiple-value-list (eval '(values nil t pi)))) "Checking #'eval passes back multiple values") - (Assert - (= 2 (length (multiple-value-list (apply #'floor '(5 3))))) + (Assert= 2 (length (multiple-value-list (apply #'floor '(5 3)))) "Checking #'apply passes back multiple values") - (Assert - (= 2 (length (multiple-value-list (funcall #'floor 5 3)))) + (Assert= 2 (length (multiple-value-list (funcall #'floor 5 3))) "Checking #'funcall passes back multiple values") - (Assert - (equal '(1 2) (multiple-value-list - (multiple-value-call #'floor (values 5 3)))) + (Assert-equal '(1 2) (multiple-value-list + (multiple-value-call #'floor (values 5 3))) "Checking #'multiple-value-call passes back multiple values correctly") - (Assert - (= 1 (length (multiple-value-list - (and (multiple-value-function-returning-nil) t)))) + (Assert= 1 (length (multiple-value-list + (and (multiple-value-function-returning-nil) t))) "Checking multiple values from non-trailing forms discarded by #'and") - (Assert - (= 5 (length (multiple-value-list - (and t (multiple-value-function-returning-nil))))) + (Assert= 5 (length (multiple-value-list + (and t (multiple-value-function-returning-nil)))) "Checking multiple values from final forms not discarded by #'and") - (Assert - (= 1 (length (multiple-value-list - (or (multiple-value-function-returning-t) t)))) + (Assert= 1 (length (multiple-value-list + (or (multiple-value-function-returning-t) t))) "Checking multiple values from non-trailing forms discarded by #'and") - (Assert - (= 5 (length (multiple-value-list - (or nil (multiple-value-function-returning-t))))) + (Assert= 5 (length (multiple-value-list + (or nil (multiple-value-function-returning-t)))) "Checking multiple values from final forms not discarded by #'and") - (Assert - (= 1 (length (multiple-value-list - (cond ((multiple-value-function-returning-t)))))) + (Assert= 1 (length (multiple-value-list + (cond ((multiple-value-function-returning-t))))) "Checking cond doesn't pass back multiple values in tests.") - (Assert - (equal (list nil pi e radians-to-degrees degrees-to-radians) + (Assert-equal (list nil pi e radians-to-degrees degrees-to-radians) (multiple-value-list - (cond (t (multiple-value-function-returning-nil))))) + (cond (t (multiple-value-function-returning-nil)))) "Checking cond passes back multiple values in clauses.") - (Assert - (= 1 (length (multiple-value-list - (prog1 (multiple-value-function-returning-nil))))) + (Assert= 1 (length (multiple-value-list + (prog1 (multiple-value-function-returning-nil)))) "Checking prog1 discards multiple values correctly.") - (Assert - (= 5 (length (multiple-value-list + (Assert= 5 (length (multiple-value-list (multiple-value-prog1 - (multiple-value-function-returning-nil))))) + (multiple-value-function-returning-nil)))) "Checking multiple-value-prog1 passes back multiple values correctly.") - (Assert - (equal (list t pi e degrees-to-radians radians-to-degrees) + (Assert-equal (list t pi e degrees-to-radians radians-to-degrees) (multiple-value-list - (catch 'VoN61Lo4Y (function-throwing-multiple-values))))) - (Assert - (equal (list t pi e degrees-to-radians radians-to-degrees) + (catch 'VoN61Lo4Y (function-throwing-multiple-values)))) + (Assert-equal (list t pi e degrees-to-radians radians-to-degrees) (multiple-value-list (loop for eye in `(a b c d ,e f g ,nil ,pi) do (when (null eye) - (return (multiple-value-function-returning-t)))))) + (return (multiple-value-function-returning-t))))) "Checking #'loop passes back multiple values correctly.") (Assert (null (or)) "Checking #'or behaves correctly with zero arguments.") - (Assert - (eq t (and)) + (Assert-eq t (and) "Checking #'and behaves correctly with zero arguments.") - (Assert - (= (* 3.0 (- pi 3.0)) + (Assert= (* 3.0 (- pi 3.0)) (letf (((values three one-four-one-five-nine) (floor pi))) - (* three one-four-one-five-nine))) + (* three one-four-one-five-nine)) "checking letf handles #'values in a basic sense")) ;; #'equalp tests. @@ -2079,66 +2056,105 @@ (eacute-character ?\u00E9) (Eacute-character ?\u00c9) (+base-chars+ (loop - with res = (make-string 96 ?\x20) - for int-char from #x20 to #x7f - for char being each element in-ref res - do (setf char (int-to-char int-char)) - finally return res))) + with res = (make-string 96 ?\x20) + for int-char from #x20 to #x7f + for char being each element in-ref res + do (setf char (int-to-char int-char)) + finally return res))) + (let ((equal-lists + '((111111111111111111111111111111111111111111111111111 + 111111111111111111111111111111111111111111111111111.0) + (0 0.0 0.000 -0 -0.0 -0.000 #b0 0/5 -0/5) + (21845 #b101010101010101 #x5555) + (1.5 1.500000000000000000000000000000000000000000000000000000000 + 3/2) + (-55 -110/2) + ;; Can't use this, these values aren't `='. + ;;(-12345678901234567890123457890123457890123457890123457890123457890 + ;; -12345678901234567890123457890123457890123457890123457890123457890.0) + ))) + (loop for li in equal-lists do + (loop for (x . tail) on li do + (loop for y in tail do + (Assert-equalp x y) + (Assert-equalp y x))))) + + (let ((diff-list + `(0 1 2 3 1000 5000000000 5555555555555555555555555555555555555 + -1 -2 -3 -1000 -5000000000 -5555555555555555555555555555555555555 + 1/2 1/3 2/3 8/2 355/113 (/ 3/2 0.2) (/ 3/2 0.7) + 55555555555555555555555555555555555555555/2718281828459045 + 0.111111111111111111111111111111111111111111111111111111111111111 + 1e+300 1e+301 -1e+300 -1e+301))) + (loop for (x . tail) on diff-list do + (loop for y in tail do + (Assert-not-equalp x y) + (Assert-not-equalp y x)))) + (Assert-equalp "hi there" "Hi There" - "checking equalp isn't case-sensitive") + "checking equalp isn't case-sensitive") (Assert-equalp 99 99.0 - "checking equalp compares numerical values of different types") + "checking equalp compares numerical values of different types") (Assert (null (equalp 99 ?c)) "checking equalp does not convert characters to numbers") ;; Fixed in Hg d0ea57eb3de4. (Assert (null (equalp "hi there" [hi there])) "checking equalp doesn't error with string and non-string") - (Assert-eq t (equalp "ABCDEEFGH\u00CDJ" string-variable) - "checking #'equalp is case-insensitive with an upcased constant") - (Assert-eq t (equalp "abcdeefgh\xedj" string-variable) - "checking #'equalp is case-insensitive with a downcased constant") - (Assert-eq t (equalp string-variable string-variable) - "checking #'equalp works when handed the same string twice") - (Assert-eq t (equalp string-variable "aBcDeeFgH\u00Edj") - "check #'equalp is case-insensitive with a variable-cased constant") - (Assert-eq t (equalp "" (bit-vector)) - "check empty string and empty bit-vector are #'equalp.") - (Assert-eq t (equalp (string) (bit-vector)) - "check empty string and empty bit-vector are #'equalp, no constants") - (Assert-eq t (equalp "hi there" (vector ?h ?i ?\ ?t ?h ?e ?r ?e)) - "check string and vector with same contents #'equalp") - (Assert-eq t (equalp (string ?h ?i ?\ ?t ?h ?e ?r ?e) - (vector ?h ?i ?\ ?t ?h ?e ?r ?e)) - "check string and vector with same contents #'equalp, no constants") - (Assert-eq t (equalp [?h ?i ?\ ?t ?h ?e ?r ?e] - (string ?h ?i ?\ ?t ?h ?e ?r ?e)) - "check string and vector with same contents #'equalp, vector constant") - (Assert-eq t (equalp [0 1.0 0.0 0 1] - (bit-vector 0 1 0 0 1)) - "check vector and bit-vector with same contents #'equalp,\ + (Assert-equalp "ABCDEEFGH\u00CDJ" string-variable + "checking #'equalp is case-insensitive with an upcased constant") + (Assert-equalp "abcdeefgh\xedj" string-variable + "checking #'equalp is case-insensitive with a downcased constant") + (Assert-equalp string-variable string-variable + "checking #'equalp works when handed the same string twice") + (Assert-equalp string-variable "aBcDeeFgH\u00Edj" + "check #'equalp is case-insensitive with a variable-cased constant") + (Assert-equalp "" (bit-vector) + "check empty string and empty bit-vector are #'equalp.") + (Assert-equalp (string) (bit-vector) + "check empty string and empty bit-vector are #'equalp, no constants") + (Assert-equalp "hi there" (vector ?h ?i ?\ ?t ?h ?e ?r ?e) + "check string and vector with same contents #'equalp") + (Assert-equalp (string ?h ?i ?\ ?t ?h ?e ?r ?e) + (vector ?h ?i ?\ ?t ?h ?e ?r ?e) + "check string and vector with same contents #'equalp, no constants") + (Assert-equalp [?h ?i ?\ ?t ?h ?e ?r ?e] + (string ?h ?i ?\ ?t ?h ?e ?r ?e) + "check string and vector with same contents #'equalp, vector constant") + (Assert-equalp [0 1.0 0.0 0 1] + (bit-vector 0 1 0 0 1) + "check vector and bit-vector with same contents #'equalp,\ + vector constant") + (Assert-not-equalp [0 2 0.0 0 1] + (bit-vector 0 1 0 0 1) + "check vector and bit-vector with different contents not #'equalp,\ vector constant") - (Assert-eq t (equalp #*01001 - (vector 0 1.0 0.0 0 1)) - "check vector and bit-vector with same contents #'equalp,\ + (Assert-equalp #*01001 + (vector 0 1.0 0.0 0 1) + "check vector and bit-vector with same contents #'equalp,\ bit-vector constant") - (Assert-eq t (equalp ?\u00E9 Eacute-character) - "checking characters are case-insensitive, one constant") - (Assert-eq nil (equalp ?\u00E9 (aref (format "%c" ?a) 0)) - "checking distinct characters are not equalp, one constant") - (Assert-eq t (equalp t (and)) - "checking symbols are correctly #'equalp") - (Assert-eq nil (equalp t (or nil '#:t)) - "checking distinct symbols with the same name are not #'equalp") - (Assert-eq t (equalp #s(char-table type generic data (?\u0080 "hi-there")) - (let ((aragh (make-char-table 'generic))) - (put-char-table ?\u0080 "hi-there" aragh) - aragh)) - "checking #'equalp succeeds correctly, char-tables") - (Assert-eq nil (equalp #s(char-table type generic data (?\u0080 "hi-there")) - (let ((aragh (make-char-table 'generic))) - (put-char-table ?\u0080 "HI-THERE" aragh) - aragh)) - "checking #'equalp fails correctly, char-tables")) + (Assert-equalp ?\u00E9 Eacute-character + "checking characters are case-insensitive, one constant") + (Assert-not-equalp ?\u00E9 (aref (format "%c" ?a) 0) + "checking distinct characters are not equalp, one constant") + (Assert-equalp t (and) + "checking symbols are correctly #'equalp") + (Assert-not-equalp t (or nil '#:t) + "checking distinct symbols with the same name are not #'equalp") + (Assert-equalp #s(char-table type generic data (?\u0080 "hi-there")) + (let ((aragh (make-char-table 'generic))) + (put-char-table ?\u0080 "hi-there" aragh) + aragh) + "checking #'equalp succeeds correctly, char-tables") + (Assert-equalp #s(char-table type generic data (?\u0080 "hi-there")) + (let ((aragh (make-char-table 'generic))) + (put-char-table ?\u0080 "HI-THERE" aragh) + aragh) + "checking #'equalp succeeds correctly, char-tables") + (Assert-not-equalp #s(char-table type generic data (?\u0080 "hi-there")) + (let ((aragh (make-char-table 'generic))) + (put-char-table ?\u0080 "hi there" aragh) + aragh) + "checking #'equalp fails correctly, char-tables")) ;; There are more tests available for equalp here: ;; @@ -2199,10 +2215,8 @@ (rassoc* (1- most-negative-fixnum) assoc*-list) (rassoc* (1- most-negative-fixnum) assoc*-list :test #'eql) "checking #'rassoc* correct if #'eql not explicitly specified") - (Assert-eq - (eql (1+most-positive-fixnum) (1+ most-positive-fixnum)) - t - "checking #'eql handles a bignum literal properly.") + (Assert-eql (1+most-positive-fixnum) (1+ most-positive-fixnum) + "checking #'eql handles a bignum literal properly.") (Assert-eq (member* (1+most-positive-fixnum) member*-list) (member* (1+ most-positive-fixnum) member*-list :test #'equal)