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