PageRenderTime 14ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/numeric/real/test_is_zero.e

http://github.com/tybor/Liberty
Specman e | 81 lines | 49 code | 8 blank | 24 comment | 0 complexity | ed6b2b820dd54ff9236fade2317b2429 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_IS_ZERO
 5   --
 6   -- Of REAL_GENERAL.
 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_extended: REAL_EXTENDED
19      do
20         assert(real_64.is_zero)
21         real_64 := -real_64
22         assert(real_64.is_zero)
23         assert(infinity_64.is_infinity)
24         real_64 := 2.0 / infinity_64
25         assert(real_64.is_zero)
26         assert(real_32.is_zero)
27         real_32 := -real_32
28         assert(real_32.is_zero)
29         assert(infinity_32.is_infinity)
30         real_32 := {REAL_32 2.0} / infinity_32
31         assert(real_32.is_zero)
32         assert(real_extended.is_zero)
33         real_extended := -real_extended
34         assert(real_extended.is_zero)
35         assert(infinity_extended.is_infinity)
36         real_extended := {REAL_EXTENDED 2.0} / infinity_extended
37         assert(real_extended.is_zero)
38      end
39
40   infinity_64: REAL_64
41      do
42         Result := infinity_32
43      end
44
45   infinity_32: REAL_32
46      local
47         x, y: REAL_32
48      do
49         x := {REAL_32 1.0}
50         Result := unchecked_c_divide(x, y)
51      end
52
53   infinity_extended: REAL_EXTENDED
54      do
55         Result := infinity_32
56      end
57
58   unchecked_c_divide (x, y: REAL_32): REAL_32
59      external "C inline"
60      alias "($x/$y)"
61      end
62   
63end -- class TEST_IS_ZERO
64--
65-- ------------------------------------------------------------------------------------------------------------------------------
66-- Copyright notice below. Please read.
67--
68-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
69-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
70-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
71-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
72-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
73-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
74--
75-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
76-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
77--
78-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
79--
80-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
81-- ------------------------------------------------------------------------------------------------------------------------------