RegressionTests__MiscArithmeticTests.st
author Stefan Vogel <sv@exept.de>
Tue, 11 Jun 2019 10:34:41 +0200
changeset 2321 32ea6329f5ad
parent 2313 aada90d91658
child 2325 070a15489964
permissions -rw-r--r--
class: stx_goodies_regression class changed: #classNamesAndAttributes make classes autoloaded that stc cannot compile (yet)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2294
99ef141514a1 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2286
diff changeset
     1
"{ Encoding: utf8 }"
99ef141514a1 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2286
diff changeset
     2
2286
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: RegressionTests }"
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
TestCase subclass:#MiscArithmeticTests
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	instanceVariableNames:''
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:''
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	poolDictionaries:''
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
	category:'tests-Regression-Numbers'
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
!MiscArithmeticTests class methodsFor:'documentation'!
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
documentation
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
"
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
    documentation to be added.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
    class:
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
        <a short class summary here, describing what instances represent>
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
    responsibilities:    
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
        <describing what my main role is>
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
    collaborators:    
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
        <describing with whom and how I talk to>
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
    API:
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
        <public api and main messages>
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
        
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
    example:
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
        <a one-line examples on how to use - can also be in a separate example method>
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
    implementation:
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
        <implementation points>
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
    [author:]
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
        Claus Gittinger
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    [instance variables:]
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    [class variables:]
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    [see also:]
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
"
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
! !
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!MiscArithmeticTests methodsFor:'tests'!
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
test01_sum
2313
aada90d91658 *** empty log message ***
sr
parents: 2295
diff changeset
    53
2286
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    "tests the accumlated error when summing up many floats"
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    |arr sum|
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    arr := #(1e100 1 -1e100 1) asDoubleArray.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    sum := arr sum.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    sum = 2 ifFalse:[
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
        Transcript showCR:'ignored expected error in sum'.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    ].
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    sum := arr esum.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    self assert:(sum = 2).
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    arr := #(1e38 1 -1e38 1) asFloatArray.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    sum := arr sum.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    sum = 2 ifFalse:[
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
        Transcript showCR:'ignored expected error in sum'.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    ].
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    sum := arr esum.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    self assert:(sum = 2).
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    "/ same using literals    
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    arr := #f32(1e38 1 -1e38 1).
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    sum := arr esum.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    self assert:(sum = 2).
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    arr := #f64(1e100 1 -1e100 1).
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    sum := arr esum.
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    self assert:(sum = 2).
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    "
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
     self run:#test01_sum
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
     self new test01_sum
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    "
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    "Created: / 09-06-2019 / 10:35:16 / Claus Gittinger"
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    "Modified: / 09-06-2019 / 14:20:16 / Claus Gittinger"
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
! !
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
!MiscArithmeticTests class methodsFor:'documentation'!
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
version_CVS
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    ^ '$Header$'
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
! !
ea0092d86b52 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98