mol_crypto_lib 0.1.1290 → 0.1.1292
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/node.deps.json +1 -1
- package/node.js +16 -21
- package/node.js.map +1 -1
- package/node.mjs +16 -21
- package/node.test.js +1159 -1164
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
package/node.test.js
CHANGED
@@ -101,27 +101,19 @@ var $node = new Proxy({ require }, {
|
|
101
101
|
return target.require(name);
|
102
102
|
if (name[0] === '.')
|
103
103
|
return target.require(name);
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
113
|
-
try {
|
114
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
115
|
-
}
|
116
|
-
catch (e) {
|
117
|
-
if ($$.$mol_fail_catch(e)) {
|
118
|
-
$$.$mol_fail_log(e);
|
119
|
-
}
|
120
|
-
}
|
121
|
-
break;
|
104
|
+
try {
|
105
|
+
target.require.resolve(name);
|
106
|
+
}
|
107
|
+
catch {
|
108
|
+
const $$ = $;
|
109
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
110
|
+
try {
|
111
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
122
112
|
}
|
123
|
-
|
124
|
-
|
113
|
+
catch (e) {
|
114
|
+
if ($$.$mol_fail_catch(e)) {
|
115
|
+
$$.$mol_fail_log(e);
|
116
|
+
}
|
125
117
|
}
|
126
118
|
}
|
127
119
|
try {
|
@@ -1752,7 +1744,10 @@ var $;
|
|
1752
1744
|
command: args_raw.join(' '),
|
1753
1745
|
dir: $node.path.relative('', dir),
|
1754
1746
|
});
|
1755
|
-
|
1747
|
+
const res = this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
|
1748
|
+
if (res.status)
|
1749
|
+
$mol_fail(new Error(res.stderr.toString() || 'Exit(' + res.status + ')'));
|
1750
|
+
return res;
|
1756
1751
|
}
|
1757
1752
|
const sub = this.$mol_run_spawn(app, args, {
|
1758
1753
|
shell: true,
|
@@ -2551,55 +2546,137 @@ var $;
|
|
2551
2546
|
"use strict";
|
2552
2547
|
var $;
|
2553
2548
|
(function ($) {
|
2554
|
-
function $
|
2555
|
-
|
2556
|
-
|
2557
|
-
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2571
|
-
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2575
|
-
|
2576
|
-
const nn = nextNode.nextSibling;
|
2577
|
-
el.removeChild(nextNode);
|
2578
|
-
nextNode = nn;
|
2579
|
-
}
|
2580
|
-
}
|
2581
|
-
}
|
2549
|
+
function $mol_assert_ok(value) {
|
2550
|
+
if (value)
|
2551
|
+
return;
|
2552
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
2553
|
+
}
|
2554
|
+
$.$mol_assert_ok = $mol_assert_ok;
|
2555
|
+
function $mol_assert_not(value) {
|
2556
|
+
if (!value)
|
2557
|
+
return;
|
2558
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
2559
|
+
}
|
2560
|
+
$.$mol_assert_not = $mol_assert_not;
|
2561
|
+
function $mol_assert_fail(handler, ErrorRight) {
|
2562
|
+
const fail = $.$mol_fail;
|
2563
|
+
try {
|
2564
|
+
$.$mol_fail = $.$mol_fail_hidden;
|
2565
|
+
handler();
|
2566
|
+
}
|
2567
|
+
catch (error) {
|
2568
|
+
$.$mol_fail = fail;
|
2569
|
+
if (typeof ErrorRight === 'string') {
|
2570
|
+
$mol_assert_equal(error.message, ErrorRight);
|
2582
2571
|
}
|
2583
2572
|
else {
|
2584
|
-
|
2585
|
-
const str = String(view);
|
2586
|
-
if (nextNode.nodeValue !== str)
|
2587
|
-
nextNode.nodeValue = str;
|
2588
|
-
nextNode = nextNode.nextSibling;
|
2589
|
-
}
|
2590
|
-
else {
|
2591
|
-
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
2592
|
-
el.insertBefore(textNode, nextNode);
|
2593
|
-
}
|
2573
|
+
$mol_assert_equal(error instanceof ErrorRight, true);
|
2594
2574
|
}
|
2575
|
+
return error;
|
2595
2576
|
}
|
2596
|
-
|
2597
|
-
|
2598
|
-
nextNode = currNode.nextSibling;
|
2599
|
-
el.removeChild(currNode);
|
2577
|
+
finally {
|
2578
|
+
$.$mol_fail = fail;
|
2600
2579
|
}
|
2580
|
+
$mol_fail(new Error('Not failed'));
|
2601
2581
|
}
|
2602
|
-
$.$
|
2582
|
+
$.$mol_assert_fail = $mol_assert_fail;
|
2583
|
+
function $mol_assert_like(...args) {
|
2584
|
+
$mol_assert_equal(...args);
|
2585
|
+
}
|
2586
|
+
$.$mol_assert_like = $mol_assert_like;
|
2587
|
+
function $mol_assert_unique(...args) {
|
2588
|
+
for (let i = 0; i < args.length; ++i) {
|
2589
|
+
for (let j = 0; j < args.length; ++j) {
|
2590
|
+
if (i === j)
|
2591
|
+
continue;
|
2592
|
+
if (!$mol_compare_deep(args[i], args[j]))
|
2593
|
+
continue;
|
2594
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${print(args[i])}`));
|
2595
|
+
}
|
2596
|
+
}
|
2597
|
+
}
|
2598
|
+
$.$mol_assert_unique = $mol_assert_unique;
|
2599
|
+
function $mol_assert_equal(...args) {
|
2600
|
+
for (let i = 1; i < args.length; ++i) {
|
2601
|
+
if ($mol_compare_deep(args[0], args[i]))
|
2602
|
+
continue;
|
2603
|
+
if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
|
2604
|
+
continue;
|
2605
|
+
return $mol_fail(new Error(`args[0] ≠ args[${i}]\n${print(args[0])}\n---\n${print(args[i])}`));
|
2606
|
+
}
|
2607
|
+
}
|
2608
|
+
$.$mol_assert_equal = $mol_assert_equal;
|
2609
|
+
const print = (val) => {
|
2610
|
+
if (!val)
|
2611
|
+
return val;
|
2612
|
+
if (typeof val === 'bigint')
|
2613
|
+
return String(val) + 'n';
|
2614
|
+
if (typeof val === 'symbol')
|
2615
|
+
return `Symbol(${val.description})`;
|
2616
|
+
if (typeof val !== 'object')
|
2617
|
+
return val;
|
2618
|
+
if ('outerHTML' in val)
|
2619
|
+
return val.outerHTML;
|
2620
|
+
try {
|
2621
|
+
return JSON.stringify(val, (k, v) => typeof v === 'bigint' ? String(v) : v, '\t');
|
2622
|
+
}
|
2623
|
+
catch (error) {
|
2624
|
+
console.error(error);
|
2625
|
+
return val;
|
2626
|
+
}
|
2627
|
+
};
|
2628
|
+
})($ || ($ = {}));
|
2629
|
+
|
2630
|
+
;
|
2631
|
+
"use strict";
|
2632
|
+
var $;
|
2633
|
+
(function ($) {
|
2634
|
+
$mol_test({
|
2635
|
+
'must be false'() {
|
2636
|
+
$mol_assert_not(0);
|
2637
|
+
},
|
2638
|
+
'must be true'() {
|
2639
|
+
$mol_assert_ok(1);
|
2640
|
+
},
|
2641
|
+
'two must be equal'() {
|
2642
|
+
$mol_assert_equal(2, 2);
|
2643
|
+
},
|
2644
|
+
'three must be equal'() {
|
2645
|
+
$mol_assert_equal(2, 2, 2);
|
2646
|
+
},
|
2647
|
+
'two must be unique'() {
|
2648
|
+
$mol_assert_unique([2], [3]);
|
2649
|
+
},
|
2650
|
+
'three must be unique'() {
|
2651
|
+
$mol_assert_unique([1], [2], [3]);
|
2652
|
+
},
|
2653
|
+
'two must be alike'() {
|
2654
|
+
$mol_assert_like([3], [3]);
|
2655
|
+
},
|
2656
|
+
'three must be alike'() {
|
2657
|
+
$mol_assert_like([3], [3], [3]);
|
2658
|
+
},
|
2659
|
+
'two object must be alike'() {
|
2660
|
+
$mol_assert_like({ a: 1 }, { a: 1 });
|
2661
|
+
},
|
2662
|
+
'three object must be alike'() {
|
2663
|
+
$mol_assert_like({ a: 1 }, { a: 1 }, { a: 1 });
|
2664
|
+
},
|
2665
|
+
});
|
2666
|
+
})($ || ($ = {}));
|
2667
|
+
|
2668
|
+
;
|
2669
|
+
"use strict";
|
2670
|
+
var $;
|
2671
|
+
(function ($_1) {
|
2672
|
+
$mol_test_mocks.push($ => {
|
2673
|
+
$.$mol_log3_come = () => { };
|
2674
|
+
$.$mol_log3_done = () => { };
|
2675
|
+
$.$mol_log3_fail = () => { };
|
2676
|
+
$.$mol_log3_warn = () => { };
|
2677
|
+
$.$mol_log3_rise = () => { };
|
2678
|
+
$.$mol_log3_area = () => () => { };
|
2679
|
+
});
|
2603
2680
|
})($ || ($ = {}));
|
2604
2681
|
|
2605
2682
|
;
|
@@ -2617,213 +2694,163 @@ var $;
|
|
2617
2694
|
;
|
2618
2695
|
"use strict";
|
2619
2696
|
|
2697
|
+
;
|
2698
|
+
"use strict";
|
2699
|
+
|
2620
2700
|
;
|
2621
2701
|
"use strict";
|
2622
2702
|
var $;
|
2623
2703
|
(function ($) {
|
2624
|
-
|
2625
|
-
|
2626
|
-
|
2627
|
-
|
2628
|
-
|
2629
|
-
|
2630
|
-
|
2631
|
-
|
2632
|
-
|
2633
|
-
|
2634
|
-
|
2635
|
-
|
2636
|
-
|
2637
|
-
|
2638
|
-
|
2639
|
-
|
2704
|
+
$mol_test({
|
2705
|
+
'get'() {
|
2706
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
2707
|
+
$mol_assert_equal(proxy.foo, 777);
|
2708
|
+
},
|
2709
|
+
'has'() {
|
2710
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
2711
|
+
$mol_assert_equal('foo' in proxy, true);
|
2712
|
+
},
|
2713
|
+
'set'() {
|
2714
|
+
const target = { foo: 777 };
|
2715
|
+
const proxy = $mol_delegate({}, () => target);
|
2716
|
+
proxy.foo = 123;
|
2717
|
+
$mol_assert_equal(target.foo, 123);
|
2718
|
+
},
|
2719
|
+
'getOwnPropertyDescriptor'() {
|
2720
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
2721
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
2722
|
+
value: 777,
|
2723
|
+
writable: true,
|
2724
|
+
enumerable: true,
|
2725
|
+
configurable: true,
|
2726
|
+
});
|
2727
|
+
},
|
2728
|
+
'ownKeys'() {
|
2729
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
2730
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
2731
|
+
},
|
2732
|
+
'getPrototypeOf'() {
|
2733
|
+
class Foo {
|
2640
2734
|
}
|
2641
|
-
|
2642
|
-
|
2735
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
2736
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
2737
|
+
},
|
2738
|
+
'setPrototypeOf'() {
|
2739
|
+
class Foo {
|
2643
2740
|
}
|
2644
|
-
|
2645
|
-
|
2646
|
-
|
2647
|
-
|
2648
|
-
|
2649
|
-
|
2650
|
-
|
2651
|
-
const func = props[field];
|
2652
|
-
if (typeof func !== 'function')
|
2653
|
-
continue;
|
2654
|
-
const wrapper = function (...args) {
|
2655
|
-
const prefix = $.$mol_jsx_prefix;
|
2656
|
-
const booked = $.$mol_jsx_booked;
|
2657
|
-
const crumbs = $.$mol_jsx_crumbs;
|
2658
|
-
try {
|
2659
|
-
$.$mol_jsx_prefix = prefix_ext;
|
2660
|
-
$.$mol_jsx_booked = booked_ext;
|
2661
|
-
$.$mol_jsx_crumbs = crumbs_ext;
|
2662
|
-
return func.call(this, ...args);
|
2663
|
-
}
|
2664
|
-
finally {
|
2665
|
-
$.$mol_jsx_prefix = prefix;
|
2666
|
-
$.$mol_jsx_booked = booked;
|
2667
|
-
$.$mol_jsx_crumbs = crumbs;
|
2668
|
-
}
|
2669
|
-
};
|
2670
|
-
$mol_func_name_from(wrapper, func);
|
2671
|
-
props[field] = wrapper;
|
2672
|
-
}
|
2673
|
-
}
|
2674
|
-
if (typeof Elem !== 'string') {
|
2675
|
-
if ('prototype' in Elem) {
|
2676
|
-
const view = node && node[String(Elem)] || new Elem;
|
2677
|
-
Object.assign(view, props);
|
2678
|
-
view[Symbol.toStringTag] = guid;
|
2679
|
-
view.childNodes = childNodes;
|
2680
|
-
if (!view.ownerDocument)
|
2681
|
-
view.ownerDocument = $.$mol_jsx_document;
|
2682
|
-
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
2683
|
-
node = view.valueOf();
|
2684
|
-
node[String(Elem)] = view;
|
2685
|
-
return node;
|
2686
|
-
}
|
2687
|
-
else {
|
2688
|
-
const prefix = $.$mol_jsx_prefix;
|
2689
|
-
const booked = $.$mol_jsx_booked;
|
2690
|
-
const crumbs = $.$mol_jsx_crumbs;
|
2691
|
-
try {
|
2692
|
-
$.$mol_jsx_prefix = guid;
|
2693
|
-
$.$mol_jsx_booked = new Set;
|
2694
|
-
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
2695
|
-
return Elem(props, ...childNodes);
|
2696
|
-
}
|
2697
|
-
finally {
|
2698
|
-
$.$mol_jsx_prefix = prefix;
|
2699
|
-
$.$mol_jsx_booked = booked;
|
2700
|
-
$.$mol_jsx_crumbs = crumbs;
|
2701
|
-
}
|
2702
|
-
}
|
2703
|
-
}
|
2704
|
-
if (!node) {
|
2705
|
-
node = Elem
|
2706
|
-
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
2707
|
-
: $.$mol_jsx_document.createDocumentFragment();
|
2708
|
-
}
|
2709
|
-
$mol_dom_render_children(node, [].concat(...childNodes));
|
2710
|
-
if (!Elem)
|
2711
|
-
return node;
|
2712
|
-
if (guid)
|
2713
|
-
node.id = guid;
|
2714
|
-
for (const key in props) {
|
2715
|
-
if (key === 'id')
|
2716
|
-
continue;
|
2717
|
-
if (typeof props[key] === 'string') {
|
2718
|
-
if (typeof node[key] === 'string')
|
2719
|
-
node[key] = props[key];
|
2720
|
-
node.setAttribute(key, props[key]);
|
2721
|
-
}
|
2722
|
-
else if (props[key] &&
|
2723
|
-
typeof props[key] === 'object' &&
|
2724
|
-
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
2725
|
-
if (typeof node[key] === 'object') {
|
2726
|
-
Object.assign(node[key], props[key]);
|
2727
|
-
continue;
|
2728
|
-
}
|
2741
|
+
const target = {};
|
2742
|
+
const proxy = $mol_delegate({}, () => target);
|
2743
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
2744
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
2745
|
+
},
|
2746
|
+
'instanceof'() {
|
2747
|
+
class Foo {
|
2729
2748
|
}
|
2730
|
-
|
2731
|
-
|
2749
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
2750
|
+
$mol_assert_ok(proxy instanceof Foo);
|
2751
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
2752
|
+
},
|
2753
|
+
'autobind'() {
|
2754
|
+
class Foo {
|
2732
2755
|
}
|
2733
|
-
|
2734
|
-
|
2735
|
-
|
2736
|
-
|
2737
|
-
}
|
2738
|
-
$.$mol_jsx = $mol_jsx;
|
2756
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
2757
|
+
$mol_assert_ok(proxy instanceof Foo);
|
2758
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
2759
|
+
},
|
2760
|
+
});
|
2739
2761
|
})($ || ($ = {}));
|
2740
2762
|
|
2741
2763
|
;
|
2742
2764
|
"use strict";
|
2743
2765
|
var $;
|
2744
|
-
(function ($) {
|
2766
|
+
(function ($_1) {
|
2745
2767
|
$mol_test({
|
2746
|
-
'
|
2747
|
-
$
|
2748
|
-
|
2749
|
-
|
2750
|
-
|
2751
|
-
$mol_assert_equal(
|
2752
|
-
$mol_assert_equal(
|
2753
|
-
},
|
2754
|
-
'Define classes'() {
|
2755
|
-
const dom = $mol_jsx("div", { class: 'foo bar' });
|
2756
|
-
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
2757
|
-
},
|
2758
|
-
'Define styles'() {
|
2759
|
-
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
2760
|
-
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
2761
|
-
},
|
2762
|
-
'Define dataset'() {
|
2763
|
-
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
2764
|
-
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
2768
|
+
'span for same uri'($) {
|
2769
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
2770
|
+
const child = span.span(4, 5, 8);
|
2771
|
+
$mol_assert_equal(child.uri, 'test.ts');
|
2772
|
+
$mol_assert_equal(child.row, 4);
|
2773
|
+
$mol_assert_equal(child.col, 5);
|
2774
|
+
$mol_assert_equal(child.length, 8);
|
2765
2775
|
},
|
2766
|
-
'
|
2767
|
-
const
|
2768
|
-
|
2776
|
+
'span after of given position'($) {
|
2777
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
2778
|
+
const child = span.after(11);
|
2779
|
+
$mol_assert_equal(child.uri, 'test.ts');
|
2780
|
+
$mol_assert_equal(child.row, 1);
|
2781
|
+
$mol_assert_equal(child.col, 7);
|
2782
|
+
$mol_assert_equal(child.length, 11);
|
2769
2783
|
},
|
2770
|
-
'
|
2771
|
-
const
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
$mol_assert_equal(
|
2784
|
+
'slice span - regular'($) {
|
2785
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
2786
|
+
const child = span.slice(1, 4);
|
2787
|
+
$mol_assert_equal(child.row, 1);
|
2788
|
+
$mol_assert_equal(child.col, 4);
|
2789
|
+
$mol_assert_equal(child.length, 3);
|
2790
|
+
const child2 = span.slice(2, 2);
|
2791
|
+
$mol_assert_equal(child2.col, 5);
|
2792
|
+
$mol_assert_equal(child2.length, 0);
|
2776
2793
|
},
|
2777
|
-
'
|
2778
|
-
const
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
$mol_assert_equal(
|
2794
|
+
'slice span - negative'($) {
|
2795
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
2796
|
+
const child = span.slice(-3, -1);
|
2797
|
+
$mol_assert_equal(child.row, 1);
|
2798
|
+
$mol_assert_equal(child.col, 5);
|
2799
|
+
$mol_assert_equal(child.length, 2);
|
2783
2800
|
},
|
2784
|
-
'
|
2785
|
-
const
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
};
|
2790
|
-
const Bar = (props, icon) => {
|
2791
|
-
return $mol_jsx("span", null,
|
2792
|
-
icon,
|
2793
|
-
$mol_jsx("i", { id: "label" }));
|
2794
|
-
};
|
2795
|
-
const dom = $mol_jsx(Foo, { id: "foo" });
|
2796
|
-
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
2801
|
+
'slice span - out of range'($) {
|
2802
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
2803
|
+
$mol_assert_fail(() => span.slice(-1, 3), `End value '3' can't be less than begin value (test.ts#1:3/5)`);
|
2804
|
+
$mol_assert_fail(() => span.slice(1, 6), `End value '6' out of range (test.ts#1:3/5)`);
|
2805
|
+
$mol_assert_fail(() => span.slice(1, 10), `End value '10' out of range (test.ts#1:3/5)`);
|
2797
2806
|
},
|
2798
|
-
'
|
2799
|
-
const
|
2800
|
-
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2807
|
+
'error handling'($) {
|
2808
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
2809
|
+
const error = span.error('Some error');
|
2810
|
+
$mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
|
2811
|
+
}
|
2812
|
+
});
|
2813
|
+
})($ || ($ = {}));
|
2814
|
+
|
2815
|
+
;
|
2816
|
+
"use strict";
|
2817
|
+
var $;
|
2818
|
+
(function ($_1) {
|
2819
|
+
$mol_test({
|
2820
|
+
'inserting'($) {
|
2821
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
2822
|
+
.insert($mol_tree2.struct('x'), 'a', 'b', 'c')
|
2823
|
+
.toString(), 'a b x\n');
|
2824
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
2825
|
+
.insert($mol_tree2.struct('x'), 'a', 'b', 'c', 'd')
|
2826
|
+
.toString(), 'a b c x\n');
|
2827
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
2828
|
+
.insert($mol_tree2.struct('x'), 0, 0, 0)
|
2829
|
+
.toString(), 'a b x\n');
|
2830
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
2831
|
+
.insert($mol_tree2.struct('x'), 0, 0, 0, 0)
|
2832
|
+
.toString(), 'a b \\\n\tx\n');
|
2833
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
2834
|
+
.insert($mol_tree2.struct('x'), null, null, null)
|
2835
|
+
.toString(), 'a b x\n');
|
2836
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
2837
|
+
.insert($mol_tree2.struct('x'), null, null, null, null)
|
2838
|
+
.toString(), 'a b \\\n\tx\n');
|
2805
2839
|
},
|
2806
|
-
'
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
};
|
2814
|
-
const dom = $mol_jsx(Foo, { id: "app" });
|
2815
|
-
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
2840
|
+
'deleting'($) {
|
2841
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
2842
|
+
.insert(null, 'a', 'b', 'c')
|
2843
|
+
.toString(), 'a b\n');
|
2844
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
2845
|
+
.insert(null, 0, 0, 0)
|
2846
|
+
.toString(), 'a b\n');
|
2816
2847
|
},
|
2817
|
-
'
|
2818
|
-
const
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
const Bar = (props) => {
|
2824
|
-
return $mol_jsx("span", null, props.icon());
|
2825
|
-
};
|
2826
|
-
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
2848
|
+
'hack'($) {
|
2849
|
+
const res = $.$mol_tree2_from_string(`foo bar xxx\n`)
|
2850
|
+
.hack({
|
2851
|
+
'bar': (input, belt) => [input.struct('777', input.hack(belt))],
|
2852
|
+
});
|
2853
|
+
$mol_assert_equal(res.toString(), 'foo 777 xxx\n');
|
2827
2854
|
},
|
2828
2855
|
});
|
2829
2856
|
})($ || ($ = {}));
|
@@ -2831,427 +2858,190 @@ var $;
|
|
2831
2858
|
;
|
2832
2859
|
"use strict";
|
2833
2860
|
var $;
|
2834
|
-
(function ($) {
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
|
2861
|
+
(function ($_1) {
|
2862
|
+
$mol_test({
|
2863
|
+
'tree parsing'($) {
|
2864
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids.length, 2);
|
2865
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids[1].type, "bar");
|
2866
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\n\n\n").kids.length, 1);
|
2867
|
+
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids.length, 2);
|
2868
|
+
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids[1].value, "bar");
|
2869
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
|
2870
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
|
2871
|
+
$mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
2872
|
+
},
|
2873
|
+
'Too many tabs'($) {
|
2874
|
+
const tree = `
|
2875
|
+
foo
|
2876
|
+
bar
|
2877
|
+
`;
|
2878
|
+
$mol_assert_fail(() => {
|
2879
|
+
$.$mol_tree2_from_string(tree, 'test');
|
2880
|
+
}, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
|
2881
|
+
},
|
2882
|
+
'Too few tabs'($) {
|
2883
|
+
const tree = `
|
2884
|
+
foo
|
2885
|
+
bar
|
2886
|
+
`;
|
2887
|
+
$mol_assert_fail(() => {
|
2888
|
+
$.$mol_tree2_from_string(tree, 'test');
|
2889
|
+
}, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
|
2890
|
+
},
|
2891
|
+
'Wrong nodes separator at start'($) {
|
2892
|
+
const tree = `foo\n \tbar\n`;
|
2893
|
+
$mol_assert_fail(() => {
|
2894
|
+
$.$mol_tree2_from_string(tree, 'test');
|
2895
|
+
}, 'Wrong nodes separator\ntest#2:1/2\n!!\n \tbar');
|
2896
|
+
},
|
2897
|
+
'Wrong nodes separator in the middle'($) {
|
2898
|
+
const tree = `foo bar\n`;
|
2899
|
+
$mol_assert_fail(() => {
|
2900
|
+
$.$mol_tree2_from_string(tree, 'test');
|
2901
|
+
}, 'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar');
|
2902
|
+
},
|
2903
|
+
'Unexpected EOF, LF required'($) {
|
2904
|
+
const tree = ` foo`;
|
2905
|
+
$mol_assert_fail(() => {
|
2906
|
+
$.$mol_tree2_from_string(tree, 'test');
|
2907
|
+
}, 'Unexpected EOF, LF required\ntest#1:5/1\n !\n foo');
|
2908
|
+
},
|
2909
|
+
'Errors skip and collect'($) {
|
2910
|
+
const tree = `foo bar`;
|
2911
|
+
const errors = [];
|
2912
|
+
const $$ = $.$mol_ambient({
|
2913
|
+
$mol_fail: (error) => {
|
2914
|
+
errors.push(error.message);
|
2915
|
+
return null;
|
2916
|
+
}
|
2917
|
+
});
|
2918
|
+
const res = $$.$mol_tree2_from_string(tree, 'test');
|
2919
|
+
$mol_assert_like(errors, [
|
2920
|
+
'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar',
|
2921
|
+
'Unexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
|
2922
|
+
]);
|
2923
|
+
$mol_assert_equal(res.toString(), 'foo bar\n');
|
2924
|
+
},
|
2925
|
+
});
|
2844
2926
|
})($ || ($ = {}));
|
2845
2927
|
|
2846
2928
|
;
|
2847
2929
|
"use strict";
|
2848
2930
|
var $;
|
2849
2931
|
(function ($) {
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
|
2859
|
-
|
2860
|
-
return size();
|
2861
|
-
const index = Number(field);
|
2862
|
-
if (index < 0)
|
2863
|
-
return undefined;
|
2864
|
-
if (index >= size())
|
2865
|
-
return undefined;
|
2866
|
-
if (index === Math.trunc(index))
|
2867
|
-
return item(index);
|
2868
|
-
}
|
2869
|
-
return $mol_range2_array.prototype[field];
|
2870
|
-
},
|
2871
|
-
set(target, field) {
|
2872
|
-
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
2873
|
-
},
|
2874
|
-
ownKeys(target) {
|
2875
|
-
return [...Array(size())].map((v, i) => String(i)).concat('length');
|
2876
|
-
},
|
2877
|
-
getOwnPropertyDescriptor(target, field) {
|
2878
|
-
if (field === "length")
|
2879
|
-
return {
|
2880
|
-
value: size(),
|
2881
|
-
writable: true,
|
2882
|
-
enumerable: false,
|
2883
|
-
configurable: false,
|
2884
|
-
};
|
2885
|
-
const index = Number(field);
|
2886
|
-
if (index === Math.trunc(index))
|
2887
|
-
return {
|
2888
|
-
get: () => this.get(target, field, this),
|
2889
|
-
enumerable: true,
|
2890
|
-
configurable: true,
|
2891
|
-
};
|
2892
|
-
return Object.getOwnPropertyDescriptor(target, field);
|
2893
|
-
}
|
2894
|
-
});
|
2895
|
-
}
|
2896
|
-
$.$mol_range2 = $mol_range2;
|
2897
|
-
class $mol_range2_array extends Array {
|
2898
|
-
concat(...tail) {
|
2899
|
-
if (tail.length === 0)
|
2900
|
-
return this;
|
2901
|
-
if (tail.length > 1) {
|
2902
|
-
let list = this;
|
2903
|
-
for (let item of tail)
|
2904
|
-
list = list.concat(item);
|
2905
|
-
return list;
|
2906
|
-
}
|
2907
|
-
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
2908
|
-
}
|
2909
|
-
filter(check, context) {
|
2910
|
-
const filtered = [];
|
2911
|
-
let cursor = -1;
|
2912
|
-
return $mol_range2(index => {
|
2913
|
-
while (cursor < this.length && index >= filtered.length - 1) {
|
2914
|
-
const val = this[++cursor];
|
2915
|
-
if (check(val, cursor, this))
|
2916
|
-
filtered.push(val);
|
2917
|
-
}
|
2918
|
-
return filtered[index];
|
2919
|
-
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
2920
|
-
}
|
2921
|
-
forEach(proceed, context) {
|
2922
|
-
for (let [key, value] of this.entries())
|
2923
|
-
proceed.call(context, value, key, this);
|
2924
|
-
}
|
2925
|
-
map(proceed, context) {
|
2926
|
-
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
2927
|
-
}
|
2928
|
-
reduce(merge, result) {
|
2929
|
-
let index = 0;
|
2930
|
-
if (arguments.length === 1) {
|
2931
|
-
result = this[index++];
|
2932
|
-
}
|
2933
|
-
for (; index < this.length; ++index) {
|
2934
|
-
result = merge(result, this[index], index, this);
|
2935
|
-
}
|
2936
|
-
return result;
|
2937
|
-
}
|
2938
|
-
toReversed() {
|
2939
|
-
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
2940
|
-
}
|
2941
|
-
slice(from = 0, to = this.length) {
|
2942
|
-
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
2943
|
-
}
|
2944
|
-
some(check, context) {
|
2945
|
-
for (let index = 0; index < this.length; ++index) {
|
2946
|
-
if (check.call(context, this[index], index, this))
|
2947
|
-
return true;
|
2948
|
-
}
|
2949
|
-
return false;
|
2950
|
-
}
|
2951
|
-
every(check, context) {
|
2952
|
-
for (let index = 0; index < this.length; ++index) {
|
2953
|
-
if (!check.call(context, this[index], index, this))
|
2954
|
-
return false;
|
2955
|
-
}
|
2956
|
-
return true;
|
2957
|
-
}
|
2958
|
-
reverse() {
|
2959
|
-
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
2960
|
-
}
|
2961
|
-
sort() {
|
2962
|
-
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
2963
|
-
}
|
2964
|
-
[Symbol.toPrimitive]() {
|
2965
|
-
return $mol_guid();
|
2966
|
-
}
|
2967
|
-
}
|
2968
|
-
$.$mol_range2_array = $mol_range2_array;
|
2932
|
+
$mol_test({
|
2933
|
+
'fromJSON'() {
|
2934
|
+
$mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
|
2935
|
+
$mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
2936
|
+
$mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
2937
|
+
$mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
|
2938
|
+
$mol_assert_equal($mol_tree2_from_json(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
2939
|
+
$mol_assert_equal($mol_tree2_from_json({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
2940
|
+
},
|
2941
|
+
});
|
2969
2942
|
})($ || ($ = {}));
|
2970
2943
|
|
2971
2944
|
;
|
2972
2945
|
"use strict";
|
2973
2946
|
var $;
|
2974
|
-
(function ($) {
|
2947
|
+
(function ($_1) {
|
2975
2948
|
$mol_test({
|
2976
|
-
'
|
2977
|
-
|
2978
|
-
|
2979
|
-
$mol_assert_equal(
|
2980
|
-
$mol_assert_equal(
|
2981
|
-
$mol_assert_equal(list[-1], undefined);
|
2982
|
-
$mol_assert_equal(list[0], 0);
|
2983
|
-
$mol_assert_equal(list[9], 9);
|
2984
|
-
$mol_assert_equal(list[9.5], undefined);
|
2985
|
-
$mol_assert_equal(list[10], undefined);
|
2986
|
-
$mol_assert_equal(calls, 2);
|
2987
|
-
},
|
2988
|
-
'infinity list'() {
|
2989
|
-
let calls = 0;
|
2990
|
-
const list = $mol_range2(index => (++calls, index));
|
2991
|
-
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
2992
|
-
$mol_assert_equal(list[0], 0);
|
2993
|
-
$mol_assert_equal(list[4], 4);
|
2994
|
-
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
2995
|
-
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
2996
|
-
$mol_assert_equal(calls, 3);
|
2997
|
-
},
|
2998
|
-
'stringify'() {
|
2999
|
-
const list = $mol_range2(i => i, () => 5);
|
3000
|
-
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
3001
|
-
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
2949
|
+
'FQN of anon function'($) {
|
2950
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
2951
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
2952
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
2953
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
3002
2954
|
},
|
3003
|
-
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
2955
|
+
});
|
2956
|
+
})($ || ($ = {}));
|
2957
|
+
|
2958
|
+
;
|
2959
|
+
"use strict";
|
2960
|
+
var $;
|
2961
|
+
(function ($) {
|
2962
|
+
$mol_test({
|
2963
|
+
'auto name'() {
|
2964
|
+
class Invalid extends $mol_error_mix {
|
3007
2965
|
}
|
3008
|
-
|
2966
|
+
const mix = new Invalid('foo');
|
2967
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
3009
2968
|
},
|
3010
|
-
'
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
}
|
3015
|
-
$mol_assert_equal(log, '01234');
|
2969
|
+
'simpe mix'() {
|
2970
|
+
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
2971
|
+
$mol_assert_equal(mix.message, 'foo');
|
2972
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
3016
2973
|
},
|
3017
|
-
'
|
3018
|
-
|
3019
|
-
|
3020
|
-
$
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3030
|
-
let calls2 = 0;
|
3031
|
-
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
3032
|
-
$mol_assert_equal(true, list instanceof Array);
|
3033
|
-
$mol_assert_equal(list.length, 15);
|
3034
|
-
$mol_assert_equal(list[0], 0);
|
3035
|
-
$mol_assert_equal(list[4], 4);
|
3036
|
-
$mol_assert_equal(list[5], 0);
|
3037
|
-
$mol_assert_equal(list[9], 4);
|
3038
|
-
$mol_assert_equal(list[10], 0);
|
3039
|
-
$mol_assert_equal(list[14], 4);
|
3040
|
-
$mol_assert_equal(list[15], undefined);
|
3041
|
-
$mol_assert_equal(calls1, 2);
|
3042
|
-
$mol_assert_equal(calls2, 2);
|
3043
|
-
},
|
3044
|
-
'lazy filter'() {
|
3045
|
-
let calls = 0;
|
3046
|
-
const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
|
3047
|
-
$mol_assert_equal(true, list instanceof Array);
|
3048
|
-
$mol_assert_equal(list.length, 3);
|
3049
|
-
$mol_assert_equal(list[0], 1);
|
3050
|
-
$mol_assert_equal(list[2], 5);
|
3051
|
-
$mol_assert_equal(list[3], undefined);
|
3052
|
-
$mol_assert_equal(calls, 8);
|
3053
|
-
},
|
3054
|
-
'lazy reverse'() {
|
3055
|
-
let calls = 0;
|
3056
|
-
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
3057
|
-
$mol_assert_equal(true, list instanceof Array);
|
3058
|
-
$mol_assert_equal(list.length, 3);
|
3059
|
-
$mol_assert_equal(list[0], 9);
|
3060
|
-
$mol_assert_equal(list[2], 7);
|
3061
|
-
$mol_assert_equal(list[3], undefined);
|
3062
|
-
$mol_assert_equal(calls, 2);
|
3063
|
-
},
|
3064
|
-
'lazy map'() {
|
3065
|
-
let calls1 = 0;
|
3066
|
-
let calls2 = 0;
|
3067
|
-
const source = $mol_range2(index => (++calls1, index), () => 5);
|
3068
|
-
const target = source.map((item, index, self) => {
|
3069
|
-
++calls2;
|
3070
|
-
$mol_assert_equal(source, self);
|
3071
|
-
return index + 10;
|
3072
|
-
}, () => 5);
|
3073
|
-
$mol_assert_equal(true, target instanceof Array);
|
3074
|
-
$mol_assert_equal(target.length, 5);
|
3075
|
-
$mol_assert_equal(target[0], 10);
|
3076
|
-
$mol_assert_equal(target[4], 14);
|
3077
|
-
$mol_assert_equal(target[5], undefined);
|
3078
|
-
$mol_assert_equal(calls1, 2);
|
3079
|
-
$mol_assert_equal(calls2, 2);
|
3080
|
-
},
|
3081
|
-
'lazy slice'() {
|
3082
|
-
let calls = 0;
|
3083
|
-
const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
|
3084
|
-
$mol_assert_equal(true, list instanceof Array);
|
3085
|
-
$mol_assert_equal(list.length, 4);
|
3086
|
-
$mol_assert_equal(list[0], 3);
|
3087
|
-
$mol_assert_equal(list[3], 6);
|
3088
|
-
$mol_assert_equal(list[4], undefined);
|
3089
|
-
$mol_assert_equal(calls, 2);
|
3090
|
-
},
|
3091
|
-
'lazy some'() {
|
3092
|
-
let calls = 0;
|
3093
|
-
$mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
|
3094
|
-
$mol_assert_equal(calls, 3);
|
3095
|
-
$mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
|
3096
|
-
$mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
|
3097
|
-
},
|
3098
|
-
'lazy every'() {
|
3099
|
-
let calls = 0;
|
3100
|
-
$mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
|
3101
|
-
$mol_assert_equal(calls, 3);
|
3102
|
-
$mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
|
3103
|
-
$mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
|
3104
|
-
},
|
3105
|
-
'lazyfy'() {
|
3106
|
-
let calls = 0;
|
3107
|
-
const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
|
3108
|
-
$mol_assert_equal(true, list instanceof Array);
|
3109
|
-
$mol_assert_equal(list.length, 4);
|
3110
|
-
$mol_assert_equal(calls, 0);
|
3111
|
-
$mol_assert_equal(list[0], 12);
|
3112
|
-
$mol_assert_equal(list[3], 15);
|
3113
|
-
$mol_assert_equal(list[4], undefined);
|
3114
|
-
$mol_assert_equal(calls, 2);
|
2974
|
+
'provide additional info'() {
|
2975
|
+
class Invalid extends $mol_error_mix {
|
2976
|
+
}
|
2977
|
+
const mix = new $mol_error_mix('Wrong password', {}, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
|
2978
|
+
const hints = [];
|
2979
|
+
if (mix instanceof $mol_error_mix) {
|
2980
|
+
for (const er of mix.errors) {
|
2981
|
+
if (er instanceof Invalid) {
|
2982
|
+
hints.push(er.cause?.hint ?? '');
|
2983
|
+
}
|
2984
|
+
}
|
2985
|
+
}
|
2986
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
3115
2987
|
},
|
3116
|
-
'prevent modification'() {
|
3117
|
-
const list = $mol_range2(i => i, () => 5);
|
3118
|
-
$mol_assert_fail(() => list.push(4), TypeError);
|
3119
|
-
$mol_assert_fail(() => list.pop(), TypeError);
|
3120
|
-
$mol_assert_fail(() => list.unshift(4), TypeError);
|
3121
|
-
$mol_assert_fail(() => list.shift(), TypeError);
|
3122
|
-
$mol_assert_fail(() => list.splice(1, 2), TypeError);
|
3123
|
-
$mol_assert_fail(() => list[1] = 2, TypeError);
|
3124
|
-
$mol_assert_fail(() => list.reverse(), TypeError);
|
3125
|
-
$mol_assert_fail(() => list.sort(), TypeError);
|
3126
|
-
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
3127
|
-
}
|
3128
2988
|
});
|
3129
2989
|
})($ || ($ = {}));
|
3130
2990
|
|
3131
2991
|
;
|
3132
2992
|
"use strict";
|
3133
2993
|
var $;
|
3134
|
-
(function ($) {
|
2994
|
+
(function ($_1) {
|
3135
2995
|
$mol_test({
|
3136
|
-
'
|
3137
|
-
$
|
3138
|
-
$
|
3139
|
-
$
|
3140
|
-
|
3141
|
-
|
3142
|
-
|
3143
|
-
|
3144
|
-
|
3145
|
-
$mol_assert_not($mol_compare_deep(1, 2));
|
3146
|
-
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
3147
|
-
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
3148
|
-
},
|
3149
|
-
'POJO'() {
|
3150
|
-
$mol_assert_ok($mol_compare_deep({}, {}));
|
3151
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
3152
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
3153
|
-
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
3154
|
-
$mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
3155
|
-
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
3156
|
-
$mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
|
3157
|
-
},
|
3158
|
-
'Array'() {
|
3159
|
-
$mol_assert_ok($mol_compare_deep([], []));
|
3160
|
-
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
3161
|
-
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
3162
|
-
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
3163
|
-
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
3164
|
-
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
3165
|
-
},
|
3166
|
-
'Non POJO are different'() {
|
3167
|
-
class Thing extends Object {
|
2996
|
+
'Collect deps'() {
|
2997
|
+
const pub1 = new $mol_wire_pub;
|
2998
|
+
const pub2 = new $mol_wire_pub;
|
2999
|
+
const sub = new $mol_wire_pub_sub;
|
3000
|
+
const bu1 = sub.track_on();
|
3001
|
+
try {
|
3002
|
+
pub1.promote();
|
3003
|
+
pub2.promote();
|
3004
|
+
pub2.promote();
|
3168
3005
|
}
|
3169
|
-
|
3170
|
-
|
3171
|
-
|
3172
|
-
|
3173
|
-
|
3174
|
-
|
3175
|
-
$
|
3176
|
-
|
3177
|
-
|
3178
|
-
|
3179
|
-
|
3180
|
-
|
3181
|
-
|
3182
|
-
|
3183
|
-
|
3184
|
-
|
3185
|
-
|
3186
|
-
|
3187
|
-
|
3188
|
-
|
3189
|
-
const obj2_copy = { test: 2, obj1: obj1_copy };
|
3190
|
-
const obj3 = { test: 3, obj2 };
|
3191
|
-
const obj3_copy = { test: 3, obj2: obj2_copy };
|
3192
|
-
obj1.obj3 = obj3;
|
3193
|
-
obj1_copy.obj3 = obj3_copy;
|
3194
|
-
$mol_assert_not($mol_compare_deep(obj1, {}));
|
3195
|
-
$mol_assert_not($mol_compare_deep(obj2, {}));
|
3196
|
-
$mol_assert_not($mol_compare_deep(obj3, {}));
|
3197
|
-
$mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
|
3198
|
-
},
|
3199
|
-
'Date'() {
|
3200
|
-
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
3201
|
-
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
3202
|
-
},
|
3203
|
-
'RegExp'() {
|
3204
|
-
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
3205
|
-
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
3206
|
-
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
3207
|
-
},
|
3208
|
-
'Error'() {
|
3209
|
-
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
3210
|
-
const fail = (message) => new Error(message);
|
3211
|
-
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
3212
|
-
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
3213
|
-
},
|
3214
|
-
'Map'() {
|
3215
|
-
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
3216
|
-
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
3217
|
-
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
3218
|
-
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
3219
|
-
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
3220
|
-
},
|
3221
|
-
'Set'() {
|
3222
|
-
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
3223
|
-
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
3224
|
-
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
3225
|
-
},
|
3226
|
-
'Uint8Array'() {
|
3227
|
-
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
3228
|
-
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
3229
|
-
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
3230
|
-
},
|
3231
|
-
'DataView'() {
|
3232
|
-
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
|
3233
|
-
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
|
3234
|
-
$mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
|
3006
|
+
finally {
|
3007
|
+
sub.track_cut();
|
3008
|
+
sub.track_off(bu1);
|
3009
|
+
}
|
3010
|
+
pub1.emit();
|
3011
|
+
pub2.emit();
|
3012
|
+
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
3013
|
+
const bu2 = sub.track_on();
|
3014
|
+
try {
|
3015
|
+
pub1.promote();
|
3016
|
+
pub1.promote();
|
3017
|
+
pub2.promote();
|
3018
|
+
}
|
3019
|
+
finally {
|
3020
|
+
sub.track_cut();
|
3021
|
+
sub.track_off(bu2);
|
3022
|
+
}
|
3023
|
+
pub1.emit();
|
3024
|
+
pub2.emit();
|
3025
|
+
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
3235
3026
|
},
|
3236
|
-
'
|
3237
|
-
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3027
|
+
'cyclic detection'($) {
|
3028
|
+
const sub1 = new $mol_wire_pub_sub;
|
3029
|
+
const sub2 = new $mol_wire_pub_sub;
|
3030
|
+
const bu1 = sub1.track_on();
|
3031
|
+
try {
|
3032
|
+
const bu2 = sub2.track_on();
|
3033
|
+
try {
|
3034
|
+
$mol_assert_fail(() => sub1.promote(), 'Circular subscription');
|
3243
3035
|
}
|
3244
|
-
|
3245
|
-
|
3036
|
+
finally {
|
3037
|
+
sub2.track_cut();
|
3038
|
+
sub2.track_off(bu2);
|
3246
3039
|
}
|
3247
3040
|
}
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
$mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
|
3253
|
-
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
|
3254
|
-
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
|
3041
|
+
finally {
|
3042
|
+
sub1.track_cut();
|
3043
|
+
sub1.track_off(bu1);
|
3044
|
+
}
|
3255
3045
|
},
|
3256
3046
|
});
|
3257
3047
|
})($ || ($ = {}));
|
@@ -3260,85 +3050,47 @@ var $;
|
|
3260
3050
|
"use strict";
|
3261
3051
|
var $;
|
3262
3052
|
(function ($) {
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
$.$mol_assert_ok = $mol_assert_ok;
|
3269
|
-
function $mol_assert_not(value) {
|
3270
|
-
if (!value)
|
3271
|
-
return;
|
3272
|
-
$mol_fail(new Error(`${value} ≠ false`));
|
3053
|
+
$.$mol_after_mock_queue = [];
|
3054
|
+
function $mol_after_mock_warp() {
|
3055
|
+
const queue = $.$mol_after_mock_queue.splice(0);
|
3056
|
+
for (const task of queue)
|
3057
|
+
task();
|
3273
3058
|
}
|
3274
|
-
$.$
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3278
|
-
|
3279
|
-
|
3280
|
-
|
3281
|
-
|
3282
|
-
|
3283
|
-
|
3284
|
-
$mol_assert_equal(error.message, ErrorRight);
|
3285
|
-
}
|
3286
|
-
else {
|
3287
|
-
$mol_assert_equal(error instanceof ErrorRight, true);
|
3288
|
-
}
|
3289
|
-
return error;
|
3290
|
-
}
|
3291
|
-
finally {
|
3292
|
-
$.$mol_fail = fail;
|
3059
|
+
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
3060
|
+
class $mol_after_mock_commmon extends $mol_object2 {
|
3061
|
+
task;
|
3062
|
+
promise = Promise.resolve();
|
3063
|
+
cancelled = false;
|
3064
|
+
id;
|
3065
|
+
constructor(task) {
|
3066
|
+
super();
|
3067
|
+
this.task = task;
|
3068
|
+
$.$mol_after_mock_queue.push(task);
|
3293
3069
|
}
|
3294
|
-
|
3295
|
-
|
3296
|
-
|
3297
|
-
|
3298
|
-
$mol_assert_equal(...args);
|
3299
|
-
}
|
3300
|
-
$.$mol_assert_like = $mol_assert_like;
|
3301
|
-
function $mol_assert_unique(...args) {
|
3302
|
-
for (let i = 0; i < args.length; ++i) {
|
3303
|
-
for (let j = 0; j < args.length; ++j) {
|
3304
|
-
if (i === j)
|
3305
|
-
continue;
|
3306
|
-
if (!$mol_compare_deep(args[i], args[j]))
|
3307
|
-
continue;
|
3308
|
-
$mol_fail(new Error(`args[${i}] = args[${j}] = ${print(args[i])}`));
|
3309
|
-
}
|
3070
|
+
destructor() {
|
3071
|
+
const index = $.$mol_after_mock_queue.indexOf(this.task);
|
3072
|
+
if (index >= 0)
|
3073
|
+
$.$mol_after_mock_queue.splice(index, 1);
|
3310
3074
|
}
|
3311
3075
|
}
|
3312
|
-
$.$
|
3313
|
-
|
3314
|
-
|
3315
|
-
|
3316
|
-
|
3317
|
-
|
3318
|
-
continue;
|
3319
|
-
return $mol_fail(new Error(`args[0] ≠ args[${i}]\n${print(args[0])}\n---\n${print(args[i])}`));
|
3076
|
+
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
3077
|
+
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
3078
|
+
delay;
|
3079
|
+
constructor(delay, task) {
|
3080
|
+
super(task);
|
3081
|
+
this.delay = delay;
|
3320
3082
|
}
|
3321
3083
|
}
|
3322
|
-
$.$
|
3323
|
-
|
3324
|
-
|
3325
|
-
|
3326
|
-
|
3327
|
-
|
3328
|
-
|
3329
|
-
|
3330
|
-
|
3331
|
-
|
3332
|
-
if ('outerHTML' in val)
|
3333
|
-
return val.outerHTML;
|
3334
|
-
try {
|
3335
|
-
return JSON.stringify(val, (k, v) => typeof v === 'bigint' ? String(v) : v, '\t');
|
3336
|
-
}
|
3337
|
-
catch (error) {
|
3338
|
-
console.error(error);
|
3339
|
-
return val;
|
3340
|
-
}
|
3341
|
-
};
|
3084
|
+
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
3085
|
+
})($ || ($ = {}));
|
3086
|
+
|
3087
|
+
;
|
3088
|
+
"use strict";
|
3089
|
+
var $;
|
3090
|
+
(function ($_1) {
|
3091
|
+
$mol_test_mocks.push($ => {
|
3092
|
+
$.$mol_after_tick = $mol_after_mock_commmon;
|
3093
|
+
});
|
3342
3094
|
})($ || ($ = {}));
|
3343
3095
|
|
3344
3096
|
;
|
@@ -3346,35 +3098,79 @@ var $;
|
|
3346
3098
|
var $;
|
3347
3099
|
(function ($) {
|
3348
3100
|
$mol_test({
|
3349
|
-
'
|
3350
|
-
$
|
3351
|
-
|
3352
|
-
|
3353
|
-
|
3354
|
-
|
3355
|
-
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3359
|
-
$mol_assert_equal(2, 2, 2);
|
3360
|
-
},
|
3361
|
-
'two must be unique'() {
|
3362
|
-
$mol_assert_unique([2], [3]);
|
3363
|
-
},
|
3364
|
-
'three must be unique'() {
|
3365
|
-
$mol_assert_unique([1], [2], [3]);
|
3366
|
-
},
|
3367
|
-
'two must be alike'() {
|
3368
|
-
$mol_assert_like([3], [3]);
|
3101
|
+
'Sync execution'() {
|
3102
|
+
class Sync extends $mol_object2 {
|
3103
|
+
static calc(a, b) {
|
3104
|
+
return a + b;
|
3105
|
+
}
|
3106
|
+
}
|
3107
|
+
__decorate([
|
3108
|
+
$mol_wire_method
|
3109
|
+
], Sync, "calc", null);
|
3110
|
+
$mol_assert_equal(Sync.calc(1, 2), 3);
|
3369
3111
|
},
|
3370
|
-
'
|
3371
|
-
$
|
3112
|
+
async 'async <=> sync'() {
|
3113
|
+
class SyncAsync extends $mol_object2 {
|
3114
|
+
static async val(a) {
|
3115
|
+
return a;
|
3116
|
+
}
|
3117
|
+
static sum(a, b) {
|
3118
|
+
const syn = $mol_wire_sync(this);
|
3119
|
+
return syn.val(a) + syn.val(b);
|
3120
|
+
}
|
3121
|
+
static async calc(a, b) {
|
3122
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
3123
|
+
}
|
3124
|
+
}
|
3125
|
+
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
3372
3126
|
},
|
3373
|
-
'
|
3374
|
-
|
3127
|
+
async 'Idempotence control'() {
|
3128
|
+
class Idempotence extends $mol_object2 {
|
3129
|
+
static logs_idemp = 0;
|
3130
|
+
static logs_unidemp = 0;
|
3131
|
+
static log_idemp() {
|
3132
|
+
this.logs_idemp += 1;
|
3133
|
+
}
|
3134
|
+
static log_unidemp() {
|
3135
|
+
this.logs_unidemp += 1;
|
3136
|
+
}
|
3137
|
+
static async val(a) {
|
3138
|
+
return a;
|
3139
|
+
}
|
3140
|
+
static sum(a, b) {
|
3141
|
+
this.log_idemp();
|
3142
|
+
this.log_unidemp();
|
3143
|
+
const syn = $mol_wire_sync(this);
|
3144
|
+
return syn.val(a) + syn.val(b);
|
3145
|
+
}
|
3146
|
+
static async calc(a, b) {
|
3147
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
3148
|
+
}
|
3149
|
+
}
|
3150
|
+
__decorate([
|
3151
|
+
$mol_wire_method
|
3152
|
+
], Idempotence, "log_idemp", null);
|
3153
|
+
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
3154
|
+
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
3155
|
+
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
3375
3156
|
},
|
3376
|
-
'
|
3377
|
-
|
3157
|
+
async 'Error handling'() {
|
3158
|
+
class Handle extends $mol_object2 {
|
3159
|
+
static async sum(a, b) {
|
3160
|
+
$mol_fail(new Error('test error ' + (a + b)));
|
3161
|
+
}
|
3162
|
+
static check() {
|
3163
|
+
try {
|
3164
|
+
return $mol_wire_sync(Handle).sum(1, 2);
|
3165
|
+
}
|
3166
|
+
catch (error) {
|
3167
|
+
if ($mol_promise_like(error))
|
3168
|
+
$mol_fail_hidden(error);
|
3169
|
+
$mol_assert_equal(error.message, 'test error 3');
|
3170
|
+
}
|
3171
|
+
}
|
3172
|
+
}
|
3173
|
+
await $mol_wire_async(Handle).check();
|
3378
3174
|
},
|
3379
3175
|
});
|
3380
3176
|
})($ || ($ = {}));
|
@@ -3382,15 +3178,56 @@ var $;
|
|
3382
3178
|
;
|
3383
3179
|
"use strict";
|
3384
3180
|
var $;
|
3385
|
-
(function ($
|
3386
|
-
$
|
3387
|
-
|
3388
|
-
|
3389
|
-
|
3390
|
-
|
3391
|
-
|
3392
|
-
|
3393
|
-
|
3181
|
+
(function ($) {
|
3182
|
+
function $mol_dom_render_children(el, childNodes) {
|
3183
|
+
const node_set = new Set(childNodes);
|
3184
|
+
let nextNode = el.firstChild;
|
3185
|
+
for (let view of childNodes) {
|
3186
|
+
if (view == null)
|
3187
|
+
continue;
|
3188
|
+
if (view instanceof $mol_dom_context.Node) {
|
3189
|
+
while (true) {
|
3190
|
+
if (!nextNode) {
|
3191
|
+
el.appendChild(view);
|
3192
|
+
break;
|
3193
|
+
}
|
3194
|
+
if (nextNode == view) {
|
3195
|
+
nextNode = nextNode.nextSibling;
|
3196
|
+
break;
|
3197
|
+
}
|
3198
|
+
else {
|
3199
|
+
if (node_set.has(nextNode)) {
|
3200
|
+
el.insertBefore(view, nextNode);
|
3201
|
+
break;
|
3202
|
+
}
|
3203
|
+
else {
|
3204
|
+
const nn = nextNode.nextSibling;
|
3205
|
+
el.removeChild(nextNode);
|
3206
|
+
nextNode = nn;
|
3207
|
+
}
|
3208
|
+
}
|
3209
|
+
}
|
3210
|
+
}
|
3211
|
+
else {
|
3212
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
3213
|
+
const str = String(view);
|
3214
|
+
if (nextNode.nodeValue !== str)
|
3215
|
+
nextNode.nodeValue = str;
|
3216
|
+
nextNode = nextNode.nextSibling;
|
3217
|
+
}
|
3218
|
+
else {
|
3219
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
3220
|
+
el.insertBefore(textNode, nextNode);
|
3221
|
+
}
|
3222
|
+
}
|
3223
|
+
}
|
3224
|
+
while (nextNode) {
|
3225
|
+
const currNode = nextNode;
|
3226
|
+
nextNode = currNode.nextSibling;
|
3227
|
+
el.removeChild(currNode);
|
3228
|
+
}
|
3229
|
+
}
|
3230
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
3394
3231
|
})($ || ($ = {}));
|
3395
3232
|
|
3396
3233
|
;
|
@@ -3401,233 +3238,353 @@ var $;
|
|
3401
3238
|
|
3402
3239
|
;
|
3403
3240
|
"use strict";
|
3241
|
+
var $;
|
3242
|
+
(function ($) {
|
3243
|
+
$.$mol_jsx_prefix = '';
|
3244
|
+
$.$mol_jsx_crumbs = '';
|
3245
|
+
$.$mol_jsx_booked = null;
|
3246
|
+
$.$mol_jsx_document = {
|
3247
|
+
getElementById: () => null,
|
3248
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
3249
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
3250
|
+
};
|
3251
|
+
$.$mol_jsx_frag = '';
|
3252
|
+
function $mol_jsx(Elem, props, ...childNodes) {
|
3253
|
+
const id = props && props.id || '';
|
3254
|
+
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
3255
|
+
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
|
3256
|
+
if (Elem && $.$mol_jsx_booked) {
|
3257
|
+
if ($.$mol_jsx_booked.has(id)) {
|
3258
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
3259
|
+
}
|
3260
|
+
else {
|
3261
|
+
$.$mol_jsx_booked.add(id);
|
3262
|
+
}
|
3263
|
+
}
|
3264
|
+
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
3265
|
+
if ($.$mol_jsx_prefix) {
|
3266
|
+
const prefix_ext = $.$mol_jsx_prefix;
|
3267
|
+
const booked_ext = $.$mol_jsx_booked;
|
3268
|
+
const crumbs_ext = $.$mol_jsx_crumbs;
|
3269
|
+
for (const field in props) {
|
3270
|
+
const func = props[field];
|
3271
|
+
if (typeof func !== 'function')
|
3272
|
+
continue;
|
3273
|
+
const wrapper = function (...args) {
|
3274
|
+
const prefix = $.$mol_jsx_prefix;
|
3275
|
+
const booked = $.$mol_jsx_booked;
|
3276
|
+
const crumbs = $.$mol_jsx_crumbs;
|
3277
|
+
try {
|
3278
|
+
$.$mol_jsx_prefix = prefix_ext;
|
3279
|
+
$.$mol_jsx_booked = booked_ext;
|
3280
|
+
$.$mol_jsx_crumbs = crumbs_ext;
|
3281
|
+
return func.call(this, ...args);
|
3282
|
+
}
|
3283
|
+
finally {
|
3284
|
+
$.$mol_jsx_prefix = prefix;
|
3285
|
+
$.$mol_jsx_booked = booked;
|
3286
|
+
$.$mol_jsx_crumbs = crumbs;
|
3287
|
+
}
|
3288
|
+
};
|
3289
|
+
$mol_func_name_from(wrapper, func);
|
3290
|
+
props[field] = wrapper;
|
3291
|
+
}
|
3292
|
+
}
|
3293
|
+
if (typeof Elem !== 'string') {
|
3294
|
+
if ('prototype' in Elem) {
|
3295
|
+
const view = node && node[String(Elem)] || new Elem;
|
3296
|
+
Object.assign(view, props);
|
3297
|
+
view[Symbol.toStringTag] = guid;
|
3298
|
+
view.childNodes = childNodes;
|
3299
|
+
if (!view.ownerDocument)
|
3300
|
+
view.ownerDocument = $.$mol_jsx_document;
|
3301
|
+
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
3302
|
+
node = view.valueOf();
|
3303
|
+
node[String(Elem)] = view;
|
3304
|
+
return node;
|
3305
|
+
}
|
3306
|
+
else {
|
3307
|
+
const prefix = $.$mol_jsx_prefix;
|
3308
|
+
const booked = $.$mol_jsx_booked;
|
3309
|
+
const crumbs = $.$mol_jsx_crumbs;
|
3310
|
+
try {
|
3311
|
+
$.$mol_jsx_prefix = guid;
|
3312
|
+
$.$mol_jsx_booked = new Set;
|
3313
|
+
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
3314
|
+
return Elem(props, ...childNodes);
|
3315
|
+
}
|
3316
|
+
finally {
|
3317
|
+
$.$mol_jsx_prefix = prefix;
|
3318
|
+
$.$mol_jsx_booked = booked;
|
3319
|
+
$.$mol_jsx_crumbs = crumbs;
|
3320
|
+
}
|
3321
|
+
}
|
3322
|
+
}
|
3323
|
+
if (!node) {
|
3324
|
+
node = Elem
|
3325
|
+
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
3326
|
+
: $.$mol_jsx_document.createDocumentFragment();
|
3327
|
+
}
|
3328
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
3329
|
+
if (!Elem)
|
3330
|
+
return node;
|
3331
|
+
if (guid)
|
3332
|
+
node.id = guid;
|
3333
|
+
for (const key in props) {
|
3334
|
+
if (key === 'id')
|
3335
|
+
continue;
|
3336
|
+
if (typeof props[key] === 'string') {
|
3337
|
+
if (typeof node[key] === 'string')
|
3338
|
+
node[key] = props[key];
|
3339
|
+
node.setAttribute(key, props[key]);
|
3340
|
+
}
|
3341
|
+
else if (props[key] &&
|
3342
|
+
typeof props[key] === 'object' &&
|
3343
|
+
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
3344
|
+
if (typeof node[key] === 'object') {
|
3345
|
+
Object.assign(node[key], props[key]);
|
3346
|
+
continue;
|
3347
|
+
}
|
3348
|
+
}
|
3349
|
+
else {
|
3350
|
+
node[key] = props[key];
|
3351
|
+
}
|
3352
|
+
}
|
3353
|
+
if ($.$mol_jsx_crumbs)
|
3354
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
3355
|
+
return node;
|
3356
|
+
}
|
3357
|
+
$.$mol_jsx = $mol_jsx;
|
3358
|
+
})($ || ($ = {}));
|
3404
3359
|
|
3405
3360
|
;
|
3406
3361
|
"use strict";
|
3407
3362
|
var $;
|
3408
3363
|
(function ($) {
|
3409
3364
|
$mol_test({
|
3410
|
-
'
|
3411
|
-
|
3412
|
-
$mol_assert_equal(proxy.foo, 777);
|
3413
|
-
},
|
3414
|
-
'has'() {
|
3415
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
3416
|
-
$mol_assert_equal('foo' in proxy, true);
|
3417
|
-
},
|
3418
|
-
'set'() {
|
3419
|
-
const target = { foo: 777 };
|
3420
|
-
const proxy = $mol_delegate({}, () => target);
|
3421
|
-
proxy.foo = 123;
|
3422
|
-
$mol_assert_equal(target.foo, 123);
|
3365
|
+
'Make empty div'() {
|
3366
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
3423
3367
|
},
|
3424
|
-
'
|
3425
|
-
const
|
3426
|
-
$
|
3427
|
-
|
3428
|
-
writable: true,
|
3429
|
-
enumerable: true,
|
3430
|
-
configurable: true,
|
3431
|
-
});
|
3368
|
+
'Define native field'() {
|
3369
|
+
const dom = $mol_jsx("input", { value: '123' });
|
3370
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
3371
|
+
$mol_assert_equal(dom.value, '123');
|
3432
3372
|
},
|
3433
|
-
'
|
3434
|
-
const
|
3435
|
-
$
|
3373
|
+
'Define classes'() {
|
3374
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
3375
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
3436
3376
|
},
|
3437
|
-
'
|
3438
|
-
|
3439
|
-
|
3440
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
3441
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
3377
|
+
'Define styles'() {
|
3378
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
3379
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
3442
3380
|
},
|
3443
|
-
'
|
3444
|
-
|
3445
|
-
|
3446
|
-
const target = {};
|
3447
|
-
const proxy = $mol_delegate({}, () => target);
|
3448
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
3449
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
3381
|
+
'Define dataset'() {
|
3382
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
3383
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
3450
3384
|
},
|
3451
|
-
'
|
3452
|
-
|
3453
|
-
|
3454
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
3455
|
-
$mol_assert_ok(proxy instanceof Foo);
|
3456
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
3385
|
+
'Define attributes'() {
|
3386
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
3387
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
3457
3388
|
},
|
3458
|
-
'
|
3459
|
-
|
3460
|
-
|
3461
|
-
|
3462
|
-
|
3463
|
-
$
|
3389
|
+
'Define child nodes'() {
|
3390
|
+
const dom = $mol_jsx("div", null,
|
3391
|
+
"hello",
|
3392
|
+
$mol_jsx("strong", null, "world"),
|
3393
|
+
"!");
|
3394
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
3464
3395
|
},
|
3465
|
-
|
3466
|
-
|
3467
|
-
|
3468
|
-
;
|
3469
|
-
"
|
3470
|
-
|
3471
|
-
(function ($_1) {
|
3472
|
-
$mol_test({
|
3473
|
-
'span for same uri'($) {
|
3474
|
-
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
3475
|
-
const child = span.span(4, 5, 8);
|
3476
|
-
$mol_assert_equal(child.uri, 'test.ts');
|
3477
|
-
$mol_assert_equal(child.row, 4);
|
3478
|
-
$mol_assert_equal(child.col, 5);
|
3479
|
-
$mol_assert_equal(child.length, 8);
|
3396
|
+
'Function as component'() {
|
3397
|
+
const Button = (props, target) => {
|
3398
|
+
return $mol_jsx("button", { title: props.hint }, target());
|
3399
|
+
};
|
3400
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
3401
|
+
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
3480
3402
|
},
|
3481
|
-
'
|
3482
|
-
const
|
3483
|
-
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3487
|
-
|
3403
|
+
'Nested guid generation'() {
|
3404
|
+
const Foo = () => {
|
3405
|
+
return $mol_jsx("div", null,
|
3406
|
+
$mol_jsx(Bar, { id: "bar" },
|
3407
|
+
$mol_jsx("img", { id: "icon" })));
|
3408
|
+
};
|
3409
|
+
const Bar = (props, icon) => {
|
3410
|
+
return $mol_jsx("span", null,
|
3411
|
+
icon,
|
3412
|
+
$mol_jsx("i", { id: "label" }));
|
3413
|
+
};
|
3414
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
3415
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
3488
3416
|
},
|
3489
|
-
'
|
3490
|
-
const
|
3491
|
-
|
3492
|
-
|
3493
|
-
|
3494
|
-
|
3495
|
-
|
3496
|
-
$mol_assert_equal(child2.col, 5);
|
3497
|
-
$mol_assert_equal(child2.length, 0);
|
3417
|
+
'Fail on non unique ids'() {
|
3418
|
+
const App = () => {
|
3419
|
+
return $mol_jsx("div", null,
|
3420
|
+
$mol_jsx("span", { id: "bar" }),
|
3421
|
+
$mol_jsx("span", { id: "bar" }));
|
3422
|
+
};
|
3423
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
3498
3424
|
},
|
3499
|
-
'
|
3500
|
-
const
|
3501
|
-
|
3502
|
-
|
3503
|
-
|
3504
|
-
|
3425
|
+
'Owner based guid generationn'() {
|
3426
|
+
const Foo = () => {
|
3427
|
+
return $mol_jsx("div", null,
|
3428
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
3429
|
+
};
|
3430
|
+
const Bar = (props) => {
|
3431
|
+
return $mol_jsx("span", null, props.icon());
|
3432
|
+
};
|
3433
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
3434
|
+
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
3505
3435
|
},
|
3506
|
-
'
|
3507
|
-
const
|
3508
|
-
|
3509
|
-
|
3510
|
-
|
3436
|
+
'Fail on same ids from different caller'() {
|
3437
|
+
const Foo = () => {
|
3438
|
+
return $mol_jsx("div", null,
|
3439
|
+
$mol_jsx("img", { id: "icon" }),
|
3440
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
3441
|
+
};
|
3442
|
+
const Bar = (props) => {
|
3443
|
+
return $mol_jsx("span", null, props.icon());
|
3444
|
+
};
|
3445
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
3511
3446
|
},
|
3512
|
-
'error handling'($) {
|
3513
|
-
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
3514
|
-
const error = span.error('Some error');
|
3515
|
-
$mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
|
3516
|
-
}
|
3517
3447
|
});
|
3518
3448
|
})($ || ($ = {}));
|
3519
3449
|
|
3520
3450
|
;
|
3521
3451
|
"use strict";
|
3522
3452
|
var $;
|
3523
|
-
(function ($
|
3524
|
-
$
|
3525
|
-
|
3526
|
-
|
3527
|
-
|
3528
|
-
|
3529
|
-
|
3530
|
-
|
3531
|
-
|
3532
|
-
|
3533
|
-
.insert($mol_tree2.struct('x'), 0, 0, 0)
|
3534
|
-
.toString(), 'a b x\n');
|
3535
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
3536
|
-
.insert($mol_tree2.struct('x'), 0, 0, 0, 0)
|
3537
|
-
.toString(), 'a b \\\n\tx\n');
|
3538
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
3539
|
-
.insert($mol_tree2.struct('x'), null, null, null)
|
3540
|
-
.toString(), 'a b x\n');
|
3541
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
3542
|
-
.insert($mol_tree2.struct('x'), null, null, null, null)
|
3543
|
-
.toString(), 'a b \\\n\tx\n');
|
3544
|
-
},
|
3545
|
-
'deleting'($) {
|
3546
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
3547
|
-
.insert(null, 'a', 'b', 'c')
|
3548
|
-
.toString(), 'a b\n');
|
3549
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
3550
|
-
.insert(null, 0, 0, 0)
|
3551
|
-
.toString(), 'a b\n');
|
3552
|
-
},
|
3553
|
-
'hack'($) {
|
3554
|
-
const res = $.$mol_tree2_from_string(`foo bar xxx\n`)
|
3555
|
-
.hack({
|
3556
|
-
'bar': (input, belt) => [input.struct('777', input.hack(belt))],
|
3557
|
-
});
|
3558
|
-
$mol_assert_equal(res.toString(), 'foo 777 xxx\n');
|
3559
|
-
},
|
3560
|
-
});
|
3453
|
+
(function ($) {
|
3454
|
+
function $mol_guid(length = 8, exists = () => false) {
|
3455
|
+
for (;;) {
|
3456
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
3457
|
+
if (exists(id))
|
3458
|
+
continue;
|
3459
|
+
return id;
|
3460
|
+
}
|
3461
|
+
}
|
3462
|
+
$.$mol_guid = $mol_guid;
|
3561
3463
|
})($ || ($ = {}));
|
3562
3464
|
|
3563
3465
|
;
|
3564
3466
|
"use strict";
|
3565
3467
|
var $;
|
3566
|
-
(function ($
|
3567
|
-
$
|
3568
|
-
'
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3572
|
-
|
3573
|
-
|
3574
|
-
|
3575
|
-
|
3576
|
-
|
3577
|
-
|
3578
|
-
|
3579
|
-
|
3580
|
-
|
3581
|
-
|
3582
|
-
|
3583
|
-
|
3584
|
-
|
3585
|
-
}, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
|
3586
|
-
},
|
3587
|
-
'Too few tabs'($) {
|
3588
|
-
const tree = `
|
3589
|
-
foo
|
3590
|
-
bar
|
3591
|
-
`;
|
3592
|
-
$mol_assert_fail(() => {
|
3593
|
-
$.$mol_tree2_from_string(tree, 'test');
|
3594
|
-
}, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
|
3595
|
-
},
|
3596
|
-
'Wrong nodes separator at start'($) {
|
3597
|
-
const tree = `foo\n \tbar\n`;
|
3598
|
-
$mol_assert_fail(() => {
|
3599
|
-
$.$mol_tree2_from_string(tree, 'test');
|
3600
|
-
}, 'Wrong nodes separator\ntest#2:1/2\n!!\n \tbar');
|
3601
|
-
},
|
3602
|
-
'Wrong nodes separator in the middle'($) {
|
3603
|
-
const tree = `foo bar\n`;
|
3604
|
-
$mol_assert_fail(() => {
|
3605
|
-
$.$mol_tree2_from_string(tree, 'test');
|
3606
|
-
}, 'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar');
|
3607
|
-
},
|
3608
|
-
'Unexpected EOF, LF required'($) {
|
3609
|
-
const tree = ` foo`;
|
3610
|
-
$mol_assert_fail(() => {
|
3611
|
-
$.$mol_tree2_from_string(tree, 'test');
|
3612
|
-
}, 'Unexpected EOF, LF required\ntest#1:5/1\n !\n foo');
|
3613
|
-
},
|
3614
|
-
'Errors skip and collect'($) {
|
3615
|
-
const tree = `foo bar`;
|
3616
|
-
const errors = [];
|
3617
|
-
const $$ = $.$mol_ambient({
|
3618
|
-
$mol_fail: (error) => {
|
3619
|
-
errors.push(error.message);
|
3620
|
-
return null;
|
3468
|
+
(function ($) {
|
3469
|
+
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
3470
|
+
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
3471
|
+
if (typeof item !== 'function') {
|
3472
|
+
item = index => source[index];
|
3473
|
+
size = () => source.length;
|
3474
|
+
}
|
3475
|
+
return new Proxy(source, {
|
3476
|
+
get(target, field) {
|
3477
|
+
if (typeof field === 'string') {
|
3478
|
+
if (field === 'length')
|
3479
|
+
return size();
|
3480
|
+
const index = Number(field);
|
3481
|
+
if (index < 0)
|
3482
|
+
return undefined;
|
3483
|
+
if (index >= size())
|
3484
|
+
return undefined;
|
3485
|
+
if (index === Math.trunc(index))
|
3486
|
+
return item(index);
|
3621
3487
|
}
|
3622
|
-
|
3623
|
-
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
3628
|
-
|
3629
|
-
|
3630
|
-
|
3488
|
+
return $mol_range2_array.prototype[field];
|
3489
|
+
},
|
3490
|
+
set(target, field) {
|
3491
|
+
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
3492
|
+
},
|
3493
|
+
ownKeys(target) {
|
3494
|
+
return [...Array(size())].map((v, i) => String(i)).concat('length');
|
3495
|
+
},
|
3496
|
+
getOwnPropertyDescriptor(target, field) {
|
3497
|
+
if (field === "length")
|
3498
|
+
return {
|
3499
|
+
value: size(),
|
3500
|
+
writable: true,
|
3501
|
+
enumerable: false,
|
3502
|
+
configurable: false,
|
3503
|
+
};
|
3504
|
+
const index = Number(field);
|
3505
|
+
if (index === Math.trunc(index))
|
3506
|
+
return {
|
3507
|
+
get: () => this.get(target, field, this),
|
3508
|
+
enumerable: true,
|
3509
|
+
configurable: true,
|
3510
|
+
};
|
3511
|
+
return Object.getOwnPropertyDescriptor(target, field);
|
3512
|
+
}
|
3513
|
+
});
|
3514
|
+
}
|
3515
|
+
$.$mol_range2 = $mol_range2;
|
3516
|
+
class $mol_range2_array extends Array {
|
3517
|
+
concat(...tail) {
|
3518
|
+
if (tail.length === 0)
|
3519
|
+
return this;
|
3520
|
+
if (tail.length > 1) {
|
3521
|
+
let list = this;
|
3522
|
+
for (let item of tail)
|
3523
|
+
list = list.concat(item);
|
3524
|
+
return list;
|
3525
|
+
}
|
3526
|
+
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
3527
|
+
}
|
3528
|
+
filter(check, context) {
|
3529
|
+
const filtered = [];
|
3530
|
+
let cursor = -1;
|
3531
|
+
return $mol_range2(index => {
|
3532
|
+
while (cursor < this.length && index >= filtered.length - 1) {
|
3533
|
+
const val = this[++cursor];
|
3534
|
+
if (check(val, cursor, this))
|
3535
|
+
filtered.push(val);
|
3536
|
+
}
|
3537
|
+
return filtered[index];
|
3538
|
+
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
3539
|
+
}
|
3540
|
+
forEach(proceed, context) {
|
3541
|
+
for (let [key, value] of this.entries())
|
3542
|
+
proceed.call(context, value, key, this);
|
3543
|
+
}
|
3544
|
+
map(proceed, context) {
|
3545
|
+
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
3546
|
+
}
|
3547
|
+
reduce(merge, result) {
|
3548
|
+
let index = 0;
|
3549
|
+
if (arguments.length === 1) {
|
3550
|
+
result = this[index++];
|
3551
|
+
}
|
3552
|
+
for (; index < this.length; ++index) {
|
3553
|
+
result = merge(result, this[index], index, this);
|
3554
|
+
}
|
3555
|
+
return result;
|
3556
|
+
}
|
3557
|
+
toReversed() {
|
3558
|
+
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
3559
|
+
}
|
3560
|
+
slice(from = 0, to = this.length) {
|
3561
|
+
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
3562
|
+
}
|
3563
|
+
some(check, context) {
|
3564
|
+
for (let index = 0; index < this.length; ++index) {
|
3565
|
+
if (check.call(context, this[index], index, this))
|
3566
|
+
return true;
|
3567
|
+
}
|
3568
|
+
return false;
|
3569
|
+
}
|
3570
|
+
every(check, context) {
|
3571
|
+
for (let index = 0; index < this.length; ++index) {
|
3572
|
+
if (!check.call(context, this[index], index, this))
|
3573
|
+
return false;
|
3574
|
+
}
|
3575
|
+
return true;
|
3576
|
+
}
|
3577
|
+
reverse() {
|
3578
|
+
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
3579
|
+
}
|
3580
|
+
sort() {
|
3581
|
+
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
3582
|
+
}
|
3583
|
+
[Symbol.toPrimitive]() {
|
3584
|
+
return $mol_guid();
|
3585
|
+
}
|
3586
|
+
}
|
3587
|
+
$.$mol_range2_array = $mol_range2_array;
|
3631
3588
|
})($ || ($ = {}));
|
3632
3589
|
|
3633
3590
|
;
|
@@ -3635,166 +3592,158 @@ var $;
|
|
3635
3592
|
var $;
|
3636
3593
|
(function ($) {
|
3637
3594
|
$mol_test({
|
3638
|
-
'
|
3639
|
-
|
3640
|
-
$
|
3641
|
-
$mol_assert_equal(
|
3642
|
-
$mol_assert_equal(
|
3643
|
-
$mol_assert_equal(
|
3644
|
-
$mol_assert_equal(
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
;
|
3650
|
-
"use strict";
|
3651
|
-
var $;
|
3652
|
-
(function ($_1) {
|
3653
|
-
$mol_test({
|
3654
|
-
'FQN of anon function'($) {
|
3655
|
-
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
3656
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
3657
|
-
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
3658
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
3595
|
+
'lazy calls'() {
|
3596
|
+
let calls = 0;
|
3597
|
+
const list = $mol_range2(index => (++calls, index), () => 10);
|
3598
|
+
$mol_assert_equal(true, list instanceof Array);
|
3599
|
+
$mol_assert_equal(list.length, 10);
|
3600
|
+
$mol_assert_equal(list[-1], undefined);
|
3601
|
+
$mol_assert_equal(list[0], 0);
|
3602
|
+
$mol_assert_equal(list[9], 9);
|
3603
|
+
$mol_assert_equal(list[9.5], undefined);
|
3604
|
+
$mol_assert_equal(list[10], undefined);
|
3605
|
+
$mol_assert_equal(calls, 2);
|
3659
3606
|
},
|
3660
|
-
|
3661
|
-
|
3662
|
-
|
3663
|
-
;
|
3664
|
-
|
3665
|
-
|
3666
|
-
(
|
3667
|
-
|
3668
|
-
|
3669
|
-
class Invalid extends $mol_error_mix {
|
3670
|
-
}
|
3671
|
-
const mix = new Invalid('foo');
|
3672
|
-
$mol_assert_equal(mix.name, 'Invalid_Error');
|
3607
|
+
'infinity list'() {
|
3608
|
+
let calls = 0;
|
3609
|
+
const list = $mol_range2(index => (++calls, index));
|
3610
|
+
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
3611
|
+
$mol_assert_equal(list[0], 0);
|
3612
|
+
$mol_assert_equal(list[4], 4);
|
3613
|
+
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
3614
|
+
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
3615
|
+
$mol_assert_equal(calls, 3);
|
3673
3616
|
},
|
3674
|
-
'
|
3675
|
-
const
|
3676
|
-
$mol_assert_equal(
|
3677
|
-
$mol_assert_equal(
|
3617
|
+
'stringify'() {
|
3618
|
+
const list = $mol_range2(i => i, () => 5);
|
3619
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
3620
|
+
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
3678
3621
|
},
|
3679
|
-
'
|
3680
|
-
|
3681
|
-
|
3682
|
-
|
3683
|
-
const hints = [];
|
3684
|
-
if (mix instanceof $mol_error_mix) {
|
3685
|
-
for (const er of mix.errors) {
|
3686
|
-
if (er instanceof Invalid) {
|
3687
|
-
hints.push(er.cause?.hint ?? '');
|
3688
|
-
}
|
3689
|
-
}
|
3622
|
+
'for-of'() {
|
3623
|
+
let log = '';
|
3624
|
+
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
3625
|
+
log += i;
|
3690
3626
|
}
|
3691
|
-
$mol_assert_equal(
|
3627
|
+
$mol_assert_equal(log, '12345');
|
3692
3628
|
},
|
3693
|
-
|
3694
|
-
|
3695
|
-
|
3696
|
-
;
|
3697
|
-
"use strict";
|
3698
|
-
var $;
|
3699
|
-
(function ($_1) {
|
3700
|
-
$mol_test({
|
3701
|
-
'Collect deps'() {
|
3702
|
-
const pub1 = new $mol_wire_pub;
|
3703
|
-
const pub2 = new $mol_wire_pub;
|
3704
|
-
const sub = new $mol_wire_pub_sub;
|
3705
|
-
const bu1 = sub.track_on();
|
3706
|
-
try {
|
3707
|
-
pub1.promote();
|
3708
|
-
pub2.promote();
|
3709
|
-
pub2.promote();
|
3710
|
-
}
|
3711
|
-
finally {
|
3712
|
-
sub.track_cut();
|
3713
|
-
sub.track_off(bu1);
|
3714
|
-
}
|
3715
|
-
pub1.emit();
|
3716
|
-
pub2.emit();
|
3717
|
-
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
3718
|
-
const bu2 = sub.track_on();
|
3719
|
-
try {
|
3720
|
-
pub1.promote();
|
3721
|
-
pub1.promote();
|
3722
|
-
pub2.promote();
|
3723
|
-
}
|
3724
|
-
finally {
|
3725
|
-
sub.track_cut();
|
3726
|
-
sub.track_off(bu2);
|
3629
|
+
'for-in'() {
|
3630
|
+
let log = '';
|
3631
|
+
for (let i in $mol_range2(i => i, () => 5)) {
|
3632
|
+
log += i;
|
3727
3633
|
}
|
3728
|
-
|
3729
|
-
pub2.emit();
|
3730
|
-
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
3634
|
+
$mol_assert_equal(log, '01234');
|
3731
3635
|
},
|
3732
|
-
'
|
3733
|
-
|
3734
|
-
|
3735
|
-
|
3736
|
-
|
3737
|
-
|
3738
|
-
|
3739
|
-
|
3740
|
-
|
3741
|
-
|
3742
|
-
|
3743
|
-
|
3744
|
-
|
3745
|
-
|
3746
|
-
|
3747
|
-
|
3748
|
-
|
3749
|
-
|
3636
|
+
'forEach'() {
|
3637
|
+
let log = '';
|
3638
|
+
$mol_range2(i => i, () => 5).forEach(i => log += i);
|
3639
|
+
$mol_assert_equal(log, '01234');
|
3640
|
+
},
|
3641
|
+
'reduce'() {
|
3642
|
+
let calls = 0;
|
3643
|
+
const list = $mol_range2().slice(1, 6);
|
3644
|
+
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
3645
|
+
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
3646
|
+
},
|
3647
|
+
'lazy concat'() {
|
3648
|
+
let calls1 = 0;
|
3649
|
+
let calls2 = 0;
|
3650
|
+
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
3651
|
+
$mol_assert_equal(true, list instanceof Array);
|
3652
|
+
$mol_assert_equal(list.length, 15);
|
3653
|
+
$mol_assert_equal(list[0], 0);
|
3654
|
+
$mol_assert_equal(list[4], 4);
|
3655
|
+
$mol_assert_equal(list[5], 0);
|
3656
|
+
$mol_assert_equal(list[9], 4);
|
3657
|
+
$mol_assert_equal(list[10], 0);
|
3658
|
+
$mol_assert_equal(list[14], 4);
|
3659
|
+
$mol_assert_equal(list[15], undefined);
|
3660
|
+
$mol_assert_equal(calls1, 2);
|
3661
|
+
$mol_assert_equal(calls2, 2);
|
3662
|
+
},
|
3663
|
+
'lazy filter'() {
|
3664
|
+
let calls = 0;
|
3665
|
+
const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
|
3666
|
+
$mol_assert_equal(true, list instanceof Array);
|
3667
|
+
$mol_assert_equal(list.length, 3);
|
3668
|
+
$mol_assert_equal(list[0], 1);
|
3669
|
+
$mol_assert_equal(list[2], 5);
|
3670
|
+
$mol_assert_equal(list[3], undefined);
|
3671
|
+
$mol_assert_equal(calls, 8);
|
3672
|
+
},
|
3673
|
+
'lazy reverse'() {
|
3674
|
+
let calls = 0;
|
3675
|
+
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
3676
|
+
$mol_assert_equal(true, list instanceof Array);
|
3677
|
+
$mol_assert_equal(list.length, 3);
|
3678
|
+
$mol_assert_equal(list[0], 9);
|
3679
|
+
$mol_assert_equal(list[2], 7);
|
3680
|
+
$mol_assert_equal(list[3], undefined);
|
3681
|
+
$mol_assert_equal(calls, 2);
|
3682
|
+
},
|
3683
|
+
'lazy map'() {
|
3684
|
+
let calls1 = 0;
|
3685
|
+
let calls2 = 0;
|
3686
|
+
const source = $mol_range2(index => (++calls1, index), () => 5);
|
3687
|
+
const target = source.map((item, index, self) => {
|
3688
|
+
++calls2;
|
3689
|
+
$mol_assert_equal(source, self);
|
3690
|
+
return index + 10;
|
3691
|
+
}, () => 5);
|
3692
|
+
$mol_assert_equal(true, target instanceof Array);
|
3693
|
+
$mol_assert_equal(target.length, 5);
|
3694
|
+
$mol_assert_equal(target[0], 10);
|
3695
|
+
$mol_assert_equal(target[4], 14);
|
3696
|
+
$mol_assert_equal(target[5], undefined);
|
3697
|
+
$mol_assert_equal(calls1, 2);
|
3698
|
+
$mol_assert_equal(calls2, 2);
|
3699
|
+
},
|
3700
|
+
'lazy slice'() {
|
3701
|
+
let calls = 0;
|
3702
|
+
const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
|
3703
|
+
$mol_assert_equal(true, list instanceof Array);
|
3704
|
+
$mol_assert_equal(list.length, 4);
|
3705
|
+
$mol_assert_equal(list[0], 3);
|
3706
|
+
$mol_assert_equal(list[3], 6);
|
3707
|
+
$mol_assert_equal(list[4], undefined);
|
3708
|
+
$mol_assert_equal(calls, 2);
|
3709
|
+
},
|
3710
|
+
'lazy some'() {
|
3711
|
+
let calls = 0;
|
3712
|
+
$mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
|
3713
|
+
$mol_assert_equal(calls, 3);
|
3714
|
+
$mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
|
3715
|
+
$mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
|
3750
3716
|
},
|
3751
|
-
|
3752
|
-
|
3753
|
-
|
3754
|
-
;
|
3755
|
-
|
3756
|
-
|
3757
|
-
|
3758
|
-
|
3759
|
-
|
3760
|
-
|
3761
|
-
|
3762
|
-
|
3763
|
-
|
3764
|
-
|
3765
|
-
|
3766
|
-
|
3767
|
-
|
3768
|
-
|
3769
|
-
|
3770
|
-
|
3771
|
-
|
3772
|
-
|
3773
|
-
|
3774
|
-
|
3775
|
-
|
3776
|
-
|
3777
|
-
|
3778
|
-
|
3779
|
-
|
3780
|
-
}
|
3781
|
-
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
3782
|
-
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
3783
|
-
delay;
|
3784
|
-
constructor(delay, task) {
|
3785
|
-
super(task);
|
3786
|
-
this.delay = delay;
|
3717
|
+
'lazy every'() {
|
3718
|
+
let calls = 0;
|
3719
|
+
$mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
|
3720
|
+
$mol_assert_equal(calls, 3);
|
3721
|
+
$mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
|
3722
|
+
$mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
|
3723
|
+
},
|
3724
|
+
'lazyfy'() {
|
3725
|
+
let calls = 0;
|
3726
|
+
const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
|
3727
|
+
$mol_assert_equal(true, list instanceof Array);
|
3728
|
+
$mol_assert_equal(list.length, 4);
|
3729
|
+
$mol_assert_equal(calls, 0);
|
3730
|
+
$mol_assert_equal(list[0], 12);
|
3731
|
+
$mol_assert_equal(list[3], 15);
|
3732
|
+
$mol_assert_equal(list[4], undefined);
|
3733
|
+
$mol_assert_equal(calls, 2);
|
3734
|
+
},
|
3735
|
+
'prevent modification'() {
|
3736
|
+
const list = $mol_range2(i => i, () => 5);
|
3737
|
+
$mol_assert_fail(() => list.push(4), TypeError);
|
3738
|
+
$mol_assert_fail(() => list.pop(), TypeError);
|
3739
|
+
$mol_assert_fail(() => list.unshift(4), TypeError);
|
3740
|
+
$mol_assert_fail(() => list.shift(), TypeError);
|
3741
|
+
$mol_assert_fail(() => list.splice(1, 2), TypeError);
|
3742
|
+
$mol_assert_fail(() => list[1] = 2, TypeError);
|
3743
|
+
$mol_assert_fail(() => list.reverse(), TypeError);
|
3744
|
+
$mol_assert_fail(() => list.sort(), TypeError);
|
3745
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
3787
3746
|
}
|
3788
|
-
}
|
3789
|
-
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
3790
|
-
})($ || ($ = {}));
|
3791
|
-
|
3792
|
-
;
|
3793
|
-
"use strict";
|
3794
|
-
var $;
|
3795
|
-
(function ($_1) {
|
3796
|
-
$mol_test_mocks.push($ => {
|
3797
|
-
$.$mol_after_tick = $mol_after_mock_commmon;
|
3798
3747
|
});
|
3799
3748
|
})($ || ($ = {}));
|
3800
3749
|
|
@@ -3803,79 +3752,125 @@ var $;
|
|
3803
3752
|
var $;
|
3804
3753
|
(function ($) {
|
3805
3754
|
$mol_test({
|
3806
|
-
'
|
3807
|
-
|
3808
|
-
|
3809
|
-
|
3810
|
-
|
3811
|
-
}
|
3812
|
-
__decorate([
|
3813
|
-
$mol_wire_method
|
3814
|
-
], Sync, "calc", null);
|
3815
|
-
$mol_assert_equal(Sync.calc(1, 2), 3);
|
3755
|
+
'nulls & undefineds'() {
|
3756
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
3757
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
3758
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
3759
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
3816
3760
|
},
|
3817
|
-
|
3818
|
-
|
3819
|
-
|
3820
|
-
|
3821
|
-
|
3822
|
-
|
3823
|
-
const syn = $mol_wire_sync(this);
|
3824
|
-
return syn.val(a) + syn.val(b);
|
3825
|
-
}
|
3826
|
-
static async calc(a, b) {
|
3827
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
3828
|
-
}
|
3829
|
-
}
|
3830
|
-
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
3761
|
+
'number'() {
|
3762
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
3763
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
3764
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
3765
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
3766
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
3831
3767
|
},
|
3832
|
-
|
3833
|
-
|
3834
|
-
|
3835
|
-
|
3836
|
-
|
3837
|
-
|
3838
|
-
|
3839
|
-
|
3840
|
-
|
3841
|
-
|
3842
|
-
|
3843
|
-
|
3844
|
-
|
3845
|
-
|
3846
|
-
|
3847
|
-
|
3848
|
-
|
3849
|
-
|
3850
|
-
|
3851
|
-
static async calc(a, b) {
|
3852
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
3853
|
-
}
|
3768
|
+
'POJO'() {
|
3769
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
3770
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
3771
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
3772
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
3773
|
+
$mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
3774
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
3775
|
+
$mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
|
3776
|
+
},
|
3777
|
+
'Array'() {
|
3778
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
3779
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
3780
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
3781
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
3782
|
+
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
3783
|
+
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
3784
|
+
},
|
3785
|
+
'Non POJO are different'() {
|
3786
|
+
class Thing extends Object {
|
3854
3787
|
}
|
3855
|
-
|
3856
|
-
|
3857
|
-
|
3858
|
-
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
3859
|
-
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
3860
|
-
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
3788
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
3789
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
3790
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
3861
3791
|
},
|
3862
|
-
|
3863
|
-
|
3864
|
-
|
3865
|
-
|
3792
|
+
'POJO with symbols'() {
|
3793
|
+
const sym = Symbol();
|
3794
|
+
$mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
|
3795
|
+
$mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
|
3796
|
+
},
|
3797
|
+
'same POJOs with cyclic reference'() {
|
3798
|
+
const a = { foo: {} };
|
3799
|
+
a['self'] = a;
|
3800
|
+
const b = { foo: {} };
|
3801
|
+
b['self'] = b;
|
3802
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
3803
|
+
},
|
3804
|
+
'same POJOs with cyclic reference with cache warmup'() {
|
3805
|
+
const obj1 = { test: 1, obj3: null };
|
3806
|
+
const obj1_copy = { test: 1, obj3: null };
|
3807
|
+
const obj2 = { test: 2, obj1 };
|
3808
|
+
const obj2_copy = { test: 2, obj1: obj1_copy };
|
3809
|
+
const obj3 = { test: 3, obj2 };
|
3810
|
+
const obj3_copy = { test: 3, obj2: obj2_copy };
|
3811
|
+
obj1.obj3 = obj3;
|
3812
|
+
obj1_copy.obj3 = obj3_copy;
|
3813
|
+
$mol_assert_not($mol_compare_deep(obj1, {}));
|
3814
|
+
$mol_assert_not($mol_compare_deep(obj2, {}));
|
3815
|
+
$mol_assert_not($mol_compare_deep(obj3, {}));
|
3816
|
+
$mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
|
3817
|
+
},
|
3818
|
+
'Date'() {
|
3819
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
3820
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
3821
|
+
},
|
3822
|
+
'RegExp'() {
|
3823
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
3824
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
3825
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
3826
|
+
},
|
3827
|
+
'Error'() {
|
3828
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
3829
|
+
const fail = (message) => new Error(message);
|
3830
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
3831
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
3832
|
+
},
|
3833
|
+
'Map'() {
|
3834
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
3835
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
3836
|
+
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
3837
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
3838
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
3839
|
+
},
|
3840
|
+
'Set'() {
|
3841
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
3842
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
3843
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
3844
|
+
},
|
3845
|
+
'Uint8Array'() {
|
3846
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
3847
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
3848
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
3849
|
+
},
|
3850
|
+
'DataView'() {
|
3851
|
+
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
|
3852
|
+
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
|
3853
|
+
$mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
|
3854
|
+
},
|
3855
|
+
'Serializale'() {
|
3856
|
+
class User {
|
3857
|
+
name;
|
3858
|
+
rand;
|
3859
|
+
constructor(name, rand = Math.random()) {
|
3860
|
+
this.name = name;
|
3861
|
+
this.rand = rand;
|
3866
3862
|
}
|
3867
|
-
|
3868
|
-
|
3869
|
-
return $mol_wire_sync(Handle).sum(1, 2);
|
3870
|
-
}
|
3871
|
-
catch (error) {
|
3872
|
-
if ($mol_promise_like(error))
|
3873
|
-
$mol_fail_hidden(error);
|
3874
|
-
$mol_assert_equal(error.message, 'test error 3');
|
3875
|
-
}
|
3863
|
+
[Symbol.toPrimitive](mode) {
|
3864
|
+
return this.name;
|
3876
3865
|
}
|
3877
3866
|
}
|
3878
|
-
|
3867
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
3868
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
3869
|
+
},
|
3870
|
+
'Iterable'() {
|
3871
|
+
$mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
|
3872
|
+
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
|
3873
|
+
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
|
3879
3874
|
},
|
3880
3875
|
});
|
3881
3876
|
})($ || ($ = {}));
|