diff options
| author | 2025-03-06 13:57:22 -0500 | |
|---|---|---|
| committer | 2025-03-06 13:57:22 -0500 | |
| commit | 691f41511b1bbae62409c1cec63ba43ba1e17210 (patch) | |
| tree | ef2a723afcae1753834f866475ac5a860fe2bab2 | |
| parent | add subtyping back (diff) | |
test overrides
| -rw-r--r-- | tests/run.scm | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/run.scm b/tests/run.scm index 7ff4a6c..b41f536 100644 --- a/tests/run.scm +++ b/tests/run.scm @@ -277,4 +277,27 @@ (list (gsampling (exact-integer-generator)))))))))) +(test-group "overrides" + (define sub (make-new-SAHP)) + (define-global-SAHP (sub ('exact-rational x)) + 1) + (test-group "non-overridable in local scope has precedence over global scope" + (letrec-SAHP ((sub ('number (lambda (x) 2)))) + (test-property (lambda (x) (= (sub x) 2)) + (list (gsampling + (inexact-real-generator) + (exact-rational-generator)))))) + (test-group "override in local scope to global scope" + (letrec-SAHP ((sub ('number + 'overridable + (lambda (x) 2)))) + (define (is-local-scope x) + (= (sub x) 2)) + (define (is-global-scope x) + (= (sub x) 1)) + (test-property is-local-scope + (list (inexact-complex-generator))) + (test-property is-global-scope + (list (exact-rational-generator)))))) + ;;; TODO: tests of override |
