RegressionTests__MiscArithmeticTests.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Feb 2020 17:19:49 +0100
changeset 2586 7dc7be5a6f3d
parent 2414 8cf9b2d022f5
permissions -rw-r--r--
#OTHER by cg s

"{ Package: 'stx:goodies/regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#MiscArithmeticTests
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression-Numbers'
!

!MiscArithmeticTests class methodsFor:'documentation'!

documentation
"
    documentation to be added.

    class:
	<a short class summary here, describing what instances represent>

    responsibilities:
	<describing what my main role is>

    collaborators:
	<describing with whom and how I talk to>

    API:
	<public api and main messages>

    example:
	<a one-line examples on how to use - can also be in a separate example method>

    implementation:
	<implementation points>

    [author:]
	Claus Gittinger

    [instance variables:]

    [class variables:]

    [see also:]

"
! !

!MiscArithmeticTests methodsFor:'tests'!

test01_sum
    <pragma: +STXExtendedArrayLiterals>

    "tests the accumulated error when summing up many floats"

    |arr sum|

    arr := #(1e100 1 -1e100 1) asDoubleArray.
    sum := arr sum.
    sum = 2 ifFalse:[
	Transcript showCR:'ignored expected error in sum'.
    ].
    sum := arr esum.
    self assert:(sum = 2).

    arr := #(1e38 1 -1e38 1) asFloatArray.
    sum := arr sum.
    sum = 2 ifFalse:[
	Transcript showCR:'ignored expected error in sum'.
    ].
    sum := arr esum.
    self assert:(sum = 2).

    "/ same using literals
    arr := #f32(1e38 1 -1e38 1).
    sum := arr esum.
    self assert:(sum = 2).

    arr := #f64(1e100 1 -1e100 1).
    sum := arr esum.
    self assert:(sum = 2).

    "
     self run:#test01_sum
     self new test01_sum
    "

    "Created: / 09-06-2019 / 10:35:16 / Claus Gittinger"
    "Modified: / 09-06-2019 / 14:20:16 / Claus Gittinger"
! !

!MiscArithmeticTests class methodsFor:'documentation'!

version_CVS
    ^ '$Header$'
! !