/test/language/unclassified/ac/test_ac02.e
Specman e | 93 lines | 58 code | 9 blank | 26 comment | 0 complexity | 554486ceee93643053850812a3e527a0 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_AC02 5 -- From a bug report of Alex Cozzi 6 7insert 8 EIFFELTEST_TOOLS 9 10creation {ANY} 11 make 12 13feature {ANY} 14 Test_count: INTEGER is 10 15 16 make is 17 local 18 c1: AUX_AC_COMPLEX; c2: AUX_AC_COMPLEX; c3: AUX_AC_COMPLEX; rnd_generator: PRESS_RANDOM_NUMBER_GENERATOR 19 i: INTEGER 20 do 21 from 22 create rnd_generator.make 23 i := 0 24 variant 25 Test_count - i 26 until 27 i = Test_count 28 loop 29 c1 := random_complex(rnd_generator) 30 c2 := random_complex(rnd_generator) 31 c3 := random_complex(rnd_generator) 32 test_plus(c1, c2, c3) 33 test_times(c1, c2, c3) 34 test_plus_and_times(c1, c2, c3) 35 i := i + 1 36 end 37 end 38 39 random_complex (rnd: RANDOM_NUMBER_GENERATOR): AUX_AC_COMPLEX is 40 local 41 re: REAL; im: REAL 42 do 43 rnd.next 44 re := rnd.last_real 45 rnd.next 46 im := rnd.last_real 47 Result.set_item(re, im) 48 end 49 50 test_plus (x, y, z: AUX_AC_COMPLEX) is 51 local 52 zero: AUX_AC_COMPLEX 53 do 54 zero := zero.zero 55 assert(x + zero = x) 56 assert(x + y = y + x) 57 -- assert(((x + y) + z) = (x + (y + z))); 58 end 59 60 test_times (x, y, z: AUX_AC_COMPLEX) is 61 local 62 one: AUX_AC_COMPLEX 63 do 64 one := one.one 65 assert(x * one = x) 66 -- assert((x * y) = (y * x)); 67 -- assert(((x * y) * z) = (x * (y * z))); 68 end 69 70 test_plus_and_times (x, y, z: AUX_AC_COMPLEX) is 71 do 72 -- assert(((x + y) * z) = (x * z + y * z)); 73 end 74 75end -- class TEST_AC02 76-- 77-- ------------------------------------------------------------------------------------------------------------------------------ 78-- Copyright notice below. Please read. 79-- 80-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 81-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 82-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 83-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 84-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 85-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 86-- 87-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 88-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 89-- 90-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 91-- 92-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 93-- ------------------------------------------------------------------------------------------------------------------------------