;; -*-theme-d-*-

;; Copyright (C) 2018  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 test672)

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

  (define-simple-proc main (() <none> nonpure)
    (report-test (expt 2 3) 8)
    (report-test (expt 2 -3) (rational 1 8))
    (report-test (expt 2 3.5) 11.313708498984761)
    (report-test (expt 0 1.0) 0.0)
    (report-test (expt 0 0.0) 1.0)
    (report-test (expt 2 (rational 0 1)) 1)
    (report-test (expt 2 (rational 1 1)) 2)
    (report-test (expt 2 (rational 3 1)) 8)
    (report-test (expt 2 (rational -3 1)) (rational 1 8))
    (report-test (expt 3 (rational 4 5)) 2.4082246852806923)
    (report-test (expt -3 (rational 4 5))
		 (complex -1.9482946966653392 1.4155189542146738))
    (report-test (expt 2 (complex 1.5 -1))
		 (complex 2.1757361740278176 -1.8072554055879297))
    (console-newline)

    (report-test (expt 2.5 -3) 0.064)
    (report-test (expt 0.0 0) 1)
    (report-test (expt 2.5 -1.5) 0.25298221281347033)
    (report-test (expt -2.5 -1.5)
		 (complex -4.6472078574484644e-17 0.25298221281347033))
    (report-test (expt 0.0 0.0) 1.0)
    (report-test (expt 0.0 2.0) 0.0)
    (report-test (expt 1.0 (rational 0 1)) 1.0)
    (report-test (expt 1.5 (rational 4 5)) 1.3831618672225916)
    (report-test (expt -1.5 (rational 4 5))
		 (complex -1.119001456554461 0.8130021470867594))
    (report-test (expt 2.5 (complex 1.0 -1.5))
		 (complex 0.48775201192445783 -2.451957987989118))
    (console-newline)

    (report-test (expt (rational 4 5) 3) (rational 64 125))
    (report-test (expt (rational -4 5) -3) (rational -125 64))
    (report-test (expt (rational 5 3) 1.5) 2.151657414559676)
    (report-test (expt (rational -5 3) 1.5)
		 (complex -3.952530548403265e-16 -2.151657414559676))
    (report-test (expt (rational 0 1) 0.0) 1.0)
    (report-test (expt (rational 0 1) 1.5) 0.0)
    (report-test (expt (rational 5 7) (rational 3 1)) (rational 125 343))
    (report-test (expt (rational 5 7) (rational 3 2)) 0.603681610520369)
    (report-test (expt (rational -5 7) (rational 3 2))
		 (complex -1.1089451280418336e-16 -0.6036816105203691))
    (report-test (expt (rational -5 7) (complex 1.5 -2.5))
		 (complex 1159.1937976990553 -1036.5809470734252))
    (console-newline)

    (report-test (expt (complex -0.5 2.0) 3) (complex 5.875 -6.5))
    (report-test (expt (complex -0.5 2.0) 0) 1)
    (report-test (expt (complex -0.5 2.0) 1.5)
		 (complex -2.7052356139934957 +1.2013740996120919))
    (report-test (expt (complex -0.5 2.0) (rational -6 3))
		 (complex -0.20761245674740486 0.11072664359861592))
    (report-test (expt (complex -0.5 2.0) (rational 5 4))
		 (complex -1.589349826769204 1.8910746320753018))
    (report-test (expt (complex -0.5 2.0) (complex -2.0 1.5))
		 (complex -0.012787319494071922 -0.008659058125692969))
    (console-newline)))
