1 |
class TEST |
2 |
|
3 |
creation |
4 |
make |
5 |
|
6 |
feature {NONE} -- Creation |
7 |
|
8 |
make is |
9 |
-- Run tests. |
10 |
do |
11 |
test ( |
12 |
agent (o: detachable TEST): detachable TEST |
13 |
do |
14 |
Result := f (o) |
15 |
end, |
16 |
True |
17 |
) |
18 |
test ( |
19 |
agent (o: detachable TEST): detachable TEST |
20 |
local |
21 |
a: A [attached TEST] |
22 |
do |
23 |
create a |
24 |
Result := a.f (o) |
25 |
end, |
26 |
True |
27 |
) |
28 |
test ( |
29 |
agent (o: detachable TEST): detachable TEST |
30 |
local |
31 |
a: A [attached TEST] |
32 |
do |
33 |
create a |
34 |
Result := a.g (o) |
35 |
end, |
36 |
True |
37 |
) |
38 |
test ( |
39 |
agent (o: detachable TEST): detachable TEST |
40 |
local |
41 |
a: A [attached TEST] |
42 |
do |
43 |
create a |
44 |
Result := a.h (o) |
45 |
end, |
46 |
False |
47 |
) |
48 |
test ( |
49 |
agent (o: detachable TEST): detachable TEST |
50 |
local |
51 |
a: A [attached TEST] |
52 |
do |
53 |
create a |
54 |
Result := a.i (o) |
55 |
end, |
56 |
False |
57 |
) |
58 |
test ( |
59 |
agent (o: detachable TEST): detachable TEST |
60 |
local |
61 |
a: A [detachable TEST] |
62 |
do |
63 |
create {A [attached TEST]} a |
64 |
Result := a.f (o) |
65 |
end, |
66 |
True |
67 |
) |
68 |
test ( |
69 |
agent (o: detachable TEST): detachable TEST |
70 |
local |
71 |
a: A [detachable TEST] |
72 |
do |
73 |
create {A [attached TEST]} a |
74 |
Result := a.g (o) |
75 |
end, |
76 |
True |
77 |
) |
78 |
test ( |
79 |
agent (o: detachable TEST): detachable TEST |
80 |
local |
81 |
a: A [attached TEST] |
82 |
do |
83 |
create {B [attached TEST]} a |
84 |
Result := a.h (o) |
85 |
end, |
86 |
True |
87 |
) |
88 |
test ( |
89 |
agent (o: detachable TEST): detachable TEST |
90 |
local |
91 |
a: A [attached TEST] |
92 |
do |
93 |
create {B [attached TEST]} a |
94 |
Result := a.i (o) |
95 |
end, |
96 |
True |
97 |
) |
98 |
end |
99 |
|
100 |
feature {NONE} -- Test |
101 |
|
102 |
test_number: INTEGER |
103 |
-- Number of the test |
104 |
|
105 |
test (c: attached FUNCTION [detachable TEST, detachable TEST]; e: BOOLEAN) |
106 |
local |
107 |
i: INTEGER |
108 |
do |
109 |
if i = 0 then |
110 |
i := 1 |
111 |
if c.item ([Current]) = Current then |
112 |
i := 2 |
113 |
else |
114 |
-- Incorrect result |
115 |
i := 3 |
116 |
end |
117 |
if c.item ([Void]) /= Void then |
118 |
-- Incorrect result |
119 |
i := 3 |
120 |
elseif e then |
121 |
-- Exception is not generated |
122 |
i := 3 |
123 |
end |
124 |
end |
125 |
test_number := test_number + 1 |
126 |
io.put_string ("Test " + test_number.out + ": ") |
127 |
if i = 2 then |
128 |
io.put_string ("OK") |
129 |
else |
130 |
io.put_string ("FAILED") |
131 |
end |
132 |
io.put_new_line |
133 |
rescue |
134 |
if not e then |
135 |
i := 3 |
136 |
end |
137 |
retry |
138 |
end |
139 |
|
140 |
f (a: detachable TEST): attached TEST |
141 |
external "C inline" |
142 |
alias "return eif_access($a);" |
143 |
end |
144 |
|
145 |
end |