PageRenderTime 22ms CodeModel.GetById 17ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/numeric/real/test_maths.e

http://github.com/tybor/Liberty
Specman e | 134 lines | 108 code | 5 blank | 21 comment | 0 complexity | e7d80f98c88fe0c957f9e19aba1f9555 MD5 | raw file
  1-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries.
  2-- See the Copyright notice at the end of this file.
  3--
  4class TEST_MATHS
  5
  6insert
  7   EIFFELTEST_TOOLS
  8   PLATFORM
  9
 10create {}
 11   make
 12
 13feature {}
 14   make
 15      local
 16         i_8: INTEGER_8; i_16: INTEGER_16; i_32: INTEGER_32; i_64: INTEGER_64; r_32, real_32: REAL_32
 17         r_64, real_64: REAL_64
 18      do
 19         r_32 := Maximum_integer_8.to_real_32
 20         assert(r_32 = 1.27e+2)
 21         r_64 := Maximum_integer_8.to_real_64
 22         assert(r_64 = 1.27e+2)
 23         r_32 := Maximum_integer_16.to_real_32
 24         assert(r_32 = 3.2767e+04)
 25         r_64 := Maximum_integer_16.to_real_64
 26         assert(r_64 = 3.2767e+04)
 27         assert(not Maximum_integer_32.fit_real_32)
 28         real_32 := Maximum_integer_32.force_to_real_32
 29         real_64 := Maximum_integer_32.to_real_64
 30         assert(real_32 /= real_64)
 31         assert(Minimum_integer_32.fit_real_32)
 32         i_32 := -16777216
 33         assert(i_32.fit_real_32)
 34         real_32 := i_32.to_real_32
 35         assert(real_32.force_to_integer_32 = i_32)
 36         real_64 := i_32
 37         assert(real_32 = real_64)
 38         i_32 := -16777217
 39         assert(not i_32.fit_real_32)
 40         i_32 := -16777218
 41         assert(i_32.fit_real_32)
 42         real_32 := i_32.to_real_32
 43         assert(real_32.force_to_integer_32 = i_32)
 44         real_64 := i_32
 45         assert(real_32 = real_64)
 46         i_32 := 16777216
 47         assert(i_32.fit_real_32)
 48         real_32 := i_32.to_real_32
 49         real_64 := i_32
 50         assert(real_32 = real_64)
 51         i_32 := 16777217
 52         assert(not i_32.fit_real_32)
 53         i_32 := 16777218
 54         assert(i_32.fit_real_32)
 55         real_32 := i_32.to_real_32
 56         real_64 := i_32
 57         assert(real_32 = real_64)
 58         assert(not Maximum_integer_64.fit_real_64)
 59         assert(Minimum_integer_64.fit_real_64)
 60         i_64 := 9007199254740992
 61         assert(i_64.fit_real_64)
 62         real_64 := i_64.to_real_64
 63         assert(real_64.force_to_integer_64 = i_64)
 64         i_64 := 9007199254740995
 65         assert(not i_64.fit_real_64)
 66         i_64 := 9007199254740994
 67         assert(i_64.fit_real_64)
 68         real_64 := i_64.to_real_64
 69         assert(real_64.force_to_integer_64 = i_64)
 70         i_64 := -9007199254740992
 71         assert(i_64.fit_real_64)
 72         real_64 := i_64.force_to_real_64
 73         assert(real_64.force_to_integer_64 = i_64)
 74         i_64 := -9007199254740993
 75         assert(not i_64.fit_real_64)
 76         i_64 := -9007199254740994
 77         assert(i_64.fit_real_64)
 78         real_64 := i_64.force_to_real_64
 79         assert(real_64.force_to_integer_64 = i_64)
 80         i_8 := 1
 81         r_64 := i_8.log
 82         assert(r_64 = 0.0)
 83         i_16 := 1
 84         r_64 := i_16.log
 85         assert(r_64 = 0.0)
 86         i_32 := 1
 87         r_64 := i_32.log
 88         assert(r_64 = 0.0)
 89         i_64 := 1
 90         r_64 := i_64.log
 91         assert(r_64 = 0.0)
 92         i_8 := 1
 93         r_64 := i_8.log10
 94         assert(r_64 = 0.0)
 95         i_16 := 1
 96         r_64 := i_16.log10
 97         assert(r_64 = 0.0)
 98         i_32 := 1
 99         r_64 := i_32.log10
100         assert(r_64 = 0.0)
101         i_64 := 1
102         r_64 := i_64.log10
103         assert(r_64 = 0.0)
104         number := Maximum_integer_8.to_number
105         assert(number @= Maximum_integer_8)
106         number := Maximum_integer_16.to_number
107         assert(number @= Maximum_integer_16)
108         number := Maximum_integer_32.to_number
109         assert(number @= Maximum_integer_32)
110         number := Maximum_integer_64.to_number
111         assert(number @= Maximum_integer_64)
112      end
113
114   number: NUMBER
115
116end -- class TEST_MATHS
117--
118-- ------------------------------------------------------------------------------------------------------------------------------
119-- Copyright notice below. Please read.
120--
121-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
122-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
123-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
124-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
125-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
126-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
127--
128-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
129-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
130--
131-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
132--
133-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
134-- ------------------------------------------------------------------------------------------------------------------------------