#QUALITY by cg
class: RegressionTests::FloatTest
changed:
#actualPrecisionOf:
#test00_Precision
#test04_Arithmetic
#test08_Representation
--- a/RegressionTests__FloatTest.st Tue Apr 12 12:26:00 2016 +0200
+++ b/RegressionTests__FloatTest.st Tue Apr 12 13:05:05 2016 +0200
@@ -16,14 +16,15 @@
"get the actual number of valid bits in the mantissa.
This does a real test (i.e. does not believe the compiled-in ifdefs)"
- |one x count|
+ |one x count two|
one := aFloatClass unity. "/ 1.0 in this class
+ two := one coerce:2.0.
x := one.
count := 0.
-
+
[one + x > one] whileTrue:[
- x := x / 2.
+ x := x / two.
count := count + 1.
].
^ count
@@ -42,22 +43,6 @@
|a b|
- self assert: (Float unity class == Float).
- self assert: (ShortFloat unity class == ShortFloat).
- self assert: (LongFloat unity class == LongFloat).
-
- self assert: (Float unity = 1.0).
- self assert: (ShortFloat unity = 1.0).
- self assert: (LongFloat unity = 1.0).
-
- self assert: (Float zero class == Float).
- self assert: (ShortFloat zero class == ShortFloat).
- self assert: (LongFloat zero class == LongFloat).
-
- self assert: (Float zero = 0.0).
- self assert: (ShortFloat zero = 0.0).
- self assert: (LongFloat zero = 0.0).
-
self assert:( (a := Float precision) = (b := self actualPrecisionOf:Float))
description:('Float precision: %1 ~~ actual: %2' bindWith:a with:b).
self assert:( (a := ShortFloat precision) = (b := self actualPrecisionOf:ShortFloat))
@@ -347,6 +332,21 @@
self assert:( 1.0 asLongFloat / 1.0 asFloat ) class == LongFloat.
self assert:( 1.0 asLongFloat / 1 ) class == LongFloat.
+ self assert:( 1.0 / 2.0 ) class == Float.
+ self assert:( 1.0 / 2.0 asShortFloat) class == Float.
+ self assert:( 1.0 / 2.0 asLongFloat) class == LongFloat.
+ self assert:( 1.0 / 2) class == Float.
+
+ self assert:( 1.0 asShortFloat / 2.0 ) class == Float.
+ self assert:( 1.0 asShortFloat / 2.0 asShortFloat) class == ShortFloat.
+ self assert:( 1.0 asShortFloat / 2.0 asLongFloat) class == LongFloat.
+ self assert:( 1.0 asShortFloat / 2) class == ShortFloat.
+
+ self assert:( 1.0 asLongFloat / 2.0 ) class == LongFloat.
+ self assert:( 1.0 asLongFloat / 2.0 asShortFloat ) class == LongFloat.
+ self assert:( 1.0 asLongFloat / 2.0 asFloat ) class == LongFloat.
+ self assert:( 1.0 asLongFloat / 2 ) class == LongFloat.
+
self assert:( 5.0 rem: 2.0 ) class == Float.
self assert:( 5.0 rem: 2.0 asShortFloat) class == Float.
self assert:( 5.0 rem: 2.0 asLongFloat) class == LongFloat.
@@ -749,6 +749,26 @@
!
test08_Representation
+ self assert: (Float unity class == Float).
+ self assert: (ShortFloat unity class == ShortFloat).
+ self assert: (LongFloat unity class == LongFloat).
+
+ self assert: (Float unity = 1.0).
+ self assert: (ShortFloat unity = 1.0).
+ self assert: (LongFloat unity = 1.0).
+
+ self assert: (Float zero class == Float).
+ self assert: (ShortFloat zero class == ShortFloat).
+ self assert: (LongFloat zero class == LongFloat).
+
+ self assert: (Float zero = 0.0).
+ self assert: (ShortFloat zero = 0.0).
+ self assert: (LongFloat zero = 0.0).
+
+ self assert:( LongFloat unity = 1 asLongFloat ).
+ self assert:( ShortFloat unity = 1 asShortFloat ).
+ self assert:( Float unity = 1 asFloat ).
+
self assert:( 0.0 exponent = 0 ).
self assert:( 1.0 exponent = 1 ).
self assert:( 2.0 exponent = 2 ).
@@ -782,10 +802,6 @@
self assert:( 0.125 asLongFloat exponent = -2 ).
self assert:( 0.00000011111 asLongFloat exponent = -23 ).
- self assert:( LongFloat unity = 1 asLongFloat ).
- self assert:( ShortFloat unity = 1 asShortFloat ).
- self assert:( Float unity = 1 asFloat ).
-
"
self basicNew test08_Representation
"