;; -*-theme-d-*-

;; Copyright (C) 2017  Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.

;; Expected results: translation and running OK


(define-proper-program (tests test534)

  (import (standard-library core)
	  (standard-library console-io))

  (use (standard-library complex))

  (define-class <complex> <object> #f #t #t public ()
    ((i-re <integer> public hidden)
     (i-im <integer> public hidden)))

  (define-simple-proc complex (((i-re <integer>) (i-im <integer>))
			       <complex>
			       pure)
    (make <complex> i-re i-im))

  (define-simple-proc real-part (((cx <complex>)) <integer> pure)
    (field-ref cx 'i-re))

  (define-simple-proc imag-part (((cx <complex>)) <integer> pure)
    (field-ref cx 'i-im))

  (define-simple-proc main (() <none> nonpure)
    (let ((cx1 <complex> (complex 1 2))
	  (cx2 (@ (standard-library complex) <complex>)
	       ((@ (standard-library complex) complex) 1.5 2.5)))
      (console-display-line (real-part cx1))
      (console-display-line (imag-part cx1))
      (console-display-line ((@ (standard-library complex) real-part) cx2))
      (console-display-line ((@ (standard-library complex) imag-part) cx2)))))

