Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 300x 300x 1x 1x 300x 300x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 100x 100x 1x 1x 1x 1x 100x 100x 100x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | // Copyright (c) ZeroC, Inc.
import { Ice } from "@zeroc/ice";
import { Test } from "./Test.js";
import { TestHelper, test } from "../../Common/TestHelper.js";
import { Test as ClientPrivate } from "./ClientPrivate.js";
const ArrayUtil = Ice.ArrayUtil;
export class Client extends TestHelper {
async allTests() {
const communicator = this.communicator();
const out = this.getWriter();
const initial = new Test.InitialPrx(communicator, `initial:${this.getTestEndpoint()}`);
out.write("testing marshaling... ");
const oo4 = (await initial.pingPong(new Test.OneOptional()));
test(oo4.a === undefined);
const oo1 = new Test.OneOptional();
oo1.a = 15;
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.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.mips === undefined);
test(mo4.ied === undefined);
test(mo4.ifsd === undefined);
test(mo4.ivsd === undefined);
test(mo4.imipd === 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 = 99n;
mo1.f = 5.5;
mo1.g = 1.0;
mo1.h = "test";
mo1.i = Test.MyEnum.MyEnumMember;
mo1.j = new Test.MyInterfacePrx(communicator, "test");
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.mips = [new Test.MyInterfacePrx(communicator, "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.imipd = new Map();
mo1.imipd.set(5, new Test.MyInterfacePrx(communicator, "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 == 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(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.mips[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.imipd.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.ifsd = mo5.ifsd;
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(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.mips === undefined);
test(mo7.ied === undefined);
test(mo7.ifsd.get(4).equals(new Test.FixedStruct(78)));
test(mo7.ivsd === undefined);
test(mo7.imipd === 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.ss = mo1.ss;
mo8.sid = mo1.sid;
mo8.vs = mo1.vs;
mo8.es = mo1.es;
mo8.vss = mo1.vss;
mo8.mips = mo1.mips;
mo8.ied = mo1.ied;
mo8.ivsd = mo1.ivsd;
mo8.imipd = mo1.imipd;
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 === 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.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.mips[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.imipd.get(5).equals(communicator.stringToProxy("test")));
test(mo9.bos === undefined);
let g = new Test.G();
g.gg1Opt = new Test.G1("gg1Opt");
g.gg2 = new Test.G2(10n);
g.gg2Opt = new Test.G2(20n);
g.gg1 = new Test.G1("gg1");
g = (await initial.opG(g));
test(g.gg1Opt.a == "gg1Opt");
test(g.gg2.a === 10n);
test(g.gg2Opt.a === 20n);
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 members... ");
let f = new Test.F();
f.fsf = new Test.FixedStruct();
f.fse = f.fsf;
f = (await initial.pingPong(f));
test(f.fse.equals(f.fsf));
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);
await initial.opByte(null); // same as initial.opByte(undefined);
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opByte(56);
test(p1 === 56);
test(p2 === 56);
}
{
let [p1, p2] = await initial.opBool();
test(p1 === undefined);
test(p2 === undefined);
await initial.opBool(null); // same as initial.opBool(undefined);
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opBool(true);
test(p1 === true);
test(p2 === true);
}
{
let [p1, p2] = await initial.opShort();
test(p1 === undefined);
test(p2 === undefined);
await initial.opShort(null); // same as initial.opShort(undefined);
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opShort(56);
test(p1 === 56);
test(p2 === 56);
}
{
let [p1, p2] = await initial.opInt();
test(p1 === undefined);
test(p2 === undefined);
await initial.opInt(null); // same as initial.opInt(undefined);
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opInt(56);
test(p1 === 56);
test(p2 === 56);
}
{
let [p1, p2] = await initial.opLong();
test(p1 === undefined);
test(p2 === undefined);
await initial.opLong(null); // same as initial.opLong(undefined);
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opLong(56n);
test(p1 === 56n);
test(p2 === 56n);
}
{
let [p1, p2] = await initial.opFloat();
test(p1 === undefined);
test(p2 === undefined);
await initial.opFloat(null); // same as initial.opFloat(undefined);
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opFloat(1.0);
test(p1 === 1.0);
test(p2 === 1.0);
}
{
let [p1, p2] = await initial.opDouble();
test(p1 === undefined);
test(p2 === undefined);
await initial.opDouble(null); // same as initial.opDouble(undefined);
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opDouble(1.0);
test(p1 === 1.0);
test(p2 === 1.0);
}
{
let [p1, p2] = await initial.opString();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opString(null); // Same as initial.opString(undefined);
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opString("test");
test(p1 === "test");
test(p2 === "test");
}
{
let [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); // Same as initial.opMyEnum(undefined);
test(p1 === undefined);
test(p2 === undefined);
}
{
let [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); // Same as initial.opSmallStruct(undefined);
test(p1 === undefined);
test(p2 === undefined);
}
{
let [p1, p2] = await initial.opFixedStruct();
test(p1 === undefined);
test(p2 === undefined);
await initial.opFixedStruct(null); // same as initial.opFixedStruct(undefined);
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)));
}
{
let [p1, p2] = await initial.opVarStruct();
test(p1 === undefined);
test(p2 === undefined);
await initial.opVarStruct(null); // same as initial.opVarStruct(undefined);
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")));
}
{
let [p1, p2] = await initial.opOneOptional(new Test.OneOptional());
test(p1 === p2);
test(p2.a === undefined);
// Same as initial.opOneOptional(new Test.OneOptional(undefined));
[p1, p2] = await initial.opOneOptional(new Test.OneOptional(null));
test(p1 === p2);
test(p2.a === undefined);
[p1, p2] = await initial.opOneOptional(new Test.OneOptional(58));
test(p1 === p2);
test(p2.a === 58);
}
{
let [p1, p2] = await initial.opMyInterfaceProxy();
test(p1 === undefined);
test(p2 === undefined);
await initial.opMyInterfaceProxy(null); // same as initial.opMyInterfaceProxy(undefined);
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opMyInterfaceProxy(new Test.MyInterfacePrx(communicator, "test"));
test(p1.equals(new Test.MyInterfacePrx(communicator, "test")));
test(p2.equals(new Test.MyInterfacePrx(communicator, "test")));
}
{
let [p1, p2] = await initial.opByteSeq();
test(p1 === undefined);
test(p2 === undefined);
await initial.opByteSeq(null); // same as initial.opByteSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const 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);
}
}
{
let [p1, p2] = await initial.opBoolSeq();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opBoolSeq(null); // same as initial.opBoolSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const 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);
}
}
{
let [p1, p2] = await initial.opShortSeq();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opShortSeq(null); // same as initial.opShortSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const 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);
}
}
{
let [p1, p2] = await initial.opIntSeq();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opIntSeq(null); // same as initial.opIntSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const 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);
}
}
{
let [p1, p2] = await initial.opLongSeq();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opLongSeq(null); // same as initial.opLongSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const data = [];
for (let i = 0; i < 100; ++i) {
data[i] = 56n;
}
[p1, p2] = await initial.opLongSeq(data);
test(p1.length === 100);
test(p2.length === 100);
for (let i = 0; i < 100; ++i) {
test(p1[i] === 56n);
test(p2[i] === 56n);
}
}
{
let [p1, p2] = await initial.opFloatSeq();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opFloatSeq(null); // same as initial.opFloatSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const 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);
}
}
{
let [p1, p2] = await initial.opDoubleSeq();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opDoubleSeq(null); // same as initial.opDoubleSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const 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);
}
}
{
let [p1, p2] = await initial.opStringSeq();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opStringSeq(null); // same as initial.opStringSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const 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");
}
}
{
let [p1, p2] = await initial.opSmallStructSeq();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opSmallStructSeq(null); // same as initial.opSmallStructSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const 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()));
}
}
{
let [p1, p2] = await initial.opFixedStructSeq();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opFixedStructSeq(null); // same as initial.opFixedStructSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const 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()));
}
}
{
let [p1, p2] = await initial.opVarStructSeq();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opVarStructSeq(null); // same as initial.opVarStructSeq(undefined);
test(p1 === undefined);
test(p2 === undefined);
const 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("")));
}
}
{
let [p1, p2] = await initial.opIntIntDict();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opIntIntDict(null); // same as initial.opIntIntDict(undefined);
test(p1 === undefined);
test(p2 === undefined);
const data = new Map();
data.set(1, 2);
data.set(2, 3);
[p1, p2] = await initial.opIntIntDict(data);
test(Ice.MapUtil.equals(p1, p2));
}
{
let [p1, p2] = await initial.opStringIntDict();
test(p1 === undefined);
test(p2 === undefined);
[p1, p2] = await initial.opStringIntDict(null); // same as initial.opStringIntDict(undefined);
test(p1 === undefined);
test(p2 === undefined);
const data = new Map();
data.set("1", 1);
data.set("2", 2);
[p1, p2] = await initial.opStringIntDict(data);
test(Ice.MapUtil.equals(p1, p2));
}
out.writeLine("ok");
out.write("testing exception optionals... ");
try {
await initial.opOptionalException();
test(false);
}
catch (ex) {
if (ex instanceof Test.OptionalException) {
test(ex.a === undefined);
test(ex.b === undefined);
}
else {
test(false, ex);
}
}
try {
await initial.opOptionalException(30, "test");
test(false);
}
catch (ex) {
if (ex instanceof Test.OptionalException) {
test(ex.a === 30);
test(ex.b == "test");
}
else {
test(false, ex);
}
}
try {
await initial.opDerivedException();
test(false);
}
catch (ex) {
if (ex instanceof Test.DerivedException) {
test(ex.a === undefined);
test(ex.b === undefined);
test(ex.ss === undefined);
test(ex.d1 == "d1");
test(ex.d2 == "d2");
}
else {
test(false, ex);
}
}
try {
await initial.opDerivedException(30, "test2");
test(false);
}
catch (ex) {
if (ex instanceof Test.DerivedException) {
test(ex.a === 30);
test(ex.b == "test2");
test(ex.ss == "test2");
}
else {
test(false, ex);
}
}
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);
{
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));
}
out.writeLine("ok");
await initial.shutdown();
}
async run(args) {
let communicator = null;
try {
[communicator] = this.initialize(args);
await this.allTests();
}
finally {
if (communicator) {
await communicator.destroy();
}
}
}
}
|