From 7726cb254503c2c3d082ffb8aed9c12cbeeec12e Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 21 Jul 2019 09:50:18 +0200 Subject: [PATCH] bubble sort works again --- test/src/comp-tests.el | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index e2a9b1ce49c..4462f35246a 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el @@ -334,26 +334,26 @@ (error err)) '(wrong-type-argument consp 3)))) -;; (ert-deftest comp-tests-bubble-sort () -;; "Run bubble sort." -;; (defun comp-bubble-sort-f (list) -;; (let ((i (length list))) -;; (while (> i 1) -;; (let ((b list)) -;; (while (cdr b) -;; (when (< (cadr b) (car b)) -;; (setcar b (prog1 (cadr b) -;; (setcdr b (cons (car b) (cddr b)))))) -;; (setq b (cdr b)))) -;; (setq i (1- i))) -;; list)) - -;; (native-compile #'comp-bubble-sort-f) - -;; (let* ((list1 (mapcar 'random (make-list 1000 most-positive-fixnum))) -;; (list2 (copy-sequence list1))) -;; (should (equal (comp-bubble-sort-f list1) -;; (sort list2 #'<))))) +(ert-deftest comp-tests-bubble-sort () + "Run bubble sort." + (defun comp-bubble-sort-f (list) + (let ((i (length list))) + (while (> i 1) + (let ((b list)) + (while (cdr b) + (when (< (cadr b) (car b)) + (setcar b (prog1 (cadr b) + (setcdr b (cons (car b) (cddr b)))))) + (setq b (cdr b)))) + (setq i (1- i))) + list)) + + (native-compile #'comp-bubble-sort-f) + + (let* ((list1 (mapcar 'random (make-list 1000 most-positive-fixnum))) + (list2 (copy-sequence list1))) + (should (equal (comp-bubble-sort-f list1) + (sort list2 #'<))))) (ert-deftest comp-tests-list-inline () "Test some inlined list functions." -- 2.39.5