RegressionTests__FloatTest.st
branchjv
changeset 1486 27e6519ac900
parent 1485 5a1aadddbc7f
child 1499 26a16a04219b
--- a/RegressionTests__FloatTest.st	Tue Apr 05 19:13:28 2016 +0100
+++ b/RegressionTests__FloatTest.st	Wed Apr 13 23:15:27 2016 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "{ Package: 'exept:regression' }"
 
 "{ NameSpace: RegressionTests }"
@@ -18,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
@@ -44,25 +43,12 @@
 
     |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)).
-    self assert:( (a := ShortFloat precision) = (b := self actualPrecisionOf:ShortFloat)).
-    self assert:( (a := LongFloat precision) = (b := self actualPrecisionOf:LongFloat)).
+    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))
+                description:('ShortFloat precision: %1 ~~ actual: %2' bindWith:a with:b).
+    self assert:( (a := LongFloat precision) = (b := self actualPrecisionOf:LongFloat))
+                description:('LongFloat precision: %1 ~~ actual: %2' bindWith:a with:b).
 
     "
      self basicNew test00_Precision
@@ -346,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.
@@ -748,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 ).
@@ -781,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
     "