File: test927.thb

package info (click to toggle)
theme-d 7.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,036 kB
  • sloc: lisp: 9,625; sh: 5,321; makefile: 715; ansic: 477
file content (38 lines) | stat: -rw-r--r-- 1,195 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
;; -*-theme-d-*-

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

;; Expected results: compilation OK

(define-body (tests test927)
  
  (declare-simple-method c-exp2_2 (<complex>) <complex> pure)
  
  (add-method r-exp2
    (unchecked-prim-proc r-exp2 (<real>) <real> pure))
  
  (define-simple-virtual-method exp2 (((nr <number>)) <number> pure)
    (raise-simple 'exp2:dispatch-error))
  
  (define-simple-virtual-method exp2 (((nr <real-number>)) <real-number> pure)
    (raise-simple 'exp2:dispatch-error))
  
  (include-virtual-methods exp2 c-exp2_2)
  
  (include-virtual-methods exp2 r-exp2)
  
  (define-simple-virtual-method exp2 (((rat <rational>)) <real-number> pure)
    (let* ((rat-s (simplify-rational rat))
           (i-numer (numerator rat-s))
           (i-denom (denominator rat-s)))
      (if (equal? i-denom 1)
          (i-expt 2 i-numer)
          (r-exp2 (rational->real rat)))))
  
  (define-simple-virtual-method exp2 (((i <integer>)) <rational-number> pure)
    (i-expt 2 i))
  
  (define-simple-method c-exp2_2 (((exponent <complex>)) <complex> pure)
    (c-exp (* exponent gl-r-ln2))))