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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23