summaryrefslogtreecommitdiff
path: root/js/test/Ice/scope/Client.js
blob: 2f0f1313de949b41a61958afae52a2eb2785c5f7 (plain)
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
// **********************************************************************
//
// 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 Test = require("Test").Test;
    const Inner = require("Test").Inner;
    const TestHelper = require("TestHelper").TestHelper;
    const test = TestHelper.test;

    class Client extends TestHelper
    {
        async allTests()
        {
            const out = this.getWriter();
            const communicator = this.communicator();

            out.write("test same Slice type name in different scopes... ");

            {
                const i1 = await Test.IPrx.checkedCast(communicator.stringToProxy("i1:" + this.getTestEndpoint()));
                const s1 = new Test.S(0);

                const [s2, s3] = await i1.opS(s1);
                test(s2.equals(s1));
                test(s3.equals(s1));

                const [sseq2, sseq3] = await i1.opSSeq([s1]);
                test(sseq2[0].equals(s1));
                test(sseq3[0].equals(s1));

                const smap1 = new Map([["a", s1]]);
                const [smap2, smap3] = await i1.opSMap(smap1);
                test(smap2.get("a").equals(s1));
                test(smap3.get("a").equals(s1));

                const c1 = new Test.C(s1);

                const [c2, c3] = await i1.opC(c1);
                test(c2.s.equals(s1));
                test(c3.s.equals(s1));

                const [cseq2, cseq3] = await i1.opCSeq([c1]);
                test(cseq2[0].s.equals(s1));
                test(cseq3[0].s.equals(s1));

                const cmap1 = new Map([["a", c1]]);
                const [cmap2, cmap3] = await i1.opCMap(cmap1);
                test(cmap2.get("a").s.equals(s1));
                test(cmap3.get("a").s.equals(s1));
            }

            {
                const i2 = await Test.Inner.Inner2.IPrx.checkedCast(
                    communicator.stringToProxy("i2:" + this.getTestEndpoint()));
                const s1 = new Test.Inner.Inner2.S(0);

                const [s2, s3] = await i2.opS(s1);
                test(s2.equals(s1));
                test(s3.equals(s1));

                const [sseq2, sseq3] = await i2.opSSeq([s1]);
                test(sseq2[0].equals(s1));
                test(sseq3[0].equals(s1));

                const smap1 = new Map([["a", s1]]);
                const [smap2, smap3] = await i2.opSMap(smap1);
                test(smap2.get("a").equals(s1));
                test(smap3.get("a").equals(s1));

                const c1 = new Test.Inner.Inner2.C(s1);

                const [c2, c3] = await i2.opC(c1);
                test(c2.s.equals(s1));
                test(c3.s.equals(s1));

                const [cseq2, cseq3] = await i2.opCSeq([c1]);
                test(cseq2[0].s.equals(s1));
                test(cseq3[0].s.equals(s1));

                const cmap1 = new Map([["a", c1]]);
                const [cmap2, cmap3] = await i2.opCMap(cmap1);
                test(cmap2.get("a").s.equals(s1));
                test(cmap3.get("a").s.equals(s1));
            }

            {
                const i3 = await Test.Inner.IPrx.checkedCast(
                    communicator.stringToProxy("i3:" + this.getTestEndpoint()));
                const s1 = new Test.Inner.Inner2.S(0);

                const [s2, s3] = await i3.opS(s1);
                test(s2.equals(s1));
                test(s3.equals(s1));

                const [sseq2, sseq3] = await i3.opSSeq([s1]);
                test(sseq2[0].equals(s1));
                test(sseq3[0].equals(s1));

                const smap1 = new Map([["a", s1]]);
                const [smap2, smap3] = await i3.opSMap(smap1);
                test(smap2.get("a").equals(s1));
                test(smap3.get("a").equals(s1));

                const c1 = new Test.Inner.Inner2.C(s1);

                const [c2, c3] = await i3.opC(c1);
                test(c2.s.equals(s1));
                test(c3.s.equals(s1));

                const [cseq2, cseq3] = await i3.opCSeq([c1]);
                test(cseq2[0].s.equals(s1));
                test(cseq3[0].s.equals(s1));

                const cmap1 = new Map([["a", c1]]);
                const [cmap2, cmap3] = await i3.opCMap(cmap1);
                test(cmap2.get("a").s.equals(s1));
                test(cmap3.get("a").s.equals(s1));
            }

            {
                const i4 = await Inner.Test.Inner2.IPrx.checkedCast(
                    communicator.stringToProxy("i4:" + this.getTestEndpoint()));
                const s1 = new Test.S(0);

                const [s2, s3] = await i4.opS(s1);
                test(s2.equals(s1));
                test(s3.equals(s1));

                const [sseq2, sseq3] = await i4.opSSeq([s1]);
                test(sseq2[0].equals(s1));
                test(sseq3[0].equals(s1));

                const smap1 = new Map([["a", s1]]);
                const [smap2, smap3] = await i4.opSMap(smap1);
                test(smap2.get("a").equals(s1));
                test(smap3.get("a").equals(s1));

                const c1 = new Test.C(s1);

                const [c2, c3] = await i4.opC(c1);
                test(c2.s.equals(s1));
                test(c3.s.equals(s1));

                const [cseq2, cseq3] = await i4.opCSeq([c1]);
                test(cseq2[0].s.equals(s1));
                test(cseq3[0].s.equals(s1));

                const cmap1 = new Map([["a", c1]]);
                const [cmap2, cmap3] = await i4.opCMap(cmap1);
                test(cmap2.get("a").s.equals(s1));
                test(cmap3.get("a").s.equals(s1));
            }

            {
                const i1 = await Test.IPrx.checkedCast(communicator.stringToProxy("i1:" + this.getTestEndpoint()));
                await i1.shutdown();
            }

            out.writeLine("ok");
        }

        async run(args)
        {
            let communicator;
            try
            {
                [communicator] = this.initialize(args);
                await this.allTests();
            }
            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));