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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
|
// **********************************************************************
//
// Copyright (c) 2003-present ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
(function(module, require, exports)
{
const Ice = require("ice").Ice;
const Test = require("Test").Test;
const TestHelper = require("TestHelper").TestHelper;
const test = TestHelper.test;
const ClientPrivate = require("ClientPrivate").Test;
const ArrayUtil = Ice.ArrayUtil;
class Client extends TestHelper
{
async allTests(Test)
{
const communicator = this.communicator();
const out = this.getWriter();
out.write("testing stringToProxy... ");
const ref = "initial:" + this.getTestEndpoint();
const base = communicator.stringToProxy(ref);
test(base !== null);
out.writeLine("ok");
let oo1 = new Test.OneOptional();
oo1.a = 15;
out.write("testing checked cast... ");
const initial = await Test.InitialPrx.checkedCast(base);
test(initial !== null);
test(initial.equals(base));
out.writeLine("ok");
out.write("testing marshaling... ");
const oo4 = await initial.pingPong(new Test.OneOptional());
test(oo4.a === undefined);
const oo5 = await initial.pingPong(oo1);
test(oo5.a === oo1.a);
const mo4 = await initial.pingPong(new Test.MultiOptional());
test(mo4.a === undefined);
test(mo4.b === undefined);
test(mo4.c === undefined);
test(mo4.d === undefined);
test(mo4.e === undefined);
test(mo4.f === undefined);
test(mo4.g === undefined);
test(mo4.h === undefined);
test(mo4.i === undefined);
test(mo4.j === undefined);
test(mo4.k === undefined);
test(mo4.bs === undefined);
test(mo4.ss === undefined);
test(mo4.iid === undefined);
test(mo4.sid === undefined);
test(mo4.fs === undefined);
test(mo4.vs === undefined);
test(mo4.shs === undefined);
test(mo4.es === undefined);
test(mo4.fss === undefined);
test(mo4.vss === undefined);
test(mo4.oos === undefined);
test(mo4.oops === undefined);
test(mo4.ied === undefined);
test(mo4.ifsd === undefined);
test(mo4.ivsd === undefined);
test(mo4.iood === undefined);
test(mo4.ioopd === undefined);
test(mo4.bos === undefined);
test(mo4.ser === undefined);
const mo1 = new Test.MultiOptional();
mo1.a = 15;
mo1.b = true;
mo1.c = 19;
mo1.d = 78;
mo1.e = new Ice.Long(0, 99);
mo1.f = 5.5;
mo1.g = 1.0;
mo1.h = "test";
mo1.i = Test.MyEnum.MyEnumMember;
mo1.j = communicator.stringToProxy("test");
mo1.k = mo1;
mo1.bs = new Uint8Array([5]);
mo1.ss = ["test", "test2"];
mo1.iid = new Map();
mo1.iid.set(4, 3);
mo1.sid = new Map();
mo1.sid.set("test", 10);
mo1.fs = new Test.FixedStruct();
mo1.fs.m = 78;
mo1.vs = new Test.VarStruct();
mo1.vs.m = "hello";
mo1.shs = [1];
mo1.es = [Test.MyEnum.MyEnumMember, Test.MyEnum.MyEnumMember];
mo1.fss = [mo1.fs];
mo1.vss = [mo1.vs];
mo1.oos = [oo1];
mo1.oops = [communicator.stringToProxy("test")];
mo1.ied = new Map();
mo1.ied.set(4, Test.MyEnum.MyEnumMember);
mo1.ifsd = new Map();
mo1.ifsd.set(4, mo1.fs);
mo1.ivsd = new Map();
mo1.ivsd.set(5, mo1.vs);
mo1.iood = new Map();
mo1.iood.set(5, new Test.OneOptional(15));
mo1.ioopd = new Map();
mo1.ioopd.set(5, communicator.stringToProxy("test"));
mo1.bos = [false, true, false];
const mo5 = await initial.pingPong(mo1);
test(mo1.a == mo5.a);
test(mo1.b == mo5.b);
test(mo1.c == mo5.c);
test(mo1.d == mo5.d);
test(mo1.e.equals(mo5.e));
test(mo1.f == mo5.f);
test(mo1.g == mo5.g);
test(mo1.h == mo5.h);
test(mo1.i == mo5.i);
test(mo1.j.equals(mo5.j));
test(mo5.k == mo5);
test(ArrayUtil.equals(mo5.bs, mo1.bs));
test(ArrayUtil.equals(mo5.ss, mo1.ss));
test(mo5.iid.get(4) == 3);
test(mo5.sid.get("test") == 10);
test(mo5.fs.equals(mo1.fs));
test(mo5.vs.equals(mo1.vs));
test(ArrayUtil.equals(mo5.shs, mo1.shs));
test(mo5.es[0] == Test.MyEnum.MyEnumMember && mo5.es[1] == Test.MyEnum.MyEnumMember);
test(mo5.fss[0].equals(new Test.FixedStruct(78)));
test(mo5.vss[0].equals(new Test.VarStruct("hello")));
test(mo5.oos[0].a == 15);
test(mo5.oops[0].equals(communicator.stringToProxy("test")));
test(mo5.ied.get(4) == Test.MyEnum.MyEnumMember);
test(mo5.ifsd.get(4).equals(new Test.FixedStruct(78)));
test(mo5.ivsd.get(5).equals(new Test.VarStruct("hello")));
test(mo5.iood.get(5).a == 15);
test(mo5.ioopd.get(5).equals(communicator.stringToProxy("test")));
test(ArrayUtil.equals(mo5.bos, [false, true, false]));
// Clear the first half of the optional parameters
const mo6 = new Test.MultiOptional();
mo6.b = mo5.b;
mo6.d = mo5.d;
mo6.f = mo5.f;
mo6.h = mo5.h;
mo6.j = mo5.j;
mo6.bs = mo5.bs;
mo6.iid = mo5.iid;
mo6.fs = mo5.fs;
mo6.shs = mo5.shs;
mo6.fss = mo5.fss;
mo6.oos = mo5.oos;
mo6.ifsd = mo5.ifsd;
mo6.iood = mo5.iood;
mo6.bos = mo5.bos;
const mo7 = await initial.pingPong(mo6);
test(mo7.a === undefined);
test(mo7.b == mo1.b);
test(mo7.c === undefined);
test(mo7.d == mo1.d);
test(mo7.e === undefined);
test(mo7.f == mo1.f);
test(mo7.g === undefined);
test(mo7.h == mo1.h);
test(mo7.i === undefined);
test(mo7.j.equals(mo1.j));
test(mo7.k === undefined);
test(ArrayUtil.equals(mo7.bs, mo1.bs));
test(mo7.ss === undefined);
test(mo7.iid.get(4) == 3);
test(mo7.sid === undefined);
test(mo7.fs.equals(mo1.fs));
test(mo7.vs === undefined);
test(ArrayUtil.equals(mo7.shs, mo1.shs));
test(mo7.es === undefined);
test(mo7.fss[0].equals(new Test.FixedStruct(78)));
test(mo7.vss === undefined);
test(mo7.oos[0].a == 15);
test(mo7.oops === undefined);
test(mo7.ied === undefined);
test(mo7.ifsd.get(4).equals(new Test.FixedStruct(78)));
test(mo7.ivsd === undefined);
test(mo7.iood.get(5).a == 15);
test(mo7.ioopd === undefined);
test(ArrayUtil.equals(mo7.bos, [false, true, false]));
// Clear the second half of the optional parameters
const mo8 = new Test.MultiOptional();
mo8.a = mo1.a;
mo8.c = mo1.c;
mo8.e = mo1.e;
mo8.g = mo1.g;
mo8.i = mo1.i;
mo8.k = mo8;
mo8.ss = mo1.ss;
mo8.sid = mo1.sid;
mo8.vs = mo1.vs;
mo8.es = mo1.es;
mo8.vss = mo1.vss;
mo8.oops = mo1.oops;
mo8.ied = mo1.ied;
mo8.ivsd = mo1.ivsd;
mo8.ioopd = mo1.ioopd;
const mo9 = await initial.pingPong(mo8);
test(mo9.a == mo1.a);
test(mo9.b === undefined);
test(mo9.c == mo1.c);
test(mo9.d === undefined);
test(mo9.e.equals(mo1.e));
test(mo9.f === undefined);
test(mo9.g == mo1.g);
test(mo9.h === undefined);
test(mo9.i == mo1.i);
test(mo9.j === undefined);
test(mo9.k == mo9);
test(mo9.bs === undefined);
test(ArrayUtil.equals(mo9.ss, mo1.ss));
test(mo9.iid === undefined);
test(mo9.sid.get("test") == 10);
test(mo9.fs === undefined);
test(mo9.vs.equals(mo1.vs));
test(mo9.shs === undefined);
test(mo9.es[0] == Test.MyEnum.MyEnumMember && mo9.es[1] == Test.MyEnum.MyEnumMember);
test(mo9.fss === undefined);
test(mo9.vss[0].equals(new Test.VarStruct("hello")));
test(mo9.oos === undefined);
test(mo9.oops[0].equals(communicator.stringToProxy("test")));
test(mo9.ied.get(4) == Test.MyEnum.MyEnumMember);
test(mo9.ifsd === undefined);
test(mo9.ivsd.get(5).equals(new Test.VarStruct("hello")));
test(mo9.iood === undefined);
test(mo9.ioopd.get(5).equals(communicator.stringToProxy("test")));
test(mo9.bos === undefined);
//
// Use the 1.0 encoding with operations whose only class parameters are optional.
//
const initial2 = initial.ice_encodingVersion(Ice.Encoding_1_0);
const oo = new Test.OneOptional(53);
await initial.sendOptionalClass(true, oo);
await initial2.sendOptionalClass(true, oo);
oo1 = await initial.returnOptionalClass(true);
test(oo1 !== undefined && oo1.a == 53);
oo1 = await initial2.returnOptionalClass(true);
test(oo1 === undefined);
const recursive1 = [new Test.Recursive()];
const recursive2 = [new Test.Recursive()];
recursive1[0].value = recursive2;
const outer = new Test.Recursive();
outer.value = recursive1;
await initial.pingPong(outer);
let g = new Test.G();
g.gg1Opt = new Test.G1("gg1Opt");
g.gg2 = new Test.G2(new Ice.Long(0, 10));
g.gg2Opt = new Test.G2(new Ice.Long(0, 20));
g.gg1 = new Test.G1("gg1");
g = await initial.opG(g);
test(g.gg1Opt.a == "gg1Opt");
test(g.gg2.a.equals(new Ice.Long(0, 10)));
test(g.gg2Opt.a.equals(new Ice.Long(0, 20)));
test(g.gg1.a == "gg1");
const init2 = ClientPrivate.Initial2Prx.uncheckedCast(initial);
await init2.opVoid(5, "test");
out.writeLine("ok");
out.write("testing marshaling of large containers with fixed size elements... ");
let mc = new Test.MultiOptional();
mc.bs = new Uint8Array(1000);
mc.shs = new Array(300);
mc.fss = [];
for(let i = 0; i < 300; ++i)
{
mc.fss[i] = new Test.FixedStruct();
}
mc.ifsd = new Map();
for(let i = 0; i < 300; ++i)
{
mc.ifsd.set(i, new Test.FixedStruct());
}
mc = await initial.pingPong(mc);
test(mc.bs.length == 1000);
test(mc.shs.length == 300);
test(mc.fss.length == 300);
test(mc.ifsd.size == 300);
out.writeLine("ok");
out.write("testing tag marshaling... ");
let b = await initial.pingPong(new Test.B());
test(b.ma === undefined);
test(b.mb === undefined);
test(b.mc === undefined);
b.ma = 10;
b.mb = 11;
b.mc = 12;
b.md = 13;
b = await initial.pingPong(b);
test(b.ma == 10);
test(b.mb == 11);
test(b.mc == 12);
test(b.md == 13);
out.writeLine("ok");
out.write("testing marshaling of objects with optional objects... ");
let f = new Test.F();
f.af = new Test.A();
f.ae = f.af;
f = await initial.pingPong(f);
test(f.ae === f.af);
out.writeLine("ok");
out.write("testing optional with default values... ");
let wd = await initial.pingPong(new Test.WD());
test(wd.a == 5);
test(wd.s == "test");
wd.a = undefined;
wd.s = undefined;
wd = await initial.pingPong(wd);
test(wd.a === undefined);
test(wd.s === undefined);
out.writeLine("ok");
out.write("testing optional parameters... ");
let [p1, p2] = await initial.opByte(); // same as initial.opByte(undefined);
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opByte(56);
test(p1 === 56);
test(p2 === 56);
[p1, p2] = await initial.opBool();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opBool(true);
test(p1 === true);
test(p2 === true);
[p1, p2] = await initial.opShort();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opShort(56);
test(p1 === 56);
test(p2 === 56);
[p1, p2] = await initial.opInt();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opInt(56);
test(p1 === 56);
test(p2 === 56);
[p1, p2] = await initial.opLong();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opLong(new Ice.Long(0, 56));
test(p1.equals(new Ice.Long(0, 56)));
test(p2.equals(new Ice.Long(0, 56)));
[p1, p2] = await initial.opFloat();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opFloat(1.0);
test(p1 === 1.0);
test(p2 === 1.0);
[p1, p2] = await initial.opDouble();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opDouble(1.0);
test(p1 === 1.0);
test(p2 === 1.0);
[p1, p2] = await initial.opString();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opString("test");
test(p1 === "test");
test(p2 === "test");
[p1, p2] = await initial.opMyEnum();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opMyEnum(Test.MyEnum.MyEnumMember);
test(p1 === Test.MyEnum.MyEnumMember);
test(p2 === Test.MyEnum.MyEnumMember);
[p1, p2] = await initial.opMyEnum(null); // Test null enum
test(p1 === Test.MyEnum.MyEnumMember);
test(p2 === Test.MyEnum.MyEnumMember);
[p1, p2] = await initial.opSmallStruct();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opSmallStruct(new Test.SmallStruct(56));
test(p1.equals(new Test.SmallStruct(56)));
test(p2.equals(new Test.SmallStruct(56)));
[p1, p2] = await initial.opSmallStruct(null); // Test null struct
test(p1.equals(new Test.SmallStruct(0)));
test(p2.equals(new Test.SmallStruct(0)));
[p1, p2] = await initial.opFixedStruct();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opFixedStruct(new Test.FixedStruct(56));
test(p1.equals(new Test.FixedStruct(56)));
test(p2.equals(new Test.FixedStruct(56)));
[p1, p2] = await initial.opVarStruct();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opVarStruct(new Test.VarStruct("test"));
test(p1.equals(new Test.VarStruct("test")));
test(p2.equals(new Test.VarStruct("test")));
[p1, p2] = await initial.opOneOptional();
test(p1 === undefined);
test(p2 === undefined);
if(await initial.supportsNullOptional())
{
[p1, p2] = await initial.opOneOptional(null);
test(p1 === null);
test(p2 === null);
}
[p1, p2] = await initial.opOneOptional(new Test.OneOptional(58));
test(p1 === p2);
test(p2.a === 58);
[p1, p2] = await initial.opOneOptionalProxy();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opOneOptionalProxy(communicator.stringToProxy("test"));
test(p1.equals(communicator.stringToProxy("test")));
test(p2.equals(communicator.stringToProxy("test")));
[p1, p2] = await initial.opByteSeq();
test(p1 === undefined);
test(p2 === undefined);
let data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = 56;
}
[p1, p2] = await initial.opByteSeq(new Uint8Array(data));
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i] === 56);
test(p2[i] === 56);
}
[p1, p2] = await initial.opBoolSeq();
test(p1 === undefined);
test(p2 === undefined);
data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = true;
}
[p1, p2] = await initial.opBoolSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i] === true);
test(p2[i] === true);
}
[p1, p2] = await initial.opShortSeq();
test(p1 === undefined);
test(p2 === undefined);
data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = 56;
}
[p1, p2] = await initial.opShortSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i] === 56);
test(p2[i] === 56);
}
[p1, p2] = await initial.opIntSeq();
test(p1 === undefined);
test(p2 === undefined);
data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = 56;
}
[p1, p2] = await initial.opIntSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i] === 56);
test(p2[i] === 56);
}
[p1, p2] = await initial.opLongSeq();
test(p1 === undefined);
test(p2 === undefined);
data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = new Ice.Long(0, 56);
}
[p1, p2] = await initial.opLongSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i].equals(new Ice.Long(0, 56)));
test(p2[i].equals(new Ice.Long(0, 56)));
}
[p1, p2] = await initial.opFloatSeq();
test(p1 === undefined);
test(p2 === undefined);
data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = 1.0;
}
[p1, p2] = await initial.opFloatSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i] === 1.0);
test(p2[i] === 1.0);
}
[p1, p2] = await initial.opDoubleSeq();
test(p1 === undefined);
test(p2 === undefined);
data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = 1.0;
}
[p1, p2] = await initial.opDoubleSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i] === 1.0);
test(p2[i] === 1.0);
}
[p1, p2] = await initial.opStringSeq();
test(p1 === undefined);
test(p2 === undefined);
data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = "test1";
}
[p1, p2] = await initial.opStringSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i] == "test1");
test(p2[i] == "test1");
}
[p1, p2] = await initial.opSmallStructSeq();
test(p1 === undefined);
test(p2 === undefined);
data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = new Test.SmallStruct();
}
[p1, p2] = await initial.opSmallStructSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i].equals(new Test.SmallStruct()));
test(p2[i].equals(new Test.SmallStruct()));
}
[p1, p2] = await initial.opFixedStructSeq();
test(p1 === undefined);
test(p2 === undefined);
data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = new Test.FixedStruct();
}
[p1, p2] = await initial.opFixedStructSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i].equals(new Test.FixedStruct()));
test(p2[i].equals(new Test.FixedStruct()));
}
[p1, p2] = await initial.opVarStructSeq();
test(p1 === undefined);
test(p2 === undefined);
data = [];
for(let i = 0; i < 100; ++i)
{
data[i] = new Test.VarStruct("");
}
[p1, p2] = await initial.opVarStructSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for(let i = 0; i < 100; ++i)
{
test(p1[i].equals(new Test.VarStruct("")));
test(p2[i].equals(new Test.VarStruct("")));
}
[p1, p2] = await initial.opIntIntDict();
test(p1 === undefined);
test(p2 === undefined);
data = new Map();
data.set(1, 2);
data.set(2, 3);
[p1, p2] = await initial.opIntIntDict(data);
test(Ice.MapUtil.equals(p1, p2));
[p1, p2] = await initial.opStringIntDict();
test(p1 === undefined);
test(p2 === undefined);
data = new Map();
data.set("1", 1);
data.set("2", 2);
[p1, p2] = await initial.opStringIntDict(data);
test(Ice.MapUtil.equals(p1, p2));
[p1, p2] = await initial.opIntOneOptionalDict();
test(p1 === undefined);
test(p2 === undefined);
data = new Map();
data.set(1, new Test.OneOptional(58));
data.set(2, new Test.OneOptional(59));
[p1, p2] = await initial.opIntOneOptionalDict(data);
test(p1.get(1).a === 58 && p2.get(2).a === 59);
out.writeLine("ok");
out.write("testing exception optionals... ");
try
{
await initial.opOptionalException();
test(false);
}
catch(ex)
{
test(ex instanceof Test.OptionalException, ex);
test(ex.a === undefined);
test(ex.b === undefined);
test(ex.o === undefined);
}
try
{
await initial.opOptionalException(30, "test", new Test.OneOptional(53));
test(false);
}
catch(ex)
{
test(ex instanceof Test.OptionalException, ex);
test(ex.a === 30);
test(ex.b == "test");
test(ex.o.a == 53);
}
try
{
await initial.opDerivedException();
test(false);
}
catch(ex)
{
test(ex instanceof Test.DerivedException, ex);
test(ex.a === undefined);
test(ex.b === undefined);
test(ex.o === undefined);
test(ex.ss === undefined);
test(ex.o2 === undefined);
}
try
{
await initial.opDerivedException(30, "test2", new Test.OneOptional(53));
test(false);
}
catch(ex)
{
test(ex instanceof Test.DerivedException, ex);
test(ex.a === 30);
test(ex.b == "test2");
test(ex.o.a === 53);
test(ex.ss == "test2");
test(ex.o2.a === 53);
}
out.writeLine("ok");
out.write("testing optionals with marshaled results... ");
test(await initial.opMStruct1() !== undefined);
test(await initial.opMDict1() !== undefined);
test(await initial.opMSeq1() !== undefined);
test(await initial.opMG1() !== undefined);
{
let [p3, p2] = await initial.opMStruct2();
test(p3 === undefined && p2 == undefined);
const p1 = new Test.SmallStruct();
[p3, p2] = await initial.opMStruct2(p1);
test(p2.equals(p1) && p3.equals(p1));
}
{
let [p3, p2] = await initial.opMSeq2();
test(p2 === undefined && p3 === undefined);
const p1 = ["hello"];
[p3, p2] = await initial.opMSeq2(p1);
test(ArrayUtil.equals(p2, p1) && ArrayUtil.equals(p3, p1));
}
{
let [p3, p2] = await initial.opMDict2();
test(p2 === undefined && p3 === undefined);
const p1 = new Map();
p1.set("test", 54);
[p3, p2] = await initial.opMDict2(p1);
test(Ice.MapUtil.equals(p2, p1) && Ice.MapUtil.equals(p3, p1));
}
{
let [p3, p2] = await initial.opMG2();
test(p2 === undefined && p3 === undefined);
const p1 = new Test.G();
[p3, p2] = await initial.opMG2(p1);
test(p3 !== undefined && p2 !== undefined && p3 === p2);
}
out.writeLine("ok");
await initial.shutdown();
}
async run(args)
{
let communicator;
try
{
[communicator] = this.initialize(args);
await this.allTests(Test);
}
finally
{
if(communicator)
{
await communicator.destroy();
}
}
}
}
exports.Client = Client;
}(typeof global !== "undefined" && typeof global.process !== "undefined" ? module : undefined,
typeof global !== "undefined" && typeof global.process !== "undefined" ? require :
(typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) ? self.Ice._require : window.Ice._require,
typeof global !== "undefined" && typeof global.process !== "undefined" ? exports :
(typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope) ? self : window));
|