branch: externals/el-job
commit 104cbd4f46ebe286fd712be9ddabeeae4508316e
Author: Martin Edström <[email protected]>
Commit: Martin Edström <[email protected]>

    Revert "Remove old test"
    
    This reverts commit e44e6acf1bb082233c390786ae1a5721bbcb1f63.
---
 el-job-test.el | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/el-job-test.el b/el-job-test.el
index 3d8102fa5c..43baf56ae0 100644
--- a/el-job-test.el
+++ b/el-job-test.el
@@ -113,6 +113,37 @@
 
   )
 
+(ert-deftest el-job-old--split-optimally ()
+  ;; All benchmarks at zero
+  (let* ((plist (cl-loop for i below 50
+                         nconc (list (format "file-%d.org" i)
+                                     (time-convert 0 t))))
+         (items (map-keys plist))
+         (big-table (map-into (take 100 plist) '(hash-table :test equal)))
+         (tiny-table (map-into (take 10 plist) '(hash-table :test equal)))
+         (empty-table (make-hash-table :test #'equal)))
+    (should (>= 15 (length (el-job-old--split-optimally items 15 big-table))))
+    (should (>= 15 (length (el-job-old--split-optimally items 15 tiny-table))))
+    (should (= 15 (length (el-job-old--split-optimally items 15 empty-table))))
+    (should (= 5 (length (el-job-old--split-optimally (take 5 items) 15 
big-table))))
+    (should (= 5 (length (el-job-old--split-optimally (take 5 items) 15 
tiny-table))))
+    (should (= 5 (length (el-job-old--split-optimally (take 5 items) 15 
empty-table)))))
+
+  ;; All benchmarks at random nonzero duration (up to 2.0s)
+  (let* ((plist (cl-loop for i below 50
+                         nconc (list (format "file-%d.org" i)
+                                     (time-convert (/ 2.0 (1+ (random 100))) 
t))))
+         (items (map-keys plist))
+         (big-table (map-into (take 100 plist) '(hash-table :test equal)))
+         (tiny-table (map-into (take 10 plist) '(hash-table :test equal)))
+         (empty-table (make-hash-table :test #'equal)))
+    (should (>= 15 (length (el-job-old--split-optimally items 15 big-table))))
+    (should (>= 15 (length (el-job-old--split-optimally items 15 tiny-table))))
+    (should (= 15 (length (el-job-old--split-optimally items 15 empty-table))))
+    (should (= 5 (length (el-job-old--split-optimally (take 5 items) 15 
big-table))))
+    (should (= 5 (length (el-job-old--split-optimally (take 5 items) 15 
tiny-table))))
+    (should (= 5 (length (el-job-old--split-optimally (take 5 items) 15 
empty-table))))))
+
 (ert-deftest el-job-old--ensure-compiled-lib ()
   (when (and (require 'comp nil t)
              (native-comp-available-p)

Reply via email to