From dd21c82c858b6066883e9c656adf9b4dc1b409f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sat, 8 Oct 2016 17:19:26 +0200 Subject: [PATCH] Added tests for different orders of types in the union for traversal.hl.rkt --- test/test-traversal-2.rkt | 56 ++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/test/test-traversal-2.rkt b/test/test-traversal-2.rkt index 874efbe..c8ee6f0 100644 --- a/test/test-traversal-2.rkt +++ b/test/test-traversal-2.rkt @@ -14,14 +14,14 @@ (define-fold f₃ t₃ (U (tagged tg [a String] [b Boolean]) (tagged tg [a Boolean] [c String])) String) -#;(define-fold f₄ t₄ (U (tagged tg [a String] [b Boolean]) - String - (tagged tg [a Boolean] [c String])) - String) -#;(define-fold f₄ t₄ (U (tagged t0) - String - (tagged tg [a Boolean] [c String])) - String) +(define-fold f₄ t₄ (U (tagged tg [a String] [b Boolean]) + String + (tagged tg [a Boolean] [c String])) + String) +(define-fold f₅ t₅ (U (tagged t0) + String + (tagged tg [a Boolean] [c String])) + String) (define-fold f₆ t₆ (U String (tagged tg [a String] [b Boolean])) String) @@ -53,7 +53,23 @@ Integer) (tagged tg [a #t] [c 'def]) 1) -#;(check-equal?-values: +(check-equal?-values: + ((f₄ string? string->symbol+acc) (tagged tg [a "abc"] [b #f]) 0) + : (Values (U (tagged tg [a Symbol] [b Boolean]) + Symbol + (tagged tg [a Boolean] [c Symbol])) + Integer) + (tagged tg [a 'abc] [b #f]) 1) + +(check-equal?-values: + ((f₄ string? string->symbol+acc) "ghi" 0) + : (Values (U (tagged tg [a Symbol] [b Boolean]) + Symbol + (tagged tg [a Boolean] [c Symbol])) + Integer) + 'ghi 1) + +(check-equal?-values: ((f₄ string? string->symbol+acc) (tagged tg [a #t] [c "def"]) 0) : (Values (U (tagged tg [a Symbol] [b Boolean]) Symbol @@ -61,14 +77,30 @@ Integer) (tagged tg [a #t] [c 'def]) 1) -#;(check-equal?-values: - ((f₄ string? string->symbol+acc) "ghi" 0) - : (Values (U (tagged tg [a Symbol] [b Boolean]) +(check-equal?-values: + ((f₅ string? string->symbol+acc) (tagged t0 #:instance) 0) + : (Values (U (tagged t0) + Symbol + (tagged tg [a Boolean] [c Symbol])) + Integer) + (tagged t0 #:instance) 0) + +(check-equal?-values: + ((f₅ string? string->symbol+acc) "ghi" 0) + : (Values (U (tagged t0) Symbol (tagged tg [a Boolean] [c Symbol])) Integer) 'ghi 1) +(check-equal?-values: + ((f₅ string? string->symbol+acc) (tagged tg [a #t] [c "def"]) 0) + : (Values (U (tagged t0) + Symbol + (tagged tg [a Boolean] [c Symbol])) + Integer) + (tagged tg [a #t] [c 'def]) 1) + (check-equal?-values: ((f₆ string? string->symbol+acc) (tagged tg [a "abc"] [b #f]) 0) : (Values (U (tagged tg [a Symbol] [b Boolean])