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