PageRenderTime 26ms CodeModel.GetById 19ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/test/lib/numeric/real/test_double4.e

http://github.com/tybor/Liberty
Specman e | 90 lines | 63 code | 5 blank | 22 comment | 1 complexity | 7fac1bc53c572119973b26888f959e72 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_DOUBLE4
 5
 6create {}
 7   make
 8
 9feature {ANY}
10   make
11      local
12         d: REAL_64; i: INTEGER; r: REAL_32
13      do
14         i := 2
15         assert(i.sign = 1)
16         i := -2
17         assert(i.sign = -1)
18         assert(0.sign = 0)
19         r := 2
20         assert(r.sign = 1)
21         r := -2
22         assert(r.sign = -1)
23         assert(0.0.sign = 0)
24         d := 2
25         assert(d.sign = 1)
26         d := -2
27         assert(d.sign = -1)
28         d := 0
29         assert(d.sign = 0)
30         d := 3.5
31         assert(d.floor = 3)
32         assert(d.ceiling = 4)
33         d := -3.5
34         assert(d.floor = -4)
35         assert(d.ceiling = -3)
36         d := 2.0
37         assert(d.floor = 2)
38         assert(d.ceiling = 2)
39         assert(0.4.rounded.force_to_integer_32 = 0)
40         assert(0.51.rounded.force_to_integer_32 = 1)
41         assert(1.49.rounded.force_to_integer_32 = 1)
42         assert(1.51.rounded.force_to_integer_32 = 2)
43         assert((-0.4).rounded.force_to_integer_32 = 0)
44         assert((-0.51).rounded.force_to_integer_32 = -1)
45         assert((-1.49).rounded.force_to_integer_32 = -1)
46         assert((-1.51).rounded.force_to_integer_32 = -2)
47         assert(0.4.rounded = 0)
48         assert(0.51.rounded = 1)
49         assert(1.49.rounded = 1)
50         assert(1.51.rounded = 2)
51         assert((-0.4).rounded = 0)
52         assert((-0.51).rounded = -1)
53         assert((-1.49).rounded = -1)
54         assert((-1.51).rounded = -2)
55      end
56
57   assert (b: BOOLEAN)
58      do
59         cpt := cpt + 1
60         if not b then
61            sedb_breakpoint
62            std_output.put_string("TEST_DOUBLE4: ERROR Test # ")
63            std_output.put_integer(cpt)
64            std_output.put_string("%N")
65         else
66            -- std_output.put_string("Yes%N");
67         end
68      end
69
70   cpt: INTEGER
71
72end -- class TEST_DOUBLE4
73--
74-- ------------------------------------------------------------------------------------------------------------------------------
75-- Copyright notice below. Please read.
76--
77-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
78-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
79-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
80-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
81-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
82-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
83--
84-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
85-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
86--
87-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
88--
89-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
90-- ------------------------------------------------------------------------------------------------------------------------------