From 1bb895eabf74a1e571887eb1521915e668a5c28d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 15 Apr 2017 23:53:23 +0200 Subject: services: Service types can now specify a default value for instances. * gnu/services.scm (&no-default-value): New variable. ()[default-value]: New field. (): Rename constructor from 'service' to 'make-service'. (service): New macro. (%service-with-default-value): New procedure. (&missing-value-service-error): New error condition. * tests/services.scm ("services, default value"): New test. * doc/guix.texi (Service Types and Services): Document 'default-value'. (Service Reference): Explain default values. --- tests/services.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/services.scm b/tests/services.scm index 7983427a7d..8484ee982a 100644 --- a/tests/services.scm +++ b/tests/services.scm @@ -31,6 +31,17 @@ (test-begin "services") +(test-equal "services, default value" + '(42 123 234 error) + (let* ((t1 (service-type (name 't1) (extensions '()))) + (t2 (service-type (name 't2) (extensions '()) + (default-value 42)))) + (list (service-value (service t2)) + (service-value (service t2 123)) + (service-value (service t1 234)) + (guard (c ((missing-value-service-error? c) 'error)) + (service t1))))) + (test-assert "service-back-edges" (let* ((t1 (service-type (name 't1) (extensions '()) (compose +) (extend *))) -- cgit 1.4.1