/test/lib/numeric/natural/test_natural1.e
Specman e | 142 lines | 100 code | 20 blank | 22 comment | 0 complexity | e9454ec06f4283854f5a0dc239181e9f 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_NATURAL1 5 6inherit 7 EIFFELTEST_TOOLS 8 9create {} 10 main 11 12feature {} 13 main 14 local 15 a8, b8, c8, d8, e8, f8, g8, h8, j8: NATURAL_8 16 a64, b64, c64, d64, e64, f64, g64, h64, j64: NATURAL_64 17 do 18 assert(j8 = 0.to_natural_8) 19 a8 := a8 + 1.to_natural_8 20 21 assert(a8 /= 0.to_natural_8) 22 assert(a8 = 1.to_natural_8) 23 24 b8 := 2.to_natural_8 25 c8 := 100.to_natural_8 26 27 assert(b8 = b8) 28 assert(a8 + a8 = b8) 29 assert(a8 < b8) 30 assert(a8 <= b8) 31 assert(b8 >= b8) 32 assert(b8 >= a8) 33 assert(b8 > a8) 34 assert(c8 > b8) 35 assert(c8 = c8) 36 37 e8 := c8 38 d8 := c8 + e8 39 assert(d8 > c8) 40 assert(d8 >= e8) 41 assert(d8 >= e8 + c8) 42 assert(d8 <= e8 + c8) 43 44 assert(a8 = a8) 45 assert(not (a8 = j8)) 46 assert(not (j8 = a8)) 47 assert(j8 < a8) 48 assert(not (a8 < j8)) 49 assert(j8 <= a8) 50 assert(a8 > j8) 51 assert(a8 >= j8) 52 53 h8 := 10.to_natural_8 54 g8 := c8 // h8 55 f8 := c8 \\ h8 56 assert(g8 = h8) 57 assert(f8 = (a8 - a8)) 58 assert((a8 + b8).to_integer_32 = 3) 59 assert(a8.out.is_equal("1")) 60 assert(b8.out.is_equal("2")) 61 assert(d8.out.is_equal("200")) 62 63 -- ---------------------------------------- 64 assert(j64 = 0.to_natural_64) 65 a64 := a64 + 1.to_natural_64 66 67 assert(a64 /= 0.to_natural_64) 68 assert(a64 = 1.to_natural_64) 69 70 b64 := 2.to_natural_64 71 c64 := 100.to_natural_64 72 73 assert(b64 = b64) 74 assert(a64 + a64 = b64) 75 assert(a64 < b64) 76 assert(a64 <= b64) 77 assert(b64 >= b64) 78 assert(b64 >= a64) 79 assert(b64 > a64) 80 assert(c64 > b64) 81 assert(c64 = c64) 82 83 e64 := c64 84 d64 := c64 + e64 85 assert(d64 > c64) 86 assert(d64 >= e64) 87 assert(d64 >= e64 + c64) 88 assert(d64 <= e64 + c64) 89 90 assert(a64 = a64) 91 assert(not (a64 = j64)) 92 assert(not (j64 = a64)) 93 assert(j64 < a64) 94 assert(not (a64 < j64)) 95 assert(j64 <= a64) 96 assert(a64 > j64) 97 assert(a64 >= j64) 98 99 h64 := 10.to_natural_64 100 g64 := c64 // h64 101 f64 := c64 \\ h64 102 assert(g64 = h64) 103 assert(f64 = (a64 - a64)) 104 assert((a64 + b64).to_integer_32 = 3) 105 assert(a64.out.is_equal("1")) 106 assert(a64.to_number.to_string.is_equal("1")) 107 assert(b64.out.is_equal("2")) 108 assert(d64.out.is_equal("200")) 109 110 d64 := 9223372036854775807.to_natural_64 111 assert(d64.out.is_equal("9223372036854775807")) 112 d64 := d64 * 2.to_natural_64 113 assert(d64.out.is_equal("18446744073709551614")) 114 assert(d64.to_number.to_string.is_equal("18446744073709551614")) 115 116 d64 := d64 + 1.to_natural_64 117 assert(d64.out.is_equal("18446744073709551615")) 118 assert(d64.to_number.to_string.is_equal("18446744073709551615")) 119 d64 := d64 #+ 1.to_natural_64 120 assert(d64.out.is_equal("0")) 121 122 end 123 124end -- class TEST_NATURAL1 125-- 126-- ------------------------------------------------------------------------------------------------------------------------------ 127-- Copyright notice below. Please read. 128-- 129-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 130-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 131-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 132-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 133-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 134-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 135-- 136-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 137-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 138-- 139-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 140-- 141-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 142-- ------------------------------------------------------------------------------------------------------------------------------