diff options
Diffstat (limited to 'tests/entity-test.scm')
| -rw-r--r-- | tests/entity-test.scm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/entity-test.scm b/tests/entity-test.scm index 988d1c9..795aa1c 100644 --- a/tests/entity-test.scm +++ b/tests/entity-test.scm @@ -132,4 +132,19 @@ (let ((e '(#:type t #:x 0 #:skip-pipelines (fixture-skip)))) (test-equal "skipped" 0 (entity-ref (fixture-pipeline e) #:x)))) +(define-pipeline (guarded-pipeline guarded-skip) (ent) + guard: (entity-ref ent #:active? #f) + (entity-set ent #:x 99)) + +(test-group "define-pipeline with guard:" + (let ((e '(#:type t #:x 0 #:active? #t))) + (test-equal "runs body when guard passes" 99 + (entity-ref (guarded-pipeline e) #:x))) + (let ((e '(#:type t #:x 0))) + (test-equal "returns entity unchanged when guard fails" 0 + (entity-ref (guarded-pipeline e) #:x))) + (let ((e '(#:type t #:x 0 #:active? #t #:skip-pipelines (guarded-skip)))) + (test-equal "skip-pipelines takes precedence over guard" 0 + (entity-ref (guarded-pipeline e) #:x)))) + (test-end "entity") |
