forked from HaxeFoundation/hxcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.hx
More file actions
269 lines (228 loc) · 7.39 KB
/
Client.hx
File metadata and controls
269 lines (228 loc) · 7.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
class ClientOne implements pack.HostInterface
{
public function new() { }
public function getOne() : Int return 1;
public function getOneString() : String return "1";
}
class ClientFoo implements IFoo {
public function new() {}
public function baz():String {
return 'foo';
}
}
class Client
{
public static var clientBool0 = true;
public static var clientBool1 = false;
public static var clientBool2 = true;
public static var clientBool3 = false;
public static function main()
{
Common.status = "running";
// See if it compiles
if (sys.thread.Thread.current()==null)
{
Common.status = "Cppia Thread.current not working.";
return;
}
if (Common.hostImplementation.getOne()!=1)
{
Common.status = "Bad call to getOne";
return;
}
if (Common.hostImplementation.getOneString()!="1")
{
Common.status = "Bad call to getOneString";
return;
}
var c = new ClientExtends();
if (!c.ok())
{
Common.status = "Bad client extension";
return;
}
if (c.whoStartedYou()!="HostBase")
{
Common.status = "Bad class fallthrough - got " + c.whoStartedYou();
return;
}
if (c.whoOverridesYou()!="ClientExtends")
{
Common.status = "Bad class override - got " + c.whoOverridesYou();
return;
}
if (!c.testPointers())
{
Common.status = "Could not move native pointers";
return;
}
var hostInterface:IHostInterface = c;
if (hostInterface.whoStartedYou()!="HostBase")
{
Common.status = "Bad interface fallthrough";
return;
}
if (hostInterface.whoOverridesYou()!="ClientExtends")
{
Common.status = "Bad interface override";
return;
}
if (hostInterface.hostImplOnly(1,"two",3)!="1two3")
{
Common.status = "Bad hostImplOnly implementation";
return;
}
if (!c.testOne())
{
Common.status = "Bad ClientExtends getOne";
return;
}
var clientInterface:IClientInterface = c;
if (clientInterface.whoStartedYou()!="HostBase")
{
Common.status = "Bad client interface fallthrough";
return;
}
if (clientInterface.uniqueClientFunc()!="uniqueClientFunc")
{
Common.status = "Bad new client interface call";
return;
}
if (clientInterface.whoOverridesYou()!="ClientExtends")
{
Common.status = "Bad client interface override";
return;
}
var clientHostInterface:IClientHostInterface = c;
if (clientHostInterface.whoStartedYou()!="HostBase")
{
Common.status = "Bad client interface fallthrough";
return;
}
if (clientHostInterface.whoOverridesYou()!="ClientExtends")
{
Common.status = "Bad client interface override";
return;
}
if (clientHostInterface.whoAreYou()!="ClientExtends")
{
Common.status = "Bad client/host interface";
return;
}
var c:ClientIHostImpl = new ClientIHostImpl();
if (c.hostImplOnly(0,null,0)!="client" || c.whoStartedYou()!="client" || c.whoOverridesYou()!="client")
{
Common.status = "Trouble implementing host interface";
return;
}
var c:ClientExtends = new ClientExtends2();
if (c.getGeneration()!=2)
{
Common.status = "Error calling cppia super function";
return;
}
var c = new ClientExtends2();
if (c.testOne())
{
Common.status = "ClientExtends2 getOne should fail";
return;
}
if (!c.testOneExtended())
{
Common.status = "ClientExtends2 testOneExtended failed";
return;
}
if (!c.testFour())
{
Common.status = "ClientExtends2 testFour error";
return;
}
var hostBools = HostBase.hostBool0 + "/" + HostBase.hostBool1+ "/" + HostBase.hostBool2+ "/" + HostBase.hostBool3;
var clientBools = clientBool0 + "/" + clientBool1+ "/" + clientBool2+ "/" + clientBool3;
if (hostBools!=clientBools)
{
Common.status = "Error in bool representation:" + hostBools + "!=" + clientBools;
return;
}
switch LocalFunctionExceptions.testLocalCallingStatic() {
case Error(message):
Common.status = 'Failed test for throw in static called by local: ' + message;
return;
default:
}
switch LocalFunctionExceptions.testCatchWithinLocal() {
case Error(message):
Common.status = 'Failed test for catch in local function: ' + message;
return;
default:
}
switch LocalFunctionExceptions.testCatchFromLocal() {
case Error(message):
Common.status = 'Failed test for catching exception from local function: ' + message;
return;
default:
}
switch LocalFunctionExceptions.testObjMethodOnReturn() {
case Error(message):
Common.status = 'Failed test for running object method on returned value: ' + message;
return;
default:
}
switch LocalFunctionExceptions.testClassMethodOnReturn() {
case Error(message):
Common.status = 'Failed test for running class method on returned value: ' + message;
return;
default:
}
switch LocalFunctionExceptions.testHostClassMethodOnHostReturn() {
case Error(message):
Common.status = 'Failed test for running host class method on returned value: ' + message;
return;
default:
}
switch ReturnExpressions.testHostThisReturn() {
case Error(message):
Common.status = 'Failed test for host this return stopping argument evaluation: ' + message;
return;
default:
}
switch ReturnExpressions.testHostArgReturn() {
case Error(message):
Common.status = 'Failed test for argument return stopping argument evaluation: ' + message;
return;
default:
}
switch ReturnExpressions.testClientThisReturn() {
case Error(message):
Common.status = 'Failed test for client this return stopping evaluation: ' + message;
return;
default:
}
switch ReturnExpressions.testFuncReturn() {
case Error(message):
Common.status = 'Failed test for function value return stopping evaluation: ' + message;
return;
default:
}
// regression test for #926
var x:Dynamic = 3;
x *= 5;
if (x != 15) {
Common.status = 'Failed regression test for #926. x: $x';
return;
}
// regression test for #1257
var x = 1290555;
x *= 1290555;
if (x != -915102823) {
Common.status = 'Failed regression test for #1257. x: $x';
return;
}
final extending = new ClientExtendedExtendedRoot();
extending.addValue();
Common.clientRoot = extending;
Common.clientImplementation = new ClientOne();
Common.status = "ok";
Common.callback = () -> Common.callbackSet = 2;
}
}