1606
|
1 |
"{ Package: 'stx:goodies/regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#QDoubleTests
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'tests-regression'
|
|
10 |
!
|
|
11 |
|
|
12 |
!QDoubleTests class methodsFor:'documentation'!
|
|
13 |
|
|
14 |
documentation
|
|
15 |
"
|
|
16 |
documentation to be added.
|
|
17 |
|
|
18 |
[author:]
|
|
19 |
cg
|
|
20 |
|
|
21 |
[instance variables:]
|
|
22 |
|
|
23 |
[class variables:]
|
|
24 |
|
|
25 |
[see also:]
|
|
26 |
|
|
27 |
"
|
|
28 |
! !
|
|
29 |
|
|
30 |
!QDoubleTests methodsFor:'tests'!
|
|
31 |
|
|
32 |
test_01_instance_creation
|
|
33 |
|d|
|
|
34 |
|
|
35 |
d := QDouble fromFloat:1.0.
|
|
36 |
|
|
37 |
"
|
|
38 |
self run:#test_01_instance_creation
|
|
39 |
self new test_01_instance_creation
|
|
40 |
"
|
|
41 |
|
|
42 |
"Created: / 12-06-2017 / 17:03:46 / cg"
|
|
43 |
"Modified: / 12-06-2017 / 18:41:14 / cg"
|
|
44 |
!
|
|
45 |
|
|
46 |
test_02_addition
|
|
47 |
|d1 d2 l1 l2 sum_l q1 q2 sum_d sum_q|
|
|
48 |
|
|
49 |
d1 := 1.0.
|
|
50 |
d2 := 1.0e-16.
|
|
51 |
sum_d := d1 + d2.
|
|
52 |
"/ precision is lost with doubles!!
|
|
53 |
self assert:( sum_d - 1.0 = 0.0 ).
|
|
54 |
|
|
55 |
l1 := 1.0 asLongFloat.
|
|
56 |
l2 := 1.0e-16 asLongFloat.
|
|
57 |
sum_l := l1 + l2.
|
|
58 |
"/ no precision is lost with long doubles!!
|
|
59 |
self assert:( (sum_l - (1.0 asLongFloat)) > 0.0 ).
|
|
60 |
|
|
61 |
q1 := QDouble fromFloat:1.0.
|
|
62 |
q2 := QDouble fromFloat:1.0e-16.
|
|
63 |
|
|
64 |
sum_q := q1 + q2.
|
|
65 |
|
|
66 |
"
|
|
67 |
self run:#test_02_addition
|
|
68 |
self new test_02_addition
|
|
69 |
"
|
|
70 |
|
|
71 |
"Created: / 12-06-2017 / 17:05:07 / cg"
|
|
72 |
"Modified: / 12-06-2017 / 18:41:25 / cg"
|
|
73 |
!
|
|
74 |
|
|
75 |
test_03_subtract
|
|
76 |
|d1 d2 l1 l2 diff_l q1 q2 diff_d diff_q|
|
|
77 |
|
|
78 |
d1 := 1.0.
|
|
79 |
d2 := 0.99999.
|
|
80 |
diff_d := d1 - d2.
|
|
81 |
"/ precision is lost with doubles!!
|
|
82 |
|
|
83 |
l1 := 1.0 asLongFloat.
|
|
84 |
l2 := 0.99999 asLongFloat.
|
|
85 |
diff_l := l1 - l2.
|
|
86 |
"/ no precision is lost with long doubles!!
|
|
87 |
|
|
88 |
q1 := QDouble fromFloat:1.0.
|
|
89 |
q2 := QDouble fromFloat:0.99999.
|
|
90 |
|
|
91 |
diff_q := q1 - q2.
|
|
92 |
|
|
93 |
"
|
|
94 |
self run:#test_03_subtract
|
|
95 |
self new test_03_subtract
|
|
96 |
"
|
|
97 |
|
|
98 |
"Created: / 12-06-2017 / 23:12:00 / cg"
|
|
99 |
! !
|
|
100 |
|
|
101 |
!QDoubleTests class methodsFor:'documentation'!
|
|
102 |
|
|
103 |
version
|
|
104 |
^ '$Header$'
|
|
105 |
!
|
|
106 |
|
|
107 |
version_CVS
|
|
108 |
^ '$Header$'
|
|
109 |
! !
|
|
110 |
|