comparison tests/automated/lisp-tests.el @ 5323:f87bb35a6b94

Test sanity-checking of :start, :end keyword arguments when appropriate. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el (wrong-type-argument): Add a missing parenthesis here. Make sure #'count #'position #'find #'delete* #'remove* #'reduce #'delete-duplicates #'remove-duplicates #'replace #'mismatch #'search sanity check their :start and :end keyword arguments.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 30 Dec 2010 01:14:13 +0000
parents c096d8051f89
children 7b391d07b334 6506fcb40fcf
comparison
equal deleted inserted replaced
5322:df125a42c50c 5323:f87bb35a6b94
2547 (Check-Error wrong-type-argument 2547 (Check-Error wrong-type-argument
2548 (fill [1 2 3 4 5] 1 :start (float most-positive-fixnum))) 2548 (fill [1 2 3 4 5] 1 :start (float most-positive-fixnum)))
2549 (Check-Error wrong-type-argument 2549 (Check-Error wrong-type-argument
2550 (fill "1 2 3 4 5" ?1 :start (float most-positive-fixnum))) 2550 (fill "1 2 3 4 5" ?1 :start (float most-positive-fixnum)))
2551 (Check-Error wrong-type-argument 2551 (Check-Error wrong-type-argument
2552 (fill #*10101010 1 :start (float most-positive-fixnum)) 2552 (fill #*10101010 1 :start (float most-positive-fixnum)))
2553 (Check-Error wrong-type-argument 2553 (Check-Error wrong-type-argument
2554 (fill '(1 2 3 4 5) 1 :end (float most-positive-fixnum))) 2554 (fill '(1 2 3 4 5) 1 :end (float most-positive-fixnum)))
2555 (Check-Error wrong-type-argument 2555 (Check-Error wrong-type-argument
2556 (fill [1 2 3 4 5] 1 :end (float most-positive-fixnum))) 2556 (fill [1 2 3 4 5] 1 :end (float most-positive-fixnum)))
2557 (Check-Error wrong-type-argument 2557 (Check-Error wrong-type-argument
2667 :end1 (1+ most-positive-fixnum))) 2667 :end1 (1+ most-positive-fixnum)))
2668 (Check-Error args-out-of-range 2668 (Check-Error args-out-of-range
2669 (replace '(1 2 3 4 5) [5 4 3 2 1] 2669 (replace '(1 2 3 4 5) [5 4 3 2 1]
2670 :end2 (1+ most-positive-fixnum)))) 2670 :end2 (1+ most-positive-fixnum))))
2671 2671
2672 (symbol-macrolet
2673 ((list-length 2048) (vector-length 512) (string-length (* 8192 2)))
2674 (let ((list
2675 ;; CIRCULAR_LIST_SUSPICION_LENGTH is 1024, it's helpful if this list
2676 ;; is longer than that.
2677 (make-list list-length 'make-list))
2678 (vector (make-vector vector-length 'make-vector))
2679 (bit-vector (make-bit-vector vector-length 1))
2680 (string (make-string string-length
2681 (or (decode-char 'ucs #x20ac) ?\xFF)))
2682 (item 'cons))
2683 (dolist (function '(count position find delete* remove* reduce))
2684 (Check-Error args-out-of-range
2685 (funcall function item list
2686 :start (1+ list-length) :end (1+ list-length)))
2687 (Check-Error wrong-type-argument
2688 (funcall function item list
2689 :start -1 :end list-length))
2690 (Check-Error args-out-of-range
2691 (funcall function item list :end (* 2 list-length)))
2692 (Check-Error args-out-of-range
2693 (funcall function item vector
2694 :start (1+ vector-length) :end (1+ vector-length)))
2695 (Check-Error wrong-type-argument
2696 (funcall function item vector :start -1))
2697 (Check-Error args-out-of-range
2698 (funcall function item vector :end (* 2 vector-length)))
2699 (Check-Error args-out-of-range
2700 (funcall function item bit-vector
2701 :start (1+ vector-length) :end (1+ vector-length)))
2702 (Check-Error wrong-type-argument
2703 (funcall function item bit-vector :start -1))
2704 (Check-Error args-out-of-range
2705 (funcall function item bit-vector :end (* 2 vector-length)))
2706 (Check-Error args-out-of-range
2707 (funcall function item string
2708 :start (1+ string-length) :end (1+ string-length)))
2709 (Check-Error wrong-type-argument
2710 (funcall function item string :start -1))
2711 (Check-Error args-out-of-range
2712 (funcall function item string :end (* 2 string-length))))
2713 (dolist (function '(delete-duplicates remove-duplicates))
2714 (Check-Error args-out-of-range
2715 (funcall function (copy-sequence list)
2716 :start (1+ list-length) :end (1+ list-length)))
2717 (Check-Error wrong-type-argument
2718 (funcall function (copy-sequence list)
2719 :start -1 :end list-length))
2720 (Check-Error args-out-of-range
2721 (funcall function (copy-sequence list)
2722 :end (* 2 list-length)))
2723 (Check-Error args-out-of-range
2724 (funcall function (copy-sequence vector)
2725 :start (1+ vector-length) :end (1+ vector-length)))
2726 (Check-Error wrong-type-argument
2727 (funcall function (copy-sequence vector) :start -1))
2728 (Check-Error args-out-of-range
2729 (funcall function (copy-sequence vector)
2730 :end (* 2 vector-length)))
2731 (Check-Error args-out-of-range
2732 (funcall function (copy-sequence bit-vector)
2733 :start (1+ vector-length) :end (1+ vector-length)))
2734 (Check-Error wrong-type-argument
2735 (funcall function (copy-sequence bit-vector) :start -1))
2736 (Check-Error args-out-of-range
2737 (funcall function (copy-sequence bit-vector)
2738 :end (* 2 vector-length)))
2739 (Check-Error args-out-of-range
2740 (funcall function (copy-sequence string)
2741 :start (1+ string-length) :end (1+ string-length)))
2742 (Check-Error wrong-type-argument
2743 (funcall function (copy-sequence string) :start -1))
2744 (Check-Error args-out-of-range
2745 (funcall function (copy-sequence string)
2746 :end (* 2 string-length))))
2747 (dolist (function '(replace mismatch search))
2748 (Check-Error args-out-of-range
2749 (funcall function (copy-sequence list) (copy-sequence list)
2750 :start1 (1+ list-length) :end1 (1+ list-length)))
2751 (Check-Error wrong-type-argument
2752 (funcall function (copy-sequence list) (copy-sequence list)
2753 :start1 -1 :end1 list-length))
2754 (Check-Error args-out-of-range
2755 (funcall function (copy-sequence list) (copy-sequence list)
2756 :end1 (* 2 list-length)))
2757 (Check-Error args-out-of-range
2758 (funcall function (copy-sequence vector)
2759 (copy-sequence vector) :start1 (1+ vector-length)
2760 :end1 (1+ vector-length)))
2761 (Check-Error wrong-type-argument
2762 (funcall function (copy-sequence vector)
2763 (copy-sequence vector) :start1 -1))
2764 (Check-Error args-out-of-range
2765 (funcall function (copy-sequence vector)
2766 (copy-sequence vector)
2767 :end1 (* 2 vector-length)))
2768 (Check-Error args-out-of-range
2769 (funcall function (copy-sequence bit-vector)
2770 (copy-sequence bit-vector)
2771 :start1 (1+ vector-length)
2772 :end1 (1+ vector-length)))
2773 (Check-Error wrong-type-argument
2774 (funcall function (copy-sequence bit-vector)
2775 (copy-sequence bit-vector) :start1 -1))
2776 (Check-Error args-out-of-range
2777 (funcall function (copy-sequence bit-vector)
2778 (copy-sequence bit-vector)
2779 :end1 (* 2 vector-length)))
2780 (Check-Error args-out-of-range
2781 (funcall function (copy-sequence string)
2782 (copy-sequence string)
2783 :start1 (1+ string-length)
2784 :end1 (1+ string-length)))
2785 (Check-Error wrong-type-argument
2786 (funcall function (copy-sequence string)
2787 (copy-sequence string) :start1 -1))
2788 (Check-Error args-out-of-range
2789 (funcall function (copy-sequence string)
2790 (copy-sequence string)
2791 :end1 (* 2 string-length))))))
2792
2672 ;;; end of lisp-tests.el 2793 ;;; end of lisp-tests.el