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