1//
2// Copyright (c) ZeroC, Inc. All rights reserved.
3//
4
5import {Ice} from "ice";
6import {Test} from "./generated";
7import {TestHelper} from "../../../Common/TestHelper";
8const test = TestHelper.test;
9
10export async function run(communicator:Ice.Communicator, prx:Test.MyClassPrx, bidir:boolean, helper:TestHelper)
11{
12    const literals = await prx.opStringLiterals();
13
14    test(Test.s0 == "\\" &&
15            Test.s0 == Test.sw0 &&
16            Test.s0 == literals[0] &&
17            Test.s0 == literals[11]);
18
19    test(Test.s1 == "A" &&
20            Test.s1 == Test.sw1 &&
21            Test.s1 == literals[1] &&
22            Test.s1 == literals[12]);
23
24    test(Test.s2 == "Ice" &&
25            Test.s2 == Test.sw2 &&
26            Test.s2 == literals[2] &&
27            Test.s2 == literals[13]);
28
29    test(Test.s3 == "A21" &&
30            Test.s3 == Test.sw3 &&
31            Test.s3 == literals[3] &&
32            Test.s3 == literals[14]);
33
34    test(Test.s4 == "\\u0041 \\U00000041" &&
35            Test.s4 == Test.sw4 &&
36            Test.s4 == literals[4] &&
37            Test.s4 == literals[15]);
38
39    test(Test.s5 == "\u00FF" &&
40            Test.s5 == Test.sw5 &&
41            Test.s5 == literals[5] &&
42            Test.s5 == literals[16]);
43
44    test(Test.s6 == "\u03FF" &&
45            Test.s6 == Test.sw6 &&
46            Test.s6 == literals[6] &&
47            Test.s6 == literals[17]);
48
49    test(Test.s7 == "\u05F0" &&
50            Test.s7 == Test.sw7 &&
51            Test.s7 == literals[7] &&
52            Test.s7 == literals[18]);
53
54    test(Test.s8 == "\uD800\uDC00" &&
55            Test.s8 == Test.sw8 &&
56            Test.s8 == literals[8] &&
57            Test.s8 == literals[19]);
58
59    test(Test.s9 == "\uD83C\uDF4C" &&
60            Test.s9 == Test.sw9 &&
61            Test.s9 == literals[9] &&
62            Test.s9 == literals[20]);
63
64    test(Test.s10 == "\u0DA7" &&
65            Test.s10 == Test.sw10 &&
66            Test.s10 == literals[10] &&
67            Test.s10 == literals[21]);
68
69    test(Test.ss0 == "'\"?\\\u0007\b\f\n\r\t\v\u0006" &&
70            Test.ss0 == Test.ss1 &&
71            Test.ss0 == Test.ss2 &&
72            Test.ss0 == literals[22] &&
73            Test.ss0 == literals[23] &&
74            Test.ss0 == literals[24]);
75
76    test(Test.ss3 == "\\\\U\\u\\" &&
77            Test.ss3 == literals[25]);
78
79    test(Test.ss4 == "\\A\\" &&
80            Test.ss4 == literals[26]);
81
82    test(Test.ss5 == "\\u0041\\" &&
83            Test.ss5 == literals[27]);
84
85    test(Test.su0 == Test.su1 &&
86            Test.su0 == Test.su2 &&
87            Test.su0 == literals[28] &&
88            Test.su0 == literals[29] &&
89            Test.su0 == literals[30]);
90
91    await prx.ice_ping();
92
93    test(await prx.ice_isA(Test.MyClass.ice_staticId()));
94
95    test((await prx.ice_id()) === Test.MyDerivedClass.ice_staticId());
96
97    test((await prx.ice_ids()).length === 3);
98
99    await prx.opVoid();
100
101    {
102        const [retval, p3] = await prx.opByte(0xff, 0x0f);
103        test(p3 === 0xf0);
104        test(retval === 0xff);
105    }
106
107    {
108        const [retval, p3] = await prx.opBool(true, false);
109        test(p3);
110        test(!retval);
111    }
112
113    {
114        const lo = new Ice.Long(0, 12);
115        const [retval, s, i, l] = await prx.opShortIntLong(10, 11, lo);
116
117        test(s === 10);
118        test(i === 11);
119        test(l.equals(lo));
120        test(retval.equals(lo));
121    }
122
123    {
124        const [retval, f, d] = await prx.opFloatDouble(3.14, 1.1E10);
125        test((f - 3.14) <= 0.01);
126        test(d == 1.1E10);
127        test(retval == 1.1E10);
128    }
129
130    try
131    {
132        await prx.opByte(0xffff, 0xff0f);
133        test(false);
134    }
135    catch(ex)
136    {
137        test(ex instanceof Ice.MarshalException, ex);
138    }
139
140    try
141    {
142        await prx.opShortIntLong(-32768 - 1, 0, new Ice.Long(0));
143        test(false);
144    }
145    catch(ex)
146    {
147        test(ex instanceof Ice.MarshalException, ex);
148    }
149
150    try
151    {
152        await prx.opShortIntLong(32767 + 1, 0, new Ice.Long(0));
153        test(false);
154    }
155    catch(ex)
156    {
157        test(ex instanceof Ice.MarshalException, ex);
158    }
159
160    try
161    {
162        await prx.opShortIntLong(0, -2147483648 - 1, new Ice.Long(0));
163        test(false);
164    }
165    catch(ex)
166    {
167        test(ex instanceof Ice.MarshalException, ex);
168    }
169
170    try
171    {
172        await prx.opShortIntLong(0, 2147483647 + 1, new Ice.Long(0));
173        test(false);
174    }
175    catch(ex)
176    {
177        test(ex instanceof Ice.MarshalException, ex);
178    }
179
180    try
181    {
182        await prx.opShortIntLong(0, 0, new Ice.Long(0, 0xFFFFFFFF + 1));
183        test(false);
184    }
185    catch(ex)
186    {
187        test(ex instanceof RangeError, ex);
188    }
189
190    try
191    {
192        await prx.opShortIntLong(0, 0, new Ice.Long(0xFFFFFFFF + 1, 0));
193        test(false);
194    }
195    catch(ex)
196    {
197        test(ex instanceof RangeError, ex);
198    }
199
200    try
201    {
202        await prx.opShortIntLong(0, 0, new Ice.Long(0, -1));
203        test(false);
204    }
205    catch(ex)
206    {
207        test(ex instanceof RangeError, ex);
208    }
209
210    try
211    {
212        await prx.opShortIntLong(Number.NaN, 0, new Ice.Long(0, 0));
213        test(false);
214    }
215    catch(ex)
216    {
217        test(ex instanceof Ice.MarshalException, ex);
218    }
219
220    try
221    {
222        await prx.opFloatDouble(Number.MAX_VALUE, 0);
223        test(false);
224    }
225    catch(ex)
226    {
227        test(ex instanceof Ice.MarshalException, ex);
228    }
229
230    try
231    {
232        await prx.opFloatDouble(-Number.MAX_VALUE, 0);
233        test(false);
234    }
235    catch(ex)
236    {
237        test(ex instanceof Ice.MarshalException, ex);
238    }
239
240    await prx.opFloatDouble(Number.NaN, Number.NaN);
241    await prx.opFloatDouble(-Number.NaN, -Number.NaN);
242    await prx.opFloatDouble(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
243    await prx.opFloatDouble(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);
244
245    {
246        const [retval, p3] = await prx.opString("hello", "world");
247        test(p3 === "world hello");
248        test(retval === "hello world");
249    }
250
251    {
252        const [retval, p2] = await prx.opMyEnum(Test.MyEnum.enum2);
253        test(p2 === Test.MyEnum.enum2);
254        test(retval === Test.MyEnum.enum3);
255    }
256
257    {
258        // Test null enum
259        const [retval, p2] = await prx.opMyEnum(null);
260        test(p2 === Test.MyEnum.enum1);
261        test(retval === Test.MyEnum.enum3);
262    }
263
264    {
265            const [retval, p2, p3] = await prx.opMyClass(prx);
266
267        test(p2.ice_getIdentity().equals(Ice.stringToIdentity("test")));
268        test(p3.ice_getIdentity().equals(Ice.stringToIdentity("noSuchIdentity")));
269        test(retval.ice_getIdentity().equals(Ice.stringToIdentity("test")));
270    }
271
272    {
273        const si1 = new Test.Structure();
274        si1.p = prx;
275        si1.e = Test.MyEnum.enum3;
276        si1.s = new Test.AnotherStruct();
277        si1.s.s = "abc";
278        const si2 = new Test.Structure();
279        si2.p = null;
280        si2.e = Test.MyEnum.enum2;
281        si2.s = new Test.AnotherStruct();
282        si2.s.s = "def";
283
284        const [retval, p3] = await prx.opStruct(si1, si2);
285        test(retval.p === null);
286        test(retval.e === Test.MyEnum.enum2);
287        test(retval.s.s === "def");
288        test(p3.p !== null);
289        test(p3.e === Test.MyEnum.enum3);
290        test(p3.s.s === "a new string");
291    }
292
293    {
294        const si1 = new Test.Structure();
295        // Test null struct
296        const [retval, p3] = await prx.opStruct(si1, null);
297
298        test(retval.p === null);
299        test(retval.e === Test.MyEnum.enum1);
300        test(retval.s.s === "");
301        test(p3.p === null);
302        test(p3.e === Test.MyEnum.enum1);
303        test(p3.s.s === "a new string");
304    }
305
306    {
307        const bsi1 = new Uint8Array([0x01, 0x11, 0x12, 0x22]);
308        const bsi2 = new Uint8Array([0xf1, 0xf2, 0xf3, 0xf4]);
309
310        const [retval, p3] = await prx.opByteS(bsi1, bsi2);
311
312        test(p3.length === 4);
313        test(p3[0] === 0x22);
314        test(p3[1] === 0x12);
315        test(p3[2] === 0x11);
316        test(p3[3] === 0x01);
317        test(retval.length === 8);
318        test(retval[0] === 0x01);
319        test(retval[1] === 0x11);
320        test(retval[2] === 0x12);
321        test(retval[3] === 0x22);
322        test(retval[4] === 0xf1);
323        test(retval[5] === 0xf2);
324        test(retval[6] === 0xf3);
325        test(retval[7] === 0xf4);
326    }
327
328    {
329        const bsi1 = [true, true, false];
330        const bsi2 = [false];
331        const [retval, p3] = await prx.opBoolS(bsi1, bsi2);
332
333        test(p3.length == 4);
334        test(p3[0]);
335        test(p3[1]);
336        test(!p3[2]);
337        test(!p3[3]);
338        test(retval.length == 3);
339        test(!retval[0]);
340        test(retval[1]);
341        test(retval[2]);
342    }
343
344    {
345        const ssi = [1, 2, 3];
346        const isi = [5, 6, 7, 8];
347        const l1 = new Ice.Long(0, 10);
348        const l2 = new Ice.Long(0, 30);
349        const l3 = new Ice.Long(0, 20);
350        const lsi = [l1, l2, l3];
351        const [retval, sso, iso, lso] = await prx.opShortIntLongS(ssi, isi, lsi);
352
353        test(sso.length === 3);
354        test(sso[0] === 1);
355        test(sso[1] === 2);
356        test(sso[2] === 3);
357        test(iso.length === 4);
358        test(iso[0] === 8);
359        test(iso[1] === 7);
360        test(iso[2] === 6);
361        test(iso[3] === 5);
362        test(lso.length === 6);
363        test(lso[0].equals(l1));
364        test(lso[1].equals(l2));
365        test(lso[2].equals(l3));
366        test(lso[3].equals(l1));
367        test(lso[4].equals(l2));
368        test(lso[5].equals(l3));
369        test(retval.length === 3);
370        test(retval[0].equals(l1));
371        test(retval[1].equals(l2));
372        test(retval[2].equals(l3));
373    }
374
375    {
376        const fsi = [3.14, 1.11];
377        const dsi = [1.1E10, 1.2E10, 1.3E10];
378        const [retval, fso, dso] = await prx.opFloatDoubleS(fsi, dsi);
379
380        test(fso.length === 2);
381        test((fso[0] - 3.14) <= 0.01);
382        test((fso[1] - 1.11) <= 0.01);
383        test(dso.length === 3);
384        test(dso[0] === 1.3E10);
385        test(dso[1] === 1.2E10);
386        test(dso[2] === 1.1E10);
387        test(retval.length === 5);
388        test(retval[0] === 1.1E10);
389        test(retval[1] === 1.2E10);
390        test(retval[2] === 1.3E10);
391        test((retval[3] - 3.14) <= 0.01);
392        test((retval[4] - 1.11) <= 0.01);
393    }
394
395    {
396        const ssi1 = ["abc", "de", "fghi"];
397        const ssi2 = ["xyz"];
398        const [retval, sso] = await prx.opStringS(ssi1, ssi2);
399
400        test(sso.length === 4);
401        test(sso[0] === "abc");
402        test(sso[1] === "de");
403        test(sso[2] === "fghi");
404        test(sso[3] === "xyz");
405        test(retval.length === 3);
406        test(retval[0] === "fghi");
407        test(retval[1] === "de");
408        test(retval[2] === "abc");
409    }
410
411    {
412        const bsi1 =
413            [
414                new Uint8Array([0x01, 0x11, 0x12]),
415                new Uint8Array([0xff])
416            ];
417
418        const bsi2 =
419            [
420                new Uint8Array([0x0e]),
421                new Uint8Array([0xf2, 0xf1])
422            ];
423
424        const [retval, bso] = await prx.opByteSS(bsi1, bsi2);
425
426        test(bso.length === 2);
427        test(bso[0].length === 1);
428        test(bso[0][0] === 0xff);
429        test(bso[1].length === 3);
430        test(bso[1][0] === 0x01);
431        test(bso[1][1] === 0x11);
432        test(bso[1][2] === 0x12);
433        test(retval.length === 4);
434        test(retval[0].length === 3);
435        test(retval[0][0] === 0x01);
436        test(retval[0][1] === 0x11);
437        test(retval[0][2] === 0x12);
438        test(retval[1].length === 1);
439        test(retval[1][0] === 0xff);
440        test(retval[2].length === 1);
441        test(retval[2][0] === 0x0e);
442        test(retval[3].length === 2);
443        test(retval[3][0] === 0xf2);
444        test(retval[3][1] === 0xf1);
445    }
446
447    {
448        const bsi1 =
449            [
450                [true],
451                [false],
452                [true, true]
453            ];
454
455        const bsi2 =
456            [
457                [false, false, true]
458            ];
459
460        const [retval, bso] = await prx.opBoolSS(bsi1, bsi2);
461
462        test(bso.length === 4);
463        test(bso[0].length === 1);
464        test(bso[0][0]);
465        test(bso[1].length === 1);
466        test(!bso[1][0]);
467        test(bso[2].length === 2);
468        test(bso[2][0]);
469        test(bso[2][1]);
470        test(bso[3].length === 3);
471        test(!bso[3][0]);
472        test(!bso[3][1]);
473        test(bso[3][2]);
474        test(retval.length === 3);
475        test(retval[0].length === 2);
476        test(retval[0][0]);
477        test(retval[0][1]);
478        test(retval[1].length === 1);
479        test(!retval[1][0]);
480        test(retval[2].length === 1);
481        test(retval[2][0]);
482    }
483
484    {
485        const ssi =
486            [
487                [1, 2, 5],
488                [13],
489                []
490            ];
491
492        const isi =
493            [
494                [24, 98],
495                [42]
496            ];
497
498        const l1 = new Ice.Long(0, 496);
499        const l2 = new Ice.Long(0, 1729);
500
501        const lsi =
502            [
503                [l1, l2]
504            ];
505
506        const [retval, sso, iso, lso] = await prx.opShortIntLongSS(ssi, isi, lsi);
507
508        test(retval.length === 1);
509        test(retval[0].length === 2);
510        test(retval[0][0].equals(l1));
511        test(retval[0][1].equals(l2));
512        test(sso.length === 3);
513        test(sso[0].length === 3);
514        test(sso[0][0] === 1);
515        test(sso[0][1] === 2);
516        test(sso[0][2] === 5);
517        test(sso[1].length === 1);
518        test(sso[1][0] === 13);
519        test(sso[2].length === 0);
520        test(iso.length === 2);
521        test(iso[0].length === 1);
522        test(iso[0][0] === 42);
523        test(iso[1].length === 2);
524        test(iso[1][0] === 24);
525        test(iso[1][1] === 98);
526        test(lso.length === 2);
527        test(lso[0].length === 2);
528        test(lso[0][0].equals(l1));
529        test(lso[0][1].equals(l2));
530        test(lso[1].length === 2);
531        test(lso[1][0].equals(l1));
532        test(lso[1][1].equals(l2));
533    }
534
535    {
536        const fsi =
537            [
538                [3.14],
539                [1.11],
540                []
541            ];
542
543        const dsi =
544            [
545                [1.1E10, 1.2E10, 1.3E10]
546            ];
547
548        const [retval, fso, dso] = await prx.opFloatDoubleSS(fsi, dsi);
549
550        test(fso.length === 3);
551        test(fso[0].length === 1);
552        test((fso[0][0] - 3.14) <= 0.01);
553        test(fso[1].length === 1);
554        test((fso[1][0] - 1.11) <= 0.01);
555        test(fso[2].length === 0);
556        test(dso.length === 1);
557        test(dso[0].length === 3);
558        test(dso[0][0] === 1.1E10);
559        test(dso[0][1] === 1.2E10);
560        test(dso[0][2] === 1.3E10);
561        test(retval.length === 2);
562        test(retval[0].length === 3);
563        test(retval[0][0] === 1.1E10);
564        test(retval[0][1] === 1.2E10);
565        test(retval[0][2] === 1.3E10);
566        test(retval[1].length === 3);
567        test(retval[1][0] === 1.1E10);
568        test(retval[1][1] === 1.2E10);
569        test(retval[1][2] === 1.3E10);
570    }
571
572    {
573        const ssi1 =
574            [
575                ["abc"],
576                ["de", "fghi"]
577            ];
578
579        const ssi2 =
580            [
581                [],
582                [],
583                ["xyz"]
584            ];
585
586        const [retval, sso] = await prx.opStringSS(ssi1, ssi2);
587        test(sso.length === 5);
588        test(sso[0].length === 1);
589        test(sso[0][0] === "abc");
590        test(sso[1].length === 2);
591        test(sso[1][0] === "de");
592        test(sso[1][1] === "fghi");
593        test(sso[2].length === 0);
594        test(sso[3].length === 0);
595        test(sso[4].length === 1);
596        test(sso[4][0] === "xyz");
597        test(retval.length === 3);
598        test(retval[0].length === 1);
599        test(retval[0][0] === "xyz");
600        test(retval[1].length === 0);
601        test(retval[2].length === 0);
602    }
603
604    {
605        const sssi1 =
606            [
607                [
608                    ["abc", "de"],
609                    ["xyz"]
610                ],
611                [
612                    ["hello"]
613                ]
614            ];
615
616        const sssi2 =
617            [
618                [
619                    ["", ""],
620                    ["abcd"]
621                ],
622                [
623                    [""]
624                ],
625                []
626            ];
627
628        const [retval, ssso] = await prx.opStringSSS(sssi1, sssi2);
629
630        test(ssso.length === 5);
631        test(ssso[0].length === 2);
632        test(ssso[0][0].length === 2);
633        test(ssso[0][1].length === 1);
634        test(ssso[1].length === 1);
635        test(ssso[1][0].length === 1);
636        test(ssso[2].length === 2);
637        test(ssso[2][0].length === 2);
638        test(ssso[2][1].length === 1);
639        test(ssso[3].length === 1);
640        test(ssso[3][0].length === 1);
641        test(ssso[4].length === 0);
642        test(ssso[0][0][0] === "abc");
643        test(ssso[0][0][1] === "de");
644        test(ssso[0][1][0] === "xyz");
645        test(ssso[1][0][0] === "hello");
646        test(ssso[2][0][0] === "");
647        test(ssso[2][0][1] === "");
648        test(ssso[2][1][0] === "abcd");
649        test(ssso[3][0][0] === "");
650
651        test(retval.length === 3);
652        test(retval[0].length === 0);
653        test(retval[1].length === 1);
654        test(retval[1][0].length === 1);
655        test(retval[2].length === 2);
656        test(retval[2][0].length === 2);
657        test(retval[2][1].length === 1);
658        test(retval[1][0][0] === "");
659        test(retval[2][0][0] === "");
660        test(retval[2][0][1] === "");
661        test(retval[2][1][0] === "abcd");
662    }
663
664    {
665        const di1 = new Test.ByteBoolD();
666        di1.set(10, true);
667        di1.set(100, false);
668
669        const di2 = new Test.ByteBoolD();
670        di2.set(10, true);
671        di2.set(11, false);
672        di2.set(101, true);
673
674        const [retval, p3] = await prx.opByteBoolD(di1, di2);
675        test(Ice.MapUtil.equals(p3, di1));
676        test(retval.size === 4);
677        test(retval.get(10) === true);
678        test(retval.get(11) === false);
679        test(retval.get(100) === false);
680        test(retval.get(101) === true);
681    }
682
683    {
684        const di1 = new Test.ShortIntD();
685        di1.set(110, -1);
686        di1.set(1100, 123123);
687
688        const di2 = new Test.ShortIntD();
689        di2.set(110, -1);
690        di2.set(111, -100);
691        di2.set(1101, 0);
692
693        const [retval, p3] = await prx.opShortIntD(di1, di2);
694        test(Ice.MapUtil.equals(p3, di1));
695        test(retval.size === 4);
696        test(retval.get(110) === -1);
697        test(retval.get(111) === -100);
698        test(retval.get(1100) === 123123);
699        test(retval.get(1101) === 0);
700    }
701
702    {
703        const di1 = new Test.LongFloatD();
704        di1.set(new Ice.Long(0, 999999110), -1.1);
705        di1.set(new Ice.Long(0, 999999111), 123123.2);
706
707        const di2 = new Test.LongFloatD();
708        di2.set(new Ice.Long(0, 999999110), -1.1);
709        di2.set(new Ice.Long(0, 999999120), -100.4);
710        di2.set(new Ice.Long(0, 999999130), 0.5);
711
712        const [retval, p3] = await prx.opLongFloatD(di1, di2);
713
714        test(p3.equals(di1, (v1, v2) => (Math.abs(v1) - Math.abs(v2)) <= 0.01));
715        test(retval.size === 4);
716        test(Math.abs(retval.get(new Ice.Long(0, 999999110))) - Math.abs(-1.1) <= 0.01);
717        test(Math.abs(retval.get(new Ice.Long(0, 999999120))) - Math.abs(-100.4) <= 0.01);
718        test(retval.get(new Ice.Long(0, 999999111)) - 123123.2 <= 0.01);
719        test(retval.get(new Ice.Long(0, 999999130)) - 0.5 <= 0.01);
720    }
721
722    {
723        const di1 = new Test.StringStringD();
724        di1.set("foo", "abc -1.1");
725        di1.set("bar", "abc 123123.2");
726
727        const di2 = new Test.StringStringD();
728        di2.set("foo", "abc -1.1");
729        di2.set("FOO", "abc -100.4");
730        di2.set("BAR", "abc 0.5");
731
732        const [retval, p3] = await prx.opStringStringD(di1, di2);
733        test(Ice.MapUtil.equals(p3, di1));
734        test(retval.size == 4);
735        test(retval.get("foo") === "abc -1.1");
736        test(retval.get("FOO") === "abc -100.4");
737        test(retval.get("bar") === "abc 123123.2");
738        test(retval.get("BAR") === "abc 0.5");
739    }
740
741    {
742        const di1 = new Test.StringMyEnumD();
743        di1.set("abc", Test.MyEnum.enum1);
744        di1.set("", Test.MyEnum.enum2);
745
746        const di2 = new Test.StringMyEnumD();
747        di2.set("abc", Test.MyEnum.enum1);
748        di2.set("qwerty", Test.MyEnum.enum3);
749        di2.set("Hello!!", Test.MyEnum.enum2);
750
751        const [retval, p3] = await prx.opStringMyEnumD(di1, di2);
752
753        test(Ice.MapUtil.equals(p3, di1));
754        test(retval.size === 4);
755        test(retval.get("abc") === Test.MyEnum.enum1);
756        test(retval.get("qwerty") === Test.MyEnum.enum3);
757        test(retval.get("") === Test.MyEnum.enum2);
758        test(retval.get("Hello!!") === Test.MyEnum.enum2);
759    }
760
761    {
762        const di1 = new Test.MyEnumStringD();
763        di1.set(Test.MyEnum.enum1, "abc");
764
765        const di2 = new Test.MyEnumStringD();
766        di2.set(Test.MyEnum.enum2, "Hello!!");
767        di2.set(Test.MyEnum.enum3, "qwerty");
768
769        const [retval, p3] = await prx.opMyEnumStringD(di1, di2);
770
771        test(Ice.MapUtil.equals(p3, di1));
772        test(retval.size === 3);
773        test(retval.get(Test.MyEnum.enum1) === "abc");
774        test(retval.get(Test.MyEnum.enum2) === "Hello!!");
775        test(retval.get(Test.MyEnum.enum3) === "qwerty");
776    }
777
778    {
779        const s11 = new Test.MyStruct(1, 1);
780        const s12 = new Test.MyStruct(1, 2);
781        const di1 = new Test.MyStructMyEnumD();
782        di1.set(s11, Test.MyEnum.enum1);
783        di1.set(s12, Test.MyEnum.enum2);
784        const s22 = new Test.MyStruct(2, 2);
785        const s23 = new Test.MyStruct(2, 3);
786        const di2 = new Test.MyStructMyEnumD();
787        di2.set(s11, Test.MyEnum.enum1);
788        di2.set(s22, Test.MyEnum.enum3);
789        di2.set(s23, Test.MyEnum.enum2);
790
791        const [retval, p3] = await prx.opMyStructMyEnumD(di1, di2);
792        test(p3.equals(di1));
793
794        test(retval.size === 4);
795        test(retval.get(s11) === Test.MyEnum.enum1);
796        test(retval.get(s12) === Test.MyEnum.enum2);
797        test(retval.get(s22) === Test.MyEnum.enum3);
798        test(retval.get(s23) === Test.MyEnum.enum2);
799    }
800
801    {
802        const ds1 = new Test.ByteBoolD();
803        ds1.set(10, true);
804        ds1.set(100, false);
805        const ds2 = new Test.ByteBoolD();
806        ds2.set(10, true);
807        ds2.set(11, false);
808        ds2.set(101, true);
809        const ds3 = new Test.ByteBoolD();
810        ds3.set(100, false);
811        ds3.set(101, false);
812
813        const [retval, p3] = await prx.opByteBoolDS([ds1, ds2], [ds3]);
814        test(retval.length == 2);
815        test(retval[0].size == 3);
816        test(retval[0].get(10) === true);
817        test(retval[0].get(11) === false);
818        test(retval[0].get(101) === true);
819        test(retval[1].size === 2);
820        test(retval[1].get(10) === true);
821        test(retval[1].get(100) === false);
822        test(p3.length == 3);
823        test(p3[0].size == 2);
824        test(p3[0].get(100) === false);
825        test(p3[0].get(101) === false);
826        test(p3[1].size == 2);
827        test(p3[1].get(10) === true);
828        test(p3[1].get(100) === false);
829        test(p3[2].size == 3);
830        test(p3[2].get(10) === true);
831        test(p3[2].get(11) === false);
832        test(p3[2].get(101) === true);
833    }
834
835    {
836        const di1 = new Test.ShortIntD();
837        di1.set(110, -1);
838        di1.set(1100, 123123);
839        const di2 = new Test.ShortIntD();
840        di2.set(110, -1);
841        di2.set(111, -100);
842        di2.set(1101, 0);
843        const di3 = new Test.ShortIntD();
844        di3.set(100, -1001);
845
846        const [retval, p3] = await prx.opShortIntDS([di1, di2], [di3]);
847        test(retval.length == 2);
848        test(retval[0].size == 3);
849        test(retval[0].get(110) === -1);
850        test(retval[0].get(111) === -100);
851        test(retval[0].get(1101) === 0);
852        test(retval[1].size === 2);
853        test(retval[1].get(110) === -1);
854        test(retval[1].get(1100) === 123123);
855
856        test(p3.length === 3);
857        test(p3[0].size === 1);
858        test(p3[0].get(100) === -1001);
859        test(p3[1].size === 2);
860        test(p3[1].get(110) === -1);
861        test(p3[1].get(1100) === 123123);
862        test(p3[2].size === 3);
863        test(p3[2].get(110) === -1);
864        test(p3[2].get(111) === -100);
865        test(p3[2].get(1101) === 0);
866    }
867
868    {
869        const di1 = new Test.LongFloatD();
870        di1.set(new Ice.Long(0, 999999110), -1.1);
871        di1.set(new Ice.Long(0, 999999111), 123123.2);
872        const di2 = new Test.LongFloatD();
873        di2.set(new Ice.Long(0, 999999110), -1.1);
874        di2.set(new Ice.Long(0, 999999120), -100.4);
875        di2.set(new Ice.Long(0, 999999130), 0.5);
876        const di3 = new Test.LongFloatD();
877        di3.set(new Ice.Long(0, 999999140), 3.14);
878
879        const [retval, p3] = await prx.opLongFloatDS([di1, di2], [di3]);
880        test(retval.length == 2);
881        test(retval[0].size == 3);
882        test(retval[0].get(new Ice.Long(0, 999999110)) - Math.abs(-1.1) <= 0.1);
883        test(retval[0].get(new Ice.Long(0, 999999120)) - Math.abs(-100.4) <= 0.1);
884        test(retval[0].get(new Ice.Long(0, 999999130)) - 0.5 <= 0.1);
885        test(retval[1].size == 2);
886        test(retval[1].get(new Ice.Long(0, 999999110)) - Math.abs(-1.1) <= 0.1);
887        test(retval[1].get(new Ice.Long(0, 999999111)) - 123123.2 <= 0.1);
888
889        test(p3.length == 3);
890        test(p3[0].size == 1);
891        test(p3[0].get(new Ice.Long(0, 999999140)) - 3.14 <= 0.1);
892        test(p3[1].size == 2);
893        test(p3[1].get(new Ice.Long(0, 999999110)) - Math.abs(-1.1) <= 0.1);
894        test(p3[1].get(new Ice.Long(0, 999999111)) - 123123.2 <= 0.1);
895        test(p3[2].size == 3);
896        test(p3[2].get(new Ice.Long(0, 999999110)) - Math.abs(-1.1) <= 0.1);
897        test(p3[2].get(new Ice.Long(0, 999999120)) - Math.abs(-100.4) <= 0.1);
898        test(p3[2].get(new Ice.Long(0, 999999130)) - 0.5 <= 0.1);
899    }
900
901    {
902        const di1 = new Test.StringStringD();
903        di1.set("foo", "abc -1.1");
904        di1.set("bar", "abc 123123.2");
905        const di2 = new Test.StringStringD();
906        di2.set("foo", "abc -1.1");
907        di2.set("FOO", "abc -100.4");
908        di2.set("BAR", "abc 0.5");
909        const di3 = new Test.StringStringD();
910        di3.set("f00", "ABC -3.14");
911
912        const [retval, p3] = await prx.opStringStringDS([di1, di2], [di3]);
913        test(retval.length === 2);
914        test(retval[0].size === 3);
915        test(retval[0].get("foo") === "abc -1.1");
916        test(retval[0].get("FOO") === "abc -100.4");
917        test(retval[0].get("BAR") === "abc 0.5");
918        test(retval[1].size === 2);
919        test(retval[1].get("foo") === "abc -1.1");
920        test(retval[1].get("bar") === "abc 123123.2");
921
922        test(p3.length === 3);
923        test(p3[0].size === 1);
924        test(p3[0].get("f00") === "ABC -3.14");
925        test(p3[1].size === 2);
926        test(p3[1].get("foo") === "abc -1.1");
927        test(p3[1].get("bar") === "abc 123123.2");
928        test(p3[2].size === 3);
929        test(p3[2].get("foo") === "abc -1.1");
930        test(p3[2].get("FOO") === "abc -100.4");
931        test(p3[2].get("BAR") === "abc 0.5");
932    }
933
934    {
935        const di1 = new Test.StringMyEnumD();
936        di1.set("abc", Test.MyEnum.enum1);
937        di1.set("", Test.MyEnum.enum2);
938        const di2 = new Test.StringMyEnumD();
939        di2.set("abc", Test.MyEnum.enum1);
940        di2.set("qwerty", Test.MyEnum.enum3);
941        di2.set("Hello!!", Test.MyEnum.enum2);
942        const di3 = new Test.StringMyEnumD();
943        di3.set("Goodbye", Test.MyEnum.enum1);
944
945        const [retval, p3] = await prx.opStringMyEnumDS([di1, di2], [di3]);
946
947        test(retval.length == 2);
948        test(retval[0].size == 3);
949        test(retval[0].get("abc") == Test.MyEnum.enum1);
950        test(retval[0].get("qwerty") == Test.MyEnum.enum3);
951        test(retval[0].get("Hello!!") == Test.MyEnum.enum2);
952        test(retval[1].size == 2);
953        test(retval[1].get("abc") == Test.MyEnum.enum1);
954        test(retval[1].get("") == Test.MyEnum.enum2);
955
956        test(p3.length == 3);
957        test(p3[0].size == 1);
958        test(p3[0].get("Goodbye") == Test.MyEnum.enum1);
959        test(p3[1].size == 2);
960        test(p3[1].get("abc") == Test.MyEnum.enum1);
961        test(p3[1].get("") == Test.MyEnum.enum2);
962        test(p3[2].size == 3);
963        test(p3[2].get("abc") == Test.MyEnum.enum1);
964        test(p3[2].get("qwerty") == Test.MyEnum.enum3);
965        test(p3[2].get("Hello!!") == Test.MyEnum.enum2);
966    }
967
968    {
969        const di1 = new Test.MyEnumStringD();
970        di1.set(Test.MyEnum.enum1, "abc");
971        const di2 = new Test.MyEnumStringD();
972        di2.set(Test.MyEnum.enum2, "Hello!!");
973        di2.set(Test.MyEnum.enum3, "qwerty");
974        const di3 = new Test.MyEnumStringD();
975        di3.set(Test.MyEnum.enum1, "Goodbye");
976
977        const [retval, p3] = await prx.opMyEnumStringDS([di1, di2], [di3]);
978        test(retval.length == 2);
979        test(retval[0].size == 2);
980        test(retval[0].get(Test.MyEnum.enum2) === "Hello!!");
981        test(retval[0].get(Test.MyEnum.enum3) === "qwerty");
982        test(retval[1].size == 1);
983        test(retval[1].get(Test.MyEnum.enum1) === "abc");
984
985        test(p3.length == 3);
986        test(p3[0].size == 1);
987        test(p3[0].get(Test.MyEnum.enum1) === "Goodbye");
988        test(p3[1].size == 1);
989        test(p3[1].get(Test.MyEnum.enum1) === "abc");
990        test(p3[2].size == 2);
991        test(p3[2].get(Test.MyEnum.enum2) === "Hello!!");
992        test(p3[2].get(Test.MyEnum.enum3) === "qwerty");
993    }
994
995    {
996        const s11 = new Test.MyStruct(1, 1);
997        const s12 = new Test.MyStruct(1, 2);
998        const di1 = new Test.MyStructMyEnumD();
999        di1.set(s11, Test.MyEnum.enum1);
1000        di1.set(s12, Test.MyEnum.enum2);
1001
1002        const s22 = new Test.MyStruct(2, 2);
1003        const s23 = new Test.MyStruct(2, 3);
1004        const di2 = new Test.MyStructMyEnumD();
1005        di2.set(s11, Test.MyEnum.enum1);
1006        di2.set(s22, Test.MyEnum.enum3);
1007        di2.set(s23, Test.MyEnum.enum2);
1008
1009        const di3 = new Test.MyStructMyEnumD();
1010        di3.set(s23, Test.MyEnum.enum3);
1011
1012        const [retval, p3] = await prx.opMyStructMyEnumDS([di1, di2], [di3]);
1013        test(retval.length == 2);
1014        test(retval[0].size == 3);
1015        test(retval[0].get(s11) === Test.MyEnum.enum1);
1016        test(retval[0].get(s22) === Test.MyEnum.enum3);
1017        test(retval[0].get(s23) === Test.MyEnum.enum2);
1018        test(retval[1].size == 2);
1019        test(retval[1].get(s11) === Test.MyEnum.enum1);
1020        test(retval[1].get(s12) === Test.MyEnum.enum2);
1021
1022        test(p3.length == 3);
1023        test(p3[0].size == 1);
1024        test(p3[0].get(s23) === Test.MyEnum.enum3);
1025        test(p3[1].size == 2);
1026        test(p3[1].get(s11) === Test.MyEnum.enum1);
1027        test(p3[1].get(s12) === Test.MyEnum.enum2);
1028        test(p3[2].size == 3);
1029        test(p3[2].get(s11) === Test.MyEnum.enum1);
1030        test(p3[2].get(s22) === Test.MyEnum.enum3);
1031        test(p3[2].get(s23) === Test.MyEnum.enum2);
1032    }
1033
1034    {
1035        const sdi1 = new Test.ByteByteSD();
1036        sdi1.set(0x01, new Uint8Array([0x01, 0x11]));
1037        sdi1.set(0x22, new Uint8Array([0x12]));
1038        const sdi2 = new Test.ByteByteSD();
1039        sdi2.set(0xf1, new Uint8Array([0xf2, 0xf3]));
1040
1041        const [retval, p3] = await prx.opByteByteSD(sdi1, sdi2);
1042        test(p3.size == 1);
1043        test(p3.get(0xf1).length === 2);
1044        test(p3.get(0xf1)[0] === 0xf2);
1045        test(p3.get(0xf1)[1] === 0xf3);
1046        test(retval.size === 3);
1047        test(retval.get(0x01).length === 2);
1048        test(retval.get(0x01)[0] === 0x01);
1049        test(retval.get(0x01)[1] === 0x11);
1050        test(retval.get(0x22).length === 1);
1051        test(retval.get(0x22)[0] === 0x12);
1052        test(retval.get(0xf1).length === 2);
1053        test(retval.get(0xf1)[0] === 0xf2);
1054        test(retval.get(0xf1)[1] === 0xf3);
1055    }
1056
1057    {
1058        const si1 = [true, false];
1059        const si2 = [false, true, true];
1060        const sdi1 = new Test.BoolBoolSD();
1061        sdi1.set(false, si1);
1062        sdi1.set(true, si2);
1063        const sdi2 = new Test.BoolBoolSD();
1064        sdi2.set(false, si1);
1065
1066        const [retval, p3] = await prx.opBoolBoolSD(sdi1, sdi2);
1067        test(p3.size === 1);
1068        test(p3.get(false).length === 2);
1069        test(p3.get(false)[0] === true);
1070        test(p3.get(false)[1] === false);
1071        test(retval.size === 2);
1072        test(retval.get(false).length === 2);
1073        test(retval.get(false)[0] === true);
1074        test(retval.get(false)[1] === false);
1075        test(retval.get(true).length === 3);
1076        test(retval.get(true)[0] === false);
1077        test(retval.get(true)[1] === true);
1078        test(retval.get(true)[2] === true);
1079    }
1080
1081    {
1082        const sdi1 = new Test.ShortShortSD();
1083        const sdi2 = new Test.ShortShortSD();
1084
1085        const si1 = [1, 2, 3];
1086        const si2 = [4, 5];
1087        const si3 = [6, 7];
1088
1089        sdi1.set(1, si1);
1090        sdi1.set(2, si2);
1091        sdi2.set(4, si3);
1092
1093        const [retval, p3] = await prx.opShortShortSD(sdi1, sdi2);
1094        test(p3.size === 1);
1095        test(p3.get(4).length === 2);
1096        test(p3.get(4)[0] === 6);
1097        test(p3.get(4)[1] === 7);
1098        test(retval.size === 3);
1099        test(retval.get(1).length === 3);
1100        test(retval.get(1)[0] === 1);
1101        test(retval.get(1)[1] === 2);
1102        test(retval.get(1)[2] === 3);
1103        test(retval.get(2).length === 2);
1104        test(retval.get(2)[0] === 4);
1105        test(retval.get(2)[1] === 5);
1106        test(retval.get(4).length === 2);
1107        test(retval.get(4)[0] === 6);
1108        test(retval.get(4)[1] === 7);
1109    }
1110
1111    {
1112        const sdi1 = new Test.IntIntSD();
1113        const sdi2 = new Test.IntIntSD();
1114
1115        const si1 = [100, 200, 300];
1116        const si2 = [400, 500];
1117        const si3 = [600, 700];
1118
1119        sdi1.set(100, si1);
1120        sdi1.set(200, si2);
1121        sdi2.set(400, si3);
1122
1123        const [retval, p3] = await prx.opIntIntSD(sdi1, sdi2);
1124        test(p3.size === 1);
1125        test(p3.get(400).length === 2);
1126        test(p3.get(400)[0] === 600);
1127        test(p3.get(400)[1] === 700);
1128        test(retval.size === 3);
1129        test(retval.get(100).length === 3);
1130        test(retval.get(100)[0] === 100);
1131        test(retval.get(100)[1] === 200);
1132        test(retval.get(100)[2] === 300);
1133        test(retval.get(200).length === 2);
1134        test(retval.get(200)[0] === 400);
1135        test(retval.get(200)[1] === 500);
1136        test(retval.get(400).length === 2);
1137        test(retval.get(400)[0] === 600);
1138        test(retval.get(400)[1] === 700);
1139    }
1140
1141    {
1142        const sdi1 = new Test.LongLongSD();
1143        const sdi2 = new Test.LongLongSD();
1144
1145        const si1 = [new Ice.Long(0, 999999110), new Ice.Long(0, 999999111), new Ice.Long(0, 999999110)];
1146        const si2 = [new Ice.Long(0, 999999120), new Ice.Long(0, 999999130)];
1147        const si3 = [new Ice.Long(0, 999999110), new Ice.Long(0, 999999120)];
1148
1149        sdi1.set(new Ice.Long(0, 999999990), si1);
1150        sdi1.set(new Ice.Long(0, 999999991), si2);
1151        sdi2.set(new Ice.Long(0, 999999992), si3);
1152
1153        const [retval, p3] = await prx.opLongLongSD(sdi1, sdi2);
1154        test(p3.size == 1);
1155        test(p3.get(new Ice.Long(0, 999999992)).length === 2);
1156        test(p3.get(new Ice.Long(0, 999999992))[0].equals(new Ice.Long(0, 999999110)));
1157        test(p3.get(new Ice.Long(0, 999999992))[1].equals(new Ice.Long(0, 999999120)));
1158        test(retval.size == 3);
1159        test(retval.get(new Ice.Long(0, 999999990)).length === 3);
1160        test(retval.get(new Ice.Long(0, 999999990))[0].equals(new Ice.Long(0, 999999110)));
1161        test(retval.get(new Ice.Long(0, 999999990))[1].equals(new Ice.Long(0, 999999111)));
1162        test(retval.get(new Ice.Long(0, 999999990))[2].equals(new Ice.Long(0, 999999110)));
1163        test(retval.get(new Ice.Long(0, 999999991)).length === 2);
1164        test(retval.get(new Ice.Long(0, 999999991))[0].equals(new Ice.Long(0, 999999120)));
1165        test(retval.get(new Ice.Long(0, 999999991))[1].equals(new Ice.Long(0, 999999130)));
1166        test(retval.get(new Ice.Long(0, 999999992)).length === 2);
1167        test(retval.get(new Ice.Long(0, 999999992))[0].equals(new Ice.Long(0, 999999110)));
1168        test(retval.get(new Ice.Long(0, 999999992))[1].equals(new Ice.Long(0, 999999120)));
1169    }
1170
1171    {
1172        const sdi1 = new Test.StringFloatSD();
1173        const sdi2 = new Test.StringFloatSD();
1174
1175        const si1 = [-1.1, 123123.2, 100.0];
1176        const si2 = [42.24, -1.61];
1177        const si3 = [-3.14, 3.14];
1178
1179        sdi1.set("abc", si1);
1180        sdi1.set("ABC", si2);
1181        sdi2.set("aBc", si3);
1182
1183        const [retval, p3] = await prx.opStringFloatSD(sdi1, sdi2);
1184
1185        test(p3.size === 1);
1186        test(p3.get("aBc").length === 2);
1187        test(p3.get("aBc")[0] - Math.abs(3.14) <= 0.1);
1188        test(p3.get("aBc")[1] - 3.14 <= 0.1);
1189        test(retval.size === 3);
1190        test(retval.get("abc").length === 3);
1191        test(retval.get("abc")[0] - Math.abs(1.1) <= 0.1);
1192        test(retval.get("abc")[1] - 123123.2 <= 0.1);
1193        test(retval.get("abc")[2] - 100.0 <= 0.1);
1194        test(retval.get("ABC").length === 2);
1195        test(retval.get("ABC")[0] - 42.24 <= 0.1);
1196        test(retval.get("ABC")[1] - Math.abs(1.61) <= 0.1);
1197        test(retval.get("aBc").length === 2);
1198        test(retval.get("aBc")[0] - Math.abs(3.14) <= 0.1);
1199        test(retval.get("aBc")[1] - 3.14 <= 0.1);
1200    }
1201
1202    {
1203        const sdi1 = new Test.StringDoubleSD();
1204        const sdi2 = new Test.StringDoubleSD();
1205
1206        const si1 = [1.1E10, 1.2E10, 1.3E10];
1207        const si2 = [1.4E10, 1.5E10];
1208        const si3 = [1.6E10, 1.7E10];
1209
1210        sdi1.set("Hello!!", si1);
1211        sdi1.set("Goodbye", si2);
1212        sdi2.set("", si3);
1213
1214        const [retval, p3] = await prx.opStringDoubleSD(sdi1, sdi2);
1215
1216        test(p3.size === 1);
1217        test(p3.get("").length === 2);
1218        test(p3.get("")[0] === 1.6E10);
1219        test(p3.get("")[1] === 1.7E10);
1220        test(retval.size === 3);
1221        test(retval.get("Hello!!").length === 3);
1222        test(retval.get("Hello!!")[0] === 1.1E10);
1223        test(retval.get("Hello!!")[1] === 1.2E10);
1224        test(retval.get("Hello!!")[2] === 1.3E10);
1225        test(retval.get("Goodbye").length === 2);
1226        test(retval.get("Goodbye")[0] === 1.4E10);
1227        test(retval.get("Goodbye")[1] === 1.5E10);
1228        test(retval.get("").length === 2);
1229        test(retval.get("")[0] === 1.6E10);
1230        test(retval.get("")[1] === 1.7E10);
1231    }
1232
1233    {
1234        const sdi1 = new Test.StringStringSD();
1235        const sdi2 = new Test.StringStringSD();
1236
1237        const si1 = ["abc", "de", "fghi"];
1238        const si2 = ["xyz", "or"];
1239        const si3 = ["and", "xor"];
1240
1241        sdi1.set("abc", si1);
1242        sdi1.set("def", si2);
1243        sdi2.set("ghi", si3);
1244
1245        const [retval, p3] = await prx.opStringStringSD(sdi1, sdi2);
1246
1247        test(p3.size === 1);
1248        test(p3.get("ghi").length === 2);
1249        test(p3.get("ghi")[0] === "and");
1250        test(p3.get("ghi")[1] === "xor");
1251        test(retval.size === 3);
1252        test(retval.get("abc").length === 3);
1253        test(retval.get("abc")[0] === "abc");
1254        test(retval.get("abc")[1] === "de");
1255        test(retval.get("abc")[2] === "fghi");
1256        test(retval.get("def").length === 2);
1257        test(retval.get("def")[0] === "xyz");
1258        test(retval.get("def")[1] === "or");
1259        test(retval.get("ghi").length === 2);
1260        test(retval.get("ghi")[0] === "and");
1261        test(retval.get("ghi")[1] === "xor");
1262    }
1263
1264    {
1265        const sdi1 = new Test.MyEnumMyEnumSD();
1266        const sdi2 = new Test.MyEnumMyEnumSD();
1267
1268        const si1 = [Test.MyEnum.enum1, Test.MyEnum.enum1, Test.MyEnum.enum2];
1269        const si2 = [Test.MyEnum.enum1, Test.MyEnum.enum2];
1270        const si3 = [Test.MyEnum.enum3, Test.MyEnum.enum3];
1271
1272        sdi1.set(Test.MyEnum.enum3, si1);
1273        sdi1.set(Test.MyEnum.enum2, si2);
1274        sdi2.set(Test.MyEnum.enum1, si3);
1275
1276        const [retval, p3] = await prx.opMyEnumMyEnumSD(sdi1, sdi2);
1277        test(p3.size == 1);
1278        test(p3.get(Test.MyEnum.enum1).length == 2);
1279        test(p3.get(Test.MyEnum.enum1)[0] == Test.MyEnum.enum3);
1280        test(p3.get(Test.MyEnum.enum1)[1] == Test.MyEnum.enum3);
1281        test(retval.size === 3);
1282        test(retval.get(Test.MyEnum.enum3).length == 3);
1283        test(retval.get(Test.MyEnum.enum3)[0] == Test.MyEnum.enum1);
1284        test(retval.get(Test.MyEnum.enum3)[1] == Test.MyEnum.enum1);
1285        test(retval.get(Test.MyEnum.enum3)[2] == Test.MyEnum.enum2);
1286        test(retval.get(Test.MyEnum.enum2).length == 2);
1287        test(retval.get(Test.MyEnum.enum2)[0] == Test.MyEnum.enum1);
1288        test(retval.get(Test.MyEnum.enum2)[1] == Test.MyEnum.enum2);
1289        test(retval.get(Test.MyEnum.enum1).length == 2);
1290        test(retval.get(Test.MyEnum.enum1)[0] == Test.MyEnum.enum3);
1291        test(retval.get(Test.MyEnum.enum1)[1] == Test.MyEnum.enum3);
1292    }
1293
1294    {
1295        const lengths = [0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000];
1296
1297        for(const l of lengths)
1298        {
1299            const s = new Array(l);
1300            for(let i = 0; i < l; ++i)
1301            {
1302                s[i] = i;
1303            }
1304
1305            const r = await prx.opIntS(s);
1306            test(r.length == l);
1307            for(let j = 0; j < r.length; ++j)
1308            {
1309                test(r[j] == -j);
1310            }
1311        }
1312    }
1313
1314    {
1315        const ctx = new Ice.Context();
1316        ctx.set("one", "ONE");
1317        ctx.set("two", "TWO");
1318        ctx.set("three", "THREE");
1319        {
1320            test(prx.ice_getContext().size === 0);
1321            const r = await prx.opContext();
1322            test(!Ice.MapUtil.equals(r, ctx));
1323        }
1324
1325        {
1326            const r = await prx.opContext(ctx);
1327            test(prx.ice_getContext().size === 0);
1328            test(Ice.MapUtil.equals(r, ctx));
1329        }
1330
1331        {
1332            const p2 = await Test.MyClassPrx.checkedCast(prx.ice_context(ctx));
1333            test(Ice.MapUtil.equals(p2.ice_getContext(), ctx));
1334            let r = await p2.opContext();
1335            test(Ice.MapUtil.equals(r, ctx));
1336            r = await p2.opContext(ctx);
1337            test(Ice.MapUtil.equals(r, ctx));
1338        }
1339    }
1340
1341    if(!bidir)
1342    {
1343        //
1344        // Test implicit context propagation
1345        //
1346        const initData = new Ice.InitializationData();
1347        initData.properties = communicator.getProperties().clone();
1348        initData.properties.setProperty("Ice.ImplicitContext", "Shared");
1349
1350        const ic = Ice.initialize(initData);
1351
1352        let ctx = new Ice.Context();
1353        ctx.set("one", "ONE");
1354        ctx.set("two", "TWO");
1355        ctx.set("three", "THREE");
1356
1357        let p3 = Test.MyClassPrx.uncheckedCast(ic.stringToProxy("test:" + helper.getTestEndpoint()));
1358
1359        ic.getImplicitContext().setContext(ctx);
1360        test(Ice.MapUtil.equals(ic.getImplicitContext().getContext(), ctx));
1361        test(Ice.MapUtil.equals(await p3.opContext(), ctx));
1362
1363        test(ic.getImplicitContext().containsKey("zero") == false);
1364        const r = ic.getImplicitContext().put("zero", "ZERO");
1365        test(r === undefined);
1366        test(ic.getImplicitContext().get("zero") == "ZERO");
1367
1368        ctx = ic.getImplicitContext().getContext();
1369        test(Ice.MapUtil.equals(await p3.opContext(), ctx));
1370
1371        const prxContext = new Ice.Context();
1372        prxContext.set("one", "UN");
1373        prxContext.set("four", "QUATRE");
1374
1375        const combined = new Ice.Context(prxContext);
1376        for(const [key, value] of ctx)
1377        {
1378            if(!combined.has(key))
1379            {
1380                combined.set(key, value);
1381            }
1382        }
1383
1384        test(combined.get("one") == "UN");
1385
1386        p3 = Test.MyClassPrx.uncheckedCast(p3.ice_context(prxContext));
1387
1388        ic.getImplicitContext().setContext(null);
1389        test(Ice.MapUtil.equals(await p3.opContext(), prxContext));
1390
1391        ic.getImplicitContext().setContext(ctx);
1392        test(Ice.MapUtil.equals(await p3.opContext(), combined));
1393
1394        test(ic.getImplicitContext().remove("one") == "ONE");
1395
1396        await ic.destroy();
1397    }
1398
1399    {
1400        const d = 1278312346.0 / 13.0;
1401        const ds = [];
1402        for(let i = 0; i < 5; i++)
1403        {
1404            ds[i] = d;
1405        }
1406
1407        await prx.opDoubleMarshaling(d, ds);
1408        await prx.opIdempotent();
1409        await prx.opNonmutating();
1410    }
1411
1412    {
1413
1414        test(await prx.opByte1(0xFF) == 0xFF);
1415        test(await prx.opShort1(0x7FFF) == 0x7FFF);
1416        test(await prx.opInt1(0x7FFFFFFF) == 0x7FFFFFFF);
1417        test((await prx.opLong1(new Ice.Long(0x7FFFFFFF, 0xFFFFFFFF))).equals(new Ice.Long(0x7FFFFFFF, 0xFFFFFFFF)));
1418        test(await prx.opFloat1(1.0) == 1.0);
1419        test(await prx.opDouble1(1.0) == 1.0);
1420        test(await prx.opString1("opString1") == "opString1");
1421        test((await prx.opStringS1(null)).length === 0);
1422        test((await prx.opByteBoolD1(null)).size === 0);
1423        test((await prx.opStringS2(null)).length === 0);
1424        test((await prx.opByteBoolD2(null)).size === 0);
1425
1426        const d = Test.MyDerivedClassPrx.uncheckedCast(prx);
1427        let s = new Test.MyStruct1();
1428        s.tesT = "Test.MyStruct1.s";
1429        s.myClass = null;
1430        s.myStruct1 = "Test.MyStruct1.myStruct1";
1431        s = await d.opMyStruct1(s);
1432        test(s.tesT == "Test.MyStruct1.s");
1433        test(s.myClass === null);
1434        test(s.myStruct1 == "Test.MyStruct1.myStruct1");
1435        let c = new Test.MyClass1();
1436        c.tesT = "Test.MyClass1.testT";
1437        c.myClass = null;
1438        c.myClass1 = "Test.MyClass1.myClass1";
1439        c = await d.opMyClass1(c);
1440        test(c.tesT == "Test.MyClass1.testT");
1441        test(c.myClass === null);
1442        test(c.myClass1 == "Test.MyClass1.myClass1");
1443    }
1444
1445    {
1446        const p1 = await prx.opMStruct1();
1447        p1.e = Test.MyEnum.enum3;
1448        const [p2, p3] = await prx.opMStruct2(p1);
1449        test(p2.equals(p1) && p3.equals(p1));
1450    }
1451
1452    {
1453        await prx.opMSeq1();
1454        const p1 = ["test"];
1455        const [p2, p3] = await prx.opMSeq2(p1);
1456        test(Ice.ArrayUtil.equals(p2, p1) && Ice.ArrayUtil.equals(p3, p1));
1457    }
1458
1459    {
1460        await prx.opMDict1();
1461        const p1 = new Map();
1462        p1.set("test", "test");
1463        const [p2, p3] = await prx.opMDict2(p1);
1464        test(Ice.MapUtil.equals(p2, p1) && Ice.MapUtil.equals(p3, p1));
1465    }
1466
1467    {
1468        const ds = [];
1469        for(let i = 0; i < 5; i++)
1470        {
1471            ds[i] = 1278312346.0 / 13.0;
1472        }
1473        await prx.opDoubleMarshaling(1278312346.0 / 13.0, ds);
1474    }
1475}
1476