/test/language/unclassified/test_clone.e
Specman e | 101 lines | 68 code | 12 blank | 21 comment | 0 complexity | b80d78dcc49b3bacefd7e09305903397 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_CLONE 5 6inherit 7 ANY 8 redefine copy, is_equal 9 end 10 11insert 12 EIFFELTEST_TOOLS 13 undefine copy, is_equal 14 end 15 16create {} 17 main 18 19feature {ANY} 20 s1, s2: STRING 21 22 a1, a2: ANIMAL 23 24 ai1, ai2: ARRAY[INTEGER_8] 25 26 p1, p2: LIB_TEST_POINT 27 28 t1, t2: TRIANGLE 29 30 main 31 local 32 test_clone: like Current 33 do 34 s1 := "foo" 35 s2 := s1.twin 36 assert(s1 /= s2) 37 assert(s1.is_equal(s2)) 38 assert(s2.capacity >= s2.count) 39 s1.put('b', 2) 40 assert(not s1.is_equal(s2)) 41 create {CAT} a1 42 a2 := a1.twin 43 assert(a1 /= a2) 44 assert(a1.is_equal(a2)) 45 ai1 := {ARRAY[INTEGER_8] 1, << 1, 2, 3 >> } 46 ai2 := ai1.twin 47 assert(ai1.is_equal(ai2)) 48 assert(ai1 /= ai2) 49 create p1.make(1, 2) 50 p2 := p1.twin 51 assert(p1 /= p2) 52 assert(p1.x = p2.x) 53 assert(p1.y = p2.y) 54 assert(p1.same_dynamic_type(p2)) 55 create t1.make(p1, p2, p2) 56 t2 := t1.twin 57 assert(t1 /= t2) 58 assert(t1.same_dynamic_type(t2)) 59 assert(t1.p1 = t2.p1) 60 assert(t1.p2 = t2.p2) 61 assert(t1.p3 = t2.p3) 62 assert(t2.p2 = t2.p3) 63 test_clone := Current.twin 64 assert(test_clone /= Current) 65 assert(test_clone.same_dynamic_type(Current)) 66 assert(test_clone.is_equal(Current)) 67 assert(test_clone.s1 = Void) 68 assert(test_clone.s2 = Void) 69 assert(test_clone.ai1 = Void) 70 assert(test_clone.t1 = Void) 71 assert(test_clone.t2 = Void) 72 end 73 74 copy (other: like Current) 75 do 76 end 77 78 is_equal (other: like Current): BOOLEAN 79 do 80 Result := True 81 end 82 83end -- class TEST_CLONE 84-- 85-- ------------------------------------------------------------------------------------------------------------------------------ 86-- Copyright notice below. Please read. 87-- 88-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 89-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 90-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 91-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 92-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 93-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 94-- 95-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 96-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 97-- 98-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 99-- 100-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 101-- ------------------------------------------------------------------------------------------------------------------------------