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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 103149 - (show annotations)
Sat May 11 19:27:55 2019 UTC (4 months ago) by alexk
File size: 1207 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 if attached b then
19 b.do_nothing
20 end
21 create c.put (Void)
22 test ("CELL [A]")
23 test ("A")
24 end
25
26 feature {NONE} -- Testing
27
28 test (type_name: STRING)
29 -- Attempt creating an object of type name `type_name` and report results.
30 local
31 t: like {REFLECTOR}.dynamic_type_from_string
32 do
33 t := {REFLECTOR}.dynamic_type_from_string (type_name)
34 if t = -1 then
35 io.put_string ("Type " + type_name + " is not found.%N")
36 elseif t = {REFLECTOR}.none_type then
37 io.put_string ("Type NONE is returned.%N")
38 elseif t < 0 then
39 io.put_string ("Negative type ID is returned.%N")
40 elseif attached {REFLECTOR}.new_instance_of (t) as o then
41 io.put_string ("An object of type " + o.generating_type.name_32.as_string_8 + " has been created.%N")
42 else
43 io.put_string ("Cannot create an object of type " + type_name + ".%N")
44 end
45 rescue
46 io.put_string ("Aborted with exception: " + if attached {EXCEPTION_MANAGER}.last_exception as e then e.tag.as_string_8 else "" end + "%N")
47 {EXCEPTIONS}.die (0)
48 end
49
50 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23