;;;;
;;;; SRFI-89
;;;;

;;; These tests have been stolen in the SRFi-89  repository:
;; https://github.com/scheme-requests-for-implementation/srfi-89/blob/master/contrib/Martin-Becze

(define* simple 1)
(test "simple1" 1 simple)

(define* (simple2) 2)
(test "simple2"  2 (simple2))

(define* (named  (#:b a 1)) a)
(test  "named" "a" (named #:b "a"))

(define* (multi-named (#:b a) (#:a z 2)) (list a z))
(test "multi-named" (list 5 2) (multi-named #:b 5))

(define* (multi-named-samename (#:b b 1) (#:a z 2)) (list b z))
(test "multi-named-samename" (list 1 2) (multi-named-samename))

(define* (named-positional (#:b a 1) z) (list a z))
(test "named-positional" (list 1 2) (named-positional 2))

(define* (named-positional-optional (#:b a 1) z (y 3)) (list a z y))
(test "named-positional-optional" (list 1 2 3) (named-positional-optional 2))

(define* (named-positional-optional-rest (#:b a 1) z (y 3) . r) (list a z y r))
(test "named-positional-optional-rest" (list 1 2 'z (list 4))
      (named-positional-optional-rest 2 'z 4))

(define* (positional x) x)
(test "positional" 1 (positional 1))

(define* (positional-optional a (b #f)) (list a b))
(test "positional-optional" '(1 #f) (positional-optional 1))

(define* (optional (b #f)) b)
(test "optional" #f (optional))

(define* (optional-named-rest (a 8) (#:key k 7) . r)
  (list a k r))

(test "positional-named-rest" '(8 7 ()) (optional-named-rest))

(test/compile-error "error.1"
                    (define* (test a b (c 1) (#:v z) f) (list a b c z)))

(test/compile-error "error.2"
 	                (define* (test  (#:v z) a b (c 1) (#:f f)) (list a b c z)))
