mol_dump_lib 0.0.804 → 0.0.806
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 +291 -245
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +1243 -1083
- package/node.js.map +1 -1
- package/node.mjs +1243 -1083
- package/node.test.js +2610 -2574
- package/node.test.js.map +1 -1
- package/package.json +42 -38
- package/web.d.ts +420 -374
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +2211 -2051
- package/web.js.map +1 -1
- package/web.mjs +2211 -2051
- package/web.test.js +728 -852
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
function require( path ){ return $node[ path ] };
|
|
3
3
|
"use strict";
|
|
4
|
+
|
|
5
|
+
;
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
;
|
|
9
|
+
"use strict";
|
|
10
|
+
|
|
11
|
+
;
|
|
12
|
+
"use strict";
|
|
4
13
|
var $;
|
|
5
14
|
(function ($_1) {
|
|
6
15
|
function $mol_test(set) {
|
|
@@ -95,148 +104,119 @@ var $;
|
|
|
95
104
|
$.$mol_test_complete = $mol_test_complete;
|
|
96
105
|
})($ || ($ = {}));
|
|
97
106
|
|
|
98
|
-
;
|
|
99
|
-
"use strict";
|
|
100
|
-
|
|
101
|
-
;
|
|
102
|
-
"use strict";
|
|
103
|
-
|
|
104
|
-
;
|
|
105
|
-
"use strict";
|
|
106
|
-
|
|
107
|
-
;
|
|
108
|
-
"use strict";
|
|
109
|
-
|
|
110
107
|
;
|
|
111
108
|
"use strict";
|
|
112
109
|
var $;
|
|
113
110
|
(function ($) {
|
|
114
|
-
function $
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
function $mol_assert_ok(value) {
|
|
112
|
+
if (value)
|
|
113
|
+
return;
|
|
114
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
117
115
|
}
|
|
118
|
-
$.$
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
131
|
-
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
132
|
-
};
|
|
133
|
-
$.$mol_jsx_frag = '';
|
|
134
|
-
function $mol_jsx(Elem, props, ...childNodes) {
|
|
135
|
-
const id = props && props.id || '';
|
|
136
|
-
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
137
|
-
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
|
|
138
|
-
if (Elem && $.$mol_jsx_booked) {
|
|
139
|
-
if ($.$mol_jsx_booked.has(id)) {
|
|
140
|
-
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
$.$mol_jsx_booked.add(id);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
147
|
-
if ($.$mol_jsx_prefix) {
|
|
148
|
-
const prefix_ext = $.$mol_jsx_prefix;
|
|
149
|
-
const booked_ext = $.$mol_jsx_booked;
|
|
150
|
-
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
151
|
-
for (const field in props) {
|
|
152
|
-
const func = props[field];
|
|
153
|
-
if (typeof func !== 'function')
|
|
154
|
-
continue;
|
|
155
|
-
const wrapper = function (...args) {
|
|
156
|
-
const prefix = $.$mol_jsx_prefix;
|
|
157
|
-
const booked = $.$mol_jsx_booked;
|
|
158
|
-
const crumbs = $.$mol_jsx_crumbs;
|
|
159
|
-
try {
|
|
160
|
-
$.$mol_jsx_prefix = prefix_ext;
|
|
161
|
-
$.$mol_jsx_booked = booked_ext;
|
|
162
|
-
$.$mol_jsx_crumbs = crumbs_ext;
|
|
163
|
-
return func.call(this, ...args);
|
|
164
|
-
}
|
|
165
|
-
finally {
|
|
166
|
-
$.$mol_jsx_prefix = prefix;
|
|
167
|
-
$.$mol_jsx_booked = booked;
|
|
168
|
-
$.$mol_jsx_crumbs = crumbs;
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
$mol_func_name_from(wrapper, func);
|
|
172
|
-
props[field] = wrapper;
|
|
173
|
-
}
|
|
116
|
+
$.$mol_assert_ok = $mol_assert_ok;
|
|
117
|
+
function $mol_assert_not(value) {
|
|
118
|
+
if (!value)
|
|
119
|
+
return;
|
|
120
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
121
|
+
}
|
|
122
|
+
$.$mol_assert_not = $mol_assert_not;
|
|
123
|
+
function $mol_assert_fail(handler, ErrorRight) {
|
|
124
|
+
const fail = $.$mol_fail;
|
|
125
|
+
try {
|
|
126
|
+
$.$mol_fail = $.$mol_fail_hidden;
|
|
127
|
+
handler();
|
|
174
128
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
view[Symbol.toStringTag] = guid;
|
|
180
|
-
view.childNodes = childNodes;
|
|
181
|
-
if (!view.ownerDocument)
|
|
182
|
-
view.ownerDocument = $.$mol_jsx_document;
|
|
183
|
-
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
184
|
-
node = view.valueOf();
|
|
185
|
-
node[String(Elem)] = view;
|
|
186
|
-
return node;
|
|
129
|
+
catch (error) {
|
|
130
|
+
$.$mol_fail = fail;
|
|
131
|
+
if (typeof ErrorRight === 'string') {
|
|
132
|
+
$mol_assert_equal(error.message ?? error, ErrorRight);
|
|
187
133
|
}
|
|
188
134
|
else {
|
|
189
|
-
|
|
190
|
-
const booked = $.$mol_jsx_booked;
|
|
191
|
-
const crumbs = $.$mol_jsx_crumbs;
|
|
192
|
-
try {
|
|
193
|
-
$.$mol_jsx_prefix = guid;
|
|
194
|
-
$.$mol_jsx_booked = new Set;
|
|
195
|
-
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
196
|
-
return Elem(props, ...childNodes);
|
|
197
|
-
}
|
|
198
|
-
finally {
|
|
199
|
-
$.$mol_jsx_prefix = prefix;
|
|
200
|
-
$.$mol_jsx_booked = booked;
|
|
201
|
-
$.$mol_jsx_crumbs = crumbs;
|
|
202
|
-
}
|
|
135
|
+
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
203
136
|
}
|
|
137
|
+
return error;
|
|
204
138
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
208
|
-
: $.$mol_jsx_document.createDocumentFragment();
|
|
139
|
+
finally {
|
|
140
|
+
$.$mol_fail = fail;
|
|
209
141
|
}
|
|
210
|
-
$
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
node.setAttribute(key, props[key]);
|
|
222
|
-
}
|
|
223
|
-
else if (props[key] &&
|
|
224
|
-
typeof props[key] === 'object' &&
|
|
225
|
-
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
226
|
-
if (typeof node[key] === 'object') {
|
|
227
|
-
Object.assign(node[key], props[key]);
|
|
142
|
+
$mol_fail(new Error('Not failed'));
|
|
143
|
+
}
|
|
144
|
+
$.$mol_assert_fail = $mol_assert_fail;
|
|
145
|
+
function $mol_assert_like(...args) {
|
|
146
|
+
$mol_assert_equal(...args);
|
|
147
|
+
}
|
|
148
|
+
$.$mol_assert_like = $mol_assert_like;
|
|
149
|
+
function $mol_assert_unique(...args) {
|
|
150
|
+
for (let i = 0; i < args.length; ++i) {
|
|
151
|
+
for (let j = 0; j < args.length; ++j) {
|
|
152
|
+
if (i === j)
|
|
228
153
|
continue;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
node[key] = props[key];
|
|
154
|
+
if (!$mol_compare_deep(args[i], args[j]))
|
|
155
|
+
continue;
|
|
156
|
+
return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
|
|
233
157
|
}
|
|
234
158
|
}
|
|
235
|
-
if ($.$mol_jsx_crumbs)
|
|
236
|
-
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
237
|
-
return node;
|
|
238
159
|
}
|
|
239
|
-
$.$
|
|
160
|
+
$.$mol_assert_unique = $mol_assert_unique;
|
|
161
|
+
function $mol_assert_equal(...args) {
|
|
162
|
+
for (let i = 1; i < args.length; ++i) {
|
|
163
|
+
if ($mol_compare_deep(args[0], args[i]))
|
|
164
|
+
continue;
|
|
165
|
+
if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
|
|
166
|
+
continue;
|
|
167
|
+
return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
$.$mol_assert_equal = $mol_assert_equal;
|
|
171
|
+
})($ || ($ = {}));
|
|
172
|
+
|
|
173
|
+
;
|
|
174
|
+
"use strict";
|
|
175
|
+
var $;
|
|
176
|
+
(function ($) {
|
|
177
|
+
$mol_test({
|
|
178
|
+
'must be false'() {
|
|
179
|
+
$mol_assert_not(0);
|
|
180
|
+
},
|
|
181
|
+
'must be true'() {
|
|
182
|
+
$mol_assert_ok(1);
|
|
183
|
+
},
|
|
184
|
+
'two must be equal'() {
|
|
185
|
+
$mol_assert_equal(2, 2);
|
|
186
|
+
},
|
|
187
|
+
'three must be equal'() {
|
|
188
|
+
$mol_assert_equal(2, 2, 2);
|
|
189
|
+
},
|
|
190
|
+
'two must be unique'() {
|
|
191
|
+
$mol_assert_unique([2], [3]);
|
|
192
|
+
},
|
|
193
|
+
'three must be unique'() {
|
|
194
|
+
$mol_assert_unique([1], [2], [3]);
|
|
195
|
+
},
|
|
196
|
+
'two must be alike'() {
|
|
197
|
+
$mol_assert_like([3], [3]);
|
|
198
|
+
},
|
|
199
|
+
'three must be alike'() {
|
|
200
|
+
$mol_assert_like([3], [3], [3]);
|
|
201
|
+
},
|
|
202
|
+
'two object must be alike'() {
|
|
203
|
+
$mol_assert_like({ a: 1 }, { a: 1 });
|
|
204
|
+
},
|
|
205
|
+
'three object must be alike'() {
|
|
206
|
+
$mol_assert_like({ a: 1 }, { a: 1 }, { a: 1 });
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
})($ || ($ = {}));
|
|
210
|
+
|
|
211
|
+
;
|
|
212
|
+
"use strict";
|
|
213
|
+
var $;
|
|
214
|
+
(function ($) {
|
|
215
|
+
function $mol_dom_serialize(node) {
|
|
216
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
217
|
+
return serializer.serializeToString(node);
|
|
218
|
+
}
|
|
219
|
+
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
240
220
|
})($ || ($ = {}));
|
|
241
221
|
|
|
242
222
|
;
|
|
@@ -346,284 +326,99 @@ var $;
|
|
|
346
326
|
"use strict";
|
|
347
327
|
var $;
|
|
348
328
|
(function ($) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
value: size(),
|
|
380
|
-
writable: true,
|
|
381
|
-
enumerable: false,
|
|
382
|
-
configurable: false,
|
|
383
|
-
};
|
|
384
|
-
const index = Number(field);
|
|
385
|
-
if (index === Math.trunc(index))
|
|
386
|
-
return {
|
|
387
|
-
get: () => this.get(target, field, this),
|
|
388
|
-
enumerable: true,
|
|
389
|
-
configurable: true,
|
|
390
|
-
};
|
|
391
|
-
return Object.getOwnPropertyDescriptor(target, field);
|
|
329
|
+
$mol_test({
|
|
330
|
+
'get'() {
|
|
331
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
332
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
333
|
+
},
|
|
334
|
+
'has'() {
|
|
335
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
336
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
337
|
+
},
|
|
338
|
+
'set'() {
|
|
339
|
+
const target = { foo: 777 };
|
|
340
|
+
const proxy = $mol_delegate({}, () => target);
|
|
341
|
+
proxy.foo = 123;
|
|
342
|
+
$mol_assert_equal(target.foo, 123);
|
|
343
|
+
},
|
|
344
|
+
'getOwnPropertyDescriptor'() {
|
|
345
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
346
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
347
|
+
value: 777,
|
|
348
|
+
writable: true,
|
|
349
|
+
enumerable: true,
|
|
350
|
+
configurable: true,
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
'ownKeys'() {
|
|
354
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
355
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
356
|
+
},
|
|
357
|
+
'getPrototypeOf'() {
|
|
358
|
+
class Foo {
|
|
392
359
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (tail.length === 0)
|
|
399
|
-
return this;
|
|
400
|
-
if (tail.length > 1) {
|
|
401
|
-
let list = this;
|
|
402
|
-
for (let item of tail)
|
|
403
|
-
list = list.concat(item);
|
|
404
|
-
return list;
|
|
360
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
361
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
362
|
+
},
|
|
363
|
+
'setPrototypeOf'() {
|
|
364
|
+
class Foo {
|
|
405
365
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
const val = this[++cursor];
|
|
414
|
-
if (check(val, cursor, this))
|
|
415
|
-
filtered.push(val);
|
|
416
|
-
}
|
|
417
|
-
return filtered[index];
|
|
418
|
-
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
419
|
-
}
|
|
420
|
-
forEach(proceed, context) {
|
|
421
|
-
for (let [key, value] of this.entries())
|
|
422
|
-
proceed.call(context, value, key, this);
|
|
423
|
-
}
|
|
424
|
-
map(proceed, context) {
|
|
425
|
-
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
426
|
-
}
|
|
427
|
-
reduce(merge, result) {
|
|
428
|
-
let index = 0;
|
|
429
|
-
if (arguments.length === 1) {
|
|
430
|
-
result = this[index++];
|
|
431
|
-
}
|
|
432
|
-
for (; index < this.length; ++index) {
|
|
433
|
-
result = merge(result, this[index], index, this);
|
|
434
|
-
}
|
|
435
|
-
return result;
|
|
436
|
-
}
|
|
437
|
-
toReversed() {
|
|
438
|
-
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
439
|
-
}
|
|
440
|
-
slice(from = 0, to = this.length) {
|
|
441
|
-
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
442
|
-
}
|
|
443
|
-
some(check, context) {
|
|
444
|
-
for (let index = 0; index < this.length; ++index) {
|
|
445
|
-
if (check.call(context, this[index], index, this))
|
|
446
|
-
return true;
|
|
366
|
+
const target = {};
|
|
367
|
+
const proxy = $mol_delegate({}, () => target);
|
|
368
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
369
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
370
|
+
},
|
|
371
|
+
'instanceof'() {
|
|
372
|
+
class Foo {
|
|
447
373
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
374
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
375
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
376
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
377
|
+
},
|
|
378
|
+
'autobind'() {
|
|
379
|
+
class Foo {
|
|
454
380
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
sort() {
|
|
461
|
-
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
|
462
|
-
}
|
|
463
|
-
[Symbol.toPrimitive]() {
|
|
464
|
-
return $mol_guid();
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
$.$mol_range2_array = $mol_range2_array;
|
|
381
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
382
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
383
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
384
|
+
},
|
|
385
|
+
});
|
|
468
386
|
})($ || ($ = {}));
|
|
469
387
|
|
|
388
|
+
;
|
|
389
|
+
"use strict";
|
|
390
|
+
|
|
391
|
+
;
|
|
392
|
+
"use strict";
|
|
393
|
+
|
|
394
|
+
;
|
|
395
|
+
"use strict";
|
|
396
|
+
|
|
470
397
|
;
|
|
471
398
|
"use strict";
|
|
472
399
|
var $;
|
|
473
|
-
(function ($) {
|
|
400
|
+
(function ($_1) {
|
|
401
|
+
$mol_test_mocks.push($ => {
|
|
402
|
+
$.$mol_log3_come = () => { };
|
|
403
|
+
$.$mol_log3_done = () => { };
|
|
404
|
+
$.$mol_log3_fail = () => { };
|
|
405
|
+
$.$mol_log3_warn = () => { };
|
|
406
|
+
$.$mol_log3_rise = () => { };
|
|
407
|
+
$.$mol_log3_area = () => () => { };
|
|
408
|
+
});
|
|
409
|
+
})($ || ($ = {}));
|
|
410
|
+
|
|
411
|
+
;
|
|
412
|
+
"use strict";
|
|
413
|
+
var $;
|
|
414
|
+
(function ($_1) {
|
|
474
415
|
$mol_test({
|
|
475
|
-
'
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
$mol_assert_equal(
|
|
479
|
-
$mol_assert_equal(
|
|
480
|
-
$mol_assert_equal(list[-1], undefined);
|
|
481
|
-
$mol_assert_equal(list[0], 0);
|
|
482
|
-
$mol_assert_equal(list[9], 9);
|
|
483
|
-
$mol_assert_equal(list[9.5], undefined);
|
|
484
|
-
$mol_assert_equal(list[10], undefined);
|
|
485
|
-
$mol_assert_equal(calls, 2);
|
|
486
|
-
},
|
|
487
|
-
'infinity list'() {
|
|
488
|
-
let calls = 0;
|
|
489
|
-
const list = $mol_range2(index => (++calls, index));
|
|
490
|
-
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
|
491
|
-
$mol_assert_equal(list[0], 0);
|
|
492
|
-
$mol_assert_equal(list[4], 4);
|
|
493
|
-
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
|
494
|
-
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
|
495
|
-
$mol_assert_equal(calls, 3);
|
|
496
|
-
},
|
|
497
|
-
'stringify'() {
|
|
498
|
-
const list = $mol_range2(i => i, () => 5);
|
|
499
|
-
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
500
|
-
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
|
501
|
-
},
|
|
502
|
-
'for-of'() {
|
|
503
|
-
let log = '';
|
|
504
|
-
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
|
505
|
-
log += i;
|
|
506
|
-
}
|
|
507
|
-
$mol_assert_equal(log, '12345');
|
|
508
|
-
},
|
|
509
|
-
'for-in'() {
|
|
510
|
-
let log = '';
|
|
511
|
-
for (let i in $mol_range2(i => i, () => 5)) {
|
|
512
|
-
log += i;
|
|
513
|
-
}
|
|
514
|
-
$mol_assert_equal(log, '01234');
|
|
515
|
-
},
|
|
516
|
-
'forEach'() {
|
|
517
|
-
let log = '';
|
|
518
|
-
$mol_range2(i => i, () => 5).forEach(i => log += i);
|
|
519
|
-
$mol_assert_equal(log, '01234');
|
|
520
|
-
},
|
|
521
|
-
'reduce'() {
|
|
522
|
-
let calls = 0;
|
|
523
|
-
const list = $mol_range2().slice(1, 6);
|
|
524
|
-
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
|
525
|
-
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
|
526
|
-
},
|
|
527
|
-
'lazy concat'() {
|
|
528
|
-
let calls1 = 0;
|
|
529
|
-
let calls2 = 0;
|
|
530
|
-
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
|
531
|
-
$mol_assert_equal(true, list instanceof Array);
|
|
532
|
-
$mol_assert_equal(list.length, 15);
|
|
533
|
-
$mol_assert_equal(list[0], 0);
|
|
534
|
-
$mol_assert_equal(list[4], 4);
|
|
535
|
-
$mol_assert_equal(list[5], 0);
|
|
536
|
-
$mol_assert_equal(list[9], 4);
|
|
537
|
-
$mol_assert_equal(list[10], 0);
|
|
538
|
-
$mol_assert_equal(list[14], 4);
|
|
539
|
-
$mol_assert_equal(list[15], undefined);
|
|
540
|
-
$mol_assert_equal(calls1, 2);
|
|
541
|
-
$mol_assert_equal(calls2, 2);
|
|
542
|
-
},
|
|
543
|
-
'lazy filter'() {
|
|
544
|
-
let calls = 0;
|
|
545
|
-
const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
|
|
546
|
-
$mol_assert_equal(true, list instanceof Array);
|
|
547
|
-
$mol_assert_equal(list.length, 3);
|
|
548
|
-
$mol_assert_equal(list[0], 1);
|
|
549
|
-
$mol_assert_equal(list[2], 5);
|
|
550
|
-
$mol_assert_equal(list[3], undefined);
|
|
551
|
-
$mol_assert_equal(calls, 8);
|
|
552
|
-
},
|
|
553
|
-
'lazy reverse'() {
|
|
554
|
-
let calls = 0;
|
|
555
|
-
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
|
556
|
-
$mol_assert_equal(true, list instanceof Array);
|
|
557
|
-
$mol_assert_equal(list.length, 3);
|
|
558
|
-
$mol_assert_equal(list[0], 9);
|
|
559
|
-
$mol_assert_equal(list[2], 7);
|
|
560
|
-
$mol_assert_equal(list[3], undefined);
|
|
561
|
-
$mol_assert_equal(calls, 2);
|
|
562
|
-
},
|
|
563
|
-
'lazy map'() {
|
|
564
|
-
let calls1 = 0;
|
|
565
|
-
let calls2 = 0;
|
|
566
|
-
const source = $mol_range2(index => (++calls1, index), () => 5);
|
|
567
|
-
const target = source.map((item, index, self) => {
|
|
568
|
-
++calls2;
|
|
569
|
-
$mol_assert_equal(source, self);
|
|
570
|
-
return index + 10;
|
|
571
|
-
}, () => 5);
|
|
572
|
-
$mol_assert_equal(true, target instanceof Array);
|
|
573
|
-
$mol_assert_equal(target.length, 5);
|
|
574
|
-
$mol_assert_equal(target[0], 10);
|
|
575
|
-
$mol_assert_equal(target[4], 14);
|
|
576
|
-
$mol_assert_equal(target[5], undefined);
|
|
577
|
-
$mol_assert_equal(calls1, 2);
|
|
578
|
-
$mol_assert_equal(calls2, 2);
|
|
579
|
-
},
|
|
580
|
-
'lazy slice'() {
|
|
581
|
-
let calls = 0;
|
|
582
|
-
const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
|
|
583
|
-
$mol_assert_equal(true, list instanceof Array);
|
|
584
|
-
$mol_assert_equal(list.length, 4);
|
|
585
|
-
$mol_assert_equal(list[0], 3);
|
|
586
|
-
$mol_assert_equal(list[3], 6);
|
|
587
|
-
$mol_assert_equal(list[4], undefined);
|
|
588
|
-
$mol_assert_equal(calls, 2);
|
|
589
|
-
},
|
|
590
|
-
'lazy some'() {
|
|
591
|
-
let calls = 0;
|
|
592
|
-
$mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
|
|
593
|
-
$mol_assert_equal(calls, 3);
|
|
594
|
-
$mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
|
|
595
|
-
$mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
|
|
596
|
-
},
|
|
597
|
-
'lazy every'() {
|
|
598
|
-
let calls = 0;
|
|
599
|
-
$mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
|
|
600
|
-
$mol_assert_equal(calls, 3);
|
|
601
|
-
$mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
|
|
602
|
-
$mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
|
|
603
|
-
},
|
|
604
|
-
'lazyfy'() {
|
|
605
|
-
let calls = 0;
|
|
606
|
-
const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
|
|
607
|
-
$mol_assert_equal(true, list instanceof Array);
|
|
608
|
-
$mol_assert_equal(list.length, 4);
|
|
609
|
-
$mol_assert_equal(calls, 0);
|
|
610
|
-
$mol_assert_equal(list[0], 12);
|
|
611
|
-
$mol_assert_equal(list[3], 15);
|
|
612
|
-
$mol_assert_equal(list[4], undefined);
|
|
613
|
-
$mol_assert_equal(calls, 2);
|
|
416
|
+
'FQN of anon function'($) {
|
|
417
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
418
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
419
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
420
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
614
421
|
},
|
|
615
|
-
'prevent modification'() {
|
|
616
|
-
const list = $mol_range2(i => i, () => 5);
|
|
617
|
-
$mol_assert_fail(() => list.push(4), TypeError);
|
|
618
|
-
$mol_assert_fail(() => list.pop(), TypeError);
|
|
619
|
-
$mol_assert_fail(() => list.unshift(4), TypeError);
|
|
620
|
-
$mol_assert_fail(() => list.shift(), TypeError);
|
|
621
|
-
$mol_assert_fail(() => list.splice(1, 2), TypeError);
|
|
622
|
-
$mol_assert_fail(() => list[1] = 2, TypeError);
|
|
623
|
-
$mol_assert_fail(() => list.reverse(), TypeError);
|
|
624
|
-
$mol_assert_fail(() => list.sort(), TypeError);
|
|
625
|
-
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
626
|
-
}
|
|
627
422
|
});
|
|
628
423
|
})($ || ($ = {}));
|
|
629
424
|
|
|
@@ -632,125 +427,74 @@ var $;
|
|
|
632
427
|
var $;
|
|
633
428
|
(function ($) {
|
|
634
429
|
$mol_test({
|
|
635
|
-
'
|
|
636
|
-
$
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
},
|
|
641
|
-
'number'() {
|
|
642
|
-
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
643
|
-
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
644
|
-
$mol_assert_not($mol_compare_deep(1, 2));
|
|
645
|
-
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
646
|
-
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
647
|
-
},
|
|
648
|
-
'POJO'() {
|
|
649
|
-
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
650
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
651
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
652
|
-
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
653
|
-
$mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
654
|
-
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
655
|
-
$mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
|
|
656
|
-
},
|
|
657
|
-
'Array'() {
|
|
658
|
-
$mol_assert_ok($mol_compare_deep([], []));
|
|
659
|
-
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
660
|
-
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
661
|
-
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
662
|
-
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
|
663
|
-
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
|
664
|
-
},
|
|
665
|
-
'Non POJO are different'() {
|
|
666
|
-
class Thing extends Object {
|
|
430
|
+
'init with overload'() {
|
|
431
|
+
class X extends $mol_object {
|
|
432
|
+
foo() {
|
|
433
|
+
return 1;
|
|
434
|
+
}
|
|
667
435
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
'POJO with symbols'() {
|
|
673
|
-
const sym = Symbol();
|
|
674
|
-
$mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
|
|
675
|
-
$mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
|
|
676
|
-
},
|
|
677
|
-
'same POJOs with cyclic reference'() {
|
|
678
|
-
const a = { foo: {} };
|
|
679
|
-
a['self'] = a;
|
|
680
|
-
const b = { foo: {} };
|
|
681
|
-
b['self'] = b;
|
|
682
|
-
$mol_assert_ok($mol_compare_deep(a, b));
|
|
683
|
-
},
|
|
684
|
-
'same POJOs with cyclic reference with cache warmup'() {
|
|
685
|
-
const obj1 = { test: 1, obj3: null };
|
|
686
|
-
const obj1_copy = { test: 1, obj3: null };
|
|
687
|
-
const obj2 = { test: 2, obj1 };
|
|
688
|
-
const obj2_copy = { test: 2, obj1: obj1_copy };
|
|
689
|
-
const obj3 = { test: 3, obj2 };
|
|
690
|
-
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
691
|
-
obj1.obj3 = obj3;
|
|
692
|
-
obj1_copy.obj3 = obj3_copy;
|
|
693
|
-
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
694
|
-
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
695
|
-
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
696
|
-
$mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
|
|
697
|
-
},
|
|
698
|
-
'Date'() {
|
|
699
|
-
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
700
|
-
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
701
|
-
},
|
|
702
|
-
'RegExp'() {
|
|
703
|
-
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
704
|
-
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
705
|
-
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
706
|
-
},
|
|
707
|
-
'Error'() {
|
|
708
|
-
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
709
|
-
const fail = (message) => new Error(message);
|
|
710
|
-
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
711
|
-
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
712
|
-
},
|
|
713
|
-
'Map'() {
|
|
714
|
-
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
715
|
-
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
716
|
-
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
717
|
-
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
718
|
-
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
719
|
-
},
|
|
720
|
-
'Set'() {
|
|
721
|
-
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
722
|
-
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
723
|
-
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
724
|
-
},
|
|
725
|
-
'Uint8Array'() {
|
|
726
|
-
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
727
|
-
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
728
|
-
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
436
|
+
var x = X.make({
|
|
437
|
+
foo: () => 2,
|
|
438
|
+
});
|
|
439
|
+
$mol_assert_equal(x.foo(), 2);
|
|
729
440
|
},
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
441
|
+
});
|
|
442
|
+
})($ || ($ = {}));
|
|
443
|
+
|
|
444
|
+
;
|
|
445
|
+
"use strict";
|
|
446
|
+
var $;
|
|
447
|
+
(function ($_1) {
|
|
448
|
+
$mol_test({
|
|
449
|
+
'Collect deps'() {
|
|
450
|
+
const pub1 = new $mol_wire_pub;
|
|
451
|
+
const pub2 = new $mol_wire_pub;
|
|
452
|
+
const sub = new $mol_wire_pub_sub;
|
|
453
|
+
const bu1 = sub.track_on();
|
|
454
|
+
try {
|
|
455
|
+
pub1.promote();
|
|
456
|
+
pub2.promote();
|
|
457
|
+
pub2.promote();
|
|
458
|
+
}
|
|
459
|
+
finally {
|
|
460
|
+
sub.track_cut();
|
|
461
|
+
sub.track_off(bu1);
|
|
462
|
+
}
|
|
463
|
+
pub1.emit();
|
|
464
|
+
pub2.emit();
|
|
465
|
+
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
|
466
|
+
const bu2 = sub.track_on();
|
|
467
|
+
try {
|
|
468
|
+
pub1.promote();
|
|
469
|
+
pub1.promote();
|
|
470
|
+
pub2.promote();
|
|
471
|
+
}
|
|
472
|
+
finally {
|
|
473
|
+
sub.track_cut();
|
|
474
|
+
sub.track_off(bu2);
|
|
475
|
+
}
|
|
476
|
+
pub1.emit();
|
|
477
|
+
pub2.emit();
|
|
478
|
+
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
|
734
479
|
},
|
|
735
|
-
'
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
480
|
+
'cyclic detection'($) {
|
|
481
|
+
const sub1 = new $mol_wire_pub_sub;
|
|
482
|
+
const sub2 = new $mol_wire_pub_sub;
|
|
483
|
+
const bu1 = sub1.track_on();
|
|
484
|
+
try {
|
|
485
|
+
const bu2 = sub2.track_on();
|
|
486
|
+
try {
|
|
487
|
+
$mol_assert_fail(() => sub1.promote(), 'Circular subscription');
|
|
742
488
|
}
|
|
743
|
-
|
|
744
|
-
|
|
489
|
+
finally {
|
|
490
|
+
sub2.track_cut();
|
|
491
|
+
sub2.track_off(bu2);
|
|
745
492
|
}
|
|
746
493
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
$mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
|
|
752
|
-
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
|
|
753
|
-
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
|
|
494
|
+
finally {
|
|
495
|
+
sub1.track_cut();
|
|
496
|
+
sub1.track_off(bu1);
|
|
497
|
+
}
|
|
754
498
|
},
|
|
755
499
|
});
|
|
756
500
|
})($ || ($ = {}));
|
|
@@ -759,66 +503,47 @@ var $;
|
|
|
759
503
|
"use strict";
|
|
760
504
|
var $;
|
|
761
505
|
(function ($) {
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
$.$mol_assert_ok = $mol_assert_ok;
|
|
768
|
-
function $mol_assert_not(value) {
|
|
769
|
-
if (!value)
|
|
770
|
-
return;
|
|
771
|
-
$mol_fail(new Error(`${value} ≠ false`));
|
|
772
|
-
}
|
|
773
|
-
$.$mol_assert_not = $mol_assert_not;
|
|
774
|
-
function $mol_assert_fail(handler, ErrorRight) {
|
|
775
|
-
const fail = $.$mol_fail;
|
|
776
|
-
try {
|
|
777
|
-
$.$mol_fail = $.$mol_fail_hidden;
|
|
778
|
-
handler();
|
|
779
|
-
}
|
|
780
|
-
catch (error) {
|
|
781
|
-
$.$mol_fail = fail;
|
|
782
|
-
if (typeof ErrorRight === 'string') {
|
|
783
|
-
$mol_assert_equal(error.message ?? error, ErrorRight);
|
|
784
|
-
}
|
|
785
|
-
else {
|
|
786
|
-
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
787
|
-
}
|
|
788
|
-
return error;
|
|
789
|
-
}
|
|
790
|
-
finally {
|
|
791
|
-
$.$mol_fail = fail;
|
|
792
|
-
}
|
|
793
|
-
$mol_fail(new Error('Not failed'));
|
|
794
|
-
}
|
|
795
|
-
$.$mol_assert_fail = $mol_assert_fail;
|
|
796
|
-
function $mol_assert_like(...args) {
|
|
797
|
-
$mol_assert_equal(...args);
|
|
506
|
+
$.$mol_after_mock_queue = [];
|
|
507
|
+
function $mol_after_mock_warp() {
|
|
508
|
+
const queue = $.$mol_after_mock_queue.splice(0);
|
|
509
|
+
for (const task of queue)
|
|
510
|
+
task();
|
|
798
511
|
}
|
|
799
|
-
$.$
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
512
|
+
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
|
513
|
+
class $mol_after_mock_commmon extends $mol_object2 {
|
|
514
|
+
task;
|
|
515
|
+
promise = Promise.resolve();
|
|
516
|
+
cancelled = false;
|
|
517
|
+
id;
|
|
518
|
+
constructor(task) {
|
|
519
|
+
super();
|
|
520
|
+
this.task = task;
|
|
521
|
+
$.$mol_after_mock_queue.push(task);
|
|
522
|
+
}
|
|
523
|
+
destructor() {
|
|
524
|
+
const index = $.$mol_after_mock_queue.indexOf(this.task);
|
|
525
|
+
if (index >= 0)
|
|
526
|
+
$.$mol_after_mock_queue.splice(index, 1);
|
|
809
527
|
}
|
|
810
528
|
}
|
|
811
|
-
$.$
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
continue;
|
|
818
|
-
return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
|
|
529
|
+
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
|
530
|
+
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
|
531
|
+
delay;
|
|
532
|
+
constructor(delay, task) {
|
|
533
|
+
super(task);
|
|
534
|
+
this.delay = delay;
|
|
819
535
|
}
|
|
820
536
|
}
|
|
821
|
-
$.$
|
|
537
|
+
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
|
538
|
+
})($ || ($ = {}));
|
|
539
|
+
|
|
540
|
+
;
|
|
541
|
+
"use strict";
|
|
542
|
+
var $;
|
|
543
|
+
(function ($_1) {
|
|
544
|
+
$mol_test_mocks.push($ => {
|
|
545
|
+
$.$mol_after_tick = $mol_after_mock_commmon;
|
|
546
|
+
});
|
|
822
547
|
})($ || ($ = {}));
|
|
823
548
|
|
|
824
549
|
;
|
|
@@ -826,35 +551,79 @@ var $;
|
|
|
826
551
|
var $;
|
|
827
552
|
(function ($) {
|
|
828
553
|
$mol_test({
|
|
829
|
-
'
|
|
830
|
-
$
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
$mol_assert_equal(2, 2, 2);
|
|
840
|
-
},
|
|
841
|
-
'two must be unique'() {
|
|
842
|
-
$mol_assert_unique([2], [3]);
|
|
843
|
-
},
|
|
844
|
-
'three must be unique'() {
|
|
845
|
-
$mol_assert_unique([1], [2], [3]);
|
|
846
|
-
},
|
|
847
|
-
'two must be alike'() {
|
|
848
|
-
$mol_assert_like([3], [3]);
|
|
554
|
+
'Sync execution'() {
|
|
555
|
+
class Sync extends $mol_object2 {
|
|
556
|
+
static calc(a, b) {
|
|
557
|
+
return a + b;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
__decorate([
|
|
561
|
+
$mol_wire_method
|
|
562
|
+
], Sync, "calc", null);
|
|
563
|
+
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
849
564
|
},
|
|
850
|
-
'
|
|
851
|
-
$
|
|
565
|
+
async 'async <=> sync'() {
|
|
566
|
+
class SyncAsync extends $mol_object2 {
|
|
567
|
+
static async val(a) {
|
|
568
|
+
return a;
|
|
569
|
+
}
|
|
570
|
+
static sum(a, b) {
|
|
571
|
+
const syn = $mol_wire_sync(this);
|
|
572
|
+
return syn.val(a) + syn.val(b);
|
|
573
|
+
}
|
|
574
|
+
static async calc(a, b) {
|
|
575
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
|
852
579
|
},
|
|
853
|
-
'
|
|
854
|
-
|
|
580
|
+
async 'Idempotence control'() {
|
|
581
|
+
class Idempotence extends $mol_object2 {
|
|
582
|
+
static logs_idemp = 0;
|
|
583
|
+
static logs_unidemp = 0;
|
|
584
|
+
static log_idemp() {
|
|
585
|
+
this.logs_idemp += 1;
|
|
586
|
+
}
|
|
587
|
+
static log_unidemp() {
|
|
588
|
+
this.logs_unidemp += 1;
|
|
589
|
+
}
|
|
590
|
+
static async val(a) {
|
|
591
|
+
return a;
|
|
592
|
+
}
|
|
593
|
+
static sum(a, b) {
|
|
594
|
+
this.log_idemp();
|
|
595
|
+
this.log_unidemp();
|
|
596
|
+
const syn = $mol_wire_sync(this);
|
|
597
|
+
return syn.val(a) + syn.val(b);
|
|
598
|
+
}
|
|
599
|
+
static async calc(a, b) {
|
|
600
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
__decorate([
|
|
604
|
+
$mol_wire_method
|
|
605
|
+
], Idempotence, "log_idemp", null);
|
|
606
|
+
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
607
|
+
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
608
|
+
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
855
609
|
},
|
|
856
|
-
'
|
|
857
|
-
|
|
610
|
+
async 'Error handling'() {
|
|
611
|
+
class Handle extends $mol_object2 {
|
|
612
|
+
static async sum(a, b) {
|
|
613
|
+
$mol_fail(new Error('test error ' + (a + b)));
|
|
614
|
+
}
|
|
615
|
+
static check() {
|
|
616
|
+
try {
|
|
617
|
+
return $mol_wire_sync(Handle).sum(1, 2);
|
|
618
|
+
}
|
|
619
|
+
catch (error) {
|
|
620
|
+
if ($mol_promise_like(error))
|
|
621
|
+
$mol_fail_hidden(error);
|
|
622
|
+
$mol_assert_equal(error.message, 'test error 3');
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
await $mol_wire_async(Handle).check();
|
|
858
627
|
},
|
|
859
628
|
});
|
|
860
629
|
})($ || ($ = {}));
|
|
@@ -862,35 +631,129 @@ var $;
|
|
|
862
631
|
;
|
|
863
632
|
"use strict";
|
|
864
633
|
|
|
865
|
-
;
|
|
866
|
-
"use strict";
|
|
867
|
-
|
|
868
|
-
;
|
|
869
|
-
"use strict";
|
|
870
|
-
var $;
|
|
871
|
-
(function ($_1) {
|
|
872
|
-
$mol_test_mocks.push($ => {
|
|
873
|
-
$.$mol_log3_come = () => { };
|
|
874
|
-
$.$mol_log3_done = () => { };
|
|
875
|
-
$.$mol_log3_fail = () => { };
|
|
876
|
-
$.$mol_log3_warn = () => { };
|
|
877
|
-
$.$mol_log3_rise = () => { };
|
|
878
|
-
$.$mol_log3_area = () => () => { };
|
|
879
|
-
});
|
|
880
|
-
})($ || ($ = {}));
|
|
881
|
-
|
|
882
634
|
;
|
|
883
635
|
"use strict";
|
|
884
636
|
var $;
|
|
885
|
-
(function ($
|
|
886
|
-
$
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
637
|
+
(function ($) {
|
|
638
|
+
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
639
|
+
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
640
|
+
if (typeof item !== 'function') {
|
|
641
|
+
item = index => source[index];
|
|
642
|
+
size = () => source.length;
|
|
643
|
+
}
|
|
644
|
+
return new Proxy(source, {
|
|
645
|
+
get(target, field) {
|
|
646
|
+
if (typeof field === 'string') {
|
|
647
|
+
if (field === 'length')
|
|
648
|
+
return size();
|
|
649
|
+
const index = Number(field);
|
|
650
|
+
if (index < 0)
|
|
651
|
+
return undefined;
|
|
652
|
+
if (index >= size())
|
|
653
|
+
return undefined;
|
|
654
|
+
if (index === Math.trunc(index))
|
|
655
|
+
return item(index);
|
|
656
|
+
}
|
|
657
|
+
return $mol_range2_array.prototype[field];
|
|
658
|
+
},
|
|
659
|
+
set(target, field) {
|
|
660
|
+
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
|
661
|
+
},
|
|
662
|
+
ownKeys(target) {
|
|
663
|
+
return [...Array(size())].map((v, i) => String(i)).concat('length');
|
|
664
|
+
},
|
|
665
|
+
getOwnPropertyDescriptor(target, field) {
|
|
666
|
+
if (field === "length")
|
|
667
|
+
return {
|
|
668
|
+
value: size(),
|
|
669
|
+
writable: true,
|
|
670
|
+
enumerable: false,
|
|
671
|
+
configurable: false,
|
|
672
|
+
};
|
|
673
|
+
const index = Number(field);
|
|
674
|
+
if (index === Math.trunc(index))
|
|
675
|
+
return {
|
|
676
|
+
get: () => this.get(target, field, this),
|
|
677
|
+
enumerable: true,
|
|
678
|
+
configurable: true,
|
|
679
|
+
};
|
|
680
|
+
return Object.getOwnPropertyDescriptor(target, field);
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
$.$mol_range2 = $mol_range2;
|
|
685
|
+
class $mol_range2_array extends Array {
|
|
686
|
+
concat(...tail) {
|
|
687
|
+
if (tail.length === 0)
|
|
688
|
+
return this;
|
|
689
|
+
if (tail.length > 1) {
|
|
690
|
+
let list = this;
|
|
691
|
+
for (let item of tail)
|
|
692
|
+
list = list.concat(item);
|
|
693
|
+
return list;
|
|
694
|
+
}
|
|
695
|
+
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
696
|
+
}
|
|
697
|
+
filter(check, context) {
|
|
698
|
+
const filtered = [];
|
|
699
|
+
let cursor = -1;
|
|
700
|
+
return $mol_range2(index => {
|
|
701
|
+
while (cursor < this.length && index >= filtered.length - 1) {
|
|
702
|
+
const val = this[++cursor];
|
|
703
|
+
if (check(val, cursor, this))
|
|
704
|
+
filtered.push(val);
|
|
705
|
+
}
|
|
706
|
+
return filtered[index];
|
|
707
|
+
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
708
|
+
}
|
|
709
|
+
forEach(proceed, context) {
|
|
710
|
+
for (let [key, value] of this.entries())
|
|
711
|
+
proceed.call(context, value, key, this);
|
|
712
|
+
}
|
|
713
|
+
map(proceed, context) {
|
|
714
|
+
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
715
|
+
}
|
|
716
|
+
reduce(merge, result) {
|
|
717
|
+
let index = 0;
|
|
718
|
+
if (arguments.length === 1) {
|
|
719
|
+
result = this[index++];
|
|
720
|
+
}
|
|
721
|
+
for (; index < this.length; ++index) {
|
|
722
|
+
result = merge(result, this[index], index, this);
|
|
723
|
+
}
|
|
724
|
+
return result;
|
|
725
|
+
}
|
|
726
|
+
toReversed() {
|
|
727
|
+
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
728
|
+
}
|
|
729
|
+
slice(from = 0, to = this.length) {
|
|
730
|
+
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
731
|
+
}
|
|
732
|
+
some(check, context) {
|
|
733
|
+
for (let index = 0; index < this.length; ++index) {
|
|
734
|
+
if (check.call(context, this[index], index, this))
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
return false;
|
|
738
|
+
}
|
|
739
|
+
every(check, context) {
|
|
740
|
+
for (let index = 0; index < this.length; ++index) {
|
|
741
|
+
if (!check.call(context, this[index], index, this))
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
reverse() {
|
|
747
|
+
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
|
748
|
+
}
|
|
749
|
+
sort() {
|
|
750
|
+
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
|
751
|
+
}
|
|
752
|
+
[Symbol.toPrimitive]() {
|
|
753
|
+
return $mol_guid();
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
$.$mol_range2_array = $mol_range2_array;
|
|
894
757
|
})($ || ($ = {}));
|
|
895
758
|
|
|
896
759
|
;
|
|
@@ -898,188 +761,158 @@ var $;
|
|
|
898
761
|
var $;
|
|
899
762
|
(function ($) {
|
|
900
763
|
$mol_test({
|
|
901
|
-
'
|
|
902
|
-
|
|
903
|
-
$
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
$mol_assert_equal(
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
proxy.foo = 123;
|
|
913
|
-
$mol_assert_equal(target.foo, 123);
|
|
764
|
+
'lazy calls'() {
|
|
765
|
+
let calls = 0;
|
|
766
|
+
const list = $mol_range2(index => (++calls, index), () => 10);
|
|
767
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
768
|
+
$mol_assert_equal(list.length, 10);
|
|
769
|
+
$mol_assert_equal(list[-1], undefined);
|
|
770
|
+
$mol_assert_equal(list[0], 0);
|
|
771
|
+
$mol_assert_equal(list[9], 9);
|
|
772
|
+
$mol_assert_equal(list[9.5], undefined);
|
|
773
|
+
$mol_assert_equal(list[10], undefined);
|
|
774
|
+
$mol_assert_equal(calls, 2);
|
|
914
775
|
},
|
|
915
|
-
'
|
|
916
|
-
|
|
917
|
-
$
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
776
|
+
'infinity list'() {
|
|
777
|
+
let calls = 0;
|
|
778
|
+
const list = $mol_range2(index => (++calls, index));
|
|
779
|
+
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
|
780
|
+
$mol_assert_equal(list[0], 0);
|
|
781
|
+
$mol_assert_equal(list[4], 4);
|
|
782
|
+
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
|
783
|
+
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
|
784
|
+
$mol_assert_equal(calls, 3);
|
|
923
785
|
},
|
|
924
|
-
'
|
|
925
|
-
const
|
|
926
|
-
$
|
|
786
|
+
'stringify'() {
|
|
787
|
+
const list = $mol_range2(i => i, () => 5);
|
|
788
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
789
|
+
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
|
927
790
|
},
|
|
928
|
-
'
|
|
929
|
-
|
|
791
|
+
'for-of'() {
|
|
792
|
+
let log = '';
|
|
793
|
+
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
|
794
|
+
log += i;
|
|
930
795
|
}
|
|
931
|
-
|
|
932
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
796
|
+
$mol_assert_equal(log, '12345');
|
|
933
797
|
},
|
|
934
|
-
'
|
|
935
|
-
|
|
798
|
+
'for-in'() {
|
|
799
|
+
let log = '';
|
|
800
|
+
for (let i in $mol_range2(i => i, () => 5)) {
|
|
801
|
+
log += i;
|
|
936
802
|
}
|
|
937
|
-
|
|
938
|
-
const proxy = $mol_delegate({}, () => target);
|
|
939
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
940
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
803
|
+
$mol_assert_equal(log, '01234');
|
|
941
804
|
},
|
|
942
|
-
'
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
947
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
805
|
+
'forEach'() {
|
|
806
|
+
let log = '';
|
|
807
|
+
$mol_range2(i => i, () => 5).forEach(i => log += i);
|
|
808
|
+
$mol_assert_equal(log, '01234');
|
|
948
809
|
},
|
|
949
|
-
'
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
$
|
|
954
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
810
|
+
'reduce'() {
|
|
811
|
+
let calls = 0;
|
|
812
|
+
const list = $mol_range2().slice(1, 6);
|
|
813
|
+
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
|
814
|
+
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
|
955
815
|
},
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
;
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
;
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
(
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
var x = X.make({
|
|
974
|
-
foo: () => 2,
|
|
975
|
-
});
|
|
976
|
-
$mol_assert_equal(x.foo(), 2);
|
|
816
|
+
'lazy concat'() {
|
|
817
|
+
let calls1 = 0;
|
|
818
|
+
let calls2 = 0;
|
|
819
|
+
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
|
820
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
821
|
+
$mol_assert_equal(list.length, 15);
|
|
822
|
+
$mol_assert_equal(list[0], 0);
|
|
823
|
+
$mol_assert_equal(list[4], 4);
|
|
824
|
+
$mol_assert_equal(list[5], 0);
|
|
825
|
+
$mol_assert_equal(list[9], 4);
|
|
826
|
+
$mol_assert_equal(list[10], 0);
|
|
827
|
+
$mol_assert_equal(list[14], 4);
|
|
828
|
+
$mol_assert_equal(list[15], undefined);
|
|
829
|
+
$mol_assert_equal(calls1, 2);
|
|
830
|
+
$mol_assert_equal(calls2, 2);
|
|
977
831
|
},
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
;
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
(
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
const pub1 = new $mol_wire_pub;
|
|
988
|
-
const pub2 = new $mol_wire_pub;
|
|
989
|
-
const sub = new $mol_wire_pub_sub;
|
|
990
|
-
const bu1 = sub.track_on();
|
|
991
|
-
try {
|
|
992
|
-
pub1.promote();
|
|
993
|
-
pub2.promote();
|
|
994
|
-
pub2.promote();
|
|
995
|
-
}
|
|
996
|
-
finally {
|
|
997
|
-
sub.track_cut();
|
|
998
|
-
sub.track_off(bu1);
|
|
999
|
-
}
|
|
1000
|
-
pub1.emit();
|
|
1001
|
-
pub2.emit();
|
|
1002
|
-
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
|
1003
|
-
const bu2 = sub.track_on();
|
|
1004
|
-
try {
|
|
1005
|
-
pub1.promote();
|
|
1006
|
-
pub1.promote();
|
|
1007
|
-
pub2.promote();
|
|
1008
|
-
}
|
|
1009
|
-
finally {
|
|
1010
|
-
sub.track_cut();
|
|
1011
|
-
sub.track_off(bu2);
|
|
1012
|
-
}
|
|
1013
|
-
pub1.emit();
|
|
1014
|
-
pub2.emit();
|
|
1015
|
-
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
|
832
|
+
'lazy filter'() {
|
|
833
|
+
let calls = 0;
|
|
834
|
+
const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
|
|
835
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
836
|
+
$mol_assert_equal(list.length, 3);
|
|
837
|
+
$mol_assert_equal(list[0], 1);
|
|
838
|
+
$mol_assert_equal(list[2], 5);
|
|
839
|
+
$mol_assert_equal(list[3], undefined);
|
|
840
|
+
$mol_assert_equal(calls, 8);
|
|
1016
841
|
},
|
|
1017
|
-
'
|
|
1018
|
-
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
842
|
+
'lazy reverse'() {
|
|
843
|
+
let calls = 0;
|
|
844
|
+
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
|
845
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
846
|
+
$mol_assert_equal(list.length, 3);
|
|
847
|
+
$mol_assert_equal(list[0], 9);
|
|
848
|
+
$mol_assert_equal(list[2], 7);
|
|
849
|
+
$mol_assert_equal(list[3], undefined);
|
|
850
|
+
$mol_assert_equal(calls, 2);
|
|
851
|
+
},
|
|
852
|
+
'lazy map'() {
|
|
853
|
+
let calls1 = 0;
|
|
854
|
+
let calls2 = 0;
|
|
855
|
+
const source = $mol_range2(index => (++calls1, index), () => 5);
|
|
856
|
+
const target = source.map((item, index, self) => {
|
|
857
|
+
++calls2;
|
|
858
|
+
$mol_assert_equal(source, self);
|
|
859
|
+
return index + 10;
|
|
860
|
+
}, () => 5);
|
|
861
|
+
$mol_assert_equal(true, target instanceof Array);
|
|
862
|
+
$mol_assert_equal(target.length, 5);
|
|
863
|
+
$mol_assert_equal(target[0], 10);
|
|
864
|
+
$mol_assert_equal(target[4], 14);
|
|
865
|
+
$mol_assert_equal(target[5], undefined);
|
|
866
|
+
$mol_assert_equal(calls1, 2);
|
|
867
|
+
$mol_assert_equal(calls2, 2);
|
|
868
|
+
},
|
|
869
|
+
'lazy slice'() {
|
|
870
|
+
let calls = 0;
|
|
871
|
+
const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
|
|
872
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
873
|
+
$mol_assert_equal(list.length, 4);
|
|
874
|
+
$mol_assert_equal(list[0], 3);
|
|
875
|
+
$mol_assert_equal(list[3], 6);
|
|
876
|
+
$mol_assert_equal(list[4], undefined);
|
|
877
|
+
$mol_assert_equal(calls, 2);
|
|
878
|
+
},
|
|
879
|
+
'lazy some'() {
|
|
880
|
+
let calls = 0;
|
|
881
|
+
$mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
|
|
882
|
+
$mol_assert_equal(calls, 3);
|
|
883
|
+
$mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
|
|
884
|
+
$mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
|
|
1035
885
|
},
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
;
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
}
|
|
1066
|
-
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
|
1067
|
-
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
|
1068
|
-
delay;
|
|
1069
|
-
constructor(delay, task) {
|
|
1070
|
-
super(task);
|
|
1071
|
-
this.delay = delay;
|
|
886
|
+
'lazy every'() {
|
|
887
|
+
let calls = 0;
|
|
888
|
+
$mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
|
|
889
|
+
$mol_assert_equal(calls, 3);
|
|
890
|
+
$mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
|
|
891
|
+
$mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
|
|
892
|
+
},
|
|
893
|
+
'lazyfy'() {
|
|
894
|
+
let calls = 0;
|
|
895
|
+
const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
|
|
896
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
897
|
+
$mol_assert_equal(list.length, 4);
|
|
898
|
+
$mol_assert_equal(calls, 0);
|
|
899
|
+
$mol_assert_equal(list[0], 12);
|
|
900
|
+
$mol_assert_equal(list[3], 15);
|
|
901
|
+
$mol_assert_equal(list[4], undefined);
|
|
902
|
+
$mol_assert_equal(calls, 2);
|
|
903
|
+
},
|
|
904
|
+
'prevent modification'() {
|
|
905
|
+
const list = $mol_range2(i => i, () => 5);
|
|
906
|
+
$mol_assert_fail(() => list.push(4), TypeError);
|
|
907
|
+
$mol_assert_fail(() => list.pop(), TypeError);
|
|
908
|
+
$mol_assert_fail(() => list.unshift(4), TypeError);
|
|
909
|
+
$mol_assert_fail(() => list.shift(), TypeError);
|
|
910
|
+
$mol_assert_fail(() => list.splice(1, 2), TypeError);
|
|
911
|
+
$mol_assert_fail(() => list[1] = 2, TypeError);
|
|
912
|
+
$mol_assert_fail(() => list.reverse(), TypeError);
|
|
913
|
+
$mol_assert_fail(() => list.sort(), TypeError);
|
|
914
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
1072
915
|
}
|
|
1073
|
-
}
|
|
1074
|
-
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
|
1075
|
-
})($ || ($ = {}));
|
|
1076
|
-
|
|
1077
|
-
;
|
|
1078
|
-
"use strict";
|
|
1079
|
-
var $;
|
|
1080
|
-
(function ($_1) {
|
|
1081
|
-
$mol_test_mocks.push($ => {
|
|
1082
|
-
$.$mol_after_tick = $mol_after_mock_commmon;
|
|
1083
916
|
});
|
|
1084
917
|
})($ || ($ = {}));
|
|
1085
918
|
|
|
@@ -1088,86 +921,129 @@ var $;
|
|
|
1088
921
|
var $;
|
|
1089
922
|
(function ($) {
|
|
1090
923
|
$mol_test({
|
|
1091
|
-
'
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
}
|
|
1097
|
-
__decorate([
|
|
1098
|
-
$mol_wire_method
|
|
1099
|
-
], Sync, "calc", null);
|
|
1100
|
-
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
924
|
+
'nulls & undefineds'() {
|
|
925
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
926
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
927
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
928
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
1101
929
|
},
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
const syn = $mol_wire_sync(this);
|
|
1109
|
-
return syn.val(a) + syn.val(b);
|
|
1110
|
-
}
|
|
1111
|
-
static async calc(a, b) {
|
|
1112
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
|
930
|
+
'number'() {
|
|
931
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
932
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
933
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
934
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
935
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
1116
936
|
},
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
static async calc(a, b) {
|
|
1137
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
1138
|
-
}
|
|
937
|
+
'POJO'() {
|
|
938
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
939
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
940
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
941
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
942
|
+
$mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
943
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
944
|
+
$mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
|
|
945
|
+
},
|
|
946
|
+
'Array'() {
|
|
947
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
948
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
949
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
950
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
951
|
+
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
|
952
|
+
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
|
953
|
+
},
|
|
954
|
+
'Non POJO are different'() {
|
|
955
|
+
class Thing extends Object {
|
|
1139
956
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
1144
|
-
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
1145
|
-
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
957
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
958
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
959
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
1146
960
|
},
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
961
|
+
'POJO with symbols'() {
|
|
962
|
+
const sym = Symbol();
|
|
963
|
+
$mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
|
|
964
|
+
$mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
|
|
965
|
+
},
|
|
966
|
+
'same POJOs with cyclic reference'() {
|
|
967
|
+
const a = { foo: {} };
|
|
968
|
+
a['self'] = a;
|
|
969
|
+
const b = { foo: {} };
|
|
970
|
+
b['self'] = b;
|
|
971
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
972
|
+
},
|
|
973
|
+
'same POJOs with cyclic reference with cache warmup'() {
|
|
974
|
+
const obj1 = { test: 1, obj3: null };
|
|
975
|
+
const obj1_copy = { test: 1, obj3: null };
|
|
976
|
+
const obj2 = { test: 2, obj1 };
|
|
977
|
+
const obj2_copy = { test: 2, obj1: obj1_copy };
|
|
978
|
+
const obj3 = { test: 3, obj2 };
|
|
979
|
+
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
980
|
+
obj1.obj3 = obj3;
|
|
981
|
+
obj1_copy.obj3 = obj3_copy;
|
|
982
|
+
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
983
|
+
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
984
|
+
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
985
|
+
$mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
|
|
986
|
+
},
|
|
987
|
+
'Date'() {
|
|
988
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
989
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
990
|
+
},
|
|
991
|
+
'RegExp'() {
|
|
992
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
993
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
994
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
995
|
+
},
|
|
996
|
+
'Error'() {
|
|
997
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
998
|
+
const fail = (message) => new Error(message);
|
|
999
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
1000
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
1001
|
+
},
|
|
1002
|
+
'Map'() {
|
|
1003
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
1004
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
1005
|
+
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
1006
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
1007
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
1008
|
+
},
|
|
1009
|
+
'Set'() {
|
|
1010
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
1011
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
1012
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
1013
|
+
},
|
|
1014
|
+
'Uint8Array'() {
|
|
1015
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
1016
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
1017
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
1018
|
+
},
|
|
1019
|
+
'DataView'() {
|
|
1020
|
+
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
|
|
1021
|
+
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
|
|
1022
|
+
$mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
|
|
1023
|
+
},
|
|
1024
|
+
'Serializale'() {
|
|
1025
|
+
class User {
|
|
1026
|
+
name;
|
|
1027
|
+
rand;
|
|
1028
|
+
constructor(name, rand = Math.random()) {
|
|
1029
|
+
this.name = name;
|
|
1030
|
+
this.rand = rand;
|
|
1151
1031
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
return $mol_wire_sync(Handle).sum(1, 2);
|
|
1155
|
-
}
|
|
1156
|
-
catch (error) {
|
|
1157
|
-
if ($mol_promise_like(error))
|
|
1158
|
-
$mol_fail_hidden(error);
|
|
1159
|
-
$mol_assert_equal(error.message, 'test error 3');
|
|
1160
|
-
}
|
|
1032
|
+
[Symbol.toPrimitive](mode) {
|
|
1033
|
+
return this.name;
|
|
1161
1034
|
}
|
|
1162
1035
|
}
|
|
1163
|
-
|
|
1036
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
1037
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
1038
|
+
},
|
|
1039
|
+
'Iterable'() {
|
|
1040
|
+
$mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
|
|
1041
|
+
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
|
|
1042
|
+
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
|
|
1164
1043
|
},
|
|
1165
1044
|
});
|
|
1166
1045
|
})($ || ($ = {}));
|
|
1167
1046
|
|
|
1168
|
-
;
|
|
1169
|
-
"use strict";
|
|
1170
|
-
|
|
1171
1047
|
;
|
|
1172
1048
|
"use strict";
|
|
1173
1049
|
var $;
|