/[eiffelstudio]/trunk/eweasel/tests/final130/test2.e
ViewVC logotype

Contents of /trunk/eweasel/tests/final130/test2.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 103149 - (show annotations)
Sat May 11 19:27:55 2019 UTC (5 months, 1 week ago) by alexk
File size: 1188 byte(s)
Added an example to test how removed classes are dealt with by `new_instance_of`.
1 class
2 TEST
3
4 create
5 make
6
7 feature {NONE} -- Creation
8
9 make
10 local
11 a: A
12 b: B
13 c: CELL [detachable A]
14 do
15 if attached a then
16 a.do_nothing
17 end
18 (create {B}).do_nothing
19 create c.put (Void)
20 test ("CELL [A]")
21 test ("A")
22 end
23
24 feature {NONE} -- Testing
25
26 test (type_name: STRING)
27 -- Attempt creating an object of type name `type_name` and report results.
28 local
29 t: like {REFLECTOR}.dynamic_type_from_string
30 do
31 t := {REFLECTOR}.dynamic_type_from_string (type_name)
32 if t = -1 then
33 io.put_string ("Type " + type_name + " is not found.%N")
34 elseif t = {REFLECTOR}.none_type then
35 io.put_string ("Type NONE is returned.%N")
36 elseif t < 0 then
37 io.put_string ("Negative type ID is returned.%N")
38 elseif attached {REFLECTOR}.new_instance_of (t) as o then
39 io.put_string ("An object of type " + o.generating_type.name_32.as_string_8 + " has been created.%N")
40 else
41 io.put_string ("Cannot create an object of type " + type_name + ".%N")
42 end
43 rescue
44 io.put_string ("Aborted with exception: " + if attached {EXCEPTION_MANAGER}.last_exception as e then e.tag.as_string_8 else "" end + "%N")
45 {EXCEPTIONS}.die (0)
46 end
47
48 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23