Test cases for block *args handling.
;; test_blockargs.nu
;;  tests for argument handling in Nu blocks.
;;
;;  Copyright (c) 2008 Jeff Buck


(class TestBlockArgs is NuTestCase
     
     (imethod (id) testSimpleArgs is
          (function make-list (a b c)
               (list a b c))
          (assert_equal '(1 2 3) (make-list 1 2 3)))
     
     (imethod (id) testRestArgs is
          (function make-list (a b *rest)
               (append (list a b) *rest))
          (assert_equal '(1 2 3) (make-list 1 2 3))
          (assert_equal '(1 2 3 4 5) (make-list 1 2 3 4 5)))
     
     (imethod (id) testOverrideImplicitArgs1 is
          (function make-list (*args)
               (*args))
          (assert_equal '(1 2 3) (make-list 1 2 3))
          (assert_equal '() (make-list)))
     
     (imethod (id) testOverrideImplicitArgs2 is
          (function make-list (a b *args)
               (list a b *args))
          (assert_equal '(1 2 ()) (make-list 1 2))
          (assert_equal '(1 2 (3)) (make-list 1 2 3)))

		(imethod (id) testBlock is
			(assert_equal '(1 2) ((do (a b) (list a b)) 1 2))
			(assert_equal '(1 2) ((do (a b *args) (list a b)) 1 2 3 4))
			(assert_equal '(3 4) ((do (a b *args) (*args)) 1 2 3 4))
			(assert_equal '(1 (3 4)) ((do (a b *args) (list a *args)) 1 2 3 4))))