(use-modules (oop goops)
             (aiscm compile)
             (aiscm element)
             (aiscm int)
             (srfi srfi-64))
(define i (make <int> #:value 2))
(define j (make <int> #:value 3))
(test-equal "get parameters of '(+ i 2)" '(i 2) (expr->params '(+ i 2)))
(test-equal "get parameters of '(+ i (* j k))" '(i j k) (expr->params '(+ i (* j k))))
(test-equal "get descriptor of '(+ i 2)" '<+_?_?> (expr->descr '(+ i 2)))
(test-equal "get descriptor of '(+ i (* j k))" '<+_?_<*_?_?>> (expr->descr '(+ i (* j k))))
(test-equal "convert expression to method call" '(<+_?_<*_?_?>> i j k) (expr->call '(+ i (* j k))))
(test-eqv "check number of temporaries" 3 (length (expr->temps '(+ i (* j k)))))
(test-equal "expr->method creates method definition" 'define-method (car (expr->method '(+ i j))))
(test-equal "expr->method uses descriptor as method name" (expr->descr '(+ i j)) (caadr (expr->method '(+ i j))))
(test-eqv "compiling method generates and calls it" 5 (get (comp (+ i j))))
(run-tests)
