/test/language/agent/test_agent34.e
Specman e | 63 lines | 32 code | 6 blank | 25 comment | 0 complexity | 5be53c14a2ced9b299e8ec39fe780b51 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_AGENT34 5 -- SZ:116: 6 7insert 8 EIFFELTEST_TOOLS 9 10create {} 11 make 12 13feature {} 14 make 15 local 16 my_collection: COLLECTION[STRING]; my_list: LINKED_LIST[STRING]; my_set: HASHED_SET[STRING] 17 do 18 my_collection := {ARRAY[STRING] 1, << "Benedicte", "Lucien", "Marie" >> } 19 create my_list.make 20 -- Using an agent to fill `my_list' using `my_collection': 21 my_collection.for_each(agent my_list.add_last(?)) 22 create my_set.make 23 -- Using an agent to fill `my_set' with `my_list': 24 my_list.for_each(agent my_set.add(?)) 25 -- Using an agent to print `my_set': 26 my_set.for_each(agent print_item(?)) 27 end 28 29 counter: INTEGER 30 31 print_item (item: STRING) 32 do 33 counter := counter + 1 34 inspect 35 counter 36 when 1 then 37 assert(item.is_equal("Benedicte")) 38 when 2 then 39 assert(item.is_equal("Marie")) 40 when 3 then 41 assert(item.is_equal("Lucien")) 42 end 43 end 44 45end -- class TEST_AGENT34 46-- 47-- ------------------------------------------------------------------------------------------------------------------------------ 48-- Copyright notice below. Please read. 49-- 50-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 51-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 52-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 53-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 54-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 55-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 56-- 57-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 58-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 59-- 60-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 61-- 62-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 63-- ------------------------------------------------------------------------------------------------------------------------------