/test/lib/numeric/integer/test_integer6.e
Specman e | 107 lines | 72 code | 5 blank | 30 comment | 1 complexity | c21fabddebba2e9aabfe2d38a61745b7 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_INTEGER6 5 -- 6 -- Balancing rule implies some weird stuff... 7 -- 8 9create {} 10 make 11 12feature {ANY} 13 make 14 local 15 a8, b8: INTEGER_8; a16: INTEGER_16; a32: INTEGER_32; a64: INTEGER_64 16 do 17 a8 := 0xff 18 b8 := a8.bit_shift_right(1) 19 assert(b8 = 0xff) 20 a8 := 0xff 21 b8 := a8.bit_shift_right_unsigned(1) 22 assert(b8 = 0x7f) 23 -- ----------------------------------------------------- 24 a16 := 0x00ff 25 a8 := a16.low_8 26 assert(a8 = 0xff) 27 a8 := a16.high_8 28 assert(a8 = 0x00) 29 a16 := 0xffff 30 a8 := a16.low_8 31 assert(a8 = 0xff) 32 a8 := a16.high_8 33 assert(a8 = 0xff) 34 a16 := 0xff7f 35 a8 := a16.low_8 36 assert(a8 = 0x7f) 37 a8 := a16.high_8 38 assert(a8 = 0xff) 39 -- ----------------------------------------------------- 40 -- ----------------------------------------------------- 41 a32 := 0x0000ffff 42 a16 := a32.low_16 43 assert(a16 = 0xffff) 44 a16 := a32.high_16 45 assert(a16 = 0x0000) 46 a32 := 0xffffffff 47 a16 := a32.low_16 48 assert(a16 = 0xffff) 49 a16 := a32.high_16 50 assert(a16 = 0xffff) 51 a32 := 0xffff7fff 52 a16 := a32.low_16 53 assert(a16 = 0x7fff) 54 a16 := a32.high_16 55 assert(a16 = 0xffff) 56 -- ----------------------------------------------------- 57 -- ----------------------------------------------------- 58 a64 := 0x00000000ffffffff 59 a32 := a64.low_32 60 assert(a32 = 0xffffffff) 61 a32 := a64.high_32 62 assert(a32 = 0x00000000) 63 a64 := 0xffffffffffffffff 64 a32 := a64.low_32 65 assert(a32 = 0xffffffff) 66 a32 := a64.high_32 67 assert(a32 = 0xffffffff) 68 a64 := 0xffffffff7fffffff 69 a32 := a64.low_32 70 assert(a32 = 0x7fffffff) 71 a32 := a64.high_32 72 assert(a32 = 0xffffffff) 73 -- ----------------------------------------------------- 74 end 75 76 assert (b: BOOLEAN) 77 do 78 cpt := cpt + 1 79 if not b then 80 sedb_breakpoint 81 std_output.put_string("TEST_INTEGER6: ERROR Test # ") 82 std_output.put_integer(cpt) 83 std_output.put_string("%N") 84 end 85 end 86 87 cpt: INTEGER 88 89end -- class TEST_INTEGER6 90-- 91-- ------------------------------------------------------------------------------------------------------------------------------ 92-- Copyright notice below. Please read. 93-- 94-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 95-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 96-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 97-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 98-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 99-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 100-- 101-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 102-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 103-- 104-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 105-- 106-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 107-- ------------------------------------------------------------------------------------------------------------------------------