RegressionTests__FloatTest.st
changeset 1878 1b8f50bc363e
parent 1861 c75410027243
child 1915 af63d419f526
equal deleted inserted replaced
1877:1c54a7a05eab 1878:1b8f50bc363e
   406      self basicNew test04_Arithmetic
   406      self basicNew test04_Arithmetic
   407     "
   407     "
   408 !
   408 !
   409 
   409 
   410 test05_Comparing
   410 test05_Comparing
   411     |convArray check v1 v2 v1b 
   411     |convArray check v1 v2 v1b|
   412      compiledMethod|
       
   413 
   412 
   414     convArray := OrderedCollection new.
   413     convArray := OrderedCollection new.
   415     convArray addAll:#(yourself asInteger asFloat asShortFloat asLongFloat).
   414     convArray addAll:#(yourself asInteger asFloat asShortFloat asLongFloat).
   416 
   415 
   417     (Smalltalk at:#LargeFloat) notNil ifTrue:[
   416     (Smalltalk at:#LargeFloat) notNil ifTrue:[
   452 
   451 
   453     check value:-30 value:1.
   452     check value:-30 value:1.
   454     check value:-1 value:30.
   453     check value:-1 value:30.
   455 
   454 
   456     "/ test fails when stc code, jit code works
   455     "/ test fails when stc code, jit code works
   457     compiledMethod := self class compiledMethodAt:#'test05_Comparing'.
   456     (Helper 
   458     (compiledMethod notNil 
   457         isStcCompiledMethod:#'test05_Comparing'
   459     and:[compiledMethod byteCode isNil]) ifTrue:[ 
   458         in:self) ifTrue:[ 
   460         "/ stc-compiled code handles not slightly differently
   459             "/ stc-compiled code handles not slightly differently
   461         "/ listed compares will fail
   460             "/ listed compares will fail
   462         'FloatTest >> test05_Comparing: test with 200000000000000000000 or similiar are skipped due would fail when stc code' infoPrintCR.
   461             'FloatTest >> test05_Comparing: test with 200000000000000000000 or similiar are skipped due would fail when stc code' infoPrintCR.
   463     ] ifFalse:[    
   462         ] ifFalse:[    
   464         self assert:( 200000000000000000000.0 = 200000000000000000001 ).
   463             self assert:( 200000000000000000000.0 = 200000000000000000001 ).
   465         self assert:( 200000000000000000000.0 = 200000000000000000000 ).
   464             self assert:( 200000000000000000000.0 = 200000000000000000000 ).
   466         self assert:( 200000000000000000000.0 asLongFloat = 200000000000000000000 ).
   465             self assert:( 200000000000000000000.0 asLongFloat = 200000000000000000000 ).
   467 
   466 
   468         self assert:( 200000000000000000000 = 200000000000000000000.0).
   467             self assert:( 200000000000000000000 = 200000000000000000000.0).
   469         self assert:( 200000000000000000000 = 200000000000000000000.0 asLongFloat ).
   468             self assert:( 200000000000000000000 = 200000000000000000000.0 asLongFloat ).
   470 
   469 
   471         self assert:( 200000000000000000000.0 < 200000100000000000000 ).
   470             self assert:( 200000000000000000000.0 < 200000100000000000000 ).
   472         self assert:( 200000000000000000000.0 asLongFloat < 200000000000100000000 ).
   471             self assert:( 200000000000000000000.0 asLongFloat < 200000000000100000000 ).
   473         self assert:( 200000000000000000000.0 asShortFloat < 200001000000000000000 ).
   472             self assert:( 200000000000000000000.0 asShortFloat < 200001000000000000000 ).
   474 
   473 
   475         self assert:( 200000000000000000000 < 200001000000000000000.0).
   474             self assert:( 200000000000000000000 < 200001000000000000000.0).
   476         self assert:( 200000000000000000000 < 200001000000000000000.0 asLongFloat ).
   475             self assert:( 200000000000000000000 < 200001000000000000000.0 asLongFloat ).
   477         self assert:( 200000000000000000000 < 200001000000000000000.0 asShortFloat ).
   476             self assert:( 200000000000000000000 < 200001000000000000000.0 asShortFloat ).
   478 
   477 
   479         self assert:( 200000000000000000000.0 <= 200000100000000000000 ).
   478             self assert:( 200000000000000000000.0 <= 200000100000000000000 ).
   480         self assert:( 200000000000000000000.0 <= 200000000000000000000 ).
   479             self assert:( 200000000000000000000.0 <= 200000000000000000000 ).
   481         self assert:( 200000000000000000000.0 asLongFloat <= 200000000000000000001 ).
   480             self assert:( 200000000000000000000.0 asLongFloat <= 200000000000000000001 ).
   482         self assert:( 200000000000000000000.0 asLongFloat <= 200000000000000000000 ).
   481             self assert:( 200000000000000000000.0 asLongFloat <= 200000000000000000000 ).
   483 
   482 
   484         self assert:( 200000000000000000000 <= 200001000000000000000.0).
   483             self assert:( 200000000000000000000 <= 200001000000000000000.0).
   485         self assert:( 200000000000000000000 <= 200000000000000000000.0).
   484             self assert:( 200000000000000000000 <= 200000000000000000000.0).
   486         self assert:( 200000000000000000000 <= 200001000000000000000.0 asLongFloat ).
   485             self assert:( 200000000000000000000 <= 200001000000000000000.0 asLongFloat ).
   487         self assert:( 200000000000000000000 <= 200000000000000000000.0 asLongFloat ).
   486             self assert:( 200000000000000000000 <= 200000000000000000000.0 asLongFloat ).
   488     ].
   487         ].
   489 
   488 
   490     self assert:( 2000000.0 asShortFloat = 2000000 ).
   489     self assert:( 2000000.0 asShortFloat = 2000000 ).
   491     self assert:( 2000000 = 2000000.0 asShortFloat ).
   490     self assert:( 2000000 = 2000000.0 asShortFloat ).
   492 
   491 
   493     self assert:( 2000000.0 asShortFloat <= 200000100000000000000 ).
   492     self assert:( 2000000.0 asShortFloat <= 200000100000000000000 ).