mol_vary 0.0.69 → 0.0.71
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.d.ts +4 -0
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +78 -57
- package/node.js.map +1 -1
- package/node.mjs +78 -57
- package/node.test.js +1730 -1711
- package/node.test.js.map +1 -1
- package/package.json +5 -2
- package/web.js +48 -46
- package/web.js.map +1 -1
- package/web.mjs +48 -46
- package/web.test.js +0 -2
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -213,6 +213,20 @@ var $;
|
|
|
213
213
|
;
|
|
214
214
|
"use strict";
|
|
215
215
|
|
|
216
|
+
;
|
|
217
|
+
"use strict";
|
|
218
|
+
var $;
|
|
219
|
+
(function ($) {
|
|
220
|
+
const mod = require('module');
|
|
221
|
+
const internals = mod.builtinModules;
|
|
222
|
+
function $node_internal_check(name) {
|
|
223
|
+
if (name.startsWith('node:'))
|
|
224
|
+
return true;
|
|
225
|
+
return internals.includes(name);
|
|
226
|
+
}
|
|
227
|
+
$.$node_internal_check = $node_internal_check;
|
|
228
|
+
})($ || ($ = {}));
|
|
229
|
+
|
|
216
230
|
;
|
|
217
231
|
"use strict";
|
|
218
232
|
var $;
|
|
@@ -292,39 +306,44 @@ var $node = new Proxy({ require }, {
|
|
|
292
306
|
get(target, name, wrapper) {
|
|
293
307
|
if (target[name])
|
|
294
308
|
return target[name];
|
|
295
|
-
|
|
309
|
+
const $$ = $;
|
|
310
|
+
if ($$.$node_internal_check(name, target))
|
|
296
311
|
return target.require(name);
|
|
297
312
|
if (name[0] === '.')
|
|
298
313
|
return target.require(name);
|
|
299
|
-
const mod = target.require('module');
|
|
300
|
-
if (mod.builtinModules.indexOf(name) >= 0)
|
|
301
|
-
return target.require(name);
|
|
302
314
|
try {
|
|
303
315
|
target.require.resolve(name);
|
|
304
316
|
}
|
|
305
317
|
catch {
|
|
306
|
-
|
|
307
|
-
|
|
318
|
+
try {
|
|
319
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
320
|
+
}
|
|
321
|
+
catch (e) {
|
|
322
|
+
if ($$.$mol_promise_like(e))
|
|
323
|
+
$$.$mol_fail_hidden(e);
|
|
324
|
+
}
|
|
308
325
|
try {
|
|
309
326
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
310
327
|
}
|
|
311
328
|
catch (e) {
|
|
312
|
-
if ($$.$
|
|
313
|
-
$$.$
|
|
314
|
-
|
|
329
|
+
if ($$.$mol_promise_like(e))
|
|
330
|
+
$$.$mol_fail_hidden(e);
|
|
331
|
+
$$.$mol_fail_log(e);
|
|
315
332
|
}
|
|
316
333
|
}
|
|
317
334
|
try {
|
|
318
335
|
return target.require(name);
|
|
319
336
|
}
|
|
320
337
|
catch (error) {
|
|
321
|
-
if (
|
|
338
|
+
if ($$.$mol_promise_like(error))
|
|
339
|
+
$$.$mol_fail_hidden(error);
|
|
340
|
+
if (error && typeof error === 'object' && error.code === 'ERR_REQUIRE_ESM') {
|
|
322
341
|
const module = cache.get(name);
|
|
323
342
|
if (module)
|
|
324
343
|
return module;
|
|
325
344
|
throw Object.assign(import(name).then(module => cache.set(name, module)), { cause: error });
|
|
326
345
|
}
|
|
327
|
-
|
|
346
|
+
$$.$mol_fail_log(error);
|
|
328
347
|
return null;
|
|
329
348
|
}
|
|
330
349
|
},
|
|
@@ -2539,8 +2558,8 @@ var $;
|
|
|
2539
2558
|
if (stack.includes(val))
|
|
2540
2559
|
$mol_fail(new Error('Cyclic refs', { cause: { stack, val } }));
|
|
2541
2560
|
stack.push(val);
|
|
2542
|
-
for (
|
|
2543
|
-
dump(
|
|
2561
|
+
for (let i = 0; i < val.length; ++i)
|
|
2562
|
+
dump(val[i]);
|
|
2544
2563
|
if (stack.at(-1) !== val)
|
|
2545
2564
|
$mol_fail(new Error('Broken stack', { cause: { stack, val } }));
|
|
2546
2565
|
stack.pop();
|
|
@@ -2560,65 +2579,67 @@ var $;
|
|
|
2560
2579
|
const offset = offsets.get(val);
|
|
2561
2580
|
if (offset !== undefined)
|
|
2562
2581
|
return dump_unum($mol_vary_tip.link, offset);
|
|
2563
|
-
const
|
|
2582
|
+
const { 0: keys, 1: vals } = this.lean_find(val)?.(val) ?? [shape(val), Object.values(val)];
|
|
2564
2583
|
dump_unum($mol_vary_tip.tupl, vals.length);
|
|
2565
2584
|
acquire((vals.length + 1) * 9);
|
|
2566
2585
|
dump_list(keys);
|
|
2567
2586
|
if (stack.includes(val))
|
|
2568
2587
|
$mol_fail(new Error('Cyclic refs', { cause: { stack, val } }));
|
|
2569
2588
|
stack.push(val);
|
|
2570
|
-
for (
|
|
2571
|
-
dump(
|
|
2589
|
+
for (let i = 0; i < vals.length; ++i)
|
|
2590
|
+
dump(vals[i]);
|
|
2572
2591
|
if (stack.at(-1) !== val)
|
|
2573
2592
|
$mol_fail(new Error('Broken stack', { cause: { stack, val } }));
|
|
2574
2593
|
stack.pop();
|
|
2575
2594
|
offsets.set(val, offsets.size);
|
|
2576
2595
|
};
|
|
2577
|
-
const
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2596
|
+
const dumpers = {
|
|
2597
|
+
undefined: () => {
|
|
2598
|
+
this.array[pos++] = $mol_vary_spec.both;
|
|
2599
|
+
capacity -= 8;
|
|
2600
|
+
},
|
|
2601
|
+
boolean: val => {
|
|
2602
|
+
this.array[pos++] = val ? $mol_vary_spec.true : $mol_vary_spec.fake;
|
|
2603
|
+
capacity -= 8;
|
|
2604
|
+
},
|
|
2605
|
+
number: val => {
|
|
2606
|
+
if (!Number.isInteger(val))
|
|
2607
|
+
dump_float(val);
|
|
2608
|
+
else
|
|
2609
|
+
dumpers.bigint(val);
|
|
2610
|
+
},
|
|
2611
|
+
bigint: val => {
|
|
2612
|
+
if (val < 0) {
|
|
2613
|
+
dump_snum(val);
|
|
2592
2614
|
}
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
dump_snum(val);
|
|
2596
|
-
}
|
|
2597
|
-
else {
|
|
2598
|
-
dump_unum($mol_vary_tip.uint, val);
|
|
2599
|
-
}
|
|
2600
|
-
return;
|
|
2615
|
+
else {
|
|
2616
|
+
dump_unum($mol_vary_tip.uint, val);
|
|
2601
2617
|
}
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
if (ArrayBuffer.isView(val))
|
|
2609
|
-
return dump_buffer(val);
|
|
2610
|
-
if (Array.isArray(val))
|
|
2611
|
-
return dump_list(val);
|
|
2612
|
-
return dump_object(val);
|
|
2618
|
+
},
|
|
2619
|
+
string: val => dump_string(val),
|
|
2620
|
+
object: val => {
|
|
2621
|
+
if (!val) {
|
|
2622
|
+
capacity -= 8;
|
|
2623
|
+
return this.array[pos++] = $mol_vary_spec.none;
|
|
2613
2624
|
}
|
|
2625
|
+
if (Array.isArray(val))
|
|
2626
|
+
return dump_list(val);
|
|
2627
|
+
if (ArrayBuffer.isView(val))
|
|
2628
|
+
return dump_buffer(val);
|
|
2629
|
+
return dump_object(val);
|
|
2614
2630
|
}
|
|
2615
|
-
$mol_fail(new Error(`Unsupported type`));
|
|
2616
2631
|
};
|
|
2617
|
-
|
|
2632
|
+
const dump = (val) => {
|
|
2633
|
+
const dumper = dumpers[typeof val];
|
|
2634
|
+
if (!dumper)
|
|
2635
|
+
$mol_fail(new Error(`Unsupported type`));
|
|
2636
|
+
dumper(val);
|
|
2637
|
+
};
|
|
2638
|
+
for (let i = 0; i < data.length; ++i) {
|
|
2618
2639
|
capacity += 9;
|
|
2619
|
-
dump(
|
|
2640
|
+
dump(data[i]);
|
|
2620
2641
|
if (stack.length)
|
|
2621
|
-
$mol_fail(new Error('Stack underflow', { cause: { stack, item } }));
|
|
2642
|
+
$mol_fail(new Error('Stack underflow', { cause: { stack, item: data[i] } }));
|
|
2622
2643
|
offsets.clear();
|
|
2623
2644
|
}
|
|
2624
2645
|
if (pos !== capacity)
|
|
@@ -2823,12 +2844,12 @@ var $;
|
|
|
2823
2844
|
}
|
|
2824
2845
|
rich_node(keys) {
|
|
2825
2846
|
let node = this.rich_index;
|
|
2826
|
-
for (
|
|
2827
|
-
let sub = node.get(
|
|
2847
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
2848
|
+
let sub = node.get(keys[i]);
|
|
2828
2849
|
if (sub)
|
|
2829
2850
|
node = sub;
|
|
2830
2851
|
else
|
|
2831
|
-
node.set(
|
|
2852
|
+
node.set(keys[i], node = new Map);
|
|
2832
2853
|
}
|
|
2833
2854
|
return node;
|
|
2834
2855
|
}
|
|
@@ -2991,51 +3012,59 @@ var $;
|
|
|
2991
3012
|
$mol_test_mocks.push($ => $.$mol_fail_log = () => false);
|
|
2992
3013
|
})($ || ($ = {}));
|
|
2993
3014
|
|
|
2994
|
-
;
|
|
2995
|
-
"use strict";
|
|
2996
|
-
var $;
|
|
2997
|
-
(function ($_1) {
|
|
2998
|
-
$mol_test({
|
|
2999
|
-
'FQN of anon function'($) {
|
|
3000
|
-
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
3001
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
3002
|
-
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
3003
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
3004
|
-
},
|
|
3005
|
-
});
|
|
3006
|
-
})($ || ($ = {}));
|
|
3007
|
-
|
|
3008
3015
|
;
|
|
3009
3016
|
"use strict";
|
|
3010
3017
|
var $;
|
|
3011
3018
|
(function ($) {
|
|
3012
|
-
$
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3019
|
+
function $mol_dom_render_children(el, childNodes) {
|
|
3020
|
+
const node_set = new Set(childNodes);
|
|
3021
|
+
let nextNode = el.firstChild;
|
|
3022
|
+
for (let view of childNodes) {
|
|
3023
|
+
if (view == null)
|
|
3024
|
+
continue;
|
|
3025
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
3026
|
+
while (true) {
|
|
3027
|
+
if (!nextNode) {
|
|
3028
|
+
el.appendChild(view);
|
|
3029
|
+
break;
|
|
3030
|
+
}
|
|
3031
|
+
if (nextNode == view) {
|
|
3032
|
+
nextNode = nextNode.nextSibling;
|
|
3033
|
+
break;
|
|
3034
|
+
}
|
|
3035
|
+
else {
|
|
3036
|
+
if (node_set.has(nextNode)) {
|
|
3037
|
+
el.insertBefore(view, nextNode);
|
|
3038
|
+
break;
|
|
3039
|
+
}
|
|
3040
|
+
else {
|
|
3041
|
+
const nn = nextNode.nextSibling;
|
|
3042
|
+
el.removeChild(nextNode);
|
|
3043
|
+
nextNode = nn;
|
|
3044
|
+
}
|
|
3033
3045
|
}
|
|
3034
3046
|
}
|
|
3035
3047
|
}
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3048
|
+
else {
|
|
3049
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
|
3050
|
+
const str = String(view);
|
|
3051
|
+
if (nextNode.nodeValue !== str)
|
|
3052
|
+
nextNode.nodeValue = str;
|
|
3053
|
+
nextNode = nextNode.nextSibling;
|
|
3054
|
+
}
|
|
3055
|
+
else {
|
|
3056
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
3057
|
+
el.insertBefore(textNode, nextNode);
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
while (nextNode) {
|
|
3062
|
+
const currNode = nextNode;
|
|
3063
|
+
nextNode = currNode.nextSibling;
|
|
3064
|
+
el.removeChild(currNode);
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
3039
3068
|
})($ || ($ = {}));
|
|
3040
3069
|
|
|
3041
3070
|
;
|
|
@@ -3053,138 +3082,125 @@ var $;
|
|
|
3053
3082
|
;
|
|
3054
3083
|
"use strict";
|
|
3055
3084
|
|
|
3056
|
-
;
|
|
3057
|
-
"use strict";
|
|
3058
|
-
|
|
3059
|
-
;
|
|
3060
|
-
"use strict";
|
|
3061
|
-
var $;
|
|
3062
|
-
(function ($_1) {
|
|
3063
|
-
$mol_test({
|
|
3064
|
-
'init with overload'() {
|
|
3065
|
-
class X extends $mol_object {
|
|
3066
|
-
foo() {
|
|
3067
|
-
return 1;
|
|
3068
|
-
}
|
|
3069
|
-
}
|
|
3070
|
-
var x = X.make({
|
|
3071
|
-
foo: () => 2,
|
|
3072
|
-
});
|
|
3073
|
-
$mol_assert_equal(x.foo(), 2);
|
|
3074
|
-
},
|
|
3075
|
-
'Context in instance inherits from class'($) {
|
|
3076
|
-
const custom = $.$mol_ambient({});
|
|
3077
|
-
class X extends $.$mol_object {
|
|
3078
|
-
static $ = custom;
|
|
3079
|
-
}
|
|
3080
|
-
$mol_assert_equal(new X().$, custom);
|
|
3081
|
-
},
|
|
3082
|
-
});
|
|
3083
|
-
})($ || ($ = {}));
|
|
3084
|
-
|
|
3085
3085
|
;
|
|
3086
3086
|
"use strict";
|
|
3087
3087
|
var $;
|
|
3088
|
-
(function ($
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3088
|
+
(function ($) {
|
|
3089
|
+
$.$mol_jsx_prefix = '';
|
|
3090
|
+
$.$mol_jsx_crumbs = '';
|
|
3091
|
+
$.$mol_jsx_booked = null;
|
|
3092
|
+
$.$mol_jsx_document = {
|
|
3093
|
+
getElementById: () => null,
|
|
3094
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
3095
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
3096
|
+
};
|
|
3097
|
+
$.$mol_jsx_frag = '';
|
|
3098
|
+
function $mol_jsx(Elem, props, ...childNodes) {
|
|
3099
|
+
const id = props && props.id || '';
|
|
3100
|
+
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
3101
|
+
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
|
|
3102
|
+
if (Elem && $.$mol_jsx_booked) {
|
|
3103
|
+
if ($.$mol_jsx_booked.has(id)) {
|
|
3104
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
3099
3105
|
}
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
sub.track_off(bu1);
|
|
3106
|
+
else {
|
|
3107
|
+
$.$mol_jsx_booked.add(id);
|
|
3103
3108
|
}
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
const
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3109
|
+
}
|
|
3110
|
+
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
3111
|
+
if ($.$mol_jsx_prefix) {
|
|
3112
|
+
const prefix_ext = $.$mol_jsx_prefix;
|
|
3113
|
+
const booked_ext = $.$mol_jsx_booked;
|
|
3114
|
+
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
3115
|
+
for (const field in props) {
|
|
3116
|
+
const func = props[field];
|
|
3117
|
+
if (typeof func !== 'function')
|
|
3118
|
+
continue;
|
|
3119
|
+
const wrapper = function (...args) {
|
|
3120
|
+
const prefix = $.$mol_jsx_prefix;
|
|
3121
|
+
const booked = $.$mol_jsx_booked;
|
|
3122
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
3123
|
+
try {
|
|
3124
|
+
$.$mol_jsx_prefix = prefix_ext;
|
|
3125
|
+
$.$mol_jsx_booked = booked_ext;
|
|
3126
|
+
$.$mol_jsx_crumbs = crumbs_ext;
|
|
3127
|
+
return func.call(this, ...args);
|
|
3128
|
+
}
|
|
3129
|
+
finally {
|
|
3130
|
+
$.$mol_jsx_prefix = prefix;
|
|
3131
|
+
$.$mol_jsx_booked = booked;
|
|
3132
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
3133
|
+
}
|
|
3134
|
+
};
|
|
3135
|
+
$mol_func_name_from(wrapper, func);
|
|
3136
|
+
props[field] = wrapper;
|
|
3112
3137
|
}
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3138
|
+
}
|
|
3139
|
+
if (typeof Elem !== 'string') {
|
|
3140
|
+
if ('prototype' in Elem) {
|
|
3141
|
+
const view = node && node[String(Elem)] || new Elem;
|
|
3142
|
+
Object.assign(view, props);
|
|
3143
|
+
view[Symbol.toStringTag] = guid;
|
|
3144
|
+
view.childNodes = childNodes;
|
|
3145
|
+
if (!view.ownerDocument)
|
|
3146
|
+
view.ownerDocument = $.$mol_jsx_document;
|
|
3147
|
+
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
3148
|
+
node = view.valueOf();
|
|
3149
|
+
node[String(Elem)] = view;
|
|
3150
|
+
return node;
|
|
3116
3151
|
}
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
'cyclic detection'($) {
|
|
3122
|
-
const sub1 = new $mol_wire_pub_sub;
|
|
3123
|
-
const sub2 = new $mol_wire_pub_sub;
|
|
3124
|
-
const bu1 = sub1.track_on();
|
|
3125
|
-
try {
|
|
3126
|
-
const bu2 = sub2.track_on();
|
|
3152
|
+
else {
|
|
3153
|
+
const prefix = $.$mol_jsx_prefix;
|
|
3154
|
+
const booked = $.$mol_jsx_booked;
|
|
3155
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
3127
3156
|
try {
|
|
3128
|
-
|
|
3157
|
+
$.$mol_jsx_prefix = guid;
|
|
3158
|
+
$.$mol_jsx_booked = new Set;
|
|
3159
|
+
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
3160
|
+
return Elem(props, ...childNodes);
|
|
3129
3161
|
}
|
|
3130
3162
|
finally {
|
|
3131
|
-
|
|
3132
|
-
|
|
3163
|
+
$.$mol_jsx_prefix = prefix;
|
|
3164
|
+
$.$mol_jsx_booked = booked;
|
|
3165
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
3133
3166
|
}
|
|
3134
3167
|
}
|
|
3135
|
-
finally {
|
|
3136
|
-
sub1.track_cut();
|
|
3137
|
-
sub1.track_off(bu1);
|
|
3138
|
-
}
|
|
3139
|
-
},
|
|
3140
|
-
});
|
|
3141
|
-
})($ || ($ = {}));
|
|
3142
|
-
|
|
3143
|
-
;
|
|
3144
|
-
"use strict";
|
|
3145
|
-
var $;
|
|
3146
|
-
(function ($) {
|
|
3147
|
-
$.$mol_after_mock_queue = [];
|
|
3148
|
-
function $mol_after_mock_warp() {
|
|
3149
|
-
const queue = $.$mol_after_mock_queue.splice(0);
|
|
3150
|
-
for (const task of queue)
|
|
3151
|
-
task();
|
|
3152
|
-
}
|
|
3153
|
-
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
|
3154
|
-
class $mol_after_mock_commmon extends $mol_object2 {
|
|
3155
|
-
task;
|
|
3156
|
-
promise = Promise.resolve();
|
|
3157
|
-
cancelled = false;
|
|
3158
|
-
id;
|
|
3159
|
-
constructor(task) {
|
|
3160
|
-
super();
|
|
3161
|
-
this.task = task;
|
|
3162
|
-
$.$mol_after_mock_queue.push(task);
|
|
3163
3168
|
}
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
$.$
|
|
3169
|
+
if (!node) {
|
|
3170
|
+
node = Elem
|
|
3171
|
+
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
3172
|
+
: $.$mol_jsx_document.createDocumentFragment();
|
|
3168
3173
|
}
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3174
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
3175
|
+
if (!Elem)
|
|
3176
|
+
return node;
|
|
3177
|
+
if (guid)
|
|
3178
|
+
node.id = guid;
|
|
3179
|
+
for (const key in props) {
|
|
3180
|
+
if (key === 'id')
|
|
3181
|
+
continue;
|
|
3182
|
+
if (typeof props[key] === 'string') {
|
|
3183
|
+
if (typeof node[key] === 'string')
|
|
3184
|
+
node[key] = props[key];
|
|
3185
|
+
node.setAttribute(key, props[key]);
|
|
3186
|
+
}
|
|
3187
|
+
else if (props[key] &&
|
|
3188
|
+
typeof props[key] === 'object' &&
|
|
3189
|
+
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
3190
|
+
if (typeof node[key] === 'object') {
|
|
3191
|
+
Object.assign(node[key], props[key]);
|
|
3192
|
+
continue;
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
else {
|
|
3196
|
+
node[key] = props[key];
|
|
3197
|
+
}
|
|
3176
3198
|
}
|
|
3199
|
+
if ($.$mol_jsx_crumbs)
|
|
3200
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
3201
|
+
return node;
|
|
3177
3202
|
}
|
|
3178
|
-
$.$
|
|
3179
|
-
})($ || ($ = {}));
|
|
3180
|
-
|
|
3181
|
-
;
|
|
3182
|
-
"use strict";
|
|
3183
|
-
var $;
|
|
3184
|
-
(function ($_1) {
|
|
3185
|
-
$mol_test_mocks.push($ => {
|
|
3186
|
-
$.$mol_after_tick = $mol_after_mock_commmon;
|
|
3187
|
-
});
|
|
3203
|
+
$.$mol_jsx = $mol_jsx;
|
|
3188
3204
|
})($ || ($ = {}));
|
|
3189
3205
|
|
|
3190
3206
|
;
|
|
@@ -3192,94 +3208,101 @@ var $;
|
|
|
3192
3208
|
var $;
|
|
3193
3209
|
(function ($) {
|
|
3194
3210
|
$mol_test({
|
|
3195
|
-
'
|
|
3196
|
-
|
|
3197
|
-
static calc(a, b) {
|
|
3198
|
-
return a + b;
|
|
3199
|
-
}
|
|
3200
|
-
}
|
|
3201
|
-
__decorate([
|
|
3202
|
-
$mol_wire_method
|
|
3203
|
-
], Sync, "calc", null);
|
|
3204
|
-
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
3211
|
+
'Make empty div'() {
|
|
3212
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
3205
3213
|
},
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
}
|
|
3211
|
-
static sum(a, b) {
|
|
3212
|
-
const syn = $mol_wire_sync(this);
|
|
3213
|
-
return syn.val(a) + syn.val(b);
|
|
3214
|
-
}
|
|
3215
|
-
static async calc(a, b) {
|
|
3216
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
3217
|
-
}
|
|
3218
|
-
}
|
|
3219
|
-
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
|
3214
|
+
'Define native field'() {
|
|
3215
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
3216
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
3217
|
+
$mol_assert_equal(dom.value, '123');
|
|
3220
3218
|
},
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
static logs_unidemp = 0;
|
|
3225
|
-
static log_idemp() {
|
|
3226
|
-
this.logs_idemp += 1;
|
|
3227
|
-
}
|
|
3228
|
-
static log_unidemp() {
|
|
3229
|
-
this.logs_unidemp += 1;
|
|
3230
|
-
}
|
|
3231
|
-
static async val(a) {
|
|
3232
|
-
return a;
|
|
3233
|
-
}
|
|
3234
|
-
static sum(a, b) {
|
|
3235
|
-
this.log_idemp();
|
|
3236
|
-
this.log_unidemp();
|
|
3237
|
-
const syn = $mol_wire_sync(this);
|
|
3238
|
-
return syn.val(a) + syn.val(b);
|
|
3239
|
-
}
|
|
3240
|
-
static async calc(a, b) {
|
|
3241
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
3242
|
-
}
|
|
3243
|
-
}
|
|
3244
|
-
__decorate([
|
|
3245
|
-
$mol_wire_method
|
|
3246
|
-
], Idempotence, "log_idemp", null);
|
|
3247
|
-
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
3248
|
-
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
3249
|
-
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
3219
|
+
'Define classes'() {
|
|
3220
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
3221
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
3250
3222
|
},
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3223
|
+
'Define styles'() {
|
|
3224
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
3225
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
3226
|
+
},
|
|
3227
|
+
'Define dataset'() {
|
|
3228
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
3229
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
3230
|
+
},
|
|
3231
|
+
'Define attributes'() {
|
|
3232
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
3233
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
3234
|
+
},
|
|
3235
|
+
'Define child nodes'() {
|
|
3236
|
+
const dom = $mol_jsx("div", null,
|
|
3237
|
+
"hello",
|
|
3238
|
+
$mol_jsx("strong", null, "world"),
|
|
3239
|
+
"!");
|
|
3240
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
3241
|
+
},
|
|
3242
|
+
'Make fragment'() {
|
|
3243
|
+
const dom = $mol_jsx($mol_jsx_frag, null,
|
|
3244
|
+
$mol_jsx("br", null),
|
|
3245
|
+
$mol_jsx("hr", null));
|
|
3246
|
+
$mol_assert_equal($mol_dom_serialize(dom), '<br xmlns="http://www.w3.org/1999/xhtml" /><hr xmlns="http://www.w3.org/1999/xhtml" />');
|
|
3247
|
+
},
|
|
3248
|
+
'Spread fragment'() {
|
|
3249
|
+
const dom = $mol_jsx("div", null,
|
|
3250
|
+
$mol_jsx($mol_jsx_frag, null,
|
|
3251
|
+
$mol_jsx("br", null),
|
|
3252
|
+
$mol_jsx("hr", null)));
|
|
3253
|
+
$mol_assert_equal(dom.outerHTML, '<div><br><hr></div>');
|
|
3254
|
+
},
|
|
3255
|
+
'Function as component'() {
|
|
3256
|
+
const Button = (props, target) => {
|
|
3257
|
+
return $mol_jsx("button", { title: props.hint }, target());
|
|
3258
|
+
};
|
|
3259
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
3260
|
+
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
|
3261
|
+
},
|
|
3262
|
+
'Nested guid generation'() {
|
|
3263
|
+
const Foo = () => {
|
|
3264
|
+
return $mol_jsx("div", null,
|
|
3265
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
3266
|
+
$mol_jsx("img", { id: "icon" })));
|
|
3267
|
+
};
|
|
3268
|
+
const Bar = (props, icon) => {
|
|
3269
|
+
return $mol_jsx("span", null,
|
|
3270
|
+
icon,
|
|
3271
|
+
$mol_jsx("i", { id: "label" }));
|
|
3272
|
+
};
|
|
3273
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
3274
|
+
$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>');
|
|
3275
|
+
},
|
|
3276
|
+
'Fail on non unique ids'() {
|
|
3277
|
+
const App = () => {
|
|
3278
|
+
return $mol_jsx("div", null,
|
|
3279
|
+
$mol_jsx("span", { id: "bar" }),
|
|
3280
|
+
$mol_jsx("span", { id: "bar" }));
|
|
3281
|
+
};
|
|
3282
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
3283
|
+
},
|
|
3284
|
+
'Owner based guid generationn'() {
|
|
3285
|
+
const Foo = () => {
|
|
3286
|
+
return $mol_jsx("div", null,
|
|
3287
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
3288
|
+
};
|
|
3289
|
+
const Bar = (props) => {
|
|
3290
|
+
return $mol_jsx("span", null, props.icon());
|
|
3291
|
+
};
|
|
3292
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
3293
|
+
$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>');
|
|
3294
|
+
},
|
|
3295
|
+
'Fail on same ids from different caller'() {
|
|
3296
|
+
const Foo = () => {
|
|
3297
|
+
return $mol_jsx("div", null,
|
|
3298
|
+
$mol_jsx("img", { id: "icon" }),
|
|
3299
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
3300
|
+
};
|
|
3301
|
+
const Bar = (props) => {
|
|
3302
|
+
return $mol_jsx("span", null, props.icon());
|
|
3303
|
+
};
|
|
3304
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
3268
3305
|
},
|
|
3269
|
-
});
|
|
3270
|
-
})($ || ($ = {}));
|
|
3271
|
-
|
|
3272
|
-
;
|
|
3273
|
-
"use strict";
|
|
3274
|
-
var $;
|
|
3275
|
-
(function ($_1) {
|
|
3276
|
-
$mol_test_mocks.push($ => {
|
|
3277
|
-
$.$mol_log3_come = () => { };
|
|
3278
|
-
$.$mol_log3_done = () => { };
|
|
3279
|
-
$.$mol_log3_fail = () => { };
|
|
3280
|
-
$.$mol_log3_warn = () => { };
|
|
3281
|
-
$.$mol_log3_rise = () => { };
|
|
3282
|
-
$.$mol_log3_area = () => () => { };
|
|
3283
3306
|
});
|
|
3284
3307
|
})($ || ($ = {}));
|
|
3285
3308
|
|
|
@@ -3287,360 +3310,415 @@ var $;
|
|
|
3287
3310
|
"use strict";
|
|
3288
3311
|
var $;
|
|
3289
3312
|
(function ($) {
|
|
3290
|
-
function $
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
if (typeof sup[field] === 'function') {
|
|
3296
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
3313
|
+
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
3314
|
+
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
3315
|
+
if (typeof item !== 'function') {
|
|
3316
|
+
item = index => source[index];
|
|
3317
|
+
size = () => source.length;
|
|
3297
3318
|
}
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
}
|
|
3311
|
-
|
|
3312
|
-
;
|
|
3313
|
-
"use strict";
|
|
3314
|
-
var $;
|
|
3315
|
-
(function ($) {
|
|
3316
|
-
function $mol_wire_async(obj) {
|
|
3317
|
-
let fiber;
|
|
3318
|
-
const temp = $mol_wire_task.getter(obj);
|
|
3319
|
-
return new Proxy(obj, {
|
|
3320
|
-
get(obj, field) {
|
|
3321
|
-
const val = obj[field];
|
|
3322
|
-
if (typeof val !== 'function')
|
|
3323
|
-
return val;
|
|
3324
|
-
let fiber;
|
|
3325
|
-
const temp = $mol_wire_task.getter(val);
|
|
3326
|
-
return function $mol_wire_async(...args) {
|
|
3327
|
-
fiber?.destructor();
|
|
3328
|
-
fiber = temp(obj, args);
|
|
3329
|
-
return fiber.async();
|
|
3330
|
-
};
|
|
3319
|
+
return new Proxy(source, {
|
|
3320
|
+
get(target, field) {
|
|
3321
|
+
if (typeof field === 'string') {
|
|
3322
|
+
if (field === 'length')
|
|
3323
|
+
return size();
|
|
3324
|
+
const index = Number(field);
|
|
3325
|
+
if (index < 0)
|
|
3326
|
+
return undefined;
|
|
3327
|
+
if (index >= size())
|
|
3328
|
+
return undefined;
|
|
3329
|
+
if (index === Math.trunc(index))
|
|
3330
|
+
return item(index);
|
|
3331
|
+
}
|
|
3332
|
+
return $mol_range2_array.prototype[field];
|
|
3331
3333
|
},
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3334
|
+
set(target, field) {
|
|
3335
|
+
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
|
3336
|
+
},
|
|
3337
|
+
ownKeys(target) {
|
|
3338
|
+
return [...Array(size())].map((v, i) => String(i)).concat('length');
|
|
3336
3339
|
},
|
|
3340
|
+
getOwnPropertyDescriptor(target, field) {
|
|
3341
|
+
if (field === "length")
|
|
3342
|
+
return {
|
|
3343
|
+
value: size(),
|
|
3344
|
+
writable: true,
|
|
3345
|
+
enumerable: false,
|
|
3346
|
+
configurable: false,
|
|
3347
|
+
};
|
|
3348
|
+
const index = Number(field);
|
|
3349
|
+
if (index === Math.trunc(index))
|
|
3350
|
+
return {
|
|
3351
|
+
get: () => this.get(target, field, this),
|
|
3352
|
+
enumerable: true,
|
|
3353
|
+
configurable: true,
|
|
3354
|
+
};
|
|
3355
|
+
return Object.getOwnPropertyDescriptor(target, field);
|
|
3356
|
+
}
|
|
3337
3357
|
});
|
|
3338
3358
|
}
|
|
3339
|
-
$.$
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
static a() {
|
|
3350
|
-
return '';
|
|
3351
|
-
}
|
|
3352
|
-
static b() {
|
|
3353
|
-
return $mol_wire_async(this).a();
|
|
3354
|
-
}
|
|
3355
|
-
}
|
|
3356
|
-
},
|
|
3357
|
-
async 'Latest method calls wins'($) {
|
|
3358
|
-
class NameLogger extends $mol_object2 {
|
|
3359
|
-
static $ = $;
|
|
3360
|
-
static first = [];
|
|
3361
|
-
static last = [];
|
|
3362
|
-
static send(next) {
|
|
3363
|
-
$mol_wire_sync(this.first).push(next);
|
|
3364
|
-
$$.$mol_wait_timeout(0);
|
|
3365
|
-
this.last.push(next);
|
|
3366
|
-
}
|
|
3367
|
-
}
|
|
3368
|
-
const name = $mol_wire_async(NameLogger).send;
|
|
3369
|
-
name('john');
|
|
3370
|
-
const promise = name('jin');
|
|
3371
|
-
$.$mol_after_mock_warp();
|
|
3372
|
-
await promise;
|
|
3373
|
-
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
3374
|
-
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
3375
|
-
},
|
|
3376
|
-
async 'Latest function calls wins'($) {
|
|
3377
|
-
const first = [];
|
|
3378
|
-
const last = [];
|
|
3379
|
-
function send_name(next) {
|
|
3380
|
-
$mol_wire_sync(first).push(next);
|
|
3381
|
-
$$.$mol_wait_timeout(0);
|
|
3382
|
-
last.push(next);
|
|
3359
|
+
$.$mol_range2 = $mol_range2;
|
|
3360
|
+
class $mol_range2_array extends Array {
|
|
3361
|
+
concat(...tail) {
|
|
3362
|
+
if (tail.length === 0)
|
|
3363
|
+
return this;
|
|
3364
|
+
if (tail.length > 1) {
|
|
3365
|
+
let list = this;
|
|
3366
|
+
for (let item of tail)
|
|
3367
|
+
list = list.concat(item);
|
|
3368
|
+
return list;
|
|
3383
3369
|
}
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
$
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
;
|
|
3396
|
-
"use strict";
|
|
3397
|
-
var $;
|
|
3398
|
-
(function ($_1) {
|
|
3399
|
-
$mol_test({
|
|
3400
|
-
'test types'($) {
|
|
3401
|
-
class A {
|
|
3402
|
-
static a() {
|
|
3403
|
-
return Promise.resolve('');
|
|
3404
|
-
}
|
|
3405
|
-
static b() {
|
|
3406
|
-
return $mol_wire_sync(this).a();
|
|
3370
|
+
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
3371
|
+
}
|
|
3372
|
+
filter(check, context) {
|
|
3373
|
+
const filtered = [];
|
|
3374
|
+
let cursor = -1;
|
|
3375
|
+
return $mol_range2(index => {
|
|
3376
|
+
while (cursor < this.length && index >= filtered.length - 1) {
|
|
3377
|
+
const val = this[++cursor];
|
|
3378
|
+
if (check(val, cursor, this))
|
|
3379
|
+
filtered.push(val);
|
|
3407
3380
|
}
|
|
3381
|
+
return filtered[index];
|
|
3382
|
+
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
3383
|
+
}
|
|
3384
|
+
forEach(proceed, context) {
|
|
3385
|
+
for (let [key, value] of this.entries())
|
|
3386
|
+
proceed.call(context, value, key, this);
|
|
3387
|
+
}
|
|
3388
|
+
map(proceed, context) {
|
|
3389
|
+
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
3390
|
+
}
|
|
3391
|
+
reduce(merge, result) {
|
|
3392
|
+
let index = 0;
|
|
3393
|
+
if (arguments.length === 1) {
|
|
3394
|
+
result = this[index++];
|
|
3408
3395
|
}
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
let count = 0;
|
|
3412
|
-
class A {
|
|
3413
|
-
static a() {
|
|
3414
|
-
return $mol_wire_sync(this).b();
|
|
3415
|
-
}
|
|
3416
|
-
static b() { return Promise.resolve(++count); }
|
|
3396
|
+
for (; index < this.length; ++index) {
|
|
3397
|
+
result = merge(result, this[index], index, this);
|
|
3417
3398
|
}
|
|
3418
|
-
|
|
3419
|
-
}
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3399
|
+
return result;
|
|
3400
|
+
}
|
|
3401
|
+
toReversed() {
|
|
3402
|
+
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
3403
|
+
}
|
|
3404
|
+
slice(from = 0, to = this.length) {
|
|
3405
|
+
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
3406
|
+
}
|
|
3407
|
+
some(check, context) {
|
|
3408
|
+
for (let index = 0; index < this.length; ++index) {
|
|
3409
|
+
if (check.call(context, this[index], index, this))
|
|
3410
|
+
return true;
|
|
3427
3411
|
}
|
|
3428
|
-
|
|
3429
|
-
}
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
const a = new ($mol_wire_sync(A))();
|
|
3435
|
-
this.instances.push(a);
|
|
3436
|
-
$mol_wire_sync(this).b();
|
|
3437
|
-
}
|
|
3438
|
-
static b() { return Promise.resolve(); }
|
|
3412
|
+
return false;
|
|
3413
|
+
}
|
|
3414
|
+
every(check, context) {
|
|
3415
|
+
for (let index = 0; index < this.length; ++index) {
|
|
3416
|
+
if (!check.call(context, this[index], index, this))
|
|
3417
|
+
return false;
|
|
3439
3418
|
}
|
|
3440
|
-
|
|
3441
|
-
$mol_assert_equal(A.instances.length, 2);
|
|
3442
|
-
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
3443
|
-
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
3419
|
+
return true;
|
|
3444
3420
|
}
|
|
3445
|
-
|
|
3421
|
+
reverse() {
|
|
3422
|
+
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
|
3423
|
+
}
|
|
3424
|
+
sort() {
|
|
3425
|
+
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
|
3426
|
+
}
|
|
3427
|
+
indexOf(needle) {
|
|
3428
|
+
return this.findIndex(item => item === needle);
|
|
3429
|
+
}
|
|
3430
|
+
[Symbol.toPrimitive]() {
|
|
3431
|
+
return $mol_guid();
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
$.$mol_range2_array = $mol_range2_array;
|
|
3446
3435
|
})($ || ($ = {}));
|
|
3447
3436
|
|
|
3448
3437
|
;
|
|
3449
3438
|
"use strict";
|
|
3450
3439
|
var $;
|
|
3451
3440
|
(function ($) {
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
;
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
(
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
}
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
(
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
}
|
|
3499
|
-
|
|
3500
|
-
;
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
(
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
;
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
(
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
;
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
(
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
}
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
;
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
(
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
;
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
(
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
;
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3441
|
+
$mol_test({
|
|
3442
|
+
'lazy calls'() {
|
|
3443
|
+
let calls = 0;
|
|
3444
|
+
const list = $mol_range2(index => (++calls, index), () => 10);
|
|
3445
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
3446
|
+
$mol_assert_equal(list.length, 10);
|
|
3447
|
+
$mol_assert_equal(list[-1], undefined);
|
|
3448
|
+
$mol_assert_equal(list[0], 0);
|
|
3449
|
+
$mol_assert_equal(list[9], 9);
|
|
3450
|
+
$mol_assert_equal(list[9.5], undefined);
|
|
3451
|
+
$mol_assert_equal(list[10], undefined);
|
|
3452
|
+
$mol_assert_equal(calls, 2);
|
|
3453
|
+
},
|
|
3454
|
+
'infinity list'() {
|
|
3455
|
+
let calls = 0;
|
|
3456
|
+
const list = $mol_range2(index => (++calls, index));
|
|
3457
|
+
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
|
3458
|
+
$mol_assert_equal(list[0], 0);
|
|
3459
|
+
$mol_assert_equal(list[4], 4);
|
|
3460
|
+
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
|
3461
|
+
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
|
3462
|
+
$mol_assert_equal(calls, 3);
|
|
3463
|
+
},
|
|
3464
|
+
'stringify'() {
|
|
3465
|
+
const list = $mol_range2(i => i, () => 5);
|
|
3466
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
3467
|
+
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
|
3468
|
+
},
|
|
3469
|
+
'for-of'() {
|
|
3470
|
+
let log = '';
|
|
3471
|
+
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
|
3472
|
+
log += i;
|
|
3473
|
+
}
|
|
3474
|
+
$mol_assert_equal(log, '12345');
|
|
3475
|
+
},
|
|
3476
|
+
'for-in'() {
|
|
3477
|
+
let log = '';
|
|
3478
|
+
for (let i in $mol_range2(i => i, () => 5)) {
|
|
3479
|
+
log += i;
|
|
3480
|
+
}
|
|
3481
|
+
$mol_assert_equal(log, '01234');
|
|
3482
|
+
},
|
|
3483
|
+
'forEach'() {
|
|
3484
|
+
let log = '';
|
|
3485
|
+
$mol_range2(i => i, () => 5).forEach(i => log += i);
|
|
3486
|
+
$mol_assert_equal(log, '01234');
|
|
3487
|
+
},
|
|
3488
|
+
'reduce'() {
|
|
3489
|
+
let calls = 0;
|
|
3490
|
+
const list = $mol_range2().slice(1, 6);
|
|
3491
|
+
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
|
3492
|
+
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
|
3493
|
+
},
|
|
3494
|
+
'lazy concat'() {
|
|
3495
|
+
let calls1 = 0;
|
|
3496
|
+
let calls2 = 0;
|
|
3497
|
+
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
|
3498
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
3499
|
+
$mol_assert_equal(list.length, 15);
|
|
3500
|
+
$mol_assert_equal(list[0], 0);
|
|
3501
|
+
$mol_assert_equal(list[4], 4);
|
|
3502
|
+
$mol_assert_equal(list[5], 0);
|
|
3503
|
+
$mol_assert_equal(list[9], 4);
|
|
3504
|
+
$mol_assert_equal(list[10], 0);
|
|
3505
|
+
$mol_assert_equal(list[14], 4);
|
|
3506
|
+
$mol_assert_equal(list[15], undefined);
|
|
3507
|
+
$mol_assert_equal(calls1, 2);
|
|
3508
|
+
$mol_assert_equal(calls2, 2);
|
|
3509
|
+
},
|
|
3510
|
+
'lazy filter'() {
|
|
3511
|
+
let calls = 0;
|
|
3512
|
+
const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
|
|
3513
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
3514
|
+
$mol_assert_equal(list.length, 3);
|
|
3515
|
+
$mol_assert_equal(list[0], 1);
|
|
3516
|
+
$mol_assert_equal(list[2], 5);
|
|
3517
|
+
$mol_assert_equal(list[3], undefined);
|
|
3518
|
+
$mol_assert_equal(calls, 8);
|
|
3519
|
+
},
|
|
3520
|
+
'lazy reverse'() {
|
|
3521
|
+
let calls = 0;
|
|
3522
|
+
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
|
3523
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
3524
|
+
$mol_assert_equal(list.length, 3);
|
|
3525
|
+
$mol_assert_equal(list[0], 9);
|
|
3526
|
+
$mol_assert_equal(list[2], 7);
|
|
3527
|
+
$mol_assert_equal(list[3], undefined);
|
|
3528
|
+
$mol_assert_equal(calls, 2);
|
|
3529
|
+
},
|
|
3530
|
+
'lazy map'() {
|
|
3531
|
+
let calls1 = 0;
|
|
3532
|
+
let calls2 = 0;
|
|
3533
|
+
const source = $mol_range2(index => (++calls1, index), () => 5);
|
|
3534
|
+
const target = source.map((item, index, self) => {
|
|
3535
|
+
++calls2;
|
|
3536
|
+
$mol_assert_equal(source, self);
|
|
3537
|
+
return index + 10;
|
|
3538
|
+
}, () => 5);
|
|
3539
|
+
$mol_assert_equal(true, target instanceof Array);
|
|
3540
|
+
$mol_assert_equal(target.length, 5);
|
|
3541
|
+
$mol_assert_equal(target[0], 10);
|
|
3542
|
+
$mol_assert_equal(target[4], 14);
|
|
3543
|
+
$mol_assert_equal(target[5], undefined);
|
|
3544
|
+
$mol_assert_equal(calls1, 2);
|
|
3545
|
+
$mol_assert_equal(calls2, 2);
|
|
3546
|
+
},
|
|
3547
|
+
'lazy slice'() {
|
|
3548
|
+
let calls = 0;
|
|
3549
|
+
const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
|
|
3550
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
3551
|
+
$mol_assert_equal(list.length, 4);
|
|
3552
|
+
$mol_assert_equal(list[0], 3);
|
|
3553
|
+
$mol_assert_equal(list[3], 6);
|
|
3554
|
+
$mol_assert_equal(list[4], undefined);
|
|
3555
|
+
$mol_assert_equal(calls, 2);
|
|
3556
|
+
},
|
|
3557
|
+
'lazy some'() {
|
|
3558
|
+
let calls = 0;
|
|
3559
|
+
$mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
|
|
3560
|
+
$mol_assert_equal(calls, 3);
|
|
3561
|
+
$mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
|
|
3562
|
+
$mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
|
|
3563
|
+
},
|
|
3564
|
+
'lazy every'() {
|
|
3565
|
+
let calls = 0;
|
|
3566
|
+
$mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
|
|
3567
|
+
$mol_assert_equal(calls, 3);
|
|
3568
|
+
$mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
|
|
3569
|
+
$mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
|
|
3570
|
+
},
|
|
3571
|
+
'lazyfy'() {
|
|
3572
|
+
let calls = 0;
|
|
3573
|
+
const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
|
|
3574
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
3575
|
+
$mol_assert_equal(list.length, 4);
|
|
3576
|
+
$mol_assert_equal(calls, 0);
|
|
3577
|
+
$mol_assert_equal(list[0], 12);
|
|
3578
|
+
$mol_assert_equal(list[3], 15);
|
|
3579
|
+
$mol_assert_equal(list[4], undefined);
|
|
3580
|
+
$mol_assert_equal(calls, 2);
|
|
3581
|
+
},
|
|
3582
|
+
'prevent modification'() {
|
|
3583
|
+
const list = $mol_range2(i => i, () => 5);
|
|
3584
|
+
$mol_assert_fail(() => list.push(4), TypeError);
|
|
3585
|
+
$mol_assert_fail(() => list.pop(), TypeError);
|
|
3586
|
+
$mol_assert_fail(() => list.unshift(4), TypeError);
|
|
3587
|
+
$mol_assert_fail(() => list.shift(), TypeError);
|
|
3588
|
+
$mol_assert_fail(() => list.splice(1, 2), TypeError);
|
|
3589
|
+
$mol_assert_fail(() => list[1] = 2, TypeError);
|
|
3590
|
+
$mol_assert_fail(() => list.reverse(), TypeError);
|
|
3591
|
+
$mol_assert_fail(() => list.sort(), TypeError);
|
|
3592
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
3593
|
+
}
|
|
3594
|
+
});
|
|
3591
3595
|
})($ || ($ = {}));
|
|
3592
3596
|
|
|
3593
3597
|
;
|
|
3594
3598
|
"use strict";
|
|
3595
3599
|
var $;
|
|
3596
|
-
(function ($
|
|
3600
|
+
(function ($) {
|
|
3597
3601
|
$mol_test({
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3602
|
+
'nulls & undefineds'() {
|
|
3603
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
3604
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
3605
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
3606
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
3607
|
+
},
|
|
3608
|
+
'number'() {
|
|
3609
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
3610
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
3611
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
3612
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
3613
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
3614
|
+
},
|
|
3615
|
+
'POJO'() {
|
|
3616
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
3617
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
3618
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
3619
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
3620
|
+
$mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
3621
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
3622
|
+
$mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
|
|
3623
|
+
},
|
|
3624
|
+
'Array'() {
|
|
3625
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
3626
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
3627
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
3628
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
3629
|
+
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
|
3630
|
+
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
|
3631
|
+
},
|
|
3632
|
+
'Non POJO are different'() {
|
|
3633
|
+
class Thing extends Object {
|
|
3619
3634
|
}
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3635
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
3636
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
3637
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
3638
|
+
},
|
|
3639
|
+
'POJO with symbols'() {
|
|
3640
|
+
const sym = Symbol();
|
|
3641
|
+
$mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
|
|
3642
|
+
$mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
|
|
3643
|
+
},
|
|
3644
|
+
'same POJOs with cyclic reference'() {
|
|
3645
|
+
const a = { foo: {} };
|
|
3646
|
+
a['self'] = a;
|
|
3647
|
+
const b = { foo: {} };
|
|
3648
|
+
b['self'] = b;
|
|
3649
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
3650
|
+
},
|
|
3651
|
+
'same POJOs with cyclic reference with cache warmup'() {
|
|
3652
|
+
const obj1 = { test: 1, obj3: null };
|
|
3653
|
+
const obj1_copy = { test: 1, obj3: null };
|
|
3654
|
+
const obj2 = { test: 2, obj1 };
|
|
3655
|
+
const obj2_copy = { test: 2, obj1: obj1_copy };
|
|
3656
|
+
const obj3 = { test: 3, obj2 };
|
|
3657
|
+
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
3658
|
+
obj1.obj3 = obj3;
|
|
3659
|
+
obj1_copy.obj3 = obj3_copy;
|
|
3660
|
+
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
3661
|
+
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
3662
|
+
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
3663
|
+
$mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
|
|
3664
|
+
},
|
|
3665
|
+
'Date'() {
|
|
3666
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
3667
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
3668
|
+
},
|
|
3669
|
+
'RegExp'() {
|
|
3670
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
3671
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
3672
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
3673
|
+
},
|
|
3674
|
+
'Error'() {
|
|
3675
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
3676
|
+
const fail = (message) => new Error(message);
|
|
3677
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
3678
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
3679
|
+
},
|
|
3680
|
+
'Map'() {
|
|
3681
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
3682
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
3683
|
+
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
3684
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
3685
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
3686
|
+
},
|
|
3687
|
+
'Set'() {
|
|
3688
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
3689
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
3690
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
3691
|
+
},
|
|
3692
|
+
'Uint8Array'() {
|
|
3693
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
3694
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
3695
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
3696
|
+
},
|
|
3697
|
+
'DataView'() {
|
|
3698
|
+
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
|
|
3699
|
+
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
|
|
3700
|
+
$mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
|
|
3701
|
+
},
|
|
3702
|
+
'Serializale'() {
|
|
3703
|
+
class User {
|
|
3704
|
+
name;
|
|
3705
|
+
rand;
|
|
3706
|
+
constructor(name, rand = Math.random()) {
|
|
3707
|
+
this.name = name;
|
|
3708
|
+
this.rand = rand;
|
|
3709
|
+
}
|
|
3710
|
+
[Symbol.toPrimitive](mode) {
|
|
3711
|
+
return this.name;
|
|
3628
3712
|
}
|
|
3629
3713
|
}
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
}
|
|
3639
|
-
catch (e) {
|
|
3640
|
-
message = e.message;
|
|
3641
|
-
}
|
|
3642
|
-
$mol_assert_equal(message, error_message);
|
|
3643
|
-
}
|
|
3714
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
3715
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
3716
|
+
},
|
|
3717
|
+
'Iterable'() {
|
|
3718
|
+
$mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
|
|
3719
|
+
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
|
|
3720
|
+
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
|
|
3721
|
+
},
|
|
3644
3722
|
});
|
|
3645
3723
|
})($ || ($ = {}));
|
|
3646
3724
|
|
|
@@ -3648,182 +3726,208 @@ var $;
|
|
|
3648
3726
|
"use strict";
|
|
3649
3727
|
var $;
|
|
3650
3728
|
(function ($) {
|
|
3651
|
-
function $
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
const nn = nextNode.nextSibling;
|
|
3674
|
-
el.removeChild(nextNode);
|
|
3675
|
-
nextNode = nn;
|
|
3676
|
-
}
|
|
3677
|
-
}
|
|
3678
|
-
}
|
|
3729
|
+
function $mol_assert_ok(value) {
|
|
3730
|
+
if (value)
|
|
3731
|
+
return;
|
|
3732
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
3733
|
+
}
|
|
3734
|
+
$.$mol_assert_ok = $mol_assert_ok;
|
|
3735
|
+
function $mol_assert_not(value) {
|
|
3736
|
+
if (!value)
|
|
3737
|
+
return;
|
|
3738
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
3739
|
+
}
|
|
3740
|
+
$.$mol_assert_not = $mol_assert_not;
|
|
3741
|
+
function $mol_assert_fail(handler, ErrorRight) {
|
|
3742
|
+
const fail = $.$mol_fail;
|
|
3743
|
+
try {
|
|
3744
|
+
$.$mol_fail = $.$mol_fail_hidden;
|
|
3745
|
+
handler();
|
|
3746
|
+
}
|
|
3747
|
+
catch (error) {
|
|
3748
|
+
$.$mol_fail = fail;
|
|
3749
|
+
if (typeof ErrorRight === 'string') {
|
|
3750
|
+
$mol_assert_equal(error.message ?? error, ErrorRight);
|
|
3679
3751
|
}
|
|
3680
3752
|
else {
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3753
|
+
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
3754
|
+
}
|
|
3755
|
+
return error;
|
|
3756
|
+
}
|
|
3757
|
+
finally {
|
|
3758
|
+
$.$mol_fail = fail;
|
|
3759
|
+
}
|
|
3760
|
+
$mol_fail(new Error('Not failed'));
|
|
3761
|
+
}
|
|
3762
|
+
$.$mol_assert_fail = $mol_assert_fail;
|
|
3763
|
+
function $mol_assert_like(...args) {
|
|
3764
|
+
$mol_assert_equal(...args);
|
|
3765
|
+
}
|
|
3766
|
+
$.$mol_assert_like = $mol_assert_like;
|
|
3767
|
+
function $mol_assert_unique(...args) {
|
|
3768
|
+
for (let i = 0; i < args.length; ++i) {
|
|
3769
|
+
for (let j = 0; j < args.length; ++j) {
|
|
3770
|
+
if (i === j)
|
|
3771
|
+
continue;
|
|
3772
|
+
if (!$mol_compare_deep(args[i], args[j]))
|
|
3773
|
+
continue;
|
|
3774
|
+
return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
|
|
3691
3775
|
}
|
|
3692
3776
|
}
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3777
|
+
}
|
|
3778
|
+
$.$mol_assert_unique = $mol_assert_unique;
|
|
3779
|
+
function $mol_assert_equal(...args) {
|
|
3780
|
+
for (let i = 1; i < args.length; ++i) {
|
|
3781
|
+
if ($mol_compare_deep(args[0], args[i]))
|
|
3782
|
+
continue;
|
|
3783
|
+
return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
|
|
3697
3784
|
}
|
|
3698
3785
|
}
|
|
3699
|
-
$.$
|
|
3786
|
+
$.$mol_assert_equal = $mol_assert_equal;
|
|
3700
3787
|
})($ || ($ = {}));
|
|
3701
3788
|
|
|
3702
3789
|
;
|
|
3703
3790
|
"use strict";
|
|
3791
|
+
var $;
|
|
3792
|
+
(function ($) {
|
|
3793
|
+
$mol_test({
|
|
3794
|
+
'must be false'() {
|
|
3795
|
+
$mol_assert_not(0);
|
|
3796
|
+
},
|
|
3797
|
+
'must be true'() {
|
|
3798
|
+
$mol_assert_ok(1);
|
|
3799
|
+
},
|
|
3800
|
+
'two must be equal'() {
|
|
3801
|
+
$mol_assert_equal(2, 2);
|
|
3802
|
+
},
|
|
3803
|
+
'three must be equal'() {
|
|
3804
|
+
$mol_assert_equal(2, 2, 2);
|
|
3805
|
+
},
|
|
3806
|
+
'two must be unique'() {
|
|
3807
|
+
$mol_assert_unique([2], [3]);
|
|
3808
|
+
},
|
|
3809
|
+
'three must be unique'() {
|
|
3810
|
+
$mol_assert_unique([1], [2], [3]);
|
|
3811
|
+
},
|
|
3812
|
+
'two must be alike'() {
|
|
3813
|
+
$mol_assert_equal([3], [3]);
|
|
3814
|
+
},
|
|
3815
|
+
'three must be alike'() {
|
|
3816
|
+
$mol_assert_equal([3], [3], [3]);
|
|
3817
|
+
},
|
|
3818
|
+
'two object must be alike'() {
|
|
3819
|
+
$mol_assert_equal({ a: 1 }, { a: 1 });
|
|
3820
|
+
},
|
|
3821
|
+
'three object must be alike'() {
|
|
3822
|
+
$mol_assert_equal({ a: 1 }, { a: 1 }, { a: 1 });
|
|
3823
|
+
},
|
|
3824
|
+
});
|
|
3825
|
+
})($ || ($ = {}));
|
|
3704
3826
|
|
|
3705
3827
|
;
|
|
3706
3828
|
"use strict";
|
|
3829
|
+
var $;
|
|
3830
|
+
(function ($_1) {
|
|
3831
|
+
var $$;
|
|
3832
|
+
(function ($$) {
|
|
3833
|
+
$mol_test({
|
|
3834
|
+
"1 byte int"($) {
|
|
3835
|
+
$mol_assert_equal($mol_bigint_encode(0n), new Uint8Array(new Int8Array([0]).buffer));
|
|
3836
|
+
$mol_assert_equal($mol_bigint_encode(1n), new Uint8Array(new Int8Array([1]).buffer));
|
|
3837
|
+
$mol_assert_equal($mol_bigint_encode(-1n), new Uint8Array(new Int8Array([-1]).buffer));
|
|
3838
|
+
$mol_assert_equal($mol_bigint_encode(127n), new Uint8Array(new Int8Array([127]).buffer));
|
|
3839
|
+
$mol_assert_equal($mol_bigint_encode(-128n), new Uint8Array(new Int8Array([-128]).buffer));
|
|
3840
|
+
},
|
|
3841
|
+
"2 byte int"($) {
|
|
3842
|
+
$mol_assert_equal($mol_bigint_encode(128n), new Uint8Array(new Int16Array([128]).buffer));
|
|
3843
|
+
$mol_assert_equal($mol_bigint_encode(-129n), new Uint8Array(new Int16Array([-129]).buffer));
|
|
3844
|
+
$mol_assert_equal($mol_bigint_encode(128n * 256n - 1n), new Uint8Array(new Int16Array([128 * 256 - 1]).buffer));
|
|
3845
|
+
$mol_assert_equal($mol_bigint_encode(-128n * 256n), new Uint8Array(new Int16Array([-128 * 256]).buffer));
|
|
3846
|
+
},
|
|
3847
|
+
"3 byte int"($) {
|
|
3848
|
+
$mol_assert_equal($mol_bigint_encode(128n * 256n), new Uint8Array(new Int32Array([128 * 256]).buffer).slice(0, 3));
|
|
3849
|
+
$mol_assert_equal($mol_bigint_encode(-128n * 256n - 1n), new Uint8Array(new Int32Array([-128 * 256 - 1]).buffer).slice(0, 3));
|
|
3850
|
+
$mol_assert_equal($mol_bigint_encode(128n * 256n ** 2n - 1n), new Uint8Array(new Int32Array([128 * 256 ** 2 - 1]).buffer).slice(0, 3));
|
|
3851
|
+
$mol_assert_equal($mol_bigint_encode(-128n * 256n ** 2n), new Uint8Array(new Int32Array([-128 * 256 ** 2]).buffer).slice(0, 3));
|
|
3852
|
+
},
|
|
3853
|
+
"4 byte int"($) {
|
|
3854
|
+
$mol_assert_equal($mol_bigint_encode(128n * 256n ** 2n), new Uint8Array(new Int32Array([128 * 256 ** 2]).buffer));
|
|
3855
|
+
$mol_assert_equal($mol_bigint_encode(-128n * 256n ** 2n - 1n), new Uint8Array(new Int32Array([-128 * 256 ** 2 - 1]).buffer));
|
|
3856
|
+
$mol_assert_equal($mol_bigint_encode(128n * 256n ** 3n - 1n), new Uint8Array(new Int32Array([128 * 256 ** 3 - 1]).buffer));
|
|
3857
|
+
$mol_assert_equal($mol_bigint_encode(-128n * 256n ** 3n), new Uint8Array(new Int32Array([-128 * 256 ** 3]).buffer));
|
|
3858
|
+
},
|
|
3859
|
+
"8 byte int"($) {
|
|
3860
|
+
$mol_assert_equal($mol_bigint_encode(128n * 256n ** 7n - 1n), new Uint8Array(new BigInt64Array([128n * 256n ** 7n - 1n]).buffer));
|
|
3861
|
+
$mol_assert_equal($mol_bigint_encode(-128n * 256n ** 7n), new Uint8Array(new BigInt64Array([-128n * 256n ** 7n]).buffer));
|
|
3862
|
+
},
|
|
3863
|
+
});
|
|
3864
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
3865
|
+
})($ || ($ = {}));
|
|
3707
3866
|
|
|
3708
3867
|
;
|
|
3709
3868
|
"use strict";
|
|
3710
3869
|
var $;
|
|
3711
3870
|
(function ($) {
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
$
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
node[String(Elem)] = view;
|
|
3773
|
-
return node;
|
|
3774
|
-
}
|
|
3775
|
-
else {
|
|
3776
|
-
const prefix = $.$mol_jsx_prefix;
|
|
3777
|
-
const booked = $.$mol_jsx_booked;
|
|
3778
|
-
const crumbs = $.$mol_jsx_crumbs;
|
|
3779
|
-
try {
|
|
3780
|
-
$.$mol_jsx_prefix = guid;
|
|
3781
|
-
$.$mol_jsx_booked = new Set;
|
|
3782
|
-
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
3783
|
-
return Elem(props, ...childNodes);
|
|
3784
|
-
}
|
|
3785
|
-
finally {
|
|
3786
|
-
$.$mol_jsx_prefix = prefix;
|
|
3787
|
-
$.$mol_jsx_booked = booked;
|
|
3788
|
-
$.$mol_jsx_crumbs = crumbs;
|
|
3789
|
-
}
|
|
3790
|
-
}
|
|
3791
|
-
}
|
|
3792
|
-
if (!node) {
|
|
3793
|
-
node = Elem
|
|
3794
|
-
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
3795
|
-
: $.$mol_jsx_document.createDocumentFragment();
|
|
3796
|
-
}
|
|
3797
|
-
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
3798
|
-
if (!Elem)
|
|
3799
|
-
return node;
|
|
3800
|
-
if (guid)
|
|
3801
|
-
node.id = guid;
|
|
3802
|
-
for (const key in props) {
|
|
3803
|
-
if (key === 'id')
|
|
3804
|
-
continue;
|
|
3805
|
-
if (typeof props[key] === 'string') {
|
|
3806
|
-
if (typeof node[key] === 'string')
|
|
3807
|
-
node[key] = props[key];
|
|
3808
|
-
node.setAttribute(key, props[key]);
|
|
3809
|
-
}
|
|
3810
|
-
else if (props[key] &&
|
|
3811
|
-
typeof props[key] === 'object' &&
|
|
3812
|
-
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
3813
|
-
if (typeof node[key] === 'object') {
|
|
3814
|
-
Object.assign(node[key], props[key]);
|
|
3815
|
-
continue;
|
|
3816
|
-
}
|
|
3817
|
-
}
|
|
3818
|
-
else {
|
|
3819
|
-
node[key] = props[key];
|
|
3820
|
-
}
|
|
3821
|
-
}
|
|
3822
|
-
if ($.$mol_jsx_crumbs)
|
|
3823
|
-
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
3824
|
-
return node;
|
|
3825
|
-
}
|
|
3826
|
-
$.$mol_jsx = $mol_jsx;
|
|
3871
|
+
$mol_test({
|
|
3872
|
+
'encode empty'() {
|
|
3873
|
+
$mol_assert_equal($mol_charset_encode(''), new Uint8Array([]));
|
|
3874
|
+
},
|
|
3875
|
+
'encode 1 octet'() {
|
|
3876
|
+
$mol_assert_equal($mol_charset_encode('F'), new Uint8Array([0x46]));
|
|
3877
|
+
},
|
|
3878
|
+
'encode 2 octet'() {
|
|
3879
|
+
$mol_assert_equal($mol_charset_encode('Б'), new Uint8Array([0xd0, 0x91]));
|
|
3880
|
+
},
|
|
3881
|
+
'encode 3 octet'() {
|
|
3882
|
+
$mol_assert_equal($mol_charset_encode('ह'), new Uint8Array([0xe0, 0xa4, 0xb9]));
|
|
3883
|
+
},
|
|
3884
|
+
'encode 4 octet'() {
|
|
3885
|
+
$mol_assert_equal($mol_charset_encode('𐍈'), new Uint8Array([0xf0, 0x90, 0x8d, 0x88]));
|
|
3886
|
+
},
|
|
3887
|
+
'encode surrogate pair'() {
|
|
3888
|
+
$mol_assert_equal($mol_charset_encode('😀'), new Uint8Array([0xf0, 0x9f, 0x98, 0x80]));
|
|
3889
|
+
},
|
|
3890
|
+
});
|
|
3891
|
+
})($ || ($ = {}));
|
|
3892
|
+
|
|
3893
|
+
;
|
|
3894
|
+
"use strict";
|
|
3895
|
+
var $;
|
|
3896
|
+
(function ($_1) {
|
|
3897
|
+
var $$;
|
|
3898
|
+
(function ($$) {
|
|
3899
|
+
$mol_test({
|
|
3900
|
+
"1 byte int"($) {
|
|
3901
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array), 0n);
|
|
3902
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int8Array([1]).buffer)), 1n);
|
|
3903
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int8Array([-1]).buffer)), -1n);
|
|
3904
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int8Array([127]).buffer)), 127n);
|
|
3905
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int8Array([-128]).buffer)), -128n);
|
|
3906
|
+
},
|
|
3907
|
+
"2 byte int"($) {
|
|
3908
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int16Array([128]).buffer)), 128n);
|
|
3909
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int16Array([-129]).buffer)), -129n);
|
|
3910
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int16Array([128 * 256 - 1]).buffer)), 128n * 256n - 1n);
|
|
3911
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int16Array([-128 * 256]).buffer)), -128n * 256n);
|
|
3912
|
+
},
|
|
3913
|
+
"3 byte int"($) {
|
|
3914
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([128 * 256]).buffer).slice(0, 3)), 128n * 256n);
|
|
3915
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([-128 * 256 - 1]).buffer).slice(0, 3)), -128n * 256n - 1n);
|
|
3916
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([128 * 256 ** 2 - 1]).buffer).slice(0, 3)), 128n * 256n ** 2n - 1n);
|
|
3917
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([-128 * 256 ** 2]).buffer).slice(0, 3)), -128n * 256n ** 2n);
|
|
3918
|
+
},
|
|
3919
|
+
"4 byte int"($) {
|
|
3920
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([128 * 256 ** 2]).buffer)), 128n * 256n ** 2n);
|
|
3921
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([-128 * 256 ** 2 - 1]).buffer)), -128n * 256n ** 2n - 1n);
|
|
3922
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([128 * 256 ** 3 - 1]).buffer)), 128n * 256n ** 3n - 1n);
|
|
3923
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([-128 * 256 ** 3]).buffer)), -128n * 256n ** 3n);
|
|
3924
|
+
},
|
|
3925
|
+
"8 byte int"($) {
|
|
3926
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new BigInt64Array([128n * 256n ** 7n - 1n]).buffer)), 128n * 256n ** 7n - 1n);
|
|
3927
|
+
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new BigInt64Array([-128n * 256n ** 7n]).buffer)), -128n * 256n ** 7n);
|
|
3928
|
+
},
|
|
3929
|
+
});
|
|
3930
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
3827
3931
|
})($ || ($ = {}));
|
|
3828
3932
|
|
|
3829
3933
|
;
|
|
@@ -3831,100 +3935,300 @@ var $;
|
|
|
3831
3935
|
var $;
|
|
3832
3936
|
(function ($) {
|
|
3833
3937
|
$mol_test({
|
|
3834
|
-
'
|
|
3835
|
-
|
|
3938
|
+
'decode utf8 string'() {
|
|
3939
|
+
const str = 'Hello, ΧΨΩЫ';
|
|
3940
|
+
const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
|
|
3941
|
+
$mol_assert_equal($mol_charset_decode(encoded), str);
|
|
3942
|
+
$mol_assert_equal($mol_charset_decode(encoded, 'utf8'), str);
|
|
3836
3943
|
},
|
|
3837
|
-
'
|
|
3838
|
-
const
|
|
3839
|
-
$mol_assert_equal(
|
|
3840
|
-
$mol_assert_equal(dom.value, '123');
|
|
3944
|
+
'decode empty string'() {
|
|
3945
|
+
const encoded = new Uint8Array([]);
|
|
3946
|
+
$mol_assert_equal($mol_charset_decode(encoded), '');
|
|
3841
3947
|
},
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3948
|
+
});
|
|
3949
|
+
})($ || ($ = {}));
|
|
3950
|
+
|
|
3951
|
+
;
|
|
3952
|
+
"use strict";
|
|
3953
|
+
var $;
|
|
3954
|
+
(function ($) {
|
|
3955
|
+
$mol_test({
|
|
3956
|
+
'encode empty'() {
|
|
3957
|
+
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([]), 0, 0), ['', 0]);
|
|
3845
3958
|
},
|
|
3846
|
-
'
|
|
3847
|
-
|
|
3848
|
-
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
3959
|
+
'encode 1 octet'() {
|
|
3960
|
+
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([0x46]), 0, 1), ['F', 1]);
|
|
3849
3961
|
},
|
|
3850
|
-
'
|
|
3851
|
-
|
|
3852
|
-
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
3962
|
+
'encode 2 octet'() {
|
|
3963
|
+
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([0xd0, 0x91]), 0, 1), ['Б', 2]);
|
|
3853
3964
|
},
|
|
3854
|
-
'
|
|
3855
|
-
|
|
3856
|
-
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
3965
|
+
'encode 3 octet'() {
|
|
3966
|
+
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([0xe0, 0xa4, 0xb9]), 0, 1), ['ह', 3]);
|
|
3857
3967
|
},
|
|
3858
|
-
'
|
|
3859
|
-
|
|
3860
|
-
"hello",
|
|
3861
|
-
$mol_jsx("strong", null, "world"),
|
|
3862
|
-
"!");
|
|
3863
|
-
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
3968
|
+
'encode 4 octet'() {
|
|
3969
|
+
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([0xf0, 0x90, 0x8d, 0x88]), 0, 1), ['𐍈', 4]);
|
|
3864
3970
|
},
|
|
3865
|
-
'
|
|
3866
|
-
|
|
3867
|
-
$mol_jsx("br", null),
|
|
3868
|
-
$mol_jsx("hr", null));
|
|
3869
|
-
$mol_assert_equal($mol_dom_serialize(dom), '<br xmlns="http://www.w3.org/1999/xhtml" /><hr xmlns="http://www.w3.org/1999/xhtml" />');
|
|
3971
|
+
'encode surrogate pair'() {
|
|
3972
|
+
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([0xf0, 0x9f, 0x98, 0x80]), 0, 2), ['😀', 4]);
|
|
3870
3973
|
},
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3974
|
+
});
|
|
3975
|
+
})($ || ($ = {}));
|
|
3976
|
+
|
|
3977
|
+
;
|
|
3978
|
+
"use strict";
|
|
3979
|
+
var $;
|
|
3980
|
+
(function ($_1) {
|
|
3981
|
+
$mol_test_mocks.push($ => {
|
|
3982
|
+
$.$mol_log3_come = () => { };
|
|
3983
|
+
$.$mol_log3_done = () => { };
|
|
3984
|
+
$.$mol_log3_fail = () => { };
|
|
3985
|
+
$.$mol_log3_warn = () => { };
|
|
3986
|
+
$.$mol_log3_rise = () => { };
|
|
3987
|
+
$.$mol_log3_area = () => () => { };
|
|
3988
|
+
});
|
|
3989
|
+
})($ || ($ = {}));
|
|
3990
|
+
|
|
3991
|
+
;
|
|
3992
|
+
"use strict";
|
|
3993
|
+
|
|
3994
|
+
;
|
|
3995
|
+
"use strict";
|
|
3996
|
+
|
|
3997
|
+
;
|
|
3998
|
+
"use strict";
|
|
3999
|
+
|
|
4000
|
+
;
|
|
4001
|
+
"use strict";
|
|
4002
|
+
var $;
|
|
4003
|
+
(function ($_1) {
|
|
4004
|
+
$mol_test({
|
|
4005
|
+
'FQN of anon function'($) {
|
|
4006
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
4007
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
4008
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
4009
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
3877
4010
|
},
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
4011
|
+
});
|
|
4012
|
+
})($ || ($ = {}));
|
|
4013
|
+
|
|
4014
|
+
;
|
|
4015
|
+
"use strict";
|
|
4016
|
+
var $;
|
|
4017
|
+
(function ($) {
|
|
4018
|
+
$mol_test({
|
|
4019
|
+
'get'() {
|
|
4020
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
4021
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
3884
4022
|
},
|
|
3885
|
-
'
|
|
3886
|
-
const
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
};
|
|
3891
|
-
const
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
const
|
|
3897
|
-
$
|
|
4023
|
+
'has'() {
|
|
4024
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
4025
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
4026
|
+
},
|
|
4027
|
+
'set'() {
|
|
4028
|
+
const target = { foo: 777 };
|
|
4029
|
+
const proxy = $mol_delegate({}, () => target);
|
|
4030
|
+
proxy.foo = 123;
|
|
4031
|
+
$mol_assert_equal(target.foo, 123);
|
|
4032
|
+
},
|
|
4033
|
+
'getOwnPropertyDescriptor'() {
|
|
4034
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
4035
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
4036
|
+
value: 777,
|
|
4037
|
+
writable: true,
|
|
4038
|
+
enumerable: true,
|
|
4039
|
+
configurable: true,
|
|
4040
|
+
});
|
|
4041
|
+
},
|
|
4042
|
+
'ownKeys'() {
|
|
4043
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
4044
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
4045
|
+
},
|
|
4046
|
+
'getPrototypeOf'() {
|
|
4047
|
+
class Foo {
|
|
4048
|
+
}
|
|
4049
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
4050
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
4051
|
+
},
|
|
4052
|
+
'setPrototypeOf'() {
|
|
4053
|
+
class Foo {
|
|
4054
|
+
}
|
|
4055
|
+
const target = {};
|
|
4056
|
+
const proxy = $mol_delegate({}, () => target);
|
|
4057
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
4058
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
4059
|
+
},
|
|
4060
|
+
'instanceof'() {
|
|
4061
|
+
class Foo {
|
|
4062
|
+
}
|
|
4063
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
4064
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
4065
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
4066
|
+
},
|
|
4067
|
+
'autobind'() {
|
|
4068
|
+
class Foo {
|
|
4069
|
+
}
|
|
4070
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
4071
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
4072
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
4073
|
+
},
|
|
4074
|
+
});
|
|
4075
|
+
})($ || ($ = {}));
|
|
4076
|
+
|
|
4077
|
+
;
|
|
4078
|
+
"use strict";
|
|
4079
|
+
var $;
|
|
4080
|
+
(function ($_1) {
|
|
4081
|
+
$mol_test({
|
|
4082
|
+
'span for same uri'($) {
|
|
4083
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
4084
|
+
const child = span.span(4, 5, 8);
|
|
4085
|
+
$mol_assert_equal(child.uri, 'test.ts');
|
|
4086
|
+
$mol_assert_equal(child.row, 4);
|
|
4087
|
+
$mol_assert_equal(child.col, 5);
|
|
4088
|
+
$mol_assert_equal(child.length, 8);
|
|
4089
|
+
},
|
|
4090
|
+
'span after of given position'($) {
|
|
4091
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
4092
|
+
const child = span.after(11);
|
|
4093
|
+
$mol_assert_equal(child.uri, 'test.ts');
|
|
4094
|
+
$mol_assert_equal(child.row, 1);
|
|
4095
|
+
$mol_assert_equal(child.col, 7);
|
|
4096
|
+
$mol_assert_equal(child.length, 11);
|
|
4097
|
+
},
|
|
4098
|
+
'slice span - regular'($) {
|
|
4099
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
4100
|
+
const child = span.slice(1, 4);
|
|
4101
|
+
$mol_assert_equal(child.row, 1);
|
|
4102
|
+
$mol_assert_equal(child.col, 4);
|
|
4103
|
+
$mol_assert_equal(child.length, 3);
|
|
4104
|
+
const child2 = span.slice(2, 2);
|
|
4105
|
+
$mol_assert_equal(child2.col, 5);
|
|
4106
|
+
$mol_assert_equal(child2.length, 0);
|
|
4107
|
+
},
|
|
4108
|
+
'slice span - negative'($) {
|
|
4109
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
4110
|
+
const child = span.slice(-3, -1);
|
|
4111
|
+
$mol_assert_equal(child.row, 1);
|
|
4112
|
+
$mol_assert_equal(child.col, 5);
|
|
4113
|
+
$mol_assert_equal(child.length, 2);
|
|
4114
|
+
},
|
|
4115
|
+
'slice span - out of range'($) {
|
|
4116
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
4117
|
+
$mol_assert_fail(() => span.slice(-1, 3), `End value '3' can't be less than begin value (test.ts#1:3/5)`);
|
|
4118
|
+
$mol_assert_fail(() => span.slice(1, 6), `End value '6' out of range (test.ts#1:3/5)`);
|
|
4119
|
+
$mol_assert_fail(() => span.slice(1, 10), `End value '10' out of range (test.ts#1:3/5)`);
|
|
4120
|
+
},
|
|
4121
|
+
'error handling'($) {
|
|
4122
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
4123
|
+
const error = span.error('Some error');
|
|
4124
|
+
$mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
|
|
4125
|
+
}
|
|
4126
|
+
});
|
|
4127
|
+
})($ || ($ = {}));
|
|
4128
|
+
|
|
4129
|
+
;
|
|
4130
|
+
"use strict";
|
|
4131
|
+
var $;
|
|
4132
|
+
(function ($) {
|
|
4133
|
+
$mol_test({
|
|
4134
|
+
'all cases of using maybe'() {
|
|
4135
|
+
$mol_assert_equal($mol_maybe(0)[0], 0);
|
|
4136
|
+
$mol_assert_equal($mol_maybe(false)[0], false);
|
|
4137
|
+
$mol_assert_equal($mol_maybe(null)[0], void 0);
|
|
4138
|
+
$mol_assert_equal($mol_maybe(void 0)[0], void 0);
|
|
4139
|
+
$mol_assert_equal($mol_maybe(void 0).map(v => v.toString())[0], void 0);
|
|
4140
|
+
$mol_assert_equal($mol_maybe(0).map(v => v.toString())[0], '0');
|
|
3898
4141
|
},
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
4142
|
+
});
|
|
4143
|
+
})($ || ($ = {}));
|
|
4144
|
+
|
|
4145
|
+
;
|
|
4146
|
+
"use strict";
|
|
4147
|
+
var $;
|
|
4148
|
+
(function ($_1) {
|
|
4149
|
+
function check(tree, ideal) {
|
|
4150
|
+
$mol_assert_equal(tree.toString(), $$.$mol_tree2_from_string(ideal).toString());
|
|
4151
|
+
}
|
|
4152
|
+
$mol_test({
|
|
4153
|
+
'inserting'($) {
|
|
4154
|
+
check($.$mol_tree2_from_string(`
|
|
4155
|
+
a b c d
|
|
4156
|
+
`).insert($mol_tree2.struct('x'), 'a', 'b', 'c'), `
|
|
4157
|
+
a b x
|
|
4158
|
+
`);
|
|
4159
|
+
check($.$mol_tree2_from_string(`
|
|
4160
|
+
a b
|
|
4161
|
+
`).insert($mol_tree2.struct('x'), 'a', 'b', 'c', 'd'), `
|
|
4162
|
+
a b c x
|
|
4163
|
+
`);
|
|
4164
|
+
check($.$mol_tree2_from_string(`
|
|
4165
|
+
a b c d
|
|
4166
|
+
`)
|
|
4167
|
+
.insert($mol_tree2.struct('x'), 0, 0, 0), `
|
|
4168
|
+
a b x
|
|
4169
|
+
`);
|
|
4170
|
+
check($.$mol_tree2_from_string(`
|
|
4171
|
+
a b
|
|
4172
|
+
`)
|
|
4173
|
+
.insert($mol_tree2.struct('x'), 0, 0, 0, 0), `
|
|
4174
|
+
a b \\
|
|
4175
|
+
x
|
|
4176
|
+
`);
|
|
4177
|
+
check($.$mol_tree2_from_string(`
|
|
4178
|
+
a b c d
|
|
4179
|
+
`)
|
|
4180
|
+
.insert($mol_tree2.struct('x'), null, null, null), `
|
|
4181
|
+
a b x
|
|
4182
|
+
`);
|
|
4183
|
+
check($.$mol_tree2_from_string(`
|
|
4184
|
+
a b
|
|
4185
|
+
`)
|
|
4186
|
+
.insert($mol_tree2.struct('x'), null, null, null, null), `
|
|
4187
|
+
a b \\
|
|
4188
|
+
x
|
|
4189
|
+
`);
|
|
3906
4190
|
},
|
|
3907
|
-
'
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
4191
|
+
'updating'($) {
|
|
4192
|
+
check($.$mol_tree2_from_string(`
|
|
4193
|
+
a b c d
|
|
4194
|
+
`).update([], 'a', 'b', 'c')[0], `
|
|
4195
|
+
a b
|
|
4196
|
+
`);
|
|
4197
|
+
check($.$mol_tree2_from_string(`
|
|
4198
|
+
a b c d
|
|
4199
|
+
`).update([$mol_tree2.struct('x')])[0], `
|
|
4200
|
+
x
|
|
4201
|
+
`);
|
|
4202
|
+
check($.$mol_tree2_from_string(`
|
|
4203
|
+
a b c d
|
|
4204
|
+
`).update([$mol_tree2.struct('x'), $mol_tree2.struct('y')], 'a', 'b', 'c')[0], `
|
|
4205
|
+
a b
|
|
4206
|
+
x
|
|
4207
|
+
y
|
|
4208
|
+
`);
|
|
3917
4209
|
},
|
|
3918
|
-
'
|
|
3919
|
-
const
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
4210
|
+
'deleting'($) {
|
|
4211
|
+
const base = $.$mol_tree2_from_string(`
|
|
4212
|
+
a b c d
|
|
4213
|
+
`);
|
|
4214
|
+
check(base.insert(null, 'a', 'b', 'c'), `
|
|
4215
|
+
a b
|
|
4216
|
+
`);
|
|
4217
|
+
check(base.update(base.select('a', 'b', 'c', null).kids, 'a', 'b', 'c')[0], `
|
|
4218
|
+
a b d
|
|
4219
|
+
`);
|
|
4220
|
+
check(base.insert(null, 0, 0, 0), `
|
|
4221
|
+
a b
|
|
4222
|
+
`);
|
|
4223
|
+
},
|
|
4224
|
+
'hack'($) {
|
|
4225
|
+
const res = $.$mol_tree2_from_string(`
|
|
4226
|
+
foo bar xxx
|
|
4227
|
+
`)
|
|
4228
|
+
.hack({
|
|
4229
|
+
'bar': (input, belt) => [input.struct('777', input.hack(belt))],
|
|
4230
|
+
});
|
|
4231
|
+
$mol_assert_equal(res.map(String), ['foo 777 xxx\n']);
|
|
3928
4232
|
},
|
|
3929
4233
|
});
|
|
3930
4234
|
})($ || ($ = {}));
|
|
@@ -3932,129 +4236,71 @@ var $;
|
|
|
3932
4236
|
;
|
|
3933
4237
|
"use strict";
|
|
3934
4238
|
var $;
|
|
3935
|
-
(function ($) {
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
const val = this[++cursor];
|
|
4001
|
-
if (check(val, cursor, this))
|
|
4002
|
-
filtered.push(val);
|
|
4003
|
-
}
|
|
4004
|
-
return filtered[index];
|
|
4005
|
-
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
4006
|
-
}
|
|
4007
|
-
forEach(proceed, context) {
|
|
4008
|
-
for (let [key, value] of this.entries())
|
|
4009
|
-
proceed.call(context, value, key, this);
|
|
4010
|
-
}
|
|
4011
|
-
map(proceed, context) {
|
|
4012
|
-
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
4013
|
-
}
|
|
4014
|
-
reduce(merge, result) {
|
|
4015
|
-
let index = 0;
|
|
4016
|
-
if (arguments.length === 1) {
|
|
4017
|
-
result = this[index++];
|
|
4018
|
-
}
|
|
4019
|
-
for (; index < this.length; ++index) {
|
|
4020
|
-
result = merge(result, this[index], index, this);
|
|
4021
|
-
}
|
|
4022
|
-
return result;
|
|
4023
|
-
}
|
|
4024
|
-
toReversed() {
|
|
4025
|
-
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
4026
|
-
}
|
|
4027
|
-
slice(from = 0, to = this.length) {
|
|
4028
|
-
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
4029
|
-
}
|
|
4030
|
-
some(check, context) {
|
|
4031
|
-
for (let index = 0; index < this.length; ++index) {
|
|
4032
|
-
if (check.call(context, this[index], index, this))
|
|
4033
|
-
return true;
|
|
4034
|
-
}
|
|
4035
|
-
return false;
|
|
4036
|
-
}
|
|
4037
|
-
every(check, context) {
|
|
4038
|
-
for (let index = 0; index < this.length; ++index) {
|
|
4039
|
-
if (!check.call(context, this[index], index, this))
|
|
4040
|
-
return false;
|
|
4041
|
-
}
|
|
4042
|
-
return true;
|
|
4043
|
-
}
|
|
4044
|
-
reverse() {
|
|
4045
|
-
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
|
4046
|
-
}
|
|
4047
|
-
sort() {
|
|
4048
|
-
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
|
4049
|
-
}
|
|
4050
|
-
indexOf(needle) {
|
|
4051
|
-
return this.findIndex(item => item === needle);
|
|
4052
|
-
}
|
|
4053
|
-
[Symbol.toPrimitive]() {
|
|
4054
|
-
return $mol_guid();
|
|
4055
|
-
}
|
|
4056
|
-
}
|
|
4057
|
-
$.$mol_range2_array = $mol_range2_array;
|
|
4239
|
+
(function ($_1) {
|
|
4240
|
+
$mol_test({
|
|
4241
|
+
'tree parsing'($) {
|
|
4242
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids.length, 2);
|
|
4243
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids[1].type, "bar");
|
|
4244
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\n\n\n").kids.length, 1);
|
|
4245
|
+
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids.length, 2);
|
|
4246
|
+
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids[1].value, "bar");
|
|
4247
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
|
|
4248
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
|
|
4249
|
+
$mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
4250
|
+
},
|
|
4251
|
+
'Too many tabs'($) {
|
|
4252
|
+
const tree = `
|
|
4253
|
+
foo
|
|
4254
|
+
bar
|
|
4255
|
+
`;
|
|
4256
|
+
$mol_assert_fail(() => {
|
|
4257
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
4258
|
+
}, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
|
|
4259
|
+
},
|
|
4260
|
+
'Too few tabs'($) {
|
|
4261
|
+
const tree = `
|
|
4262
|
+
foo
|
|
4263
|
+
bar
|
|
4264
|
+
`;
|
|
4265
|
+
$mol_assert_fail(() => {
|
|
4266
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
4267
|
+
}, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
|
|
4268
|
+
},
|
|
4269
|
+
'Wrong nodes separator at start'($) {
|
|
4270
|
+
const tree = `foo\n \tbar\n`;
|
|
4271
|
+
$mol_assert_fail(() => {
|
|
4272
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
4273
|
+
}, 'Wrong nodes separator\ntest#2:1/2\n!!\n \tbar');
|
|
4274
|
+
},
|
|
4275
|
+
'Wrong nodes separator in the middle'($) {
|
|
4276
|
+
const tree = `foo bar\n`;
|
|
4277
|
+
$mol_assert_fail(() => {
|
|
4278
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
4279
|
+
}, 'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar');
|
|
4280
|
+
},
|
|
4281
|
+
'Unexpected EOF, LF required'($) {
|
|
4282
|
+
const tree = ` foo`;
|
|
4283
|
+
$mol_assert_fail(() => {
|
|
4284
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
4285
|
+
}, 'Unexpected EOF, LF required\ntest#1:5/1\n !\n foo');
|
|
4286
|
+
},
|
|
4287
|
+
'Errors skip and collect'($) {
|
|
4288
|
+
const tree = `foo bar`;
|
|
4289
|
+
const errors = [];
|
|
4290
|
+
const $$ = $.$mol_ambient({
|
|
4291
|
+
$mol_fail: (error) => {
|
|
4292
|
+
errors.push(error.message);
|
|
4293
|
+
return null;
|
|
4294
|
+
}
|
|
4295
|
+
});
|
|
4296
|
+
const res = $$.$mol_tree2_from_string(tree, 'test');
|
|
4297
|
+
$mol_assert_like(errors, [
|
|
4298
|
+
'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar',
|
|
4299
|
+
'Unexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
|
|
4300
|
+
]);
|
|
4301
|
+
$mol_assert_equal(res.toString(), 'foo bar\n');
|
|
4302
|
+
},
|
|
4303
|
+
});
|
|
4058
4304
|
})($ || ($ = {}));
|
|
4059
4305
|
|
|
4060
4306
|
;
|
|
@@ -4062,158 +4308,178 @@ var $;
|
|
|
4062
4308
|
var $;
|
|
4063
4309
|
(function ($) {
|
|
4064
4310
|
$mol_test({
|
|
4065
|
-
'
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
$mol_assert_equal(
|
|
4069
|
-
$mol_assert_equal(
|
|
4070
|
-
$mol_assert_equal(
|
|
4071
|
-
$mol_assert_equal(
|
|
4072
|
-
$mol_assert_equal(list[9], 9);
|
|
4073
|
-
$mol_assert_equal(list[9.5], undefined);
|
|
4074
|
-
$mol_assert_equal(list[10], undefined);
|
|
4075
|
-
$mol_assert_equal(calls, 2);
|
|
4311
|
+
'fromJSON'() {
|
|
4312
|
+
$mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
|
|
4313
|
+
$mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
4314
|
+
$mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
4315
|
+
$mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
|
|
4316
|
+
$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');
|
|
4317
|
+
$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');
|
|
4076
4318
|
},
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4319
|
+
});
|
|
4320
|
+
})($ || ($ = {}));
|
|
4321
|
+
|
|
4322
|
+
;
|
|
4323
|
+
"use strict";
|
|
4324
|
+
var $;
|
|
4325
|
+
(function ($) {
|
|
4326
|
+
$mol_test({
|
|
4327
|
+
'auto name'() {
|
|
4328
|
+
class Invalid extends $mol_error_mix {
|
|
4329
|
+
}
|
|
4330
|
+
const mix = new Invalid('foo');
|
|
4331
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
4086
4332
|
},
|
|
4087
|
-
'
|
|
4088
|
-
const
|
|
4089
|
-
$mol_assert_equal(
|
|
4090
|
-
$mol_assert_equal(
|
|
4333
|
+
'simpe mix'() {
|
|
4334
|
+
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
4335
|
+
$mol_assert_equal(mix.message, 'foo');
|
|
4336
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
4091
4337
|
},
|
|
4092
|
-
'
|
|
4093
|
-
|
|
4094
|
-
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
|
4095
|
-
log += i;
|
|
4338
|
+
'provide additional info'() {
|
|
4339
|
+
class Invalid extends $mol_error_mix {
|
|
4096
4340
|
}
|
|
4097
|
-
$
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4341
|
+
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' }));
|
|
4342
|
+
const hints = [];
|
|
4343
|
+
if (mix instanceof $mol_error_mix) {
|
|
4344
|
+
for (const er of mix.errors) {
|
|
4345
|
+
if (er instanceof Invalid) {
|
|
4346
|
+
hints.push(er.cause?.hint ?? '');
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4103
4349
|
}
|
|
4104
|
-
$mol_assert_equal(
|
|
4105
|
-
},
|
|
4106
|
-
'forEach'() {
|
|
4107
|
-
let log = '';
|
|
4108
|
-
$mol_range2(i => i, () => 5).forEach(i => log += i);
|
|
4109
|
-
$mol_assert_equal(log, '01234');
|
|
4110
|
-
},
|
|
4111
|
-
'reduce'() {
|
|
4112
|
-
let calls = 0;
|
|
4113
|
-
const list = $mol_range2().slice(1, 6);
|
|
4114
|
-
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
|
4115
|
-
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
|
4116
|
-
},
|
|
4117
|
-
'lazy concat'() {
|
|
4118
|
-
let calls1 = 0;
|
|
4119
|
-
let calls2 = 0;
|
|
4120
|
-
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
|
4121
|
-
$mol_assert_equal(true, list instanceof Array);
|
|
4122
|
-
$mol_assert_equal(list.length, 15);
|
|
4123
|
-
$mol_assert_equal(list[0], 0);
|
|
4124
|
-
$mol_assert_equal(list[4], 4);
|
|
4125
|
-
$mol_assert_equal(list[5], 0);
|
|
4126
|
-
$mol_assert_equal(list[9], 4);
|
|
4127
|
-
$mol_assert_equal(list[10], 0);
|
|
4128
|
-
$mol_assert_equal(list[14], 4);
|
|
4129
|
-
$mol_assert_equal(list[15], undefined);
|
|
4130
|
-
$mol_assert_equal(calls1, 2);
|
|
4131
|
-
$mol_assert_equal(calls2, 2);
|
|
4132
|
-
},
|
|
4133
|
-
'lazy filter'() {
|
|
4134
|
-
let calls = 0;
|
|
4135
|
-
const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
|
|
4136
|
-
$mol_assert_equal(true, list instanceof Array);
|
|
4137
|
-
$mol_assert_equal(list.length, 3);
|
|
4138
|
-
$mol_assert_equal(list[0], 1);
|
|
4139
|
-
$mol_assert_equal(list[2], 5);
|
|
4140
|
-
$mol_assert_equal(list[3], undefined);
|
|
4141
|
-
$mol_assert_equal(calls, 8);
|
|
4142
|
-
},
|
|
4143
|
-
'lazy reverse'() {
|
|
4144
|
-
let calls = 0;
|
|
4145
|
-
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
|
4146
|
-
$mol_assert_equal(true, list instanceof Array);
|
|
4147
|
-
$mol_assert_equal(list.length, 3);
|
|
4148
|
-
$mol_assert_equal(list[0], 9);
|
|
4149
|
-
$mol_assert_equal(list[2], 7);
|
|
4150
|
-
$mol_assert_equal(list[3], undefined);
|
|
4151
|
-
$mol_assert_equal(calls, 2);
|
|
4152
|
-
},
|
|
4153
|
-
'lazy map'() {
|
|
4154
|
-
let calls1 = 0;
|
|
4155
|
-
let calls2 = 0;
|
|
4156
|
-
const source = $mol_range2(index => (++calls1, index), () => 5);
|
|
4157
|
-
const target = source.map((item, index, self) => {
|
|
4158
|
-
++calls2;
|
|
4159
|
-
$mol_assert_equal(source, self);
|
|
4160
|
-
return index + 10;
|
|
4161
|
-
}, () => 5);
|
|
4162
|
-
$mol_assert_equal(true, target instanceof Array);
|
|
4163
|
-
$mol_assert_equal(target.length, 5);
|
|
4164
|
-
$mol_assert_equal(target[0], 10);
|
|
4165
|
-
$mol_assert_equal(target[4], 14);
|
|
4166
|
-
$mol_assert_equal(target[5], undefined);
|
|
4167
|
-
$mol_assert_equal(calls1, 2);
|
|
4168
|
-
$mol_assert_equal(calls2, 2);
|
|
4350
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
4169
4351
|
},
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4352
|
+
});
|
|
4353
|
+
})($ || ($ = {}));
|
|
4354
|
+
|
|
4355
|
+
;
|
|
4356
|
+
"use strict";
|
|
4357
|
+
var $;
|
|
4358
|
+
(function ($_1) {
|
|
4359
|
+
$mol_test({
|
|
4360
|
+
'init with overload'() {
|
|
4361
|
+
class X extends $mol_object {
|
|
4362
|
+
foo() {
|
|
4363
|
+
return 1;
|
|
4364
|
+
}
|
|
4365
|
+
}
|
|
4366
|
+
var x = X.make({
|
|
4367
|
+
foo: () => 2,
|
|
4368
|
+
});
|
|
4369
|
+
$mol_assert_equal(x.foo(), 2);
|
|
4179
4370
|
},
|
|
4180
|
-
'
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
$mol_assert_equal(
|
|
4371
|
+
'Context in instance inherits from class'($) {
|
|
4372
|
+
const custom = $.$mol_ambient({});
|
|
4373
|
+
class X extends $.$mol_object {
|
|
4374
|
+
static $ = custom;
|
|
4375
|
+
}
|
|
4376
|
+
$mol_assert_equal(new X().$, custom);
|
|
4186
4377
|
},
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4378
|
+
});
|
|
4379
|
+
})($ || ($ = {}));
|
|
4380
|
+
|
|
4381
|
+
;
|
|
4382
|
+
"use strict";
|
|
4383
|
+
var $;
|
|
4384
|
+
(function ($_1) {
|
|
4385
|
+
$mol_test({
|
|
4386
|
+
'Collect deps'() {
|
|
4387
|
+
const pub1 = new $mol_wire_pub;
|
|
4388
|
+
const pub2 = new $mol_wire_pub;
|
|
4389
|
+
const sub = new $mol_wire_pub_sub;
|
|
4390
|
+
const bu1 = sub.track_on();
|
|
4391
|
+
try {
|
|
4392
|
+
pub1.promote();
|
|
4393
|
+
pub2.promote();
|
|
4394
|
+
pub2.promote();
|
|
4395
|
+
}
|
|
4396
|
+
finally {
|
|
4397
|
+
sub.track_cut();
|
|
4398
|
+
sub.track_off(bu1);
|
|
4399
|
+
}
|
|
4400
|
+
pub1.emit();
|
|
4401
|
+
pub2.emit();
|
|
4402
|
+
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
|
4403
|
+
const bu2 = sub.track_on();
|
|
4404
|
+
try {
|
|
4405
|
+
pub1.promote();
|
|
4406
|
+
pub1.promote();
|
|
4407
|
+
pub2.promote();
|
|
4408
|
+
}
|
|
4409
|
+
finally {
|
|
4410
|
+
sub.track_cut();
|
|
4411
|
+
sub.track_off(bu2);
|
|
4412
|
+
}
|
|
4413
|
+
pub1.emit();
|
|
4414
|
+
pub2.emit();
|
|
4415
|
+
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
|
4193
4416
|
},
|
|
4194
|
-
'
|
|
4195
|
-
|
|
4196
|
-
const
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4417
|
+
'cyclic detection'($) {
|
|
4418
|
+
const sub1 = new $mol_wire_pub_sub;
|
|
4419
|
+
const sub2 = new $mol_wire_pub_sub;
|
|
4420
|
+
const bu1 = sub1.track_on();
|
|
4421
|
+
try {
|
|
4422
|
+
const bu2 = sub2.track_on();
|
|
4423
|
+
try {
|
|
4424
|
+
$mol_assert_fail(() => sub1.promote(), 'Circular subscription');
|
|
4425
|
+
}
|
|
4426
|
+
finally {
|
|
4427
|
+
sub2.track_cut();
|
|
4428
|
+
sub2.track_off(bu2);
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
finally {
|
|
4432
|
+
sub1.track_cut();
|
|
4433
|
+
sub1.track_off(bu1);
|
|
4434
|
+
}
|
|
4204
4435
|
},
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4436
|
+
});
|
|
4437
|
+
})($ || ($ = {}));
|
|
4438
|
+
|
|
4439
|
+
;
|
|
4440
|
+
"use strict";
|
|
4441
|
+
var $;
|
|
4442
|
+
(function ($) {
|
|
4443
|
+
$.$mol_after_mock_queue = [];
|
|
4444
|
+
function $mol_after_mock_warp() {
|
|
4445
|
+
const queue = $.$mol_after_mock_queue.splice(0);
|
|
4446
|
+
for (const task of queue)
|
|
4447
|
+
task();
|
|
4448
|
+
}
|
|
4449
|
+
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
|
4450
|
+
class $mol_after_mock_commmon extends $mol_object2 {
|
|
4451
|
+
task;
|
|
4452
|
+
promise = Promise.resolve();
|
|
4453
|
+
cancelled = false;
|
|
4454
|
+
id;
|
|
4455
|
+
constructor(task) {
|
|
4456
|
+
super();
|
|
4457
|
+
this.task = task;
|
|
4458
|
+
$.$mol_after_mock_queue.push(task);
|
|
4459
|
+
}
|
|
4460
|
+
destructor() {
|
|
4461
|
+
const index = $.$mol_after_mock_queue.indexOf(this.task);
|
|
4462
|
+
if (index >= 0)
|
|
4463
|
+
$.$mol_after_mock_queue.splice(index, 1);
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
|
4467
|
+
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
|
4468
|
+
delay;
|
|
4469
|
+
constructor(delay, task) {
|
|
4470
|
+
super(task);
|
|
4471
|
+
this.delay = delay;
|
|
4216
4472
|
}
|
|
4473
|
+
}
|
|
4474
|
+
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
|
4475
|
+
})($ || ($ = {}));
|
|
4476
|
+
|
|
4477
|
+
;
|
|
4478
|
+
"use strict";
|
|
4479
|
+
var $;
|
|
4480
|
+
(function ($_1) {
|
|
4481
|
+
$mol_test_mocks.push($ => {
|
|
4482
|
+
$.$mol_after_tick = $mol_after_mock_commmon;
|
|
4217
4483
|
});
|
|
4218
4484
|
})($ || ($ = {}));
|
|
4219
4485
|
|
|
@@ -4222,125 +4488,79 @@ var $;
|
|
|
4222
4488
|
var $;
|
|
4223
4489
|
(function ($) {
|
|
4224
4490
|
$mol_test({
|
|
4225
|
-
'
|
|
4226
|
-
$
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
},
|
|
4231
|
-
'number'() {
|
|
4232
|
-
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
4233
|
-
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
4234
|
-
$mol_assert_not($mol_compare_deep(1, 2));
|
|
4235
|
-
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
4236
|
-
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
4237
|
-
},
|
|
4238
|
-
'POJO'() {
|
|
4239
|
-
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
4240
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
4241
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
4242
|
-
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
4243
|
-
$mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
4244
|
-
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
4245
|
-
$mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
|
|
4246
|
-
},
|
|
4247
|
-
'Array'() {
|
|
4248
|
-
$mol_assert_ok($mol_compare_deep([], []));
|
|
4249
|
-
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
4250
|
-
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
4251
|
-
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
4252
|
-
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
|
4253
|
-
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
|
4254
|
-
},
|
|
4255
|
-
'Non POJO are different'() {
|
|
4256
|
-
class Thing extends Object {
|
|
4491
|
+
'Sync execution'() {
|
|
4492
|
+
class Sync extends $mol_object2 {
|
|
4493
|
+
static calc(a, b) {
|
|
4494
|
+
return a + b;
|
|
4495
|
+
}
|
|
4257
4496
|
}
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
'POJO with symbols'() {
|
|
4263
|
-
const sym = Symbol();
|
|
4264
|
-
$mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
|
|
4265
|
-
$mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
|
|
4266
|
-
},
|
|
4267
|
-
'same POJOs with cyclic reference'() {
|
|
4268
|
-
const a = { foo: {} };
|
|
4269
|
-
a['self'] = a;
|
|
4270
|
-
const b = { foo: {} };
|
|
4271
|
-
b['self'] = b;
|
|
4272
|
-
$mol_assert_ok($mol_compare_deep(a, b));
|
|
4273
|
-
},
|
|
4274
|
-
'same POJOs with cyclic reference with cache warmup'() {
|
|
4275
|
-
const obj1 = { test: 1, obj3: null };
|
|
4276
|
-
const obj1_copy = { test: 1, obj3: null };
|
|
4277
|
-
const obj2 = { test: 2, obj1 };
|
|
4278
|
-
const obj2_copy = { test: 2, obj1: obj1_copy };
|
|
4279
|
-
const obj3 = { test: 3, obj2 };
|
|
4280
|
-
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
4281
|
-
obj1.obj3 = obj3;
|
|
4282
|
-
obj1_copy.obj3 = obj3_copy;
|
|
4283
|
-
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
4284
|
-
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
4285
|
-
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
4286
|
-
$mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
|
|
4287
|
-
},
|
|
4288
|
-
'Date'() {
|
|
4289
|
-
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
4290
|
-
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
4291
|
-
},
|
|
4292
|
-
'RegExp'() {
|
|
4293
|
-
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
4294
|
-
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
4295
|
-
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
4296
|
-
},
|
|
4297
|
-
'Error'() {
|
|
4298
|
-
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
4299
|
-
const fail = (message) => new Error(message);
|
|
4300
|
-
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
4301
|
-
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
4302
|
-
},
|
|
4303
|
-
'Map'() {
|
|
4304
|
-
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
4305
|
-
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
4306
|
-
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
4307
|
-
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
4308
|
-
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
4309
|
-
},
|
|
4310
|
-
'Set'() {
|
|
4311
|
-
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
4312
|
-
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
4313
|
-
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
4497
|
+
__decorate([
|
|
4498
|
+
$mol_wire_method
|
|
4499
|
+
], Sync, "calc", null);
|
|
4500
|
+
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
4314
4501
|
},
|
|
4315
|
-
'
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4502
|
+
async 'async <=> sync'() {
|
|
4503
|
+
class SyncAsync extends $mol_object2 {
|
|
4504
|
+
static async val(a) {
|
|
4505
|
+
return a;
|
|
4506
|
+
}
|
|
4507
|
+
static sum(a, b) {
|
|
4508
|
+
const syn = $mol_wire_sync(this);
|
|
4509
|
+
return syn.val(a) + syn.val(b);
|
|
4510
|
+
}
|
|
4511
|
+
static async calc(a, b) {
|
|
4512
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
4513
|
+
}
|
|
4514
|
+
}
|
|
4515
|
+
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
|
4319
4516
|
},
|
|
4320
|
-
'
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4517
|
+
async 'Idempotence control'() {
|
|
4518
|
+
class Idempotence extends $mol_object2 {
|
|
4519
|
+
static logs_idemp = 0;
|
|
4520
|
+
static logs_unidemp = 0;
|
|
4521
|
+
static log_idemp() {
|
|
4522
|
+
this.logs_idemp += 1;
|
|
4523
|
+
}
|
|
4524
|
+
static log_unidemp() {
|
|
4525
|
+
this.logs_unidemp += 1;
|
|
4526
|
+
}
|
|
4527
|
+
static async val(a) {
|
|
4528
|
+
return a;
|
|
4529
|
+
}
|
|
4530
|
+
static sum(a, b) {
|
|
4531
|
+
this.log_idemp();
|
|
4532
|
+
this.log_unidemp();
|
|
4533
|
+
const syn = $mol_wire_sync(this);
|
|
4534
|
+
return syn.val(a) + syn.val(b);
|
|
4535
|
+
}
|
|
4536
|
+
static async calc(a, b) {
|
|
4537
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
__decorate([
|
|
4541
|
+
$mol_wire_method
|
|
4542
|
+
], Idempotence, "log_idemp", null);
|
|
4543
|
+
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
4544
|
+
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
4545
|
+
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
4324
4546
|
},
|
|
4325
|
-
'
|
|
4326
|
-
class
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
constructor(name, rand = Math.random()) {
|
|
4330
|
-
this.name = name;
|
|
4331
|
-
this.rand = rand;
|
|
4547
|
+
async 'Error handling'() {
|
|
4548
|
+
class Handle extends $mol_object2 {
|
|
4549
|
+
static async sum(a, b) {
|
|
4550
|
+
$mol_fail(new Error('test error ' + (a + b)));
|
|
4332
4551
|
}
|
|
4333
|
-
|
|
4334
|
-
|
|
4552
|
+
static check() {
|
|
4553
|
+
try {
|
|
4554
|
+
return $mol_wire_sync(Handle).sum(1, 2);
|
|
4555
|
+
}
|
|
4556
|
+
catch (error) {
|
|
4557
|
+
if ($mol_promise_like(error))
|
|
4558
|
+
$mol_fail_hidden(error);
|
|
4559
|
+
$mol_assert_equal(error.message, 'test error 3');
|
|
4560
|
+
}
|
|
4335
4561
|
}
|
|
4336
4562
|
}
|
|
4337
|
-
$
|
|
4338
|
-
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
4339
|
-
},
|
|
4340
|
-
'Iterable'() {
|
|
4341
|
-
$mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
|
|
4342
|
-
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
|
|
4343
|
-
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
|
|
4563
|
+
await $mol_wire_async(Handle).check();
|
|
4344
4564
|
},
|
|
4345
4565
|
});
|
|
4346
4566
|
})($ || ($ = {}));
|
|
@@ -4349,102 +4569,81 @@ var $;
|
|
|
4349
4569
|
"use strict";
|
|
4350
4570
|
var $;
|
|
4351
4571
|
(function ($) {
|
|
4352
|
-
function $
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
}
|
|
4375
|
-
else {
|
|
4376
|
-
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
4377
|
-
}
|
|
4378
|
-
return error;
|
|
4379
|
-
}
|
|
4380
|
-
finally {
|
|
4381
|
-
$.$mol_fail = fail;
|
|
4382
|
-
}
|
|
4383
|
-
$mol_fail(new Error('Not failed'));
|
|
4384
|
-
}
|
|
4385
|
-
$.$mol_assert_fail = $mol_assert_fail;
|
|
4386
|
-
function $mol_assert_like(...args) {
|
|
4387
|
-
$mol_assert_equal(...args);
|
|
4388
|
-
}
|
|
4389
|
-
$.$mol_assert_like = $mol_assert_like;
|
|
4390
|
-
function $mol_assert_unique(...args) {
|
|
4391
|
-
for (let i = 0; i < args.length; ++i) {
|
|
4392
|
-
for (let j = 0; j < args.length; ++j) {
|
|
4393
|
-
if (i === j)
|
|
4394
|
-
continue;
|
|
4395
|
-
if (!$mol_compare_deep(args[i], args[j]))
|
|
4396
|
-
continue;
|
|
4397
|
-
return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
|
|
4398
|
-
}
|
|
4399
|
-
}
|
|
4400
|
-
}
|
|
4401
|
-
$.$mol_assert_unique = $mol_assert_unique;
|
|
4402
|
-
function $mol_assert_equal(...args) {
|
|
4403
|
-
for (let i = 1; i < args.length; ++i) {
|
|
4404
|
-
if ($mol_compare_deep(args[0], args[i]))
|
|
4405
|
-
continue;
|
|
4406
|
-
if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
|
|
4407
|
-
continue;
|
|
4408
|
-
return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
|
|
4409
|
-
}
|
|
4572
|
+
function $mol_wire_async(obj) {
|
|
4573
|
+
let fiber;
|
|
4574
|
+
const temp = $mol_wire_task.getter(obj);
|
|
4575
|
+
return new Proxy(obj, {
|
|
4576
|
+
get(obj, field) {
|
|
4577
|
+
const val = obj[field];
|
|
4578
|
+
if (typeof val !== 'function')
|
|
4579
|
+
return val;
|
|
4580
|
+
let fiber;
|
|
4581
|
+
const temp = $mol_wire_task.getter(val);
|
|
4582
|
+
return function $mol_wire_async(...args) {
|
|
4583
|
+
fiber?.destructor();
|
|
4584
|
+
fiber = temp(obj, args);
|
|
4585
|
+
return fiber.async();
|
|
4586
|
+
};
|
|
4587
|
+
},
|
|
4588
|
+
apply(obj, self, args) {
|
|
4589
|
+
fiber?.destructor();
|
|
4590
|
+
fiber = temp(self, args);
|
|
4591
|
+
return fiber.async();
|
|
4592
|
+
},
|
|
4593
|
+
});
|
|
4410
4594
|
}
|
|
4411
|
-
$.$
|
|
4595
|
+
$.$mol_wire_async = $mol_wire_async;
|
|
4412
4596
|
})($ || ($ = {}));
|
|
4413
4597
|
|
|
4414
4598
|
;
|
|
4415
4599
|
"use strict";
|
|
4416
4600
|
var $;
|
|
4417
|
-
(function ($) {
|
|
4601
|
+
(function ($_1) {
|
|
4418
4602
|
$mol_test({
|
|
4419
|
-
'
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
'three must be equal'() {
|
|
4429
|
-
$mol_assert_equal(2, 2, 2);
|
|
4430
|
-
},
|
|
4431
|
-
'two must be unique'() {
|
|
4432
|
-
$mol_assert_unique([2], [3]);
|
|
4433
|
-
},
|
|
4434
|
-
'three must be unique'() {
|
|
4435
|
-
$mol_assert_unique([1], [2], [3]);
|
|
4436
|
-
},
|
|
4437
|
-
'two must be alike'() {
|
|
4438
|
-
$mol_assert_equal([3], [3]);
|
|
4439
|
-
},
|
|
4440
|
-
'three must be alike'() {
|
|
4441
|
-
$mol_assert_equal([3], [3], [3]);
|
|
4603
|
+
'test types'($) {
|
|
4604
|
+
class A {
|
|
4605
|
+
static a() {
|
|
4606
|
+
return '';
|
|
4607
|
+
}
|
|
4608
|
+
static b() {
|
|
4609
|
+
return $mol_wire_async(this).a();
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4442
4612
|
},
|
|
4443
|
-
'
|
|
4444
|
-
|
|
4613
|
+
async 'Latest method calls wins'($) {
|
|
4614
|
+
class NameLogger extends $mol_object2 {
|
|
4615
|
+
static $ = $;
|
|
4616
|
+
static first = [];
|
|
4617
|
+
static last = [];
|
|
4618
|
+
static send(next) {
|
|
4619
|
+
$mol_wire_sync(this.first).push(next);
|
|
4620
|
+
$$.$mol_wait_timeout(0);
|
|
4621
|
+
this.last.push(next);
|
|
4622
|
+
}
|
|
4623
|
+
}
|
|
4624
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
4625
|
+
name('john');
|
|
4626
|
+
const promise = name('jin');
|
|
4627
|
+
$.$mol_after_mock_warp();
|
|
4628
|
+
await promise;
|
|
4629
|
+
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
4630
|
+
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
4445
4631
|
},
|
|
4446
|
-
'
|
|
4447
|
-
|
|
4632
|
+
async 'Latest function calls wins'($) {
|
|
4633
|
+
const first = [];
|
|
4634
|
+
const last = [];
|
|
4635
|
+
function send_name(next) {
|
|
4636
|
+
$mol_wire_sync(first).push(next);
|
|
4637
|
+
$$.$mol_wait_timeout(0);
|
|
4638
|
+
last.push(next);
|
|
4639
|
+
}
|
|
4640
|
+
const name = $mol_wire_async(send_name);
|
|
4641
|
+
name('john');
|
|
4642
|
+
const promise = name('jin');
|
|
4643
|
+
$.$mol_after_mock_warp();
|
|
4644
|
+
await promise;
|
|
4645
|
+
$mol_assert_equal(first, ['john', 'jin']);
|
|
4646
|
+
$mol_assert_equal(last, ['jin']);
|
|
4448
4647
|
},
|
|
4449
4648
|
});
|
|
4450
4649
|
})($ || ($ = {}));
|
|
@@ -4452,150 +4651,131 @@ var $;
|
|
|
4452
4651
|
;
|
|
4453
4652
|
"use strict";
|
|
4454
4653
|
var $;
|
|
4455
|
-
(function ($
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
$mol_assert_equal($mol_bigint_encode(-128n * 256n ** 2n), new Uint8Array(new Int32Array([-128 * 256 ** 2]).buffer).slice(0, 3));
|
|
4477
|
-
},
|
|
4478
|
-
"4 byte int"($) {
|
|
4479
|
-
$mol_assert_equal($mol_bigint_encode(128n * 256n ** 2n), new Uint8Array(new Int32Array([128 * 256 ** 2]).buffer));
|
|
4480
|
-
$mol_assert_equal($mol_bigint_encode(-128n * 256n ** 2n - 1n), new Uint8Array(new Int32Array([-128 * 256 ** 2 - 1]).buffer));
|
|
4481
|
-
$mol_assert_equal($mol_bigint_encode(128n * 256n ** 3n - 1n), new Uint8Array(new Int32Array([128 * 256 ** 3 - 1]).buffer));
|
|
4482
|
-
$mol_assert_equal($mol_bigint_encode(-128n * 256n ** 3n), new Uint8Array(new Int32Array([-128 * 256 ** 3]).buffer));
|
|
4483
|
-
},
|
|
4484
|
-
"8 byte int"($) {
|
|
4485
|
-
$mol_assert_equal($mol_bigint_encode(128n * 256n ** 7n - 1n), new Uint8Array(new BigInt64Array([128n * 256n ** 7n - 1n]).buffer));
|
|
4486
|
-
$mol_assert_equal($mol_bigint_encode(-128n * 256n ** 7n), new Uint8Array(new BigInt64Array([-128n * 256n ** 7n]).buffer));
|
|
4487
|
-
},
|
|
4488
|
-
});
|
|
4489
|
-
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
4654
|
+
(function ($) {
|
|
4655
|
+
function $mol_wire_method(host, field, descr) {
|
|
4656
|
+
if (!descr)
|
|
4657
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
4658
|
+
const orig = descr?.value ?? host[field];
|
|
4659
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
4660
|
+
if (typeof sup[field] === 'function') {
|
|
4661
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
4662
|
+
}
|
|
4663
|
+
const temp = $mol_wire_task.getter(orig);
|
|
4664
|
+
const value = function (...args) {
|
|
4665
|
+
const fiber = temp(this ?? null, args);
|
|
4666
|
+
return fiber.sync();
|
|
4667
|
+
};
|
|
4668
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
4669
|
+
Object.assign(value, { orig });
|
|
4670
|
+
const descr2 = { ...descr, value };
|
|
4671
|
+
Reflect.defineProperty(host, field, descr2);
|
|
4672
|
+
return descr2;
|
|
4673
|
+
}
|
|
4674
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
4490
4675
|
})($ || ($ = {}));
|
|
4491
4676
|
|
|
4492
4677
|
;
|
|
4493
4678
|
"use strict";
|
|
4494
4679
|
var $;
|
|
4495
|
-
(function ($) {
|
|
4680
|
+
(function ($_1) {
|
|
4496
4681
|
$mol_test({
|
|
4497
|
-
'
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
'encode 3 octet'() {
|
|
4507
|
-
$mol_assert_equal($mol_charset_encode('ह'), new Uint8Array([0xe0, 0xa4, 0xb9]));
|
|
4682
|
+
'test types'($) {
|
|
4683
|
+
class A {
|
|
4684
|
+
static a() {
|
|
4685
|
+
return Promise.resolve('');
|
|
4686
|
+
}
|
|
4687
|
+
static b() {
|
|
4688
|
+
return $mol_wire_sync(this).a();
|
|
4689
|
+
}
|
|
4690
|
+
}
|
|
4508
4691
|
},
|
|
4509
|
-
'
|
|
4510
|
-
|
|
4692
|
+
async 'test method from host'($) {
|
|
4693
|
+
let count = 0;
|
|
4694
|
+
class A {
|
|
4695
|
+
static a() {
|
|
4696
|
+
return $mol_wire_sync(this).b();
|
|
4697
|
+
}
|
|
4698
|
+
static b() { return Promise.resolve(++count); }
|
|
4699
|
+
}
|
|
4700
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
4511
4701
|
},
|
|
4512
|
-
'
|
|
4513
|
-
|
|
4702
|
+
async 'test function'($) {
|
|
4703
|
+
let count = 0;
|
|
4704
|
+
class A {
|
|
4705
|
+
static a() {
|
|
4706
|
+
return $mol_wire_sync(this.b)();
|
|
4707
|
+
}
|
|
4708
|
+
static b() { return Promise.resolve(++count); }
|
|
4709
|
+
}
|
|
4710
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
4514
4711
|
},
|
|
4712
|
+
async 'test construct itself'($) {
|
|
4713
|
+
class A {
|
|
4714
|
+
static instances = [];
|
|
4715
|
+
static a() {
|
|
4716
|
+
const a = new ($mol_wire_sync(A))();
|
|
4717
|
+
this.instances.push(a);
|
|
4718
|
+
$mol_wire_sync(this).b();
|
|
4719
|
+
}
|
|
4720
|
+
static b() { return Promise.resolve(); }
|
|
4721
|
+
}
|
|
4722
|
+
await $mol_wire_async(A).a();
|
|
4723
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
4724
|
+
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
4725
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
4726
|
+
}
|
|
4515
4727
|
});
|
|
4516
4728
|
})($ || ($ = {}));
|
|
4517
4729
|
|
|
4518
4730
|
;
|
|
4519
4731
|
"use strict";
|
|
4520
4732
|
var $;
|
|
4521
|
-
(function ($
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
"3 byte int"($) {
|
|
4539
|
-
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([128 * 256]).buffer).slice(0, 3)), 128n * 256n);
|
|
4540
|
-
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([-128 * 256 - 1]).buffer).slice(0, 3)), -128n * 256n - 1n);
|
|
4541
|
-
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([128 * 256 ** 2 - 1]).buffer).slice(0, 3)), 128n * 256n ** 2n - 1n);
|
|
4542
|
-
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([-128 * 256 ** 2]).buffer).slice(0, 3)), -128n * 256n ** 2n);
|
|
4543
|
-
},
|
|
4544
|
-
"4 byte int"($) {
|
|
4545
|
-
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([128 * 256 ** 2]).buffer)), 128n * 256n ** 2n);
|
|
4546
|
-
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([-128 * 256 ** 2 - 1]).buffer)), -128n * 256n ** 2n - 1n);
|
|
4547
|
-
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([128 * 256 ** 3 - 1]).buffer)), 128n * 256n ** 3n - 1n);
|
|
4548
|
-
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new Int32Array([-128 * 256 ** 3]).buffer)), -128n * 256n ** 3n);
|
|
4549
|
-
},
|
|
4550
|
-
"8 byte int"($) {
|
|
4551
|
-
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new BigInt64Array([128n * 256n ** 7n - 1n]).buffer)), 128n * 256n ** 7n - 1n);
|
|
4552
|
-
$mol_assert_equal($mol_bigint_decode(new Uint8Array(new BigInt64Array([-128n * 256n ** 7n]).buffer)), -128n * 256n ** 7n);
|
|
4553
|
-
},
|
|
4554
|
-
});
|
|
4555
|
-
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
4733
|
+
(function ($) {
|
|
4734
|
+
class $mol_promise extends Promise {
|
|
4735
|
+
done;
|
|
4736
|
+
fail;
|
|
4737
|
+
constructor(executor) {
|
|
4738
|
+
let done;
|
|
4739
|
+
let fail;
|
|
4740
|
+
super((d, f) => {
|
|
4741
|
+
done = d;
|
|
4742
|
+
fail = f;
|
|
4743
|
+
executor?.(d, f);
|
|
4744
|
+
});
|
|
4745
|
+
this.done = done;
|
|
4746
|
+
this.fail = fail;
|
|
4747
|
+
}
|
|
4748
|
+
}
|
|
4749
|
+
$.$mol_promise = $mol_promise;
|
|
4556
4750
|
})($ || ($ = {}));
|
|
4557
4751
|
|
|
4558
4752
|
;
|
|
4559
4753
|
"use strict";
|
|
4560
4754
|
var $;
|
|
4561
4755
|
(function ($) {
|
|
4562
|
-
$
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4756
|
+
class $mol_after_timeout extends $mol_object2 {
|
|
4757
|
+
delay;
|
|
4758
|
+
task;
|
|
4759
|
+
id;
|
|
4760
|
+
constructor(delay, task) {
|
|
4761
|
+
super();
|
|
4762
|
+
this.delay = delay;
|
|
4763
|
+
this.task = task;
|
|
4764
|
+
this.id = setTimeout(task, delay);
|
|
4765
|
+
}
|
|
4766
|
+
destructor() {
|
|
4767
|
+
clearTimeout(this.id);
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
$.$mol_after_timeout = $mol_after_timeout;
|
|
4574
4771
|
})($ || ($ = {}));
|
|
4575
4772
|
|
|
4576
4773
|
;
|
|
4577
4774
|
"use strict";
|
|
4578
4775
|
var $;
|
|
4579
|
-
(function ($) {
|
|
4580
|
-
$
|
|
4581
|
-
|
|
4582
|
-
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([]), 0, 0), ['', 0]);
|
|
4583
|
-
},
|
|
4584
|
-
'encode 1 octet'() {
|
|
4585
|
-
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([0x46]), 0, 1), ['F', 1]);
|
|
4586
|
-
},
|
|
4587
|
-
'encode 2 octet'() {
|
|
4588
|
-
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([0xd0, 0x91]), 0, 1), ['Б', 2]);
|
|
4589
|
-
},
|
|
4590
|
-
'encode 3 octet'() {
|
|
4591
|
-
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([0xe0, 0xa4, 0xb9]), 0, 1), ['ह', 3]);
|
|
4592
|
-
},
|
|
4593
|
-
'encode 4 octet'() {
|
|
4594
|
-
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([0xf0, 0x90, 0x8d, 0x88]), 0, 1), ['𐍈', 4]);
|
|
4595
|
-
},
|
|
4596
|
-
'encode surrogate pair'() {
|
|
4597
|
-
$mol_assert_equal($mol_charset_decode_from(new Uint8Array([0xf0, 0x9f, 0x98, 0x80]), 0, 2), ['😀', 4]);
|
|
4598
|
-
},
|
|
4776
|
+
(function ($_1) {
|
|
4777
|
+
$mol_test_mocks.push($ => {
|
|
4778
|
+
$.$mol_after_timeout = $mol_after_mock_timeout;
|
|
4599
4779
|
});
|
|
4600
4780
|
})($ || ($ = {}));
|
|
4601
4781
|
|
|
@@ -4603,114 +4783,32 @@ var $;
|
|
|
4603
4783
|
"use strict";
|
|
4604
4784
|
var $;
|
|
4605
4785
|
(function ($) {
|
|
4606
|
-
$
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
value: 777,
|
|
4625
|
-
writable: true,
|
|
4626
|
-
enumerable: true,
|
|
4627
|
-
configurable: true,
|
|
4628
|
-
});
|
|
4629
|
-
},
|
|
4630
|
-
'ownKeys'() {
|
|
4631
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
4632
|
-
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
4633
|
-
},
|
|
4634
|
-
'getPrototypeOf'() {
|
|
4635
|
-
class Foo {
|
|
4636
|
-
}
|
|
4637
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
4638
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
4639
|
-
},
|
|
4640
|
-
'setPrototypeOf'() {
|
|
4641
|
-
class Foo {
|
|
4642
|
-
}
|
|
4643
|
-
const target = {};
|
|
4644
|
-
const proxy = $mol_delegate({}, () => target);
|
|
4645
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
4646
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
4647
|
-
},
|
|
4648
|
-
'instanceof'() {
|
|
4649
|
-
class Foo {
|
|
4650
|
-
}
|
|
4651
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
4652
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
4653
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
4654
|
-
},
|
|
4655
|
-
'autobind'() {
|
|
4656
|
-
class Foo {
|
|
4657
|
-
}
|
|
4658
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
4659
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
4660
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
4661
|
-
},
|
|
4662
|
-
});
|
|
4786
|
+
class $mol_after_work extends $mol_object2 {
|
|
4787
|
+
delay;
|
|
4788
|
+
task;
|
|
4789
|
+
id;
|
|
4790
|
+
constructor(delay, task) {
|
|
4791
|
+
super();
|
|
4792
|
+
this.delay = delay;
|
|
4793
|
+
this.task = task;
|
|
4794
|
+
this.id = requestIdleCallback(task, { timeout: delay });
|
|
4795
|
+
}
|
|
4796
|
+
destructor() {
|
|
4797
|
+
cancelIdleCallback(this.id);
|
|
4798
|
+
}
|
|
4799
|
+
}
|
|
4800
|
+
$.$mol_after_work = $mol_after_work;
|
|
4801
|
+
if (typeof requestIdleCallback !== 'function') {
|
|
4802
|
+
$.$mol_after_work = $mol_after_timeout;
|
|
4803
|
+
}
|
|
4663
4804
|
})($ || ($ = {}));
|
|
4664
4805
|
|
|
4665
4806
|
;
|
|
4666
4807
|
"use strict";
|
|
4667
4808
|
var $;
|
|
4668
4809
|
(function ($_1) {
|
|
4669
|
-
$
|
|
4670
|
-
|
|
4671
|
-
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
4672
|
-
const child = span.span(4, 5, 8);
|
|
4673
|
-
$mol_assert_equal(child.uri, 'test.ts');
|
|
4674
|
-
$mol_assert_equal(child.row, 4);
|
|
4675
|
-
$mol_assert_equal(child.col, 5);
|
|
4676
|
-
$mol_assert_equal(child.length, 8);
|
|
4677
|
-
},
|
|
4678
|
-
'span after of given position'($) {
|
|
4679
|
-
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
4680
|
-
const child = span.after(11);
|
|
4681
|
-
$mol_assert_equal(child.uri, 'test.ts');
|
|
4682
|
-
$mol_assert_equal(child.row, 1);
|
|
4683
|
-
$mol_assert_equal(child.col, 7);
|
|
4684
|
-
$mol_assert_equal(child.length, 11);
|
|
4685
|
-
},
|
|
4686
|
-
'slice span - regular'($) {
|
|
4687
|
-
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
4688
|
-
const child = span.slice(1, 4);
|
|
4689
|
-
$mol_assert_equal(child.row, 1);
|
|
4690
|
-
$mol_assert_equal(child.col, 4);
|
|
4691
|
-
$mol_assert_equal(child.length, 3);
|
|
4692
|
-
const child2 = span.slice(2, 2);
|
|
4693
|
-
$mol_assert_equal(child2.col, 5);
|
|
4694
|
-
$mol_assert_equal(child2.length, 0);
|
|
4695
|
-
},
|
|
4696
|
-
'slice span - negative'($) {
|
|
4697
|
-
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
4698
|
-
const child = span.slice(-3, -1);
|
|
4699
|
-
$mol_assert_equal(child.row, 1);
|
|
4700
|
-
$mol_assert_equal(child.col, 5);
|
|
4701
|
-
$mol_assert_equal(child.length, 2);
|
|
4702
|
-
},
|
|
4703
|
-
'slice span - out of range'($) {
|
|
4704
|
-
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
4705
|
-
$mol_assert_fail(() => span.slice(-1, 3), `End value '3' can't be less than begin value (test.ts#1:3/5)`);
|
|
4706
|
-
$mol_assert_fail(() => span.slice(1, 6), `End value '6' out of range (test.ts#1:3/5)`);
|
|
4707
|
-
$mol_assert_fail(() => span.slice(1, 10), `End value '10' out of range (test.ts#1:3/5)`);
|
|
4708
|
-
},
|
|
4709
|
-
'error handling'($) {
|
|
4710
|
-
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
4711
|
-
const error = span.error('Some error');
|
|
4712
|
-
$mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
|
|
4713
|
-
}
|
|
4810
|
+
$mol_test_mocks.push($ => {
|
|
4811
|
+
$.$mol_after_work = $mol_after_mock_timeout;
|
|
4714
4812
|
});
|
|
4715
4813
|
})($ || ($ = {}));
|
|
4716
4814
|
|
|
@@ -4718,192 +4816,113 @@ var $;
|
|
|
4718
4816
|
"use strict";
|
|
4719
4817
|
var $;
|
|
4720
4818
|
(function ($) {
|
|
4721
|
-
$
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4819
|
+
function $mol_wait_rest_async() {
|
|
4820
|
+
return new Promise(done => {
|
|
4821
|
+
new this.$mol_after_work(16, () => done(null));
|
|
4822
|
+
});
|
|
4823
|
+
}
|
|
4824
|
+
$.$mol_wait_rest_async = $mol_wait_rest_async;
|
|
4825
|
+
function $mol_wait_rest() {
|
|
4826
|
+
return this.$mol_wire_sync(this).$mol_wait_rest_async();
|
|
4827
|
+
}
|
|
4828
|
+
$.$mol_wait_rest = $mol_wait_rest;
|
|
4731
4829
|
})($ || ($ = {}));
|
|
4732
4830
|
|
|
4733
4831
|
;
|
|
4734
4832
|
"use strict";
|
|
4735
4833
|
var $;
|
|
4736
4834
|
(function ($_1) {
|
|
4737
|
-
|
|
4738
|
-
|
|
4835
|
+
var $$;
|
|
4836
|
+
(function ($$) {
|
|
4837
|
+
$mol_test_mocks.push($ => {
|
|
4838
|
+
$.$mol_wait_timeout = function $mol_wait_timeout_mock(timeout) { };
|
|
4839
|
+
$.$mol_wait_timeout_async = async function $mol_wait_timeout_async_mock(timeout) { };
|
|
4840
|
+
});
|
|
4841
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
4842
|
+
})($ || ($ = {}));
|
|
4843
|
+
|
|
4844
|
+
;
|
|
4845
|
+
"use strict";
|
|
4846
|
+
var $;
|
|
4847
|
+
(function ($) {
|
|
4848
|
+
function $mol_wait_timeout_async(timeout) {
|
|
4849
|
+
const promise = new $mol_promise();
|
|
4850
|
+
const task = new this.$mol_after_timeout(timeout, () => promise.done());
|
|
4851
|
+
return Object.assign(promise, {
|
|
4852
|
+
destructor: () => task.destructor()
|
|
4853
|
+
});
|
|
4739
4854
|
}
|
|
4740
|
-
$
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
a b x
|
|
4746
|
-
`);
|
|
4747
|
-
check($.$mol_tree2_from_string(`
|
|
4748
|
-
a b
|
|
4749
|
-
`).insert($mol_tree2.struct('x'), 'a', 'b', 'c', 'd'), `
|
|
4750
|
-
a b c x
|
|
4751
|
-
`);
|
|
4752
|
-
check($.$mol_tree2_from_string(`
|
|
4753
|
-
a b c d
|
|
4754
|
-
`)
|
|
4755
|
-
.insert($mol_tree2.struct('x'), 0, 0, 0), `
|
|
4756
|
-
a b x
|
|
4757
|
-
`);
|
|
4758
|
-
check($.$mol_tree2_from_string(`
|
|
4759
|
-
a b
|
|
4760
|
-
`)
|
|
4761
|
-
.insert($mol_tree2.struct('x'), 0, 0, 0, 0), `
|
|
4762
|
-
a b \\
|
|
4763
|
-
x
|
|
4764
|
-
`);
|
|
4765
|
-
check($.$mol_tree2_from_string(`
|
|
4766
|
-
a b c d
|
|
4767
|
-
`)
|
|
4768
|
-
.insert($mol_tree2.struct('x'), null, null, null), `
|
|
4769
|
-
a b x
|
|
4770
|
-
`);
|
|
4771
|
-
check($.$mol_tree2_from_string(`
|
|
4772
|
-
a b
|
|
4773
|
-
`)
|
|
4774
|
-
.insert($mol_tree2.struct('x'), null, null, null, null), `
|
|
4775
|
-
a b \\
|
|
4776
|
-
x
|
|
4777
|
-
`);
|
|
4778
|
-
},
|
|
4779
|
-
'updating'($) {
|
|
4780
|
-
check($.$mol_tree2_from_string(`
|
|
4781
|
-
a b c d
|
|
4782
|
-
`).update([], 'a', 'b', 'c')[0], `
|
|
4783
|
-
a b
|
|
4784
|
-
`);
|
|
4785
|
-
check($.$mol_tree2_from_string(`
|
|
4786
|
-
a b c d
|
|
4787
|
-
`).update([$mol_tree2.struct('x')])[0], `
|
|
4788
|
-
x
|
|
4789
|
-
`);
|
|
4790
|
-
check($.$mol_tree2_from_string(`
|
|
4791
|
-
a b c d
|
|
4792
|
-
`).update([$mol_tree2.struct('x'), $mol_tree2.struct('y')], 'a', 'b', 'c')[0], `
|
|
4793
|
-
a b
|
|
4794
|
-
x
|
|
4795
|
-
y
|
|
4796
|
-
`);
|
|
4797
|
-
},
|
|
4798
|
-
'deleting'($) {
|
|
4799
|
-
const base = $.$mol_tree2_from_string(`
|
|
4800
|
-
a b c d
|
|
4801
|
-
`);
|
|
4802
|
-
check(base.insert(null, 'a', 'b', 'c'), `
|
|
4803
|
-
a b
|
|
4804
|
-
`);
|
|
4805
|
-
check(base.update(base.select('a', 'b', 'c', null).kids, 'a', 'b', 'c')[0], `
|
|
4806
|
-
a b d
|
|
4807
|
-
`);
|
|
4808
|
-
check(base.insert(null, 0, 0, 0), `
|
|
4809
|
-
a b
|
|
4810
|
-
`);
|
|
4811
|
-
},
|
|
4812
|
-
'hack'($) {
|
|
4813
|
-
const res = $.$mol_tree2_from_string(`
|
|
4814
|
-
foo bar xxx
|
|
4815
|
-
`)
|
|
4816
|
-
.hack({
|
|
4817
|
-
'bar': (input, belt) => [input.struct('777', input.hack(belt))],
|
|
4818
|
-
});
|
|
4819
|
-
$mol_assert_equal(res.map(String), ['foo 777 xxx\n']);
|
|
4820
|
-
},
|
|
4821
|
-
});
|
|
4855
|
+
$.$mol_wait_timeout_async = $mol_wait_timeout_async;
|
|
4856
|
+
function $mol_wait_timeout(timeout) {
|
|
4857
|
+
return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
|
|
4858
|
+
}
|
|
4859
|
+
$.$mol_wait_timeout = $mol_wait_timeout;
|
|
4822
4860
|
})($ || ($ = {}));
|
|
4823
4861
|
|
|
4824
4862
|
;
|
|
4825
4863
|
"use strict";
|
|
4826
4864
|
var $;
|
|
4827
4865
|
(function ($_1) {
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
$
|
|
4832
|
-
$
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
|
|
4836
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
|
|
4837
|
-
$mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
4838
|
-
},
|
|
4839
|
-
'Too many tabs'($) {
|
|
4840
|
-
const tree = `
|
|
4841
|
-
foo
|
|
4842
|
-
bar
|
|
4843
|
-
`;
|
|
4844
|
-
$mol_assert_fail(() => {
|
|
4845
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
4846
|
-
}, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
|
|
4847
|
-
},
|
|
4848
|
-
'Too few tabs'($) {
|
|
4849
|
-
const tree = `
|
|
4850
|
-
foo
|
|
4851
|
-
bar
|
|
4852
|
-
`;
|
|
4853
|
-
$mol_assert_fail(() => {
|
|
4854
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
4855
|
-
}, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
|
|
4856
|
-
},
|
|
4857
|
-
'Wrong nodes separator at start'($) {
|
|
4858
|
-
const tree = `foo\n \tbar\n`;
|
|
4859
|
-
$mol_assert_fail(() => {
|
|
4860
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
4861
|
-
}, 'Wrong nodes separator\ntest#2:1/2\n!!\n \tbar');
|
|
4862
|
-
},
|
|
4863
|
-
'Wrong nodes separator in the middle'($) {
|
|
4864
|
-
const tree = `foo bar\n`;
|
|
4865
|
-
$mol_assert_fail(() => {
|
|
4866
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
4867
|
-
}, 'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar');
|
|
4868
|
-
},
|
|
4869
|
-
'Unexpected EOF, LF required'($) {
|
|
4870
|
-
const tree = ` foo`;
|
|
4871
|
-
$mol_assert_fail(() => {
|
|
4872
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
4873
|
-
}, 'Unexpected EOF, LF required\ntest#1:5/1\n !\n foo');
|
|
4874
|
-
},
|
|
4875
|
-
'Errors skip and collect'($) {
|
|
4876
|
-
const tree = `foo bar`;
|
|
4877
|
-
const errors = [];
|
|
4878
|
-
const $$ = $.$mol_ambient({
|
|
4879
|
-
$mol_fail: (error) => {
|
|
4880
|
-
errors.push(error.message);
|
|
4881
|
-
return null;
|
|
4882
|
-
}
|
|
4883
|
-
});
|
|
4884
|
-
const res = $$.$mol_tree2_from_string(tree, 'test');
|
|
4885
|
-
$mol_assert_like(errors, [
|
|
4886
|
-
'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar',
|
|
4887
|
-
'Unexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
|
|
4888
|
-
]);
|
|
4889
|
-
$mol_assert_equal(res.toString(), 'foo bar\n');
|
|
4890
|
-
},
|
|
4891
|
-
});
|
|
4866
|
+
var $$;
|
|
4867
|
+
(function ($$) {
|
|
4868
|
+
$mol_test_mocks.push($ => {
|
|
4869
|
+
$.$mol_wait_rest = function $mol_wait_rest_mock() { };
|
|
4870
|
+
$.$mol_wait_rest_async = async function $mol_wait_rest_async_mock() { };
|
|
4871
|
+
});
|
|
4872
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
4892
4873
|
})($ || ($ = {}));
|
|
4893
4874
|
|
|
4894
4875
|
;
|
|
4895
4876
|
"use strict";
|
|
4896
4877
|
var $;
|
|
4897
|
-
(function ($) {
|
|
4878
|
+
(function ($_1) {
|
|
4898
4879
|
$mol_test({
|
|
4899
|
-
'
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4880
|
+
async 'exec timeout auto kill child process'($) {
|
|
4881
|
+
let close_mock = () => { };
|
|
4882
|
+
const error_message = 'Run error, timeout';
|
|
4883
|
+
function mol_run_spawn_sync_mock() {
|
|
4884
|
+
return {
|
|
4885
|
+
output: [],
|
|
4886
|
+
stdout: error_message,
|
|
4887
|
+
stderr: '',
|
|
4888
|
+
status: 0,
|
|
4889
|
+
signal: null,
|
|
4890
|
+
pid: 123,
|
|
4891
|
+
};
|
|
4892
|
+
}
|
|
4893
|
+
function mol_run_spawn_mock() {
|
|
4894
|
+
return {
|
|
4895
|
+
on(name, cb) {
|
|
4896
|
+
if (name === 'exit')
|
|
4897
|
+
close_mock = cb;
|
|
4898
|
+
},
|
|
4899
|
+
kill() { close_mock(); }
|
|
4900
|
+
};
|
|
4901
|
+
}
|
|
4902
|
+
const context_mock = $.$mol_ambient({
|
|
4903
|
+
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
4904
|
+
$mol_run_spawn: mol_run_spawn_mock
|
|
4905
|
+
});
|
|
4906
|
+
class $mol_run_mock extends $mol_run {
|
|
4907
|
+
static get $() { return context_mock; }
|
|
4908
|
+
static async_enabled() {
|
|
4909
|
+
return true;
|
|
4910
|
+
}
|
|
4911
|
+
}
|
|
4912
|
+
let message = '';
|
|
4913
|
+
try {
|
|
4914
|
+
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
4915
|
+
command: 'sleep 10',
|
|
4916
|
+
dir: '.',
|
|
4917
|
+
timeout: 10,
|
|
4918
|
+
env: { 'MOL_RUN_ASYNC': '1' }
|
|
4919
|
+
});
|
|
4920
|
+
}
|
|
4921
|
+
catch (e) {
|
|
4922
|
+
message = e.message;
|
|
4923
|
+
}
|
|
4924
|
+
$mol_assert_equal(message, error_message);
|
|
4925
|
+
}
|
|
4907
4926
|
});
|
|
4908
4927
|
})($ || ($ = {}));
|
|
4909
4928
|
|