require 'test/unit'
require 'carat/lisp'

# fixture

class T

  include Lisp

  (def accumulate (fun, x, list)
    (if (null? list)
      x
    else
      (accumulate fun, (fun.call x, (car list)), (cdr list))
    end)
  end)

end

# test

class TC_Lisp < Test::Unit::TestCase

  include Lisp

  def test_accumulate
    t = T.new
    t.accumulate( proc{ |x,y| x+y }, 0, [1,2,3] )
  end

end