PageRenderTime 55ms CodeModel.GetById 47ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/test/lib/numeric/real/test_real_constant05.e

http://github.com/tybor/Liberty
Specman e | 79 lines | 46 code | 4 blank | 29 comment | 0 complexity | 8a6c53532ca8fa640d21a7a494ac71ba 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_REAL_CONSTANT05
 5   --
 6   -- Various notation for REAL_*
 7   --
 8
 9insert
10   EIFFELTEST_TOOLS
11
12create {}
13   make
14
15feature {ANY}
16   make
17      local
18         real_32: REAL_32; real_64: REAL_64; real: REAL; real_extended: REAL_EXTENDED; string: STRING
19      do
20         -- Testing REAL / REAL_64:
21         assert(0.0 < 0.1)
22         real := 10.0
23         assert(real.to_string.is_equal("10.000000"))
24         assert(real.to_string_format(1).is_equal("10.0"))
25         real_64 := 1.0E1
26         assert(real_64.to_string.is_equal("10.000000"))
27         assert(real_64.to_string_format(0).is_equal("10"))
28         assert(real = real_64)
29         assert(10.0 = 1.0e1)
30         -- Testing REAL_32:
31         real_32 := {REAL_32 0.0}
32         assert(real_32.to_string.is_equal("0.000000"))
33         assert(real_32.to_string_format(8).is_equal("0.00000000"))
34         assert(real_32 = 0.0)
35         real_32 := {REAL_32 0.5}
36         assert(real_32.to_string.is_equal("0.500000"))
37         assert(real_32.to_string_format(1).is_equal("0.5"))
38         assert(real_32 = 0.5)
39         -- Testing REAL_EXTENDED:
40         real_extended := {REAL_EXTENDED 3.5}
41         assert(real_extended = 3.5)
42         assert(real_extended.to_string.is_equal("3.500000"))
43         assert(real_extended.to_string_format(6).is_equal("3.500000"))
44         real_extended := 3.5
45         assert(real_extended = {REAL_EXTENDED 35E-1})
46         real_extended := 3.888
47         assert(real_extended.to_string.is_equal("3.888000"))
48         assert(real_extended.to_string_format(3).is_equal("3.888"))
49         -- Finally, testing assignments:
50         real_32 := {REAL_32 0.1}
51         real_64 := real_32
52         assert(real_64.to_string.is_equal("0.100000"))
53         real_extended := real_64
54         string := 155.5.to_string_scientific(4)
55         assert(155.5.to_string_scientific(4).is_equal("1.5550e+02"))
56         -- Testing manifest notation with '_' for reals
57         real_64 := 5_000.0
58         assert((real_64 - 5000.0).abs < 0.1)
59      end
60
61end -- class TEST_REAL_CONSTANT05
62--
63-- ------------------------------------------------------------------------------------------------------------------------------
64-- Copyright notice below. Please read.
65--
66-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
67-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
68-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
69-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
70-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
71-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
72--
73-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
74-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
75--
76-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
77--
78-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
79-- ------------------------------------------------------------------------------------------------------------------------------