Raymond Toy pushed to branch issue-425-correctly-rounded-math-functions-single-float at cmucl / cmucl

Commits:

6 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -70,16 +70,16 @@ variables:
    70 70
       stage: ansi-test
    
    71 71
       artifacts:
    
    72 72
         paths:
    
    73
    -      - ansi-test/test.out
    
    73
    +      - ansi-test.out
    
    74 74
       script:
    
    75 75
         - bin/run-ansi-tests.sh -l dist/bin/lisp
    
    76
    -  
    
    76
    +    - cp ../ansi-test/test.out ansi-test.out
    
    77
    +
    
    77 78
     # Default configuration for running unit tests.
    
    78 79
     .unit_test_template: &unit_test_configuration
    
    79 80
       stage: test
    
    80 81
       artifacts:
    
    81 82
         paths:
    
    82
    -      - ansi-test/test.out
    
    83 83
           - test.log
    
    84 84
       script:
    
    85 85
         - echo LANG = $LANG
    
    ... ... @@ -147,7 +147,9 @@ linux:build:
    147 147
         - job: linux:install
    
    148 148
           artifacts: true
    
    149 149
       variables:
    
    150
    -    CONFIG: "x86_linux_clang"
    
    150
    +    # Fedora 41 must build with gcc because the clang build fails some
    
    151
    +    # ansi-tests.  See [#469].
    
    152
    +    CONFIG: "x86_linux"
    
    151 153
       # These rules is needed so that the static analyzer job can run on a
    
    152 154
       # schedule because this is a prerequisite of the analyzer build.  A
    
    153 155
       # regular push or merge request does the normal stuff.
    
    ... ... @@ -171,7 +173,7 @@ linux:cross-build:
    171 173
           - linux-4/lisp
    
    172 174
       variables:
    
    173 175
         # This must match the config used for the linux build!
    
    174
    -    CONFIG: "x86_linux_clang"
    
    176
    +    CONFIG: "x86_linux"
    
    175 177
     
    
    176 178
       needs:
    
    177 179
     
    
    ... ... @@ -346,7 +348,10 @@ ubuntu:build:
    346 348
         - job: ubuntu:install
    
    347 349
           artifacts: true
    
    348 350
       variables:
    
    349
    -    CONFIG: "x86_linux_clang"
    
    351
    +    # Build with gcc on Ubuntu 25.10.  It produces a lisp than passes
    
    352
    +    # the ansi-tests.  Clang seems to fail the ansi-tests WRITE.1,
    
    353
    +    # PRINT.1, and friends when cr_pow is used.
    
    354
    +    CONFIG: "x86_linux"
    
    350 355
     
    
    351 356
     ubuntu:test:
    
    352 357
       <<: *unit_test_configuration
    

  • bin/run-unit-tests.sh
    ... ... @@ -42,9 +42,9 @@ done
    42 42
     shift $((OPTIND - 1))
    
    43 43
     
    
    44 44
     # Create the test directory needed by the issue.45 test.
    
    45
    -rm -rf test-tmp
    
    46
    -mkdir test-tmp
    
    47
    -ln -s /bin/ls test-tmp/ls-link
    
    45
    +#rm -rf test-tmp
    
    46
    +#mkdir test-tmp
    
    47
    +#ln -s /bin/ls test-tmp/ls-link
    
    48 48
     
    
    49 49
     # Set the timestamps on 64-bit-timestamp-2038.txt and
    
    50 50
     # 64-bit-timestamp-2106.txt, but only for OSes where we know this
    
    ... ... @@ -56,8 +56,9 @@ ln -s /bin/ls test-tmp/ls-link
    56 56
     # tests/os.lisp.
    
    57 57
     case `uname -s` in
    
    58 58
         Linux)
    
    59
    -	touch -d "1 April 2038" tests/resources/64-bit-timestamp-2038.txt
    
    60
    -	touch -d "1 April 2106" tests/resources/64-bit-timestamp-2106.txt
    
    59
    +	# -t format is [[CC]YY]MMDDhhmm[.ss]
    
    60
    +	touch -t 203804010000 tests/resources/64-bit-timestamp-2038.txt
    
    61
    +	touch -t 210604010000 tests/resources/64-bit-timestamp-2106.txt
    
    61 62
     	;;
    
    62 63
     esac
    
    63 64
     
    

  • src/lisp/irrat.c
    ... ... @@ -61,10 +61,22 @@ extern void cr_sincosf(float, float *, float *);
    61 61
      * Wrappers for the special functions
    
    62 62
      */
    
    63 63
     
    
    64
    +#define MAYBE_SIGNAL_INVALID(test, val)		\
    
    65
    +    if ((test)) {				\ 
    
    66
    +        return fdlibm_setexception(val, FDLIBM_INVALID);	\
    
    67
    +    }
    
    68
    +
    
    69
    +#define MAYBE_SIGNAL_OVERFLOW(x)	\
    
    70
    +    if (isinf(x)) {	\
    
    71
    +	return fdlibm_setexception(x, FDLIBM_OVERFLOW); \
    
    72
    +    }
    
    73
    +
    
    64 74
     double
    
    65 75
     lisp_sin(double x)
    
    66 76
     {
    
    67 77
     #ifdef FEATURE_CORE_MATH
    
    78
    +    MAYBE_SIGNAL_INVALID(isinf(x), x)
    
    79
    +
    
    68 80
         return cr_sin(x);
    
    69 81
     #else    
    
    70 82
         return fdlibm_sin(x);
    
    ... ... @@ -75,6 +87,8 @@ double
    75 87
     lisp_cos(double x)
    
    76 88
     {
    
    77 89
     #ifdef FEATURE_CORE_MATH
    
    90
    +    MAYBE_SIGNAL_INVALID(isinf(x), x)
    
    91
    +
    
    78 92
         return cr_cos(x);
    
    79 93
     #else    
    
    80 94
         return fdlibm_cos(x);
    
    ... ... @@ -85,6 +99,8 @@ double
    85 99
     lisp_tan(double x)
    
    86 100
     {
    
    87 101
     #ifdef FEATURE_CORE_MATH
    
    102
    +    MAYBE_SIGNAL_INVALID(isinf(x), x)
    
    103
    +
    
    88 104
         return cr_tan(x);
    
    89 105
     #else    
    
    90 106
         return fdlibm_tan(x);
    
    ... ... @@ -135,6 +151,8 @@ double
    135 151
     lisp_sinh(double x)
    
    136 152
     {
    
    137 153
     #ifdef FEATURE_CORE_MATH
    
    154
    +    MAYBE_SIGNAL_OVERFLOW(x)
    
    155
    +	
    
    138 156
         return cr_sinh(x);
    
    139 157
     #else    
    
    140 158
         return __ieee754_sinh(x);
    
    ... ... @@ -165,6 +183,8 @@ double
    165 183
     lisp_asinh(double x)
    
    166 184
     {
    
    167 185
     #ifdef FEATURE_CORE_MATH
    
    186
    +    MAYBE_SIGNAL_OVERFLOW(x)
    
    187
    +
    
    168 188
         return cr_asinh(x);
    
    169 189
     #else    
    
    170 190
         return fdlibm_asinh(x);
    
    ... ... @@ -175,6 +195,10 @@ double
    175 195
     lisp_acosh(double x)
    
    176 196
     {
    
    177 197
     #ifdef FEATURE_CORE_MATH
    
    198
    +    MAYBE_SIGNAL_INVALID(x < 1, x)
    
    199
    +
    
    200
    +    MAYBE_SIGNAL_OVERFLOW(x)
    
    201
    +    
    
    178 202
         return cr_acosh(x);
    
    179 203
     #else    
    
    180 204
         return __ieee754_acosh(x);
    
    ... ... @@ -224,13 +248,17 @@ lisp_log10(double x)
    224 248
     double
    
    225 249
     lisp_pow(double x, double y)
    
    226 250
     {
    
    251
    +#ifdef FEATURE_CORE_MATH
    
    227 252
         /*
    
    228
    -     * cr_pow seems causes ansi-tests to fail in test WRITE.1 among
    
    229
    -     * others.  Somewhere an invalid operation is occurring.  Thus
    
    230
    -     * just use fdlibm for now until we can figure out what's causing
    
    231
    -     * the failure.
    
    253
    +     * cr_pow when compiled with older versions of gcc or clang can
    
    254
    +     * cause failures in the ansi-tests [#469].  Ubuntu 25.10 and Fedora 41
    
    255
    +     * (gcc only) are known to have compilers that work well enough
    
    256
    +     * that the ansi-tests pass.
    
    232 257
          */
    
    258
    +    return cr_pow(x, y);
    
    259
    +#else    
    
    233 260
         return __ieee754_pow(x, y);
    
    261
    +#endif
    
    234 262
     }
    
    235 263
     
    
    236 264
     double
    
    ... ... @@ -448,8 +476,17 @@ lisp_log10f(float x)
    448 476
     }
    
    449 477
     
    
    450 478
     float
    
    451
    -lisp_powf(double x, double y)
    
    479
    +lisp_powf(float x, float y)
    
    452 480
     {
    
    481
    +#ifdef FEATURE_CORE_MATH
    
    482
    +    /*
    
    483
    +     * cr_pow when compiled with older versions of gcc or clang can
    
    484
    +     * cause failures in the ansi-tests [#469].  Ubuntu 25.10 and Fedora 41
    
    485
    +     * (gcc only) are known to have compilers that work well enough
    
    486
    +     * that the ansi-tests pass.
    
    487
    +     */
    
    488
    +    return cr_powf(x, y);
    
    489
    +#else    
    
    453 490
         /*
    
    454 491
          * cr_pow seems causes ansi-tests to fail in test WRITE.1 among
    
    455 492
          * others.  Somewhere an invalid operation is occurring.  Thus
    
    ... ... @@ -457,6 +494,7 @@ lisp_powf(double x, double y)
    457 494
          * the failure.
    
    458 495
          */
    
    459 496
         return (float) __ieee754_pow((double) x, (double) y);
    
    497
    +#endif
    
    460 498
     }
    
    461 499
     
    
    462 500
     float
    

  • tests/fdlibm.lisp
    ... ... @@ -90,12 +90,8 @@
    90 90
     
    
    91 91
     (define-test %acosh.exceptions
    
    92 92
       (:tag :fdlibm)
    
    93
    -  ;; Core-math returns infinity instead of signaling overflow.
    
    94
    -  #-core-math
    
    95 93
       (assert-error 'floating-point-overflow
    
    96 94
     		(kernel:%acosh ext:double-float-positive-infinity))
    
    97
    -  ;; Core-math currently returns QNaN
    
    98
    -  #-core-math
    
    99 95
       (assert-error 'floating-point-invalid-operation
    
    100 96
     		(kernel:%acosh 0d0))
    
    101 97
       (ext:with-float-traps-masked (:overflow)
    
    ... ... @@ -108,12 +104,8 @@
    108 104
       (:tag :fdlibm)
    
    109 105
       (assert-error 'floating-point-invalid-operation
    
    110 106
     		(kernel:%asinh *snan*))
    
    111
    -  ;; Core-math returns the signed infinity instead of signaling an
    
    112
    -  ;; overflow.
    
    113
    -  #-core-math
    
    114 107
       (assert-error 'floating-point-overflow
    
    115 108
     		(kernel:%asinh ext:double-float-positive-infinity))
    
    116
    -  #-core-math
    
    117 109
       (assert-error 'floating-point-overflow
    
    118 110
     		(kernel:%asinh ext:double-float-negative-infinity))
    
    119 111
       (assert-true (ext:float-nan-p (kernel:%asinh *qnan*)))
    
    ... ... @@ -218,7 +210,6 @@
    218 210
       (ext:with-float-traps-masked (:overflow)
    
    219 211
         (assert-equal ext:double-float-positive-infinity
    
    220 212
     		  (kernel:%exp 710d0)))
    
    221
    -  #-core-math
    
    222 213
       (let ((modes (ext:get-floating-point-modes)))
    
    223 214
         (unwind-protect
    
    224 215
     	 (progn
    
    ... ... @@ -675,6 +666,14 @@
    675 666
     
    
    676 667
     (define-test %cos.exceptions
    
    677 668
         (:tag :fdlibm)
    
    669
    +  ;; cos(inf) signals invalid operation
    
    670
    +  (assert-error 'floating-point-invalid-operation
    
    671
    +		(kernel:%cos ext:double-float-positive-infinity))
    
    672
    +  (assert-error 'floating-point-invalid-operation
    
    673
    +		(kernel:%cos ext:double-float-negative-infinity))
    
    674
    +  ;; cos(nan) is NaN
    
    675
    +  (assert-true (ext:float-nan-p (kernel:%cos *qnan*)))
    
    676
    +  
    
    678 677
       ;; cos(x) = 1 for |x| < 2^-27.  Signal inexact unless x = 0
    
    679 678
       (let ((x (scale-float 1d0 -28))
    
    680 679
     	(x0 0d0))
    
    ... ... @@ -690,6 +689,14 @@
    690 689
     
    
    691 690
     (define-test %sin.exceptions
    
    692 691
         (:tag :fdlibm)
    
    692
    +  ;; sin(inf) signals invalid operation
    
    693
    +  (assert-error 'floating-point-invalid-operation
    
    694
    +		(kernel:%sin ext:double-float-positive-infinity))
    
    695
    +  (assert-error 'floating-point-invalid-operation
    
    696
    +		(kernel:%sin ext:double-float-negative-infinity))
    
    697
    +  ;; sin(nan) is NaN
    
    698
    +  (assert-true (ext:float-nan-p (kernel:%sin *qnan*)))
    
    699
    +
    
    693 700
       ;; sin(x) = x for |x| < 2^-27.  Signal inexact unless x = 0
    
    694 701
       (let ((x (scale-float 1d0 -28))
    
    695 702
     	(x0 0d0))
    
    ... ... @@ -705,6 +712,14 @@
    705 712
     
    
    706 713
     (define-test %tan.exceptions
    
    707 714
         (:tag :fdlibm)
    
    715
    +  ;; tan(inf) signals invalid operation
    
    716
    +  (assert-error 'floating-point-invalid-operation
    
    717
    +		(kernel:%tan ext:double-float-positive-infinity))
    
    718
    +  (assert-error 'floating-point-invalid-operation
    
    719
    +		(kernel:%tan ext:double-float-negative-infinity))
    
    720
    +  ;; tan(nan) is NaN
    
    721
    +  (assert-true (ext:float-nan-p (kernel:%sin *qnan*)))
    
    722
    +
    
    708 723
       ;; tan(x) = x for |x| < 2^-28.  Signal inexact unless x = 0
    
    709 724
       (let ((x (scale-float 1d0 -29))
    
    710 725
     	(x0 0d0))
    
    ... ... @@ -717,3 +732,203 @@
    717 732
     	;; though the result is exactly x.
    
    718 733
     	(assert-error 'floating-point-inexact
    
    719 734
     		      (kernel:%tan x)))))
    
    735
    +
    
    736
    +;; Test cases from e_pow.c for fdlibm.
    
    737
    +(define-test %pow.case.1
    
    738
    +    (:tag :fdlibm)
    
    739
    +  ;; anything ^ 0 is 1
    
    740
    +  (assert-equal 1d0
    
    741
    +		(kernel:%pow ext:double-float-positive-infinity 0d0))
    
    742
    +  (assert-equal 1d0
    
    743
    +		(kernel:%pow ext:double-float-negative-infinity 0d0)))
    
    744
    +
    
    745
    +(define-test %pow.case.2
    
    746
    +    (:tag :fdlibm)
    
    747
    +  ;; anything ^ 1 is itself
    
    748
    +  (assert-equal ext:double-float-positive-infinity
    
    749
    +		(kernel:%pow ext:double-float-positive-infinity 1d0))
    
    750
    +  (assert-equal ext:double-float-negative-infinity
    
    751
    +		(kernel:%pow ext:double-float-negative-infinity 1d0)))
    
    752
    +
    
    753
    +(define-test %pow.case.3
    
    754
    +    (:tag :fdlibm)
    
    755
    +  ;; anything ^ NaN is NaN
    
    756
    +  (assert-true (ext:float-nan-p
    
    757
    +		(kernel:%pow pi *qnan*)))
    
    758
    +  (assert-true (ext:float-nan-p
    
    759
    +		(kernel:%pow ext:double-float-positive-infinity *qnan*))))
    
    760
    +
    
    761
    +(define-test %pow.case.4
    
    762
    +    (:tag :fdlibm)
    
    763
    +  ;; NaN ^ non-zero is NaN
    
    764
    +  (assert-true (ext:float-nan-p
    
    765
    +		(kernel:%pow *qnan* pi)))
    
    766
    +  (assert-true (ext:float-nan-p
    
    767
    +		(kernel:%pow *qnan* ext:double-float-positive-infinity))))
    
    768
    +
    
    769
    +(define-test %pow.case.5
    
    770
    +    (:tag :fdlibm)
    
    771
    +  ;; (|x| > 1) ^ +inf is +inf
    
    772
    +  (assert-equal ext:double-float-positive-infinity
    
    773
    +		(kernel:%pow pi ext:double-float-positive-infinity))
    
    774
    +  (assert-equal ext:double-float-positive-infinity
    
    775
    +		(kernel:%pow (- pi) ext:double-float-positive-infinity)))
    
    776
    +
    
    777
    +(define-test %pow.case.6
    
    778
    +    (:tag :fdlibm)
    
    779
    +  ;; (|x| > 1) ^ -inf is +0
    
    780
    +  (assert-equal +0d0
    
    781
    +		(kernel:%pow pi ext:double-float-negative-infinity))
    
    782
    +  (assert-equal +0d0
    
    783
    +		(kernel:%pow (- pi) ext:double-float-negative-infinity)))
    
    784
    +
    
    785
    +(define-test %pow.case.7
    
    786
    +    (:tag :fdlibm)
    
    787
    +  ;; (|x| < 1) ^ +inf is +0
    
    788
    +  (assert-equal +0d0
    
    789
    +		(kernel:%pow 0.5d0 ext:double-float-positive-infinity))
    
    790
    +  (assert-equal +0d0
    
    791
    +		(kernel:%pow -0.5d0 ext:double-float-positive-infinity)))
    
    792
    +
    
    793
    +(define-test %pow.case.8
    
    794
    +    (:tag :fdlibm)
    
    795
    +  ;; (|x| < 1) ^ -inf is +inf
    
    796
    +  (assert-equal ext:double-float-positive-infinity
    
    797
    +		(kernel:%pow 0.5d0 ext:double-float-negative-infinity))
    
    798
    +  (assert-equal ext:double-float-positive-infinity
    
    799
    +		(kernel:%pow -0.5d0 ext:double-float-negative-infinity)))
    
    800
    +
    
    801
    +(define-test %pow.case.9
    
    802
    +    (:tag :fdlibm)
    
    803
    +  ;; std::pow says 1^exp is 1 for any exp, including NaN.  (-1)^(+/-inf)
    
    804
    +  ;; is 1.  No errors signaled.
    
    805
    +  #+core-math
    
    806
    +  (progn
    
    807
    +    (assert-equal 1d0
    
    808
    +		  (kernel:%pow 1d0 ext:double-float-positive-infinity))
    
    809
    +    (assert-equal 1d0
    
    810
    +		  (kernel:%pow 1d0 ext:double-float-negative-infinity))
    
    811
    +    (assert-equal 1d0
    
    812
    +		  (kernel:%pow 1d0 *qnan*))
    
    813
    +    (assert-equal 1d0
    
    814
    +		  (kernel:%pow -1d0 ext:double-float-positive-infinity))
    
    815
    +    (assert-equal 1d0
    
    816
    +		  (kernel:%pow -1d0 ext:double-float-negative-infinity)))
    
    817
    +  #-core-math
    
    818
    +  ;; +-1 ^ +-inf is NaN.
    
    819
    +  ;;
    
    820
    +  ;; But the implementation signals invalid operation, so we need to
    
    821
    +  ;; check for that.
    
    822
    +  ;;
    
    823
    +  (progn
    
    824
    +  (assert-error 'floating-point-invalid-operation
    
    825
    +		(kernel:%pow 1d0 ext:double-float-positive-infinity))
    
    826
    +  (assert-error 'floating-point-invalid-operation
    
    827
    +		(kernel:%pow 1d0 ext:double-float-negative-infinity))
    
    828
    +  (assert-error 'floating-point-invalid-operation
    
    829
    +		(kernel:%pow -1d0 ext:double-float-positive-infinity))
    
    830
    +  (assert-error 'floating-point-invalid-operation
    
    831
    +		(kernel:%pow -1d0 ext:double-float-negative-infinity))
    
    832
    +  (ext:with-float-traps-masked (:invalid)
    
    833
    +    (assert-true (ext:float-nan-p
    
    834
    +		  (kernel:%pow 1d0 ext:double-float-positive-infinity)))
    
    835
    +    (assert-true (ext:float-nan-p
    
    836
    +		  (kernel:%pow 1d0 ext:double-float-negative-infinity)))
    
    837
    +    (assert-true (ext:float-nan-p
    
    838
    +		  (kernel:%pow -1d0 ext:double-float-positive-infinity)))
    
    839
    +    (assert-true (ext:float-nan-p
    
    840
    +		  (kernel:%pow -1d0 ext:double-float-negative-infinity))))))
    
    841
    +
    
    842
    +(define-test %pow.case.10
    
    843
    +    (:tag :fdlibm)
    
    844
    +  ;; +0 ^ (+anything except 0, Nan) is +0
    
    845
    +  (assert-equal +0d0
    
    846
    +		(kernel:%pow +0d0 10d0))
    
    847
    +  (assert-equal +0d0
    
    848
    +		(kernel:%pow +0d0 ext:double-float-positive-infinity)))
    
    849
    +
    
    850
    +(define-test %pow.case.11
    
    851
    +    (:tag :fdlibm)
    
    852
    +  ;; +0 ^ (+anything except 0, Nan, odd integer) is +0
    
    853
    +  (assert-equal +0d0
    
    854
    +		(kernel:%pow -0d0 10d0))
    
    855
    +  (assert-equal +0d0
    
    856
    +		(kernel:%pow -0d0 ext:double-float-positive-infinity)))
    
    857
    +
    
    858
    +(define-test %pow.case.12
    
    859
    +    (:tag :fdlibm)
    
    860
    +  ;; +0 ^ (-anything except 0, Nan) is +inf
    
    861
    +  ;;
    
    862
    +  ;; But fdlibm signals error for (+0)^(-10) instead of returning inf.  Check this.
    
    863
    +  (assert-error 'division-by-zero
    
    864
    +		(kernel:%pow +0d0 -10d0))
    
    865
    +  (ext:with-float-traps-masked (:divide-by-zero)
    
    866
    +    (assert-equal ext:double-float-positive-infinity
    
    867
    +		  (kernel:%pow +0d0 -10d0)))
    
    868
    +  ;; No signals here.
    
    869
    +  (assert-equal ext:double-float-positive-infinity
    
    870
    +		(kernel:%pow +0d0 ext:double-float-negative-infinity)))
    
    871
    +
    
    872
    +(define-test %pow.case.13
    
    873
    +    (:tag :fdlibm)
    
    874
    +  ;; -0 ^ (-anything except 0, Nan, odd integer) is +inf
    
    875
    +  ;;
    
    876
    +  ;; But (-0)^(-10) signals division by zero
    
    877
    +  (assert-error 'division-by-zero
    
    878
    +		(kernel:%pow -0d0 -10d0))
    
    879
    +  (ext:with-float-traps-masked (:divide-by-zero)
    
    880
    +    (assert-equal ext:double-float-positive-infinity
    
    881
    +		  (kernel:%pow -0d0 -10d0)))
    
    882
    +  ;; But no error here.
    
    883
    +  (assert-equal ext:double-float-positive-infinity
    
    884
    +		(kernel:%pow +0d0 ext:double-float-negative-infinity)))
    
    885
    +
    
    886
    +(define-test %pow.case.14
    
    887
    +    (:tag :fdlibm)
    
    888
    +  ;; -0 ^ (odd integer) = -( +0 ^ (odd integer))
    
    889
    +  (assert-equal (- (kernel:%pow +0d0 5d0))
    
    890
    +		(kernel:%pow -0d0 5d0)))
    
    891
    +
    
    892
    +(define-test %pow.case.15
    
    893
    +    (:tag :fdlibm)
    
    894
    +  ;; +inf ^ (+anything except 0, NaN) is +inf
    
    895
    +  (assert-equal ext:double-float-positive-infinity
    
    896
    +		(kernel:%pow ext:double-float-positive-infinity pi)))
    
    897
    +
    
    898
    +(define-test %pow.case.16
    
    899
    +    (:tag :fdlibm)
    
    900
    +  ;; +inf ^ (-anything except 0, NaN) is +0
    
    901
    +  (assert-equal +0d0
    
    902
    +		(kernel:%pow ext:double-float-positive-infinity (- pi))))
    
    903
    +
    
    904
    +(define-test %pow.case.17
    
    905
    +    (:tag :fdlibm)
    
    906
    +  ;; -inf ^ (anything) = -0 ^ (-anything)
    
    907
    +  (assert-equal (ext:with-float-traps-masked (:divide-by-zero)
    
    908
    +		  ;; This produces a divide-by-zero error so mask it
    
    909
    +		  ;; to get a value.
    
    910
    +		  (kernel:%pow -0d0 (- pi)))
    
    911
    +		(kernel:%pow ext:double-float-negative-infinity pi))
    
    912
    +  (assert-equal (kernel:%pow -0d0 pi)
    
    913
    +		(kernel:%pow ext:double-float-negative-infinity (- pi))))
    
    914
    +
    
    915
    +(define-test %pow.case.18
    
    916
    +    (:tag :fdlibm)
    
    917
    +  ;; (-anything) ^ integer is (-1)^integer * (+anything ^ integer)
    
    918
    +  (dolist (base '(-2d0 -10d0))
    
    919
    +    (dolist (power '(5 -5))
    
    920
    +      (assert-equal (* (expt -1 power)
    
    921
    +		       (kernel:%pow (- base) (coerce power 'double-float)))
    
    922
    +		    (kernel:%pow base (coerce power 'double-float))
    
    923
    +		    base power))))
    
    924
    +
    
    925
    +(define-test %pow.case.19
    
    926
    +    (:tag :fdlibm)
    
    927
    +  ;; (-anything except 0 and inf) ^ non-integer is NaN
    
    928
    +  ;;
    
    929
    +  ;; But this signals invalid, so check for that too.
    
    930
    +  (assert-error 'floating-point-invalid-operation
    
    931
    +		(kernel:%pow -2d0 1.5d0))
    
    932
    +  (ext:with-float-traps-masked (:invalid)
    
    933
    +    (assert-true (ext:float-nan-p
    
    934
    +		  (kernel:%pow -2d0 1.5d0)))))

  • tests/issues.lisp
    ... ... @@ -436,7 +436,7 @@
    436 436
     (define-test issue.45
    
    437 437
       (:tag :issues)
    
    438 438
       ;; This depends on run-tests to setup the test directory correctly!
    
    439
    -  (let* ((test-dir #p"test-tmp/")
    
    439
    +  (let* ((test-dir #p"tests/test-run-prog/")
    
    440 440
     	 (test-dir-name (namestring test-dir)))
    
    441 441
         (flet ((do-test (program)
    
    442 442
     	     (with-output-to-string (s)
    

  • tests/test-run-prog/ls-link
    1
    +#! /bin/sh
    
    2
    +exec /bin/ls "$@"