From 526ce502e5b7bce1e3577696b2c41564f7248920 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sat, 24 Mar 2018 14:03:54 +0100 Subject: base: Box 'number-children' * src/mcron/base.scm (number-children): Box it using SRFI-111 to be explicit about the mutability of this object. (update-number-children!): New procedure. (run-job, child-cleanup): Use it. * tests/base.scm ("update-number-children!: 1+") ("number-children: init", "update-number-children!: 1-"): New tests. --- tests/base.scm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/base.scm') diff --git a/tests/base.scm b/tests/base.scm index 89b7349..d7a2dbd 100644 --- a/tests/base.scm +++ b/tests/base.scm @@ -17,6 +17,7 @@ ;;; along with GNU Mcron. If not, see . (use-modules (srfi srfi-64) + (srfi srfi-111) (mcron base)) (test-begin "base") @@ -148,4 +149,35 @@ (with-output-to-string (λ () (display-schedule 1 #:schedule schdl))))) +;;; +;;; Running jobs +;;; + +;;; Import private global. +(define number-children (@@ (mcron base) number-children)) + +;;; Import private procedures. +(define update-number-children! (@@ (mcron base) update-number-children!)) + +;;; Check 'number-children' initial value. +(let ((schdl (make-schedule '() '() 'user))) + (test-equal "number-children: init" + 0 + (unbox number-children))) + +;;; Check 'update-number-children!' incrementation. +(let ((schdl (make-schedule '() '() 'user))) + (update-number-children! 1+) + (update-number-children! 1+) + (test-equal "update-number-children!: 1+" + 2 + (unbox number-children))) + +;;; Check 'update-number-children!' decrementation. +(let ((schdl (make-schedule '() '() 'user))) + (update-number-children! 1-) + (test-equal "update-number-children!: 1-" + 1 + (unbox number-children))) + (test-end) -- cgit v1.2.3