mol_dump_lib 0.0.807 → 0.0.808

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/web.test.js CHANGED
@@ -1,15 +1,6 @@
1
1
  "use strict";
2
2
  function require( path ){ return $node[ path ] };
3
3
  "use strict";
4
-
5
- ;
6
- "use strict";
7
-
8
- ;
9
- "use strict";
10
-
11
- ;
12
- "use strict";
13
4
  var $;
14
5
  (function ($_1) {
15
6
  function $mol_test(set) {
@@ -106,107 +97,12 @@ var $;
106
97
 
107
98
  ;
108
99
  "use strict";
109
- var $;
110
- (function ($) {
111
- function $mol_assert_ok(value) {
112
- if (value)
113
- return;
114
- $mol_fail(new Error(`${value} ≠ true`));
115
- }
116
- $.$mol_assert_ok = $mol_assert_ok;
117
- function $mol_assert_not(value) {
118
- if (!value)
119
- return;
120
- $mol_fail(new Error(`${value} ≠ false`));
121
- }
122
- $.$mol_assert_not = $mol_assert_not;
123
- function $mol_assert_fail(handler, ErrorRight) {
124
- const fail = $.$mol_fail;
125
- try {
126
- $.$mol_fail = $.$mol_fail_hidden;
127
- handler();
128
- }
129
- catch (error) {
130
- $.$mol_fail = fail;
131
- if (typeof ErrorRight === 'string') {
132
- $mol_assert_equal(error.message ?? error, ErrorRight);
133
- }
134
- else {
135
- $mol_assert_equal(error instanceof ErrorRight, true);
136
- }
137
- return error;
138
- }
139
- finally {
140
- $.$mol_fail = fail;
141
- }
142
- $mol_fail(new Error('Not failed'));
143
- }
144
- $.$mol_assert_fail = $mol_assert_fail;
145
- function $mol_assert_like(...args) {
146
- $mol_assert_equal(...args);
147
- }
148
- $.$mol_assert_like = $mol_assert_like;
149
- function $mol_assert_unique(...args) {
150
- for (let i = 0; i < args.length; ++i) {
151
- for (let j = 0; j < args.length; ++j) {
152
- if (i === j)
153
- continue;
154
- if (!$mol_compare_deep(args[i], args[j]))
155
- continue;
156
- return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
157
- }
158
- }
159
- }
160
- $.$mol_assert_unique = $mol_assert_unique;
161
- function $mol_assert_equal(...args) {
162
- for (let i = 1; i < args.length; ++i) {
163
- if ($mol_compare_deep(args[0], args[i]))
164
- continue;
165
- if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
166
- continue;
167
- return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
168
- }
169
- }
170
- $.$mol_assert_equal = $mol_assert_equal;
171
- })($ || ($ = {}));
172
100
 
173
101
  ;
174
102
  "use strict";
175
- var $;
176
- (function ($) {
177
- $mol_test({
178
- 'must be false'() {
179
- $mol_assert_not(0);
180
- },
181
- 'must be true'() {
182
- $mol_assert_ok(1);
183
- },
184
- 'two must be equal'() {
185
- $mol_assert_equal(2, 2);
186
- },
187
- 'three must be equal'() {
188
- $mol_assert_equal(2, 2, 2);
189
- },
190
- 'two must be unique'() {
191
- $mol_assert_unique([2], [3]);
192
- },
193
- 'three must be unique'() {
194
- $mol_assert_unique([1], [2], [3]);
195
- },
196
- 'two must be alike'() {
197
- $mol_assert_like([3], [3]);
198
- },
199
- 'three must be alike'() {
200
- $mol_assert_like([3], [3], [3]);
201
- },
202
- 'two object must be alike'() {
203
- $mol_assert_like({ a: 1 }, { a: 1 });
204
- },
205
- 'three object must be alike'() {
206
- $mol_assert_like({ a: 1 }, { a: 1 }, { a: 1 });
207
- },
208
- });
209
- })($ || ($ = {}));
103
+
104
+ ;
105
+ "use strict";
210
106
 
211
107
  ;
212
108
  "use strict";
@@ -326,400 +222,91 @@ var $;
326
222
  "use strict";
327
223
  var $;
328
224
  (function ($) {
329
- $mol_test({
330
- 'get'() {
331
- const proxy = $mol_delegate({}, () => ({ foo: 777 }));
332
- $mol_assert_equal(proxy.foo, 777);
333
- },
334
- 'has'() {
335
- const proxy = $mol_delegate({}, () => ({ foo: 777 }));
336
- $mol_assert_equal('foo' in proxy, true);
337
- },
338
- 'set'() {
339
- const target = { foo: 777 };
340
- const proxy = $mol_delegate({}, () => target);
341
- proxy.foo = 123;
342
- $mol_assert_equal(target.foo, 123);
343
- },
344
- 'getOwnPropertyDescriptor'() {
345
- const proxy = $mol_delegate({}, () => ({ foo: 777 }));
346
- $mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
347
- value: 777,
348
- writable: true,
349
- enumerable: true,
350
- configurable: true,
351
- });
352
- },
353
- 'ownKeys'() {
354
- const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
355
- $mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
356
- },
357
- 'getPrototypeOf'() {
358
- class Foo {
225
+ function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
226
+ const source = typeof item === 'function' ? new $mol_range2_array() : item;
227
+ if (typeof item !== 'function') {
228
+ item = index => source[index];
229
+ size = () => source.length;
230
+ }
231
+ return new Proxy(source, {
232
+ get(target, field) {
233
+ if (typeof field === 'string') {
234
+ if (field === 'length')
235
+ return size();
236
+ const index = Number(field);
237
+ if (index < 0)
238
+ return undefined;
239
+ if (index >= size())
240
+ return undefined;
241
+ if (index === Math.trunc(index))
242
+ return item(index);
243
+ }
244
+ return $mol_range2_array.prototype[field];
245
+ },
246
+ set(target, field) {
247
+ return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
248
+ },
249
+ ownKeys(target) {
250
+ return [...Array(size())].map((v, i) => String(i)).concat('length');
251
+ },
252
+ getOwnPropertyDescriptor(target, field) {
253
+ if (field === "length")
254
+ return {
255
+ value: size(),
256
+ writable: true,
257
+ enumerable: false,
258
+ configurable: false,
259
+ };
260
+ const index = Number(field);
261
+ if (index === Math.trunc(index))
262
+ return {
263
+ get: () => this.get(target, field, this),
264
+ enumerable: true,
265
+ configurable: true,
266
+ };
267
+ return Object.getOwnPropertyDescriptor(target, field);
359
268
  }
360
- const proxy = $mol_delegate({}, () => new Foo);
361
- $mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
362
- },
363
- 'setPrototypeOf'() {
364
- class Foo {
269
+ });
270
+ }
271
+ $.$mol_range2 = $mol_range2;
272
+ class $mol_range2_array extends Array {
273
+ concat(...tail) {
274
+ if (tail.length === 0)
275
+ return this;
276
+ if (tail.length > 1) {
277
+ let list = this;
278
+ for (let item of tail)
279
+ list = list.concat(item);
280
+ return list;
365
281
  }
366
- const target = {};
367
- const proxy = $mol_delegate({}, () => target);
368
- Object.setPrototypeOf(proxy, Foo.prototype);
369
- $mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
370
- },
371
- 'instanceof'() {
372
- class Foo {
282
+ return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
283
+ }
284
+ filter(check, context) {
285
+ const filtered = [];
286
+ let cursor = -1;
287
+ return $mol_range2(index => {
288
+ while (cursor < this.length && index >= filtered.length - 1) {
289
+ const val = this[++cursor];
290
+ if (check(val, cursor, this))
291
+ filtered.push(val);
292
+ }
293
+ return filtered[index];
294
+ }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
295
+ }
296
+ forEach(proceed, context) {
297
+ for (let [key, value] of this.entries())
298
+ proceed.call(context, value, key, this);
299
+ }
300
+ map(proceed, context) {
301
+ return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
302
+ }
303
+ reduce(merge, result) {
304
+ let index = 0;
305
+ if (arguments.length === 1) {
306
+ result = this[index++];
373
307
  }
374
- const proxy = $mol_delegate({}, () => new Foo);
375
- $mol_assert_ok(proxy instanceof Foo);
376
- $mol_assert_ok(proxy instanceof $mol_delegate);
377
- },
378
- 'autobind'() {
379
- class Foo {
380
- }
381
- const proxy = $mol_delegate({}, () => new Foo);
382
- $mol_assert_ok(proxy instanceof Foo);
383
- $mol_assert_ok(proxy instanceof $mol_delegate);
384
- },
385
- });
386
- })($ || ($ = {}));
387
-
388
- ;
389
- "use strict";
390
-
391
- ;
392
- "use strict";
393
-
394
- ;
395
- "use strict";
396
-
397
- ;
398
- "use strict";
399
- var $;
400
- (function ($_1) {
401
- $mol_test_mocks.push($ => {
402
- $.$mol_log3_come = () => { };
403
- $.$mol_log3_done = () => { };
404
- $.$mol_log3_fail = () => { };
405
- $.$mol_log3_warn = () => { };
406
- $.$mol_log3_rise = () => { };
407
- $.$mol_log3_area = () => () => { };
408
- });
409
- })($ || ($ = {}));
410
-
411
- ;
412
- "use strict";
413
- var $;
414
- (function ($_1) {
415
- $mol_test({
416
- 'FQN of anon function'($) {
417
- const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
418
- $mol_assert_equal($$.$mol_func_name_test.name, '');
419
- $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
420
- $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
421
- },
422
- });
423
- })($ || ($ = {}));
424
-
425
- ;
426
- "use strict";
427
- var $;
428
- (function ($) {
429
- $mol_test({
430
- 'init with overload'() {
431
- class X extends $mol_object {
432
- foo() {
433
- return 1;
434
- }
435
- }
436
- var x = X.make({
437
- foo: () => 2,
438
- });
439
- $mol_assert_equal(x.foo(), 2);
440
- },
441
- });
442
- })($ || ($ = {}));
443
-
444
- ;
445
- "use strict";
446
- var $;
447
- (function ($_1) {
448
- $mol_test({
449
- 'Collect deps'() {
450
- const pub1 = new $mol_wire_pub;
451
- const pub2 = new $mol_wire_pub;
452
- const sub = new $mol_wire_pub_sub;
453
- const bu1 = sub.track_on();
454
- try {
455
- pub1.promote();
456
- pub2.promote();
457
- pub2.promote();
458
- }
459
- finally {
460
- sub.track_cut();
461
- sub.track_off(bu1);
462
- }
463
- pub1.emit();
464
- pub2.emit();
465
- $mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
466
- const bu2 = sub.track_on();
467
- try {
468
- pub1.promote();
469
- pub1.promote();
470
- pub2.promote();
471
- }
472
- finally {
473
- sub.track_cut();
474
- sub.track_off(bu2);
475
- }
476
- pub1.emit();
477
- pub2.emit();
478
- $mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
479
- },
480
- 'cyclic detection'($) {
481
- const sub1 = new $mol_wire_pub_sub;
482
- const sub2 = new $mol_wire_pub_sub;
483
- const bu1 = sub1.track_on();
484
- try {
485
- const bu2 = sub2.track_on();
486
- try {
487
- $mol_assert_fail(() => sub1.promote(), 'Circular subscription');
488
- }
489
- finally {
490
- sub2.track_cut();
491
- sub2.track_off(bu2);
492
- }
493
- }
494
- finally {
495
- sub1.track_cut();
496
- sub1.track_off(bu1);
497
- }
498
- },
499
- });
500
- })($ || ($ = {}));
501
-
502
- ;
503
- "use strict";
504
- var $;
505
- (function ($) {
506
- $.$mol_after_mock_queue = [];
507
- function $mol_after_mock_warp() {
508
- const queue = $.$mol_after_mock_queue.splice(0);
509
- for (const task of queue)
510
- task();
511
- }
512
- $.$mol_after_mock_warp = $mol_after_mock_warp;
513
- class $mol_after_mock_commmon extends $mol_object2 {
514
- task;
515
- promise = Promise.resolve();
516
- cancelled = false;
517
- id;
518
- constructor(task) {
519
- super();
520
- this.task = task;
521
- $.$mol_after_mock_queue.push(task);
522
- }
523
- destructor() {
524
- const index = $.$mol_after_mock_queue.indexOf(this.task);
525
- if (index >= 0)
526
- $.$mol_after_mock_queue.splice(index, 1);
527
- }
528
- }
529
- $.$mol_after_mock_commmon = $mol_after_mock_commmon;
530
- class $mol_after_mock_timeout extends $mol_after_mock_commmon {
531
- delay;
532
- constructor(delay, task) {
533
- super(task);
534
- this.delay = delay;
535
- }
536
- }
537
- $.$mol_after_mock_timeout = $mol_after_mock_timeout;
538
- })($ || ($ = {}));
539
-
540
- ;
541
- "use strict";
542
- var $;
543
- (function ($_1) {
544
- $mol_test_mocks.push($ => {
545
- $.$mol_after_tick = $mol_after_mock_commmon;
546
- });
547
- })($ || ($ = {}));
548
-
549
- ;
550
- "use strict";
551
- var $;
552
- (function ($) {
553
- $mol_test({
554
- 'Sync execution'() {
555
- class Sync extends $mol_object2 {
556
- static calc(a, b) {
557
- return a + b;
558
- }
559
- }
560
- __decorate([
561
- $mol_wire_method
562
- ], Sync, "calc", null);
563
- $mol_assert_equal(Sync.calc(1, 2), 3);
564
- },
565
- async 'async <=> sync'() {
566
- class SyncAsync extends $mol_object2 {
567
- static async val(a) {
568
- return a;
569
- }
570
- static sum(a, b) {
571
- const syn = $mol_wire_sync(this);
572
- return syn.val(a) + syn.val(b);
573
- }
574
- static async calc(a, b) {
575
- return 5 + await $mol_wire_async(this).sum(a, b);
576
- }
577
- }
578
- $mol_assert_equal(await SyncAsync.calc(1, 2), 8);
579
- },
580
- async 'Idempotence control'() {
581
- class Idempotence extends $mol_object2 {
582
- static logs_idemp = 0;
583
- static logs_unidemp = 0;
584
- static log_idemp() {
585
- this.logs_idemp += 1;
586
- }
587
- static log_unidemp() {
588
- this.logs_unidemp += 1;
589
- }
590
- static async val(a) {
591
- return a;
592
- }
593
- static sum(a, b) {
594
- this.log_idemp();
595
- this.log_unidemp();
596
- const syn = $mol_wire_sync(this);
597
- return syn.val(a) + syn.val(b);
598
- }
599
- static async calc(a, b) {
600
- return 5 + await $mol_wire_async(this).sum(a, b);
601
- }
602
- }
603
- __decorate([
604
- $mol_wire_method
605
- ], Idempotence, "log_idemp", null);
606
- $mol_assert_equal(await Idempotence.calc(1, 2), 8);
607
- $mol_assert_equal(Idempotence.logs_idemp, 1);
608
- $mol_assert_equal(Idempotence.logs_unidemp, 3);
609
- },
610
- async 'Error handling'() {
611
- class Handle extends $mol_object2 {
612
- static async sum(a, b) {
613
- $mol_fail(new Error('test error ' + (a + b)));
614
- }
615
- static check() {
616
- try {
617
- return $mol_wire_sync(Handle).sum(1, 2);
618
- }
619
- catch (error) {
620
- if ($mol_promise_like(error))
621
- $mol_fail_hidden(error);
622
- $mol_assert_equal(error.message, 'test error 3');
623
- }
624
- }
625
- }
626
- await $mol_wire_async(Handle).check();
627
- },
628
- });
629
- })($ || ($ = {}));
630
-
631
- ;
632
- "use strict";
633
-
634
- ;
635
- "use strict";
636
- var $;
637
- (function ($) {
638
- function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
639
- const source = typeof item === 'function' ? new $mol_range2_array() : item;
640
- if (typeof item !== 'function') {
641
- item = index => source[index];
642
- size = () => source.length;
643
- }
644
- return new Proxy(source, {
645
- get(target, field) {
646
- if (typeof field === 'string') {
647
- if (field === 'length')
648
- return size();
649
- const index = Number(field);
650
- if (index < 0)
651
- return undefined;
652
- if (index >= size())
653
- return undefined;
654
- if (index === Math.trunc(index))
655
- return item(index);
656
- }
657
- return $mol_range2_array.prototype[field];
658
- },
659
- set(target, field) {
660
- return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
661
- },
662
- ownKeys(target) {
663
- return [...Array(size())].map((v, i) => String(i)).concat('length');
664
- },
665
- getOwnPropertyDescriptor(target, field) {
666
- if (field === "length")
667
- return {
668
- value: size(),
669
- writable: true,
670
- enumerable: false,
671
- configurable: false,
672
- };
673
- const index = Number(field);
674
- if (index === Math.trunc(index))
675
- return {
676
- get: () => this.get(target, field, this),
677
- enumerable: true,
678
- configurable: true,
679
- };
680
- return Object.getOwnPropertyDescriptor(target, field);
681
- }
682
- });
683
- }
684
- $.$mol_range2 = $mol_range2;
685
- class $mol_range2_array extends Array {
686
- concat(...tail) {
687
- if (tail.length === 0)
688
- return this;
689
- if (tail.length > 1) {
690
- let list = this;
691
- for (let item of tail)
692
- list = list.concat(item);
693
- return list;
694
- }
695
- return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
696
- }
697
- filter(check, context) {
698
- const filtered = [];
699
- let cursor = -1;
700
- return $mol_range2(index => {
701
- while (cursor < this.length && index >= filtered.length - 1) {
702
- const val = this[++cursor];
703
- if (check(val, cursor, this))
704
- filtered.push(val);
705
- }
706
- return filtered[index];
707
- }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
708
- }
709
- forEach(proceed, context) {
710
- for (let [key, value] of this.entries())
711
- proceed.call(context, value, key, this);
712
- }
713
- map(proceed, context) {
714
- return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
715
- }
716
- reduce(merge, result) {
717
- let index = 0;
718
- if (arguments.length === 1) {
719
- result = this[index++];
720
- }
721
- for (; index < this.length; ++index) {
722
- result = merge(result, this[index], index, this);
308
+ for (; index < this.length; ++index) {
309
+ result = merge(result, this[index], index, this);
723
310
  }
724
311
  return result;
725
312
  }
@@ -890,160 +477,573 @@ var $;
890
477
  $mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
891
478
  $mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
892
479
  },
893
- 'lazyfy'() {
894
- let calls = 0;
895
- const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
896
- $mol_assert_equal(true, list instanceof Array);
897
- $mol_assert_equal(list.length, 4);
898
- $mol_assert_equal(calls, 0);
899
- $mol_assert_equal(list[0], 12);
900
- $mol_assert_equal(list[3], 15);
901
- $mol_assert_equal(list[4], undefined);
902
- $mol_assert_equal(calls, 2);
480
+ 'lazyfy'() {
481
+ let calls = 0;
482
+ const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
483
+ $mol_assert_equal(true, list instanceof Array);
484
+ $mol_assert_equal(list.length, 4);
485
+ $mol_assert_equal(calls, 0);
486
+ $mol_assert_equal(list[0], 12);
487
+ $mol_assert_equal(list[3], 15);
488
+ $mol_assert_equal(list[4], undefined);
489
+ $mol_assert_equal(calls, 2);
490
+ },
491
+ 'prevent modification'() {
492
+ const list = $mol_range2(i => i, () => 5);
493
+ $mol_assert_fail(() => list.push(4), TypeError);
494
+ $mol_assert_fail(() => list.pop(), TypeError);
495
+ $mol_assert_fail(() => list.unshift(4), TypeError);
496
+ $mol_assert_fail(() => list.shift(), TypeError);
497
+ $mol_assert_fail(() => list.splice(1, 2), TypeError);
498
+ $mol_assert_fail(() => list[1] = 2, TypeError);
499
+ $mol_assert_fail(() => list.reverse(), TypeError);
500
+ $mol_assert_fail(() => list.sort(), TypeError);
501
+ $mol_assert_equal(list.toString(), '0,1,2,3,4');
502
+ }
503
+ });
504
+ })($ || ($ = {}));
505
+
506
+ ;
507
+ "use strict";
508
+ var $;
509
+ (function ($) {
510
+ $mol_test({
511
+ 'nulls & undefineds'() {
512
+ $mol_assert_ok($mol_compare_deep(null, null));
513
+ $mol_assert_ok($mol_compare_deep(undefined, undefined));
514
+ $mol_assert_not($mol_compare_deep(undefined, null));
515
+ $mol_assert_not($mol_compare_deep({}, null));
516
+ },
517
+ 'number'() {
518
+ $mol_assert_ok($mol_compare_deep(1, 1));
519
+ $mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
520
+ $mol_assert_not($mol_compare_deep(1, 2));
521
+ $mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
522
+ $mol_assert_not($mol_compare_deep(Object(1), Object(2)));
523
+ },
524
+ 'POJO'() {
525
+ $mol_assert_ok($mol_compare_deep({}, {}));
526
+ $mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
527
+ $mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
528
+ $mol_assert_not($mol_compare_deep({}, { a: undefined }));
529
+ $mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
530
+ $mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
531
+ $mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
532
+ },
533
+ 'Array'() {
534
+ $mol_assert_ok($mol_compare_deep([], []));
535
+ $mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
536
+ $mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
537
+ $mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
538
+ $mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
539
+ $mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
540
+ },
541
+ 'Non POJO are different'() {
542
+ class Thing extends Object {
543
+ }
544
+ $mol_assert_not($mol_compare_deep(new Thing, new Thing));
545
+ $mol_assert_not($mol_compare_deep(() => 1, () => 1));
546
+ $mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
547
+ },
548
+ 'POJO with symbols'() {
549
+ const sym = Symbol();
550
+ $mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
551
+ $mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
552
+ },
553
+ 'same POJOs with cyclic reference'() {
554
+ const a = { foo: {} };
555
+ a['self'] = a;
556
+ const b = { foo: {} };
557
+ b['self'] = b;
558
+ $mol_assert_ok($mol_compare_deep(a, b));
559
+ },
560
+ 'same POJOs with cyclic reference with cache warmup'() {
561
+ const obj1 = { test: 1, obj3: null };
562
+ const obj1_copy = { test: 1, obj3: null };
563
+ const obj2 = { test: 2, obj1 };
564
+ const obj2_copy = { test: 2, obj1: obj1_copy };
565
+ const obj3 = { test: 3, obj2 };
566
+ const obj3_copy = { test: 3, obj2: obj2_copy };
567
+ obj1.obj3 = obj3;
568
+ obj1_copy.obj3 = obj3_copy;
569
+ $mol_assert_not($mol_compare_deep(obj1, {}));
570
+ $mol_assert_not($mol_compare_deep(obj2, {}));
571
+ $mol_assert_not($mol_compare_deep(obj3, {}));
572
+ $mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
573
+ },
574
+ 'Date'() {
575
+ $mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
576
+ $mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
577
+ },
578
+ 'RegExp'() {
579
+ $mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
580
+ $mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
581
+ $mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
582
+ },
583
+ 'Error'() {
584
+ $mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
585
+ const fail = (message) => new Error(message);
586
+ $mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
587
+ $mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
588
+ },
589
+ 'Map'() {
590
+ $mol_assert_ok($mol_compare_deep(new Map, new Map));
591
+ $mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
592
+ $mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
593
+ $mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
594
+ $mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
595
+ },
596
+ 'Set'() {
597
+ $mol_assert_ok($mol_compare_deep(new Set, new Set));
598
+ $mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
599
+ $mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
600
+ },
601
+ 'Uint8Array'() {
602
+ $mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
603
+ $mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
604
+ $mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
605
+ },
606
+ 'DataView'() {
607
+ $mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
608
+ $mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
609
+ $mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
610
+ },
611
+ 'Serializale'() {
612
+ class User {
613
+ name;
614
+ rand;
615
+ constructor(name, rand = Math.random()) {
616
+ this.name = name;
617
+ this.rand = rand;
618
+ }
619
+ [Symbol.toPrimitive](mode) {
620
+ return this.name;
621
+ }
622
+ }
623
+ $mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
624
+ $mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
625
+ },
626
+ 'Iterable'() {
627
+ $mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
628
+ $mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
629
+ $mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
630
+ },
631
+ });
632
+ })($ || ($ = {}));
633
+
634
+ ;
635
+ "use strict";
636
+ var $;
637
+ (function ($) {
638
+ function $mol_assert_ok(value) {
639
+ if (value)
640
+ return;
641
+ $mol_fail(new Error(`${value} ≠ true`));
642
+ }
643
+ $.$mol_assert_ok = $mol_assert_ok;
644
+ function $mol_assert_not(value) {
645
+ if (!value)
646
+ return;
647
+ $mol_fail(new Error(`${value} ≠ false`));
648
+ }
649
+ $.$mol_assert_not = $mol_assert_not;
650
+ function $mol_assert_fail(handler, ErrorRight) {
651
+ const fail = $.$mol_fail;
652
+ try {
653
+ $.$mol_fail = $.$mol_fail_hidden;
654
+ handler();
655
+ }
656
+ catch (error) {
657
+ $.$mol_fail = fail;
658
+ if (typeof ErrorRight === 'string') {
659
+ $mol_assert_equal(error.message ?? error, ErrorRight);
660
+ }
661
+ else {
662
+ $mol_assert_equal(error instanceof ErrorRight, true);
663
+ }
664
+ return error;
665
+ }
666
+ finally {
667
+ $.$mol_fail = fail;
668
+ }
669
+ $mol_fail(new Error('Not failed'));
670
+ }
671
+ $.$mol_assert_fail = $mol_assert_fail;
672
+ function $mol_assert_like(...args) {
673
+ $mol_assert_equal(...args);
674
+ }
675
+ $.$mol_assert_like = $mol_assert_like;
676
+ function $mol_assert_unique(...args) {
677
+ for (let i = 0; i < args.length; ++i) {
678
+ for (let j = 0; j < args.length; ++j) {
679
+ if (i === j)
680
+ continue;
681
+ if (!$mol_compare_deep(args[i], args[j]))
682
+ continue;
683
+ return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
684
+ }
685
+ }
686
+ }
687
+ $.$mol_assert_unique = $mol_assert_unique;
688
+ function $mol_assert_equal(...args) {
689
+ for (let i = 1; i < args.length; ++i) {
690
+ if ($mol_compare_deep(args[0], args[i]))
691
+ continue;
692
+ if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
693
+ continue;
694
+ return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
695
+ }
696
+ }
697
+ $.$mol_assert_equal = $mol_assert_equal;
698
+ })($ || ($ = {}));
699
+
700
+ ;
701
+ "use strict";
702
+ var $;
703
+ (function ($) {
704
+ $mol_test({
705
+ 'must be false'() {
706
+ $mol_assert_not(0);
707
+ },
708
+ 'must be true'() {
709
+ $mol_assert_ok(1);
710
+ },
711
+ 'two must be equal'() {
712
+ $mol_assert_equal(2, 2);
713
+ },
714
+ 'three must be equal'() {
715
+ $mol_assert_equal(2, 2, 2);
716
+ },
717
+ 'two must be unique'() {
718
+ $mol_assert_unique([2], [3]);
719
+ },
720
+ 'three must be unique'() {
721
+ $mol_assert_unique([1], [2], [3]);
722
+ },
723
+ 'two must be alike'() {
724
+ $mol_assert_like([3], [3]);
725
+ },
726
+ 'three must be alike'() {
727
+ $mol_assert_like([3], [3], [3]);
728
+ },
729
+ 'two object must be alike'() {
730
+ $mol_assert_like({ a: 1 }, { a: 1 });
903
731
  },
904
- 'prevent modification'() {
905
- const list = $mol_range2(i => i, () => 5);
906
- $mol_assert_fail(() => list.push(4), TypeError);
907
- $mol_assert_fail(() => list.pop(), TypeError);
908
- $mol_assert_fail(() => list.unshift(4), TypeError);
909
- $mol_assert_fail(() => list.shift(), TypeError);
910
- $mol_assert_fail(() => list.splice(1, 2), TypeError);
911
- $mol_assert_fail(() => list[1] = 2, TypeError);
912
- $mol_assert_fail(() => list.reverse(), TypeError);
913
- $mol_assert_fail(() => list.sort(), TypeError);
914
- $mol_assert_equal(list.toString(), '0,1,2,3,4');
915
- }
732
+ 'three object must be alike'() {
733
+ $mol_assert_like({ a: 1 }, { a: 1 }, { a: 1 });
734
+ },
735
+ });
736
+ })($ || ($ = {}));
737
+
738
+ ;
739
+ "use strict";
740
+
741
+ ;
742
+ "use strict";
743
+
744
+ ;
745
+ "use strict";
746
+ var $;
747
+ (function ($_1) {
748
+ $mol_test_mocks.push($ => {
749
+ $.$mol_log3_come = () => { };
750
+ $.$mol_log3_done = () => { };
751
+ $.$mol_log3_fail = () => { };
752
+ $.$mol_log3_warn = () => { };
753
+ $.$mol_log3_rise = () => { };
754
+ $.$mol_log3_area = () => () => { };
916
755
  });
917
756
  })($ || ($ = {}));
918
757
 
919
758
  ;
920
759
  "use strict";
921
760
  var $;
922
- (function ($) {
761
+ (function ($_1) {
923
762
  $mol_test({
924
- 'nulls & undefineds'() {
925
- $mol_assert_ok($mol_compare_deep(null, null));
926
- $mol_assert_ok($mol_compare_deep(undefined, undefined));
927
- $mol_assert_not($mol_compare_deep(undefined, null));
928
- $mol_assert_not($mol_compare_deep({}, null));
763
+ 'FQN of anon function'($) {
764
+ const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
765
+ $mol_assert_equal($$.$mol_func_name_test.name, '');
766
+ $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
767
+ $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
929
768
  },
930
- 'number'() {
931
- $mol_assert_ok($mol_compare_deep(1, 1));
932
- $mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
933
- $mol_assert_not($mol_compare_deep(1, 2));
934
- $mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
935
- $mol_assert_not($mol_compare_deep(Object(1), Object(2)));
769
+ });
770
+ })($ || ($ = {}));
771
+
772
+ ;
773
+ "use strict";
774
+ var $;
775
+ (function ($) {
776
+ $mol_test({
777
+ 'get'() {
778
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
779
+ $mol_assert_equal(proxy.foo, 777);
936
780
  },
937
- 'POJO'() {
938
- $mol_assert_ok($mol_compare_deep({}, {}));
939
- $mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
940
- $mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
941
- $mol_assert_not($mol_compare_deep({}, { a: undefined }));
942
- $mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
943
- $mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
944
- $mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
781
+ 'has'() {
782
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
783
+ $mol_assert_equal('foo' in proxy, true);
945
784
  },
946
- 'Array'() {
947
- $mol_assert_ok($mol_compare_deep([], []));
948
- $mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
949
- $mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
950
- $mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
951
- $mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
952
- $mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
785
+ 'set'() {
786
+ const target = { foo: 777 };
787
+ const proxy = $mol_delegate({}, () => target);
788
+ proxy.foo = 123;
789
+ $mol_assert_equal(target.foo, 123);
953
790
  },
954
- 'Non POJO are different'() {
955
- class Thing extends Object {
956
- }
957
- $mol_assert_not($mol_compare_deep(new Thing, new Thing));
958
- $mol_assert_not($mol_compare_deep(() => 1, () => 1));
959
- $mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
791
+ 'getOwnPropertyDescriptor'() {
792
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
793
+ $mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
794
+ value: 777,
795
+ writable: true,
796
+ enumerable: true,
797
+ configurable: true,
798
+ });
960
799
  },
961
- 'POJO with symbols'() {
962
- const sym = Symbol();
963
- $mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
964
- $mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
800
+ 'ownKeys'() {
801
+ const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
802
+ $mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
965
803
  },
966
- 'same POJOs with cyclic reference'() {
967
- const a = { foo: {} };
968
- a['self'] = a;
969
- const b = { foo: {} };
970
- b['self'] = b;
971
- $mol_assert_ok($mol_compare_deep(a, b));
804
+ 'getPrototypeOf'() {
805
+ class Foo {
806
+ }
807
+ const proxy = $mol_delegate({}, () => new Foo);
808
+ $mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
972
809
  },
973
- 'same POJOs with cyclic reference with cache warmup'() {
974
- const obj1 = { test: 1, obj3: null };
975
- const obj1_copy = { test: 1, obj3: null };
976
- const obj2 = { test: 2, obj1 };
977
- const obj2_copy = { test: 2, obj1: obj1_copy };
978
- const obj3 = { test: 3, obj2 };
979
- const obj3_copy = { test: 3, obj2: obj2_copy };
980
- obj1.obj3 = obj3;
981
- obj1_copy.obj3 = obj3_copy;
982
- $mol_assert_not($mol_compare_deep(obj1, {}));
983
- $mol_assert_not($mol_compare_deep(obj2, {}));
984
- $mol_assert_not($mol_compare_deep(obj3, {}));
985
- $mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
810
+ 'setPrototypeOf'() {
811
+ class Foo {
812
+ }
813
+ const target = {};
814
+ const proxy = $mol_delegate({}, () => target);
815
+ Object.setPrototypeOf(proxy, Foo.prototype);
816
+ $mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
986
817
  },
987
- 'Date'() {
988
- $mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
989
- $mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
818
+ 'instanceof'() {
819
+ class Foo {
820
+ }
821
+ const proxy = $mol_delegate({}, () => new Foo);
822
+ $mol_assert_ok(proxy instanceof Foo);
823
+ $mol_assert_ok(proxy instanceof $mol_delegate);
990
824
  },
991
- 'RegExp'() {
992
- $mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
993
- $mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
994
- $mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
825
+ 'autobind'() {
826
+ class Foo {
827
+ }
828
+ const proxy = $mol_delegate({}, () => new Foo);
829
+ $mol_assert_ok(proxy instanceof Foo);
830
+ $mol_assert_ok(proxy instanceof $mol_delegate);
995
831
  },
996
- 'Error'() {
997
- $mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
998
- const fail = (message) => new Error(message);
999
- $mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
1000
- $mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
832
+ });
833
+ })($ || ($ = {}));
834
+
835
+ ;
836
+ "use strict";
837
+
838
+ ;
839
+ "use strict";
840
+ var $;
841
+ (function ($) {
842
+ $mol_test({
843
+ 'init with overload'() {
844
+ class X extends $mol_object {
845
+ foo() {
846
+ return 1;
847
+ }
848
+ }
849
+ var x = X.make({
850
+ foo: () => 2,
851
+ });
852
+ $mol_assert_equal(x.foo(), 2);
1001
853
  },
1002
- 'Map'() {
1003
- $mol_assert_ok($mol_compare_deep(new Map, new Map));
1004
- $mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
1005
- $mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
1006
- $mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
1007
- $mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
854
+ });
855
+ })($ || ($ = {}));
856
+
857
+ ;
858
+ "use strict";
859
+ var $;
860
+ (function ($_1) {
861
+ $mol_test({
862
+ 'Collect deps'() {
863
+ const pub1 = new $mol_wire_pub;
864
+ const pub2 = new $mol_wire_pub;
865
+ const sub = new $mol_wire_pub_sub;
866
+ const bu1 = sub.track_on();
867
+ try {
868
+ pub1.promote();
869
+ pub2.promote();
870
+ pub2.promote();
871
+ }
872
+ finally {
873
+ sub.track_cut();
874
+ sub.track_off(bu1);
875
+ }
876
+ pub1.emit();
877
+ pub2.emit();
878
+ $mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
879
+ const bu2 = sub.track_on();
880
+ try {
881
+ pub1.promote();
882
+ pub1.promote();
883
+ pub2.promote();
884
+ }
885
+ finally {
886
+ sub.track_cut();
887
+ sub.track_off(bu2);
888
+ }
889
+ pub1.emit();
890
+ pub2.emit();
891
+ $mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
1008
892
  },
1009
- 'Set'() {
1010
- $mol_assert_ok($mol_compare_deep(new Set, new Set));
1011
- $mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
1012
- $mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
893
+ 'cyclic detection'($) {
894
+ const sub1 = new $mol_wire_pub_sub;
895
+ const sub2 = new $mol_wire_pub_sub;
896
+ const bu1 = sub1.track_on();
897
+ try {
898
+ const bu2 = sub2.track_on();
899
+ try {
900
+ $mol_assert_fail(() => sub1.promote(), 'Circular subscription');
901
+ }
902
+ finally {
903
+ sub2.track_cut();
904
+ sub2.track_off(bu2);
905
+ }
906
+ }
907
+ finally {
908
+ sub1.track_cut();
909
+ sub1.track_off(bu1);
910
+ }
1013
911
  },
1014
- 'Uint8Array'() {
1015
- $mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
1016
- $mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
1017
- $mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
912
+ });
913
+ })($ || ($ = {}));
914
+
915
+ ;
916
+ "use strict";
917
+ var $;
918
+ (function ($) {
919
+ $.$mol_after_mock_queue = [];
920
+ function $mol_after_mock_warp() {
921
+ const queue = $.$mol_after_mock_queue.splice(0);
922
+ for (const task of queue)
923
+ task();
924
+ }
925
+ $.$mol_after_mock_warp = $mol_after_mock_warp;
926
+ class $mol_after_mock_commmon extends $mol_object2 {
927
+ task;
928
+ promise = Promise.resolve();
929
+ cancelled = false;
930
+ id;
931
+ constructor(task) {
932
+ super();
933
+ this.task = task;
934
+ $.$mol_after_mock_queue.push(task);
935
+ }
936
+ destructor() {
937
+ const index = $.$mol_after_mock_queue.indexOf(this.task);
938
+ if (index >= 0)
939
+ $.$mol_after_mock_queue.splice(index, 1);
940
+ }
941
+ }
942
+ $.$mol_after_mock_commmon = $mol_after_mock_commmon;
943
+ class $mol_after_mock_timeout extends $mol_after_mock_commmon {
944
+ delay;
945
+ constructor(delay, task) {
946
+ super(task);
947
+ this.delay = delay;
948
+ }
949
+ }
950
+ $.$mol_after_mock_timeout = $mol_after_mock_timeout;
951
+ })($ || ($ = {}));
952
+
953
+ ;
954
+ "use strict";
955
+ var $;
956
+ (function ($_1) {
957
+ $mol_test_mocks.push($ => {
958
+ $.$mol_after_tick = $mol_after_mock_commmon;
959
+ });
960
+ })($ || ($ = {}));
961
+
962
+ ;
963
+ "use strict";
964
+ var $;
965
+ (function ($) {
966
+ $mol_test({
967
+ 'Sync execution'() {
968
+ class Sync extends $mol_object2 {
969
+ static calc(a, b) {
970
+ return a + b;
971
+ }
972
+ }
973
+ __decorate([
974
+ $mol_wire_method
975
+ ], Sync, "calc", null);
976
+ $mol_assert_equal(Sync.calc(1, 2), 3);
1018
977
  },
1019
- 'DataView'() {
1020
- $mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
1021
- $mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
1022
- $mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
978
+ async 'async <=> sync'() {
979
+ class SyncAsync extends $mol_object2 {
980
+ static async val(a) {
981
+ return a;
982
+ }
983
+ static sum(a, b) {
984
+ const syn = $mol_wire_sync(this);
985
+ return syn.val(a) + syn.val(b);
986
+ }
987
+ static async calc(a, b) {
988
+ return 5 + await $mol_wire_async(this).sum(a, b);
989
+ }
990
+ }
991
+ $mol_assert_equal(await SyncAsync.calc(1, 2), 8);
1023
992
  },
1024
- 'Serializale'() {
1025
- class User {
1026
- name;
1027
- rand;
1028
- constructor(name, rand = Math.random()) {
1029
- this.name = name;
1030
- this.rand = rand;
993
+ async 'Idempotence control'() {
994
+ class Idempotence extends $mol_object2 {
995
+ static logs_idemp = 0;
996
+ static logs_unidemp = 0;
997
+ static log_idemp() {
998
+ this.logs_idemp += 1;
1031
999
  }
1032
- [Symbol.toPrimitive](mode) {
1033
- return this.name;
1000
+ static log_unidemp() {
1001
+ this.logs_unidemp += 1;
1002
+ }
1003
+ static async val(a) {
1004
+ return a;
1005
+ }
1006
+ static sum(a, b) {
1007
+ this.log_idemp();
1008
+ this.log_unidemp();
1009
+ const syn = $mol_wire_sync(this);
1010
+ return syn.val(a) + syn.val(b);
1011
+ }
1012
+ static async calc(a, b) {
1013
+ return 5 + await $mol_wire_async(this).sum(a, b);
1034
1014
  }
1035
1015
  }
1036
- $mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
1037
- $mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
1016
+ __decorate([
1017
+ $mol_wire_method
1018
+ ], Idempotence, "log_idemp", null);
1019
+ $mol_assert_equal(await Idempotence.calc(1, 2), 8);
1020
+ $mol_assert_equal(Idempotence.logs_idemp, 1);
1021
+ $mol_assert_equal(Idempotence.logs_unidemp, 3);
1038
1022
  },
1039
- 'Iterable'() {
1040
- $mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
1041
- $mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
1042
- $mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
1023
+ async 'Error handling'() {
1024
+ class Handle extends $mol_object2 {
1025
+ static async sum(a, b) {
1026
+ $mol_fail(new Error('test error ' + (a + b)));
1027
+ }
1028
+ static check() {
1029
+ try {
1030
+ return $mol_wire_sync(Handle).sum(1, 2);
1031
+ }
1032
+ catch (error) {
1033
+ if ($mol_promise_like(error))
1034
+ $mol_fail_hidden(error);
1035
+ $mol_assert_equal(error.message, 'test error 3');
1036
+ }
1037
+ }
1038
+ }
1039
+ await $mol_wire_async(Handle).check();
1043
1040
  },
1044
1041
  });
1045
1042
  })($ || ($ = {}));
1046
1043
 
1044
+ ;
1045
+ "use strict";
1046
+
1047
1047
  ;
1048
1048
  "use strict";
1049
1049
  var $;
@@ -1861,6 +1861,15 @@ var $;
1861
1861
  });
1862
1862
  })($ || ($ = {}));
1863
1863
 
1864
+ ;
1865
+ "use strict";
1866
+ var $;
1867
+ (function ($_1) {
1868
+ $mol_test_mocks.push($ => {
1869
+ $.$mol_after_frame = $mol_after_mock_commmon;
1870
+ });
1871
+ })($ || ($ = {}));
1872
+
1864
1873
  ;
1865
1874
  "use strict";
1866
1875
  var $;
@@ -1922,15 +1931,6 @@ var $;
1922
1931
  });
1923
1932
  })($ || ($ = {}));
1924
1933
 
1925
- ;
1926
- "use strict";
1927
- var $;
1928
- (function ($_1) {
1929
- $mol_test_mocks.push($ => {
1930
- $.$mol_after_frame = $mol_after_mock_commmon;
1931
- });
1932
- })($ || ($ = {}));
1933
-
1934
1934
  ;
1935
1935
  "use strict";
1936
1936
 
@@ -2025,6 +2025,95 @@ var $;
2025
2025
  $mol_wire_log.active();
2026
2026
  })($ || ($ = {}));
2027
2027
 
2028
+ ;
2029
+ "use strict";
2030
+ var $;
2031
+ (function ($_1) {
2032
+ $mol_test_mocks.push(context => {
2033
+ class $mol_state_arg_mock extends $mol_state_arg {
2034
+ static $ = context;
2035
+ static href(next) { return next || ''; }
2036
+ static go(next) {
2037
+ this.href(this.link(next));
2038
+ }
2039
+ }
2040
+ __decorate([
2041
+ $mol_mem
2042
+ ], $mol_state_arg_mock, "href", null);
2043
+ __decorate([
2044
+ $mol_action
2045
+ ], $mol_state_arg_mock, "go", null);
2046
+ context.$mol_state_arg = $mol_state_arg_mock;
2047
+ });
2048
+ $mol_test({
2049
+ 'args as dictionary'($) {
2050
+ $.$mol_state_arg.href('#!foo=bar/xxx');
2051
+ $mol_assert_equal($.$mol_state_arg.dict(), { foo: 'bar', xxx: '' });
2052
+ $.$mol_state_arg.dict({ foo: null, yyy: '', lol: '123' });
2053
+ $mol_assert_equal($.$mol_state_arg.href().replace(/.*#/, '#'), '#!yyy/lol=123');
2054
+ },
2055
+ 'one value from args'($) {
2056
+ $.$mol_state_arg.href('#!foo=bar/xxx');
2057
+ $mol_assert_equal($.$mol_state_arg.value('foo'), 'bar');
2058
+ $mol_assert_equal($.$mol_state_arg.value('xxx'), '');
2059
+ $.$mol_state_arg.value('foo', 'lol');
2060
+ $mol_assert_equal($.$mol_state_arg.href().replace(/.*#/, '#'), '#!foo=lol/xxx');
2061
+ $.$mol_state_arg.value('foo', '');
2062
+ $mol_assert_equal($.$mol_state_arg.href().replace(/.*#/, '#'), '#!foo/xxx');
2063
+ $.$mol_state_arg.value('foo', null);
2064
+ $mol_assert_equal($.$mol_state_arg.href().replace(/.*#/, '#'), '#!xxx');
2065
+ },
2066
+ 'nested args'($) {
2067
+ const base = new $.$mol_state_arg('nested.');
2068
+ class Nested extends $mol_state_arg {
2069
+ constructor(prefix) {
2070
+ super(base.prefix + prefix);
2071
+ }
2072
+ static value = (key, next) => base.value(key, next);
2073
+ }
2074
+ $.$mol_state_arg.href('#!foo=bar/nested.xxx=123');
2075
+ $mol_assert_equal(Nested.value('foo'), null);
2076
+ $mol_assert_equal(Nested.value('xxx'), '123');
2077
+ Nested.value('foo', 'lol');
2078
+ $mol_assert_equal($.$mol_state_arg.href().replace(/.*#/, '#'), '#!foo=bar/nested.xxx=123/nested.foo=lol');
2079
+ },
2080
+ });
2081
+ })($ || ($ = {}));
2082
+
2083
+ ;
2084
+ "use strict";
2085
+ var $;
2086
+ (function ($) {
2087
+ $mol_test({
2088
+ 'local get set delete'() {
2089
+ var key = '$mol_state_local_test:' + Math.random();
2090
+ $mol_assert_equal($mol_state_local.value(key), null);
2091
+ $mol_state_local.value(key, 123);
2092
+ $mol_assert_equal($mol_state_local.value(key), 123);
2093
+ $mol_state_local.value(key, null);
2094
+ $mol_assert_equal($mol_state_local.value(key), null);
2095
+ },
2096
+ });
2097
+ })($ || ($ = {}));
2098
+
2099
+ ;
2100
+ "use strict";
2101
+ var $;
2102
+ (function ($) {
2103
+ $mol_test_mocks.push(context => {
2104
+ class $mol_state_local_mock extends $mol_state_local {
2105
+ static state = {};
2106
+ static value(key, next = this.state[key]) {
2107
+ return this.state[key] = (next || null);
2108
+ }
2109
+ }
2110
+ __decorate([
2111
+ $mol_mem_key
2112
+ ], $mol_state_local_mock, "value", null);
2113
+ context.$mol_state_local = $mol_state_local_mock;
2114
+ });
2115
+ })($ || ($ = {}));
2116
+
2028
2117
  ;
2029
2118
  "use strict";
2030
2119
  var $;
@@ -3008,40 +3097,6 @@ var $;
3008
3097
  })($$ = $_1.$$ || ($_1.$$ = {}));
3009
3098
  })($ || ($ = {}));
3010
3099
 
3011
- ;
3012
- "use strict";
3013
- var $;
3014
- (function ($) {
3015
- $mol_test({
3016
- 'local get set delete'() {
3017
- var key = '$mol_state_local_test:' + Math.random();
3018
- $mol_assert_equal($mol_state_local.value(key), null);
3019
- $mol_state_local.value(key, 123);
3020
- $mol_assert_equal($mol_state_local.value(key), 123);
3021
- $mol_state_local.value(key, null);
3022
- $mol_assert_equal($mol_state_local.value(key), null);
3023
- },
3024
- });
3025
- })($ || ($ = {}));
3026
-
3027
- ;
3028
- "use strict";
3029
- var $;
3030
- (function ($) {
3031
- $mol_test_mocks.push(context => {
3032
- class $mol_state_local_mock extends $mol_state_local {
3033
- static state = {};
3034
- static value(key, next = this.state[key]) {
3035
- return this.state[key] = (next || null);
3036
- }
3037
- }
3038
- __decorate([
3039
- $mol_mem_key
3040
- ], $mol_state_local_mock, "value", null);
3041
- context.$mol_state_local = $mol_state_local_mock;
3042
- });
3043
- })($ || ($ = {}));
3044
-
3045
3100
  ;
3046
3101
  "use strict";
3047
3102
  var $;