;; -*-theme-d-*-

;; Copyright (C) 2014  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 test239)

  (import (standard-library core)
	  (standard-library math)
	  (standard-library console-io)
	  (tests numerical-test-env))

  (define-simple-proc main (() <none> nonpure)
    (report-test (+ 1 2) 3)
    (report-test (+ 1 (rational 4 5)) (rational 9 5))
    (report-test (+ 1 2.5) 3.5)
    (report-test (+ 3 (complex -1.1 -2.0)) (complex 1.9 -2.0))
    (report-test (+ (rational 4 5) 2) (rational 14 5))
    (report-test (+ (rational 4 5) (rational 3 2)) (rational 23 10))
    (report-test (+ (rational 4 5) 2.3) 3.1)
    (report-test (+ (rational 4 5) (complex 1.0 -1.0)) (complex 1.8 -1.0))
    (report-test (+ 1.5 1) 2.5)
    (report-test (+ 1.5 (rational 4 5)) 2.3)
    (report-test (+ 1.5 4.4) 5.9)
    (report-test (+ 1.5 (complex -1.1 -2.0)) (complex 0.4 -2.0))
    (report-test (+ (complex 2.0 3.0) 4) (complex 6.0 3.0))
    (report-test (+ (complex 2.0 3.0) (rational 4 5)) (complex 2.8 3.0))
    (report-test (+ (complex 2.0 3.0) -2.1) (complex -0.1 3.0))
    (report-test (+ (complex 2.0 3.0) (complex -1.1 -2.0)) (complex 0.9 1.0))
    (console-newline)

    (report-test (- 1 2) -1)
    (report-test (- 1 (rational 4 5)) (rational 1 5))
    (report-test (- 1 2.5) -1.5)
    (report-test (- 3 (complex -1.1 -2.0)) (complex 4.1 2.0))
    (report-test (- (rational 4 5) 2) (rational -6 5))
    (report-test (- (rational 4 5) (rational 3 2)) (rational -7 10))
    (report-test (- (rational 4 5) 2.3) -1.5)
    (report-test (- (rational 4 5) (complex 1.0 -1.0)) (complex -0.2 1.0))
    (report-test (- 1.5 1) 0.5)
    (report-test (- 1.5 (rational 4 5)) 0.7)
    (report-test (- 1.5 4.4) -2.9)
    (report-test (- 1.5 (complex -1.1 -2.0)) (complex 2.6 2.0))
    (report-test (- (complex 2.0 3.0) 4) (complex -2.0 3.0))
    (report-test (- (complex 2.0 3.0) (rational 4 5)) (complex 1.2 3.0))
    (report-test (- (complex 2.0 3.0) -2.1) (complex 4.1 3.0))
    (report-test (- (complex 2.0 3.0) (complex -1.1 -2.0)) (complex 3.1 5.0))
    (console-newline)

    (report-test (* 1 2) 2)
    (report-test (* 1 (rational 4 5)) (rational 4 5))
    (report-test (* 1 2.5) 2.5)
    (report-test (* 3 (complex -1.1 -2.0)) (complex -3.3 -6.0))
    (report-test (* (rational 4 5) 2) (rational 8 5))
    (report-test (* (rational 4 5) (rational 3 2)) (rational 6 5))
    (report-test (* (rational 4 5) 2.3) 1.84)
    (report-test (* (rational 4 5) (complex 1.0 -1.0)) (complex 0.8 -0.8))
    (report-test (* 1.5 1) 1.5)
    (report-test (* 1.5 (rational 4 5)) 1.2)
    (report-test (* 1.5 4.4) 6.6)
    (report-test (* 1.5 (complex -1.1 -2.0)) (complex -1.65 -3.0))
    (report-test (* (complex 2.0 3.0) 4) (complex 8.0 12.0))
    (report-test (* (complex 2.0 3.0) (rational 4 5)) (complex 1.6 2.4))
    (report-test (* (complex 2.0 3.0) -2.1) (complex -4.2 -6.3))
    (report-test (* (complex 2.0 3.0) (complex -1.1 -2.0)) (complex 3.8 -7.3))
    (console-newline)

    (report-test (/ 1 2) (rational 1 2))
    (report-test (/ 1 (rational 4 5)) (rational 5 4))
    (report-test (/ 1 2.5) 0.4)
    (report-test (/ 3 (complex -1.1 -2.0))
		 (complex -0.6333973128598849 1.1516314779270633))
    (report-test (/ (rational 4 5) 2) (rational 2 5))
    (report-test (/ (rational 4 5) (rational 3 2)) (rational 8 15))
    (report-test (/ (rational 4 5) 2.3) 0.3478260869565218)
    (report-test (/ (rational 4 5) (complex 1.0 -1.0)) (complex 0.4 0.4))
    (report-test (/ 1.5 1) 1.5)
    (report-test (/ 1.5 (rational 4 5)) 1.875)
    (report-test (/ 1.5 4.4) 0.3409090909090909)
    (report-test (/ 1.5 (complex -1.1 -2.0))
		 (complex -0.31669865642994244 0.5758157389635317))
    (report-test (/ (complex 2.0 3.0) 4) (complex 0.5 0.75))
    (report-test (/ (complex 2.0 3.0) (rational 4 5)) (complex 2.5 3.75))
    (report-test (/ (complex 2.0 3.0) -2.1)
		 (complex -0.9523809523809523 -1.4285714285714286))
    (report-test (/ (complex 2.0 3.0) (complex -1.1 -2.0))
		 (complex -1.5738963531669865 0.13435700575815734))
    (console-newline)))
