mol_key 0.0.393 → 0.0.395
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.deps.json +1 -1
- package/node.js +13 -13
- package/node.js.map +1 -1
- package/node.mjs +13 -13
- package/node.mjs.map +1 -1
- package/node.test.js +653 -653
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.js +13 -13
- package/web.js.map +1 -1
- package/web.mjs +13 -13
- package/web.mjs.map +1 -1
- package/web.test.js +423 -423
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
Error.stackTraceLimit = 50;
|
|
4
|
+
var $;
|
|
5
|
+
(function ($) {
|
|
6
|
+
})($ || ($ = {}));
|
|
7
|
+
module.exports = $;
|
|
8
|
+
//mam.ts
|
|
9
|
+
;
|
|
2
10
|
"use strict"
|
|
3
11
|
|
|
4
12
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -11,14 +19,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
11
19
|
var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
|
|
12
20
|
$.$$ = $
|
|
13
21
|
|
|
14
|
-
;
|
|
15
|
-
"use strict";
|
|
16
|
-
Error.stackTraceLimit = 50;
|
|
17
|
-
var $;
|
|
18
|
-
(function ($) {
|
|
19
|
-
})($ || ($ = {}));
|
|
20
|
-
module.exports = $;
|
|
21
|
-
//mam.ts
|
|
22
22
|
;
|
|
23
23
|
"use strict";
|
|
24
24
|
var $;
|
|
@@ -74,6 +74,63 @@ var $;
|
|
|
74
74
|
;
|
|
75
75
|
"use strict";
|
|
76
76
|
var $;
|
|
77
|
+
(function ($) {
|
|
78
|
+
})($ || ($ = {}));
|
|
79
|
+
//mol/dom/context/context.ts
|
|
80
|
+
;
|
|
81
|
+
"use strict";
|
|
82
|
+
//node/node.ts
|
|
83
|
+
;
|
|
84
|
+
"use strict";
|
|
85
|
+
var $node = new Proxy({ require }, {
|
|
86
|
+
get(target, name, wrapper) {
|
|
87
|
+
if (target[name])
|
|
88
|
+
return target[name];
|
|
89
|
+
const mod = target.require('module');
|
|
90
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
|
91
|
+
return target.require(name);
|
|
92
|
+
if (name[0] === '.')
|
|
93
|
+
return target.require(name);
|
|
94
|
+
const path = target.require('path');
|
|
95
|
+
const fs = target.require('fs');
|
|
96
|
+
let dir = path.resolve('.');
|
|
97
|
+
const suffix = `./node_modules/${name}`;
|
|
98
|
+
const $$ = $;
|
|
99
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
100
|
+
const parent = path.resolve(dir, '..');
|
|
101
|
+
if (parent === dir) {
|
|
102
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
103
|
+
try {
|
|
104
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
105
|
+
}
|
|
106
|
+
catch { }
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
dir = parent;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return target.require(name);
|
|
114
|
+
},
|
|
115
|
+
set(target, name, value) {
|
|
116
|
+
target[name] = value;
|
|
117
|
+
return true;
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
require = (req => Object.assign(function require(name) {
|
|
121
|
+
return $node[name];
|
|
122
|
+
}, req))(require);
|
|
123
|
+
//node/node.node.ts
|
|
124
|
+
;
|
|
125
|
+
"use strict";
|
|
126
|
+
var $;
|
|
127
|
+
(function ($) {
|
|
128
|
+
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
129
|
+
})($ || ($ = {}));
|
|
130
|
+
//mol/dom/context/context.node.ts
|
|
131
|
+
;
|
|
132
|
+
"use strict";
|
|
133
|
+
var $;
|
|
77
134
|
(function ($) {
|
|
78
135
|
function $mol_fail(error) {
|
|
79
136
|
throw error;
|
|
@@ -85,22 +142,82 @@ var $;
|
|
|
85
142
|
"use strict";
|
|
86
143
|
var $;
|
|
87
144
|
(function ($) {
|
|
88
|
-
function $
|
|
89
|
-
|
|
145
|
+
function $mol_dom_render_children(el, childNodes) {
|
|
146
|
+
const node_set = new Set(childNodes);
|
|
147
|
+
let nextNode = el.firstChild;
|
|
148
|
+
for (let view of childNodes) {
|
|
149
|
+
if (view == null)
|
|
150
|
+
continue;
|
|
151
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
152
|
+
while (true) {
|
|
153
|
+
if (!nextNode) {
|
|
154
|
+
el.appendChild(view);
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (nextNode == view) {
|
|
158
|
+
nextNode = nextNode.nextSibling;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
if (node_set.has(nextNode)) {
|
|
163
|
+
el.insertBefore(view, nextNode);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const nn = nextNode.nextSibling;
|
|
168
|
+
el.removeChild(nextNode);
|
|
169
|
+
nextNode = nn;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
|
176
|
+
const str = String(view);
|
|
177
|
+
if (nextNode.nodeValue !== str)
|
|
178
|
+
nextNode.nodeValue = str;
|
|
179
|
+
nextNode = nextNode.nextSibling;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
183
|
+
el.insertBefore(textNode, nextNode);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
while (nextNode) {
|
|
188
|
+
const currNode = nextNode;
|
|
189
|
+
nextNode = currNode.nextSibling;
|
|
190
|
+
el.removeChild(currNode);
|
|
191
|
+
}
|
|
90
192
|
}
|
|
91
|
-
$.$
|
|
193
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
92
194
|
})($ || ($ = {}));
|
|
93
|
-
//mol/
|
|
195
|
+
//mol/dom/render/children/children.ts
|
|
196
|
+
;
|
|
197
|
+
"use strict";
|
|
198
|
+
//mol/type/error/error.ts
|
|
199
|
+
;
|
|
200
|
+
"use strict";
|
|
201
|
+
//mol/type/assert/assert.ts
|
|
202
|
+
;
|
|
203
|
+
"use strict";
|
|
204
|
+
//mol/type/assert/assert.test.ts
|
|
205
|
+
;
|
|
206
|
+
"use strict";
|
|
207
|
+
//mol/type/partial/deep/deep.ts
|
|
208
|
+
;
|
|
209
|
+
"use strict";
|
|
210
|
+
//mol/type/partial/deep/deep.test.ts
|
|
94
211
|
;
|
|
95
212
|
"use strict";
|
|
96
213
|
var $;
|
|
97
214
|
(function ($) {
|
|
98
|
-
function $
|
|
99
|
-
|
|
215
|
+
function $mol_fail_hidden(error) {
|
|
216
|
+
throw error;
|
|
100
217
|
}
|
|
101
|
-
$.$
|
|
218
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
102
219
|
})($ || ($ = {}));
|
|
103
|
-
//mol/
|
|
220
|
+
//mol/fail/hidden/hidden.ts
|
|
104
221
|
;
|
|
105
222
|
"use strict";
|
|
106
223
|
var $;
|
|
@@ -192,256 +309,23 @@ var $;
|
|
|
192
309
|
"use strict";
|
|
193
310
|
var $;
|
|
194
311
|
(function ($) {
|
|
312
|
+
function $mol_test_complete() {
|
|
313
|
+
process.exit(0);
|
|
314
|
+
}
|
|
315
|
+
$.$mol_test_complete = $mol_test_complete;
|
|
195
316
|
})($ || ($ = {}));
|
|
196
|
-
//mol/
|
|
197
|
-
;
|
|
198
|
-
"use strict";
|
|
199
|
-
//node/node.ts
|
|
200
|
-
;
|
|
201
|
-
"use strict";
|
|
202
|
-
var $node = new Proxy({ require }, {
|
|
203
|
-
get(target, name, wrapper) {
|
|
204
|
-
if (target[name])
|
|
205
|
-
return target[name];
|
|
206
|
-
const mod = target.require('module');
|
|
207
|
-
if (mod.builtinModules.indexOf(name) >= 0)
|
|
208
|
-
return target.require(name);
|
|
209
|
-
if (name[0] === '.')
|
|
210
|
-
return target.require(name);
|
|
211
|
-
const path = target.require('path');
|
|
212
|
-
const fs = target.require('fs');
|
|
213
|
-
let dir = path.resolve('.');
|
|
214
|
-
const suffix = `./node_modules/${name}`;
|
|
215
|
-
const $$ = $;
|
|
216
|
-
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
217
|
-
const parent = path.resolve(dir, '..');
|
|
218
|
-
if (parent === dir) {
|
|
219
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
220
|
-
try {
|
|
221
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
222
|
-
}
|
|
223
|
-
catch { }
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
dir = parent;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return target.require(name);
|
|
231
|
-
},
|
|
232
|
-
set(target, name, value) {
|
|
233
|
-
target[name] = value;
|
|
234
|
-
return true;
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
require = (req => Object.assign(function require(name) {
|
|
238
|
-
return $node[name];
|
|
239
|
-
}, req))(require);
|
|
240
|
-
//node/node.node.ts
|
|
317
|
+
//mol/test/test.node.test.ts
|
|
241
318
|
;
|
|
242
319
|
"use strict";
|
|
243
320
|
var $;
|
|
244
321
|
(function ($) {
|
|
245
|
-
function $
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
const deep = stack.length;
|
|
249
|
-
let logged = false;
|
|
250
|
-
stack.push(() => {
|
|
251
|
-
logged = true;
|
|
252
|
-
self.$mol_log3_area.call(self, event);
|
|
253
|
-
});
|
|
254
|
-
return () => {
|
|
255
|
-
if (logged)
|
|
256
|
-
self.console.groupEnd();
|
|
257
|
-
if (stack.length > deep)
|
|
258
|
-
stack.length = deep;
|
|
259
|
-
};
|
|
322
|
+
function $mol_dom_serialize(node) {
|
|
323
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
324
|
+
return serializer.serializeToString(node);
|
|
260
325
|
}
|
|
261
|
-
$.$
|
|
262
|
-
$.$mol_log3_stack = [];
|
|
326
|
+
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
263
327
|
})($ || ($ = {}));
|
|
264
|
-
//mol/
|
|
265
|
-
;
|
|
266
|
-
"use strict";
|
|
267
|
-
var $;
|
|
268
|
-
(function ($) {
|
|
269
|
-
class $mol_term_color {
|
|
270
|
-
static reset = this.ansi(0, 0);
|
|
271
|
-
static bold = this.ansi(1, 22);
|
|
272
|
-
static italic = this.ansi(3, 23);
|
|
273
|
-
static underline = this.ansi(4, 24);
|
|
274
|
-
static inverse = this.ansi(7, 27);
|
|
275
|
-
static hidden = this.ansi(8, 28);
|
|
276
|
-
static strike = this.ansi(9, 29);
|
|
277
|
-
static gray = this.ansi(90, 39);
|
|
278
|
-
static red = this.ansi(91, 39);
|
|
279
|
-
static green = this.ansi(92, 39);
|
|
280
|
-
static yellow = this.ansi(93, 39);
|
|
281
|
-
static blue = this.ansi(94, 39);
|
|
282
|
-
static magenta = this.ansi(95, 39);
|
|
283
|
-
static cyan = this.ansi(96, 39);
|
|
284
|
-
static Gray = (str) => this.inverse(this.gray(str));
|
|
285
|
-
static Red = (str) => this.inverse(this.red(str));
|
|
286
|
-
static Green = (str) => this.inverse(this.green(str));
|
|
287
|
-
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
288
|
-
static Blue = (str) => this.inverse(this.blue(str));
|
|
289
|
-
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
290
|
-
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
291
|
-
static ansi(open, close) {
|
|
292
|
-
if (typeof process === 'undefined')
|
|
293
|
-
return String;
|
|
294
|
-
if (!process.stdout.isTTY)
|
|
295
|
-
return String;
|
|
296
|
-
const prefix = `\x1b[${open}m`;
|
|
297
|
-
const postfix = `\x1b[${close}m`;
|
|
298
|
-
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
299
|
-
return function colorer(str) {
|
|
300
|
-
str = String(str);
|
|
301
|
-
if (str === '')
|
|
302
|
-
return str;
|
|
303
|
-
const suffix = str.replace(suffix_regexp, prefix);
|
|
304
|
-
return prefix + suffix + postfix;
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
$.$mol_term_color = $mol_term_color;
|
|
309
|
-
})($ || ($ = {}));
|
|
310
|
-
//mol/term/color/color.ts
|
|
311
|
-
;
|
|
312
|
-
"use strict";
|
|
313
|
-
var $;
|
|
314
|
-
(function ($) {
|
|
315
|
-
function $mol_log3_node_make(level, output, type, color) {
|
|
316
|
-
return function $mol_log3_logger(event) {
|
|
317
|
-
if (!event.time)
|
|
318
|
-
event = { time: new Date().toISOString(), ...event };
|
|
319
|
-
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
|
320
|
-
let str = color(tree.toString());
|
|
321
|
-
this.console[level](str);
|
|
322
|
-
const self = this;
|
|
323
|
-
return () => self.console.groupEnd();
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
327
|
-
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
328
|
-
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
329
|
-
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
330
|
-
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
331
|
-
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
332
|
-
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
333
|
-
})($ || ($ = {}));
|
|
334
|
-
//mol/log3/log3.node.ts
|
|
335
|
-
;
|
|
336
|
-
"use strict";
|
|
337
|
-
var $;
|
|
338
|
-
(function ($_1) {
|
|
339
|
-
$mol_test_mocks.push($ => {
|
|
340
|
-
$.$mol_log3_come = () => { };
|
|
341
|
-
$.$mol_log3_done = () => { };
|
|
342
|
-
$.$mol_log3_fail = () => { };
|
|
343
|
-
$.$mol_log3_warn = () => { };
|
|
344
|
-
$.$mol_log3_rise = () => { };
|
|
345
|
-
$.$mol_log3_area = () => () => { };
|
|
346
|
-
});
|
|
347
|
-
})($ || ($ = {}));
|
|
348
|
-
//mol/log3/log3.test.ts
|
|
349
|
-
;
|
|
350
|
-
"use strict";
|
|
351
|
-
var $;
|
|
352
|
-
(function ($) {
|
|
353
|
-
function $mol_env() {
|
|
354
|
-
return {};
|
|
355
|
-
}
|
|
356
|
-
$.$mol_env = $mol_env;
|
|
357
|
-
})($ || ($ = {}));
|
|
358
|
-
//mol/env/env.ts
|
|
359
|
-
;
|
|
360
|
-
"use strict";
|
|
361
|
-
var $;
|
|
362
|
-
(function ($) {
|
|
363
|
-
$.$mol_env = function $mol_env() {
|
|
364
|
-
return this.process.env;
|
|
365
|
-
};
|
|
366
|
-
})($ || ($ = {}));
|
|
367
|
-
//mol/env/env.node.ts
|
|
368
|
-
;
|
|
369
|
-
"use strict";
|
|
370
|
-
var $;
|
|
371
|
-
(function ($) {
|
|
372
|
-
function $mol_exec(dir, command, ...args) {
|
|
373
|
-
let [app, ...args0] = command.split(' ');
|
|
374
|
-
args = [...args0, ...args];
|
|
375
|
-
this.$mol_log3_come({
|
|
376
|
-
place: '$mol_exec',
|
|
377
|
-
dir: $node.path.relative('', dir),
|
|
378
|
-
message: 'Run',
|
|
379
|
-
command: `${app} ${args.join(' ')}`,
|
|
380
|
-
});
|
|
381
|
-
var res = $node['child_process'].spawnSync(app, args, {
|
|
382
|
-
cwd: $node.path.resolve(dir),
|
|
383
|
-
shell: true,
|
|
384
|
-
env: this.$mol_env(),
|
|
385
|
-
});
|
|
386
|
-
if (res.status || res.error)
|
|
387
|
-
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
388
|
-
if (!res.stdout)
|
|
389
|
-
res.stdout = Buffer.from([]);
|
|
390
|
-
return res;
|
|
391
|
-
}
|
|
392
|
-
$.$mol_exec = $mol_exec;
|
|
393
|
-
})($ || ($ = {}));
|
|
394
|
-
//mol/exec/exec.node.ts
|
|
395
|
-
;
|
|
396
|
-
"use strict";
|
|
397
|
-
var $;
|
|
398
|
-
(function ($) {
|
|
399
|
-
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
400
|
-
})($ || ($ = {}));
|
|
401
|
-
//mol/dom/context/context.node.ts
|
|
402
|
-
;
|
|
403
|
-
"use strict";
|
|
404
|
-
var $;
|
|
405
|
-
(function ($) {
|
|
406
|
-
function $mol_dom_serialize(node) {
|
|
407
|
-
const serializer = new $mol_dom_context.XMLSerializer;
|
|
408
|
-
return serializer.serializeToString(node);
|
|
409
|
-
}
|
|
410
|
-
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
411
|
-
})($ || ($ = {}));
|
|
412
|
-
//mol/dom/serialize/serialize.ts
|
|
413
|
-
;
|
|
414
|
-
"use strict";
|
|
415
|
-
var $;
|
|
416
|
-
(function ($) {
|
|
417
|
-
$mol_test({
|
|
418
|
-
'must be false'() {
|
|
419
|
-
$mol_assert_not(0);
|
|
420
|
-
},
|
|
421
|
-
'must be true'() {
|
|
422
|
-
$mol_assert_ok(1);
|
|
423
|
-
},
|
|
424
|
-
'two must be equal'() {
|
|
425
|
-
$mol_assert_equal(2, 2);
|
|
426
|
-
},
|
|
427
|
-
'three must be equal'() {
|
|
428
|
-
$mol_assert_equal(2, 2, 2);
|
|
429
|
-
},
|
|
430
|
-
'two must be unique'() {
|
|
431
|
-
$mol_assert_unique([3], [3]);
|
|
432
|
-
},
|
|
433
|
-
'three must be unique'() {
|
|
434
|
-
$mol_assert_unique([3], [3], [3]);
|
|
435
|
-
},
|
|
436
|
-
'two must be alike'() {
|
|
437
|
-
$mol_assert_like([3], [3]);
|
|
438
|
-
},
|
|
439
|
-
'three must be alike'() {
|
|
440
|
-
$mol_assert_like([3], [3], [3]);
|
|
441
|
-
},
|
|
442
|
-
});
|
|
443
|
-
})($ || ($ = {}));
|
|
444
|
-
//mol/assert/assert.test.ts
|
|
328
|
+
//mol/dom/serialize/serialize.ts
|
|
445
329
|
;
|
|
446
330
|
"use strict";
|
|
447
331
|
var $;
|
|
@@ -539,236 +423,173 @@ var $;
|
|
|
539
423
|
;
|
|
540
424
|
"use strict";
|
|
541
425
|
var $;
|
|
542
|
-
(function ($
|
|
426
|
+
(function ($) {
|
|
543
427
|
$mol_test({
|
|
544
|
-
'
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
$
|
|
428
|
+
'must be false'() {
|
|
429
|
+
$mol_assert_not(0);
|
|
430
|
+
},
|
|
431
|
+
'must be true'() {
|
|
432
|
+
$mol_assert_ok(1);
|
|
433
|
+
},
|
|
434
|
+
'two must be equal'() {
|
|
435
|
+
$mol_assert_equal(2, 2);
|
|
436
|
+
},
|
|
437
|
+
'three must be equal'() {
|
|
438
|
+
$mol_assert_equal(2, 2, 2);
|
|
439
|
+
},
|
|
440
|
+
'two must be unique'() {
|
|
441
|
+
$mol_assert_unique([3], [3]);
|
|
442
|
+
},
|
|
443
|
+
'three must be unique'() {
|
|
444
|
+
$mol_assert_unique([3], [3], [3]);
|
|
445
|
+
},
|
|
446
|
+
'two must be alike'() {
|
|
447
|
+
$mol_assert_like([3], [3]);
|
|
448
|
+
},
|
|
449
|
+
'three must be alike'() {
|
|
450
|
+
$mol_assert_like([3], [3], [3]);
|
|
549
451
|
},
|
|
550
452
|
});
|
|
551
453
|
})($ || ($ = {}));
|
|
552
|
-
//mol/
|
|
454
|
+
//mol/assert/assert.test.ts
|
|
553
455
|
;
|
|
554
456
|
"use strict";
|
|
555
457
|
var $;
|
|
556
458
|
(function ($) {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
catch { }
|
|
573
|
-
}
|
|
574
|
-
named.add(func);
|
|
575
|
-
return name;
|
|
576
|
-
}
|
|
577
|
-
$.$mol_func_name = $mol_func_name;
|
|
578
|
-
function $mol_func_name_from(target, source) {
|
|
579
|
-
Object.defineProperty(target, 'name', { value: source.name });
|
|
580
|
-
return target;
|
|
459
|
+
function $mol_log3_area_lazy(event) {
|
|
460
|
+
const self = this;
|
|
461
|
+
const stack = self.$mol_log3_stack;
|
|
462
|
+
const deep = stack.length;
|
|
463
|
+
let logged = false;
|
|
464
|
+
stack.push(() => {
|
|
465
|
+
logged = true;
|
|
466
|
+
self.$mol_log3_area.call(self, event);
|
|
467
|
+
});
|
|
468
|
+
return () => {
|
|
469
|
+
if (logged)
|
|
470
|
+
self.console.groupEnd();
|
|
471
|
+
if (stack.length > deep)
|
|
472
|
+
stack.length = deep;
|
|
473
|
+
};
|
|
581
474
|
}
|
|
582
|
-
$.$
|
|
475
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
476
|
+
$.$mol_log3_stack = [];
|
|
583
477
|
})($ || ($ = {}));
|
|
584
|
-
//mol/
|
|
478
|
+
//mol/log3/log3.ts
|
|
585
479
|
;
|
|
586
480
|
"use strict";
|
|
587
481
|
var $;
|
|
588
482
|
(function ($) {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
627
|
-
el.insertBefore(textNode, nextNode);
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
while (nextNode) {
|
|
632
|
-
const currNode = nextNode;
|
|
633
|
-
nextNode = currNode.nextSibling;
|
|
634
|
-
el.removeChild(currNode);
|
|
483
|
+
class $mol_term_color {
|
|
484
|
+
static reset = this.ansi(0, 0);
|
|
485
|
+
static bold = this.ansi(1, 22);
|
|
486
|
+
static italic = this.ansi(3, 23);
|
|
487
|
+
static underline = this.ansi(4, 24);
|
|
488
|
+
static inverse = this.ansi(7, 27);
|
|
489
|
+
static hidden = this.ansi(8, 28);
|
|
490
|
+
static strike = this.ansi(9, 29);
|
|
491
|
+
static gray = this.ansi(90, 39);
|
|
492
|
+
static red = this.ansi(91, 39);
|
|
493
|
+
static green = this.ansi(92, 39);
|
|
494
|
+
static yellow = this.ansi(93, 39);
|
|
495
|
+
static blue = this.ansi(94, 39);
|
|
496
|
+
static magenta = this.ansi(95, 39);
|
|
497
|
+
static cyan = this.ansi(96, 39);
|
|
498
|
+
static Gray = (str) => this.inverse(this.gray(str));
|
|
499
|
+
static Red = (str) => this.inverse(this.red(str));
|
|
500
|
+
static Green = (str) => this.inverse(this.green(str));
|
|
501
|
+
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
502
|
+
static Blue = (str) => this.inverse(this.blue(str));
|
|
503
|
+
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
504
|
+
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
505
|
+
static ansi(open, close) {
|
|
506
|
+
if (typeof process === 'undefined')
|
|
507
|
+
return String;
|
|
508
|
+
if (!process.stdout.isTTY)
|
|
509
|
+
return String;
|
|
510
|
+
const prefix = `\x1b[${open}m`;
|
|
511
|
+
const postfix = `\x1b[${close}m`;
|
|
512
|
+
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
513
|
+
return function colorer(str) {
|
|
514
|
+
str = String(str);
|
|
515
|
+
if (str === '')
|
|
516
|
+
return str;
|
|
517
|
+
const suffix = str.replace(suffix_regexp, prefix);
|
|
518
|
+
return prefix + suffix + postfix;
|
|
519
|
+
};
|
|
635
520
|
}
|
|
636
521
|
}
|
|
637
|
-
$.$
|
|
522
|
+
$.$mol_term_color = $mol_term_color;
|
|
638
523
|
})($ || ($ = {}));
|
|
639
|
-
//mol/
|
|
640
|
-
;
|
|
641
|
-
"use strict";
|
|
642
|
-
//mol/type/error/error.ts
|
|
643
|
-
;
|
|
644
|
-
"use strict";
|
|
645
|
-
//mol/type/assert/assert.test.ts
|
|
646
|
-
;
|
|
647
|
-
"use strict";
|
|
648
|
-
//mol/type/assert/assert.ts
|
|
649
|
-
;
|
|
650
|
-
"use strict";
|
|
651
|
-
//mol/type/equals/equals.test.ts
|
|
652
|
-
;
|
|
653
|
-
"use strict";
|
|
654
|
-
//mol/type/equals/equals.ts
|
|
524
|
+
//mol/term/color/color.ts
|
|
655
525
|
;
|
|
656
526
|
"use strict";
|
|
657
|
-
|
|
527
|
+
var $;
|
|
528
|
+
(function ($) {
|
|
529
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
530
|
+
return function $mol_log3_logger(event) {
|
|
531
|
+
if (!event.time)
|
|
532
|
+
event = { time: new Date().toISOString(), ...event };
|
|
533
|
+
const tree = this.$mol_tree.fromJSON(event).clone({ type });
|
|
534
|
+
let str = color(tree.toString());
|
|
535
|
+
this.console[level](str);
|
|
536
|
+
const self = this;
|
|
537
|
+
return () => self.console.groupEnd();
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
541
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
542
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
543
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
544
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
545
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
546
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
547
|
+
})($ || ($ = {}));
|
|
548
|
+
//mol/log3/log3.node.ts
|
|
658
549
|
;
|
|
659
550
|
"use strict";
|
|
660
|
-
|
|
551
|
+
var $;
|
|
552
|
+
(function ($_1) {
|
|
553
|
+
$mol_test_mocks.push($ => {
|
|
554
|
+
$.$mol_log3_come = () => { };
|
|
555
|
+
$.$mol_log3_done = () => { };
|
|
556
|
+
$.$mol_log3_fail = () => { };
|
|
557
|
+
$.$mol_log3_warn = () => { };
|
|
558
|
+
$.$mol_log3_rise = () => { };
|
|
559
|
+
$.$mol_log3_area = () => () => { };
|
|
560
|
+
});
|
|
561
|
+
})($ || ($ = {}));
|
|
562
|
+
//mol/log3/log3.test.ts
|
|
661
563
|
;
|
|
662
564
|
"use strict";
|
|
663
565
|
var $;
|
|
664
566
|
(function ($) {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
return Object.setPrototypeOf(overrides, this || $);
|
|
567
|
+
function $mol_env() {
|
|
568
|
+
return {};
|
|
668
569
|
}
|
|
669
|
-
$.$
|
|
570
|
+
$.$mol_env = $mol_env;
|
|
670
571
|
})($ || ($ = {}));
|
|
671
|
-
//mol/
|
|
572
|
+
//mol/env/env.ts
|
|
672
573
|
;
|
|
673
574
|
"use strict";
|
|
674
575
|
var $;
|
|
675
576
|
(function ($) {
|
|
676
|
-
$
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
$mol_assert_equal(proxy.foo, 777);
|
|
680
|
-
},
|
|
681
|
-
'has'() {
|
|
682
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
683
|
-
$mol_assert_equal('foo' in proxy, true);
|
|
684
|
-
},
|
|
685
|
-
'set'() {
|
|
686
|
-
const target = { foo: 777 };
|
|
687
|
-
const proxy = $mol_delegate({}, () => target);
|
|
688
|
-
proxy.foo = 123;
|
|
689
|
-
$mol_assert_equal(target.foo, 123);
|
|
690
|
-
},
|
|
691
|
-
'getOwnPropertyDescriptor'() {
|
|
692
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
693
|
-
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
694
|
-
value: 777,
|
|
695
|
-
writable: true,
|
|
696
|
-
enumerable: true,
|
|
697
|
-
configurable: true,
|
|
698
|
-
});
|
|
699
|
-
},
|
|
700
|
-
'ownKeys'() {
|
|
701
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
702
|
-
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
703
|
-
},
|
|
704
|
-
'getPrototypeOf'() {
|
|
705
|
-
class Foo {
|
|
706
|
-
}
|
|
707
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
708
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
709
|
-
},
|
|
710
|
-
'setPrototypeOf'() {
|
|
711
|
-
class Foo {
|
|
712
|
-
}
|
|
713
|
-
const target = {};
|
|
714
|
-
const proxy = $mol_delegate({}, () => target);
|
|
715
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
716
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
717
|
-
},
|
|
718
|
-
'instanceof'() {
|
|
719
|
-
class Foo {
|
|
720
|
-
}
|
|
721
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
722
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
723
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
724
|
-
},
|
|
725
|
-
'autobind'() {
|
|
726
|
-
class Foo {
|
|
727
|
-
}
|
|
728
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
729
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
730
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
731
|
-
},
|
|
732
|
-
});
|
|
577
|
+
$.$mol_env = function $mol_env() {
|
|
578
|
+
return this.process.env;
|
|
579
|
+
};
|
|
733
580
|
})($ || ($ = {}));
|
|
734
|
-
//mol/
|
|
581
|
+
//mol/env/env.node.ts
|
|
735
582
|
;
|
|
736
583
|
"use strict";
|
|
737
584
|
var $;
|
|
738
585
|
(function ($) {
|
|
739
|
-
|
|
740
|
-
function $
|
|
741
|
-
|
|
742
|
-
get: (_, field) => {
|
|
743
|
-
const obj = target();
|
|
744
|
-
let val = Reflect.get(obj, field);
|
|
745
|
-
if (typeof val === 'function') {
|
|
746
|
-
val = val.bind(obj);
|
|
747
|
-
}
|
|
748
|
-
return val;
|
|
749
|
-
},
|
|
750
|
-
has: (_, field) => Reflect.has(target(), field),
|
|
751
|
-
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
752
|
-
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
753
|
-
ownKeys: () => Reflect.ownKeys(target()),
|
|
754
|
-
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
755
|
-
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
756
|
-
isExtensible: () => Reflect.isExtensible(target()),
|
|
757
|
-
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
758
|
-
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
759
|
-
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
760
|
-
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
761
|
-
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
762
|
-
});
|
|
763
|
-
instances.add(proxy);
|
|
764
|
-
return proxy;
|
|
586
|
+
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
587
|
+
function $mol_ambient(overrides) {
|
|
588
|
+
return Object.setPrototypeOf(overrides, this || $);
|
|
765
589
|
}
|
|
766
|
-
$.$
|
|
767
|
-
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
768
|
-
value: (obj) => instances.has(obj),
|
|
769
|
-
});
|
|
590
|
+
$.$mol_ambient = $mol_ambient;
|
|
770
591
|
})($ || ($ = {}));
|
|
771
|
-
//mol/
|
|
592
|
+
//mol/ambient/ambient.ts
|
|
772
593
|
;
|
|
773
594
|
"use strict";
|
|
774
595
|
var $;
|
|
@@ -827,12 +648,18 @@ var $;
|
|
|
827
648
|
//mol/owning/owning.ts
|
|
828
649
|
;
|
|
829
650
|
"use strict";
|
|
830
|
-
//mol/type/
|
|
651
|
+
//mol/type/equals/equals.ts
|
|
652
|
+
;
|
|
653
|
+
"use strict";
|
|
654
|
+
//mol/type/equals/equals.test.ts
|
|
831
655
|
;
|
|
832
656
|
"use strict";
|
|
833
657
|
//mol/type/writable/writable.ts
|
|
834
658
|
;
|
|
835
659
|
"use strict";
|
|
660
|
+
//mol/type/writable/writable.test.ts
|
|
661
|
+
;
|
|
662
|
+
"use strict";
|
|
836
663
|
var $;
|
|
837
664
|
(function ($) {
|
|
838
665
|
class $mol_object2 {
|
|
@@ -877,63 +704,103 @@ var $;
|
|
|
877
704
|
;
|
|
878
705
|
"use strict";
|
|
879
706
|
var $;
|
|
880
|
-
(function ($
|
|
707
|
+
(function ($) {
|
|
708
|
+
const instances = new WeakSet();
|
|
709
|
+
function $mol_delegate(proto, target) {
|
|
710
|
+
const proxy = new Proxy(proto, {
|
|
711
|
+
get: (_, field) => {
|
|
712
|
+
const obj = target();
|
|
713
|
+
let val = Reflect.get(obj, field);
|
|
714
|
+
if (typeof val === 'function') {
|
|
715
|
+
val = val.bind(obj);
|
|
716
|
+
}
|
|
717
|
+
return val;
|
|
718
|
+
},
|
|
719
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
720
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
721
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
722
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
723
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
724
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
725
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
726
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
727
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
728
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
729
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
730
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
731
|
+
});
|
|
732
|
+
instances.add(proxy);
|
|
733
|
+
return proxy;
|
|
734
|
+
}
|
|
735
|
+
$.$mol_delegate = $mol_delegate;
|
|
736
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
737
|
+
value: (obj) => instances.has(obj),
|
|
738
|
+
});
|
|
739
|
+
})($ || ($ = {}));
|
|
740
|
+
//mol/delegate/delegate.ts
|
|
741
|
+
;
|
|
742
|
+
"use strict";
|
|
743
|
+
var $;
|
|
744
|
+
(function ($) {
|
|
881
745
|
$mol_test({
|
|
882
|
-
'
|
|
883
|
-
$
|
|
884
|
-
$mol_assert_equal(
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
$
|
|
888
|
-
$mol_assert_equal(
|
|
889
|
-
|
|
890
|
-
|
|
746
|
+
'get'() {
|
|
747
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
748
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
749
|
+
},
|
|
750
|
+
'has'() {
|
|
751
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
752
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
753
|
+
},
|
|
754
|
+
'set'() {
|
|
755
|
+
const target = { foo: 777 };
|
|
756
|
+
const proxy = $mol_delegate({}, () => target);
|
|
757
|
+
proxy.foo = 123;
|
|
758
|
+
$mol_assert_equal(target.foo, 123);
|
|
759
|
+
},
|
|
760
|
+
'getOwnPropertyDescriptor'() {
|
|
761
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
762
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
763
|
+
value: 777,
|
|
764
|
+
writable: true,
|
|
765
|
+
enumerable: true,
|
|
766
|
+
configurable: true,
|
|
767
|
+
});
|
|
891
768
|
},
|
|
892
|
-
'
|
|
893
|
-
$
|
|
894
|
-
$
|
|
895
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
896
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
897
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
898
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
769
|
+
'ownKeys'() {
|
|
770
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
771
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
899
772
|
},
|
|
900
|
-
'
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
$
|
|
904
|
-
$mol_assert_equal(
|
|
905
|
-
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
773
|
+
'getPrototypeOf'() {
|
|
774
|
+
class Foo {
|
|
775
|
+
}
|
|
776
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
777
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
906
778
|
},
|
|
907
|
-
'
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
$
|
|
912
|
-
|
|
779
|
+
'setPrototypeOf'() {
|
|
780
|
+
class Foo {
|
|
781
|
+
}
|
|
782
|
+
const target = {};
|
|
783
|
+
const proxy = $mol_delegate({}, () => target);
|
|
784
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
785
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
913
786
|
},
|
|
914
|
-
'
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
$
|
|
787
|
+
'instanceof'() {
|
|
788
|
+
class Foo {
|
|
789
|
+
}
|
|
790
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
791
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
792
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
920
793
|
},
|
|
921
|
-
'
|
|
922
|
-
|
|
923
|
-
class Tree extends $mol_tree {
|
|
924
|
-
static $ = $.$mol_ambient({
|
|
925
|
-
$mol_fail: error => errors.push(error.message)
|
|
926
|
-
});
|
|
794
|
+
'autobind'() {
|
|
795
|
+
class Foo {
|
|
927
796
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
`, 'test');
|
|
932
|
-
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
797
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
798
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
799
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
933
800
|
},
|
|
934
801
|
});
|
|
935
802
|
})($ || ($ = {}));
|
|
936
|
-
//mol/
|
|
803
|
+
//mol/delegate/delegate.test.ts
|
|
937
804
|
;
|
|
938
805
|
"use strict";
|
|
939
806
|
var $;
|
|
@@ -1267,93 +1134,90 @@ var $;
|
|
|
1267
1134
|
;
|
|
1268
1135
|
"use strict";
|
|
1269
1136
|
var $;
|
|
1270
|
-
(function ($) {
|
|
1137
|
+
(function ($_1) {
|
|
1271
1138
|
$mol_test({
|
|
1272
|
-
'
|
|
1273
|
-
$mol_assert_equal(
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
$mol_assert_equal(
|
|
1278
|
-
$mol_assert_equal(
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
1282
|
-
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
1283
|
-
},
|
|
1284
|
-
'Define styles'() {
|
|
1285
|
-
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
1286
|
-
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
1287
|
-
},
|
|
1288
|
-
'Define dataset'() {
|
|
1289
|
-
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
1290
|
-
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
1291
|
-
},
|
|
1292
|
-
'Define attributes'() {
|
|
1293
|
-
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
1294
|
-
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
1295
|
-
},
|
|
1296
|
-
'Define child nodes'() {
|
|
1297
|
-
const dom = $mol_jsx("div", null,
|
|
1298
|
-
"hello",
|
|
1299
|
-
$mol_jsx("strong", null, "world"),
|
|
1300
|
-
"!");
|
|
1301
|
-
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
1139
|
+
'tree parsing'() {
|
|
1140
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1141
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1142
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1143
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1144
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1145
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1146
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1147
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1302
1148
|
},
|
|
1303
|
-
'
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
$mol_assert_equal(
|
|
1149
|
+
'inserting'() {
|
|
1150
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1151
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1152
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1153
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1154
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1155
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1309
1156
|
},
|
|
1310
|
-
'
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
};
|
|
1316
|
-
const Bar = (props, icon) => {
|
|
1317
|
-
return $mol_jsx("span", null,
|
|
1318
|
-
icon,
|
|
1319
|
-
$mol_jsx("i", { id: "label" }));
|
|
1320
|
-
};
|
|
1321
|
-
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
1322
|
-
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
|
1157
|
+
'fromJSON'() {
|
|
1158
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1159
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1160
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1161
|
+
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
1162
|
+
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
1323
1163
|
},
|
|
1324
|
-
'
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
};
|
|
1330
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
1164
|
+
'toJSON'() {
|
|
1165
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1166
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1167
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1168
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
1169
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
1331
1170
|
},
|
|
1332
|
-
'
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
};
|
|
1337
|
-
|
|
1338
|
-
return $mol_jsx("span", null, props.icon());
|
|
1339
|
-
};
|
|
1340
|
-
const dom = $mol_jsx(Foo, { id: "app" });
|
|
1341
|
-
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
|
1171
|
+
'hack'() {
|
|
1172
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1173
|
+
'': (tree, context) => [tree.hack(context)],
|
|
1174
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1175
|
+
});
|
|
1176
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1342
1177
|
},
|
|
1343
|
-
'
|
|
1344
|
-
const
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
$
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1178
|
+
'errors handling'($) {
|
|
1179
|
+
const errors = [];
|
|
1180
|
+
class Tree extends $mol_tree {
|
|
1181
|
+
static $ = $.$mol_ambient({
|
|
1182
|
+
$mol_fail: error => errors.push(error.message)
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
Tree.fromString(`
|
|
1186
|
+
\t \tfoo
|
|
1187
|
+
bar \\data
|
|
1188
|
+
`, 'test');
|
|
1189
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1353
1190
|
},
|
|
1354
1191
|
});
|
|
1355
1192
|
})($ || ($ = {}));
|
|
1356
|
-
//mol/
|
|
1193
|
+
//mol/tree/tree.test.ts
|
|
1194
|
+
;
|
|
1195
|
+
"use strict";
|
|
1196
|
+
var $;
|
|
1197
|
+
(function ($) {
|
|
1198
|
+
function $mol_exec(dir, command, ...args) {
|
|
1199
|
+
let [app, ...args0] = command.split(' ');
|
|
1200
|
+
args = [...args0, ...args];
|
|
1201
|
+
this.$mol_log3_come({
|
|
1202
|
+
place: '$mol_exec',
|
|
1203
|
+
dir: $node.path.relative('', dir),
|
|
1204
|
+
message: 'Run',
|
|
1205
|
+
command: `${app} ${args.join(' ')}`,
|
|
1206
|
+
});
|
|
1207
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
|
1208
|
+
cwd: $node.path.resolve(dir),
|
|
1209
|
+
shell: true,
|
|
1210
|
+
env: this.$mol_env(),
|
|
1211
|
+
});
|
|
1212
|
+
if (res.status || res.error)
|
|
1213
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
1214
|
+
if (!res.stdout)
|
|
1215
|
+
res.stdout = Buffer.from([]);
|
|
1216
|
+
return res;
|
|
1217
|
+
}
|
|
1218
|
+
$.$mol_exec = $mol_exec;
|
|
1219
|
+
})($ || ($ = {}));
|
|
1220
|
+
//mol/exec/exec.node.ts
|
|
1357
1221
|
;
|
|
1358
1222
|
"use strict";
|
|
1359
1223
|
var $;
|
|
@@ -1480,97 +1344,137 @@ var $;
|
|
|
1480
1344
|
var $;
|
|
1481
1345
|
(function ($) {
|
|
1482
1346
|
$mol_test({
|
|
1483
|
-
'
|
|
1484
|
-
$
|
|
1485
|
-
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
1486
|
-
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
1487
|
-
$mol_assert_not($mol_compare_deep({}, null));
|
|
1488
|
-
},
|
|
1489
|
-
'number'() {
|
|
1490
|
-
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
1491
|
-
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
1492
|
-
$mol_assert_not($mol_compare_deep(1, 2));
|
|
1493
|
-
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
1494
|
-
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
1347
|
+
'Make empty div'() {
|
|
1348
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
1495
1349
|
},
|
|
1496
|
-
'
|
|
1497
|
-
$
|
|
1498
|
-
$
|
|
1499
|
-
$
|
|
1500
|
-
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
1501
|
-
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
1502
|
-
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
1350
|
+
'Define native field'() {
|
|
1351
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
1352
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
1353
|
+
$mol_assert_equal(dom.value, '123');
|
|
1503
1354
|
},
|
|
1504
|
-
'
|
|
1505
|
-
$
|
|
1506
|
-
$
|
|
1507
|
-
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
1508
|
-
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1355
|
+
'Define classes'() {
|
|
1356
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
1357
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
1509
1358
|
},
|
|
1510
|
-
'
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
1514
|
-
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
1515
|
-
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
1359
|
+
'Define styles'() {
|
|
1360
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
1361
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
1516
1362
|
},
|
|
1517
|
-
'
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1520
|
-
const b = { foo: {} };
|
|
1521
|
-
b['self'] = b;
|
|
1522
|
-
$mol_assert_ok($mol_compare_deep(a, b));
|
|
1363
|
+
'Define dataset'() {
|
|
1364
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
1365
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
1523
1366
|
},
|
|
1524
|
-
'
|
|
1525
|
-
$
|
|
1526
|
-
$
|
|
1367
|
+
'Define attributes'() {
|
|
1368
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
1369
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
1527
1370
|
},
|
|
1528
|
-
'
|
|
1529
|
-
$
|
|
1530
|
-
|
|
1531
|
-
|
|
1371
|
+
'Define child nodes'() {
|
|
1372
|
+
const dom = $mol_jsx("div", null,
|
|
1373
|
+
"hello",
|
|
1374
|
+
$mol_jsx("strong", null, "world"),
|
|
1375
|
+
"!");
|
|
1376
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
1532
1377
|
},
|
|
1533
|
-
'
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
$
|
|
1378
|
+
'Function as component'() {
|
|
1379
|
+
const Button = (props, target) => {
|
|
1380
|
+
return $mol_jsx("button", { title: props.hint }, target());
|
|
1381
|
+
};
|
|
1382
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
1383
|
+
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
|
1538
1384
|
},
|
|
1539
|
-
'
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1385
|
+
'Nested guid generation'() {
|
|
1386
|
+
const Foo = () => {
|
|
1387
|
+
return $mol_jsx("div", null,
|
|
1388
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
1389
|
+
$mol_jsx("img", { id: "icon" })));
|
|
1390
|
+
};
|
|
1391
|
+
const Bar = (props, icon) => {
|
|
1392
|
+
return $mol_jsx("span", null,
|
|
1393
|
+
icon,
|
|
1394
|
+
$mol_jsx("i", { id: "label" }));
|
|
1395
|
+
};
|
|
1396
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
1397
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
|
1545
1398
|
},
|
|
1546
|
-
'
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1399
|
+
'Fail on non unique ids'() {
|
|
1400
|
+
const App = () => {
|
|
1401
|
+
return $mol_jsx("div", null,
|
|
1402
|
+
$mol_jsx("span", { id: "bar" }),
|
|
1403
|
+
$mol_jsx("span", { id: "bar" }));
|
|
1404
|
+
};
|
|
1405
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
1550
1406
|
},
|
|
1551
|
-
'
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1407
|
+
'Owner based guid generationn'() {
|
|
1408
|
+
const Foo = () => {
|
|
1409
|
+
return $mol_jsx("div", null,
|
|
1410
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
1411
|
+
};
|
|
1412
|
+
const Bar = (props) => {
|
|
1413
|
+
return $mol_jsx("span", null, props.icon());
|
|
1414
|
+
};
|
|
1415
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
1416
|
+
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
|
1555
1417
|
},
|
|
1556
|
-
'
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1418
|
+
'Fail on same ids from different caller'() {
|
|
1419
|
+
const Foo = () => {
|
|
1420
|
+
return $mol_jsx("div", null,
|
|
1421
|
+
$mol_jsx("img", { id: "icon" }),
|
|
1422
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
1423
|
+
};
|
|
1424
|
+
const Bar = (props) => {
|
|
1425
|
+
return $mol_jsx("span", null, props.icon());
|
|
1426
|
+
};
|
|
1427
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
1428
|
+
},
|
|
1429
|
+
});
|
|
1430
|
+
})($ || ($ = {}));
|
|
1431
|
+
//mol/jsx/jsx.test.tsx
|
|
1432
|
+
;
|
|
1433
|
+
"use strict";
|
|
1434
|
+
var $;
|
|
1435
|
+
(function ($) {
|
|
1436
|
+
const named = new WeakSet();
|
|
1437
|
+
function $mol_func_name(func) {
|
|
1438
|
+
let name = func.name;
|
|
1439
|
+
if (name?.length > 1)
|
|
1440
|
+
return name;
|
|
1441
|
+
if (named.has(func))
|
|
1442
|
+
return name;
|
|
1443
|
+
for (let key in this) {
|
|
1444
|
+
try {
|
|
1445
|
+
if (this[key] !== func)
|
|
1446
|
+
continue;
|
|
1447
|
+
name = key;
|
|
1448
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
1449
|
+
break;
|
|
1567
1450
|
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1451
|
+
catch { }
|
|
1452
|
+
}
|
|
1453
|
+
named.add(func);
|
|
1454
|
+
return name;
|
|
1455
|
+
}
|
|
1456
|
+
$.$mol_func_name = $mol_func_name;
|
|
1457
|
+
function $mol_func_name_from(target, source) {
|
|
1458
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
1459
|
+
return target;
|
|
1460
|
+
}
|
|
1461
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
1462
|
+
})($ || ($ = {}));
|
|
1463
|
+
//mol/func/name/name.ts
|
|
1464
|
+
;
|
|
1465
|
+
"use strict";
|
|
1466
|
+
var $;
|
|
1467
|
+
(function ($_1) {
|
|
1468
|
+
$mol_test({
|
|
1469
|
+
'FQN of anon function'($) {
|
|
1470
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
1471
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
1472
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
1473
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
1570
1474
|
},
|
|
1571
1475
|
});
|
|
1572
1476
|
})($ || ($ = {}));
|
|
1573
|
-
//mol/
|
|
1477
|
+
//mol/func/name/name.test.ts
|
|
1574
1478
|
;
|
|
1575
1479
|
"use strict";
|
|
1576
1480
|
var $;
|
|
@@ -1699,6 +1603,102 @@ var $;
|
|
|
1699
1603
|
;
|
|
1700
1604
|
"use strict";
|
|
1701
1605
|
var $;
|
|
1606
|
+
(function ($) {
|
|
1607
|
+
$mol_test({
|
|
1608
|
+
'nulls & undefineds'() {
|
|
1609
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
1610
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
1611
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
1612
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
1613
|
+
},
|
|
1614
|
+
'number'() {
|
|
1615
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
1616
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
1617
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
1618
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
1619
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
1620
|
+
},
|
|
1621
|
+
'POJO'() {
|
|
1622
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
1623
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
1624
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
1625
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
1626
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
1627
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
1628
|
+
},
|
|
1629
|
+
'Array'() {
|
|
1630
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
1631
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
1632
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
1633
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1634
|
+
},
|
|
1635
|
+
'Non POJO are different'() {
|
|
1636
|
+
class Thing extends Object {
|
|
1637
|
+
}
|
|
1638
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
1639
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
1640
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
1641
|
+
},
|
|
1642
|
+
'same POJOs with cyclic reference'() {
|
|
1643
|
+
const a = { foo: {} };
|
|
1644
|
+
a['self'] = a;
|
|
1645
|
+
const b = { foo: {} };
|
|
1646
|
+
b['self'] = b;
|
|
1647
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
1648
|
+
},
|
|
1649
|
+
'Date'() {
|
|
1650
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
1651
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
1652
|
+
},
|
|
1653
|
+
'RegExp'() {
|
|
1654
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
1655
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
1656
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
1657
|
+
},
|
|
1658
|
+
'Error'() {
|
|
1659
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
1660
|
+
const fail = (message) => new Error(message);
|
|
1661
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
1662
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
1663
|
+
},
|
|
1664
|
+
'Map'() {
|
|
1665
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
1666
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
1667
|
+
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
1668
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
1669
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
1670
|
+
},
|
|
1671
|
+
'Set'() {
|
|
1672
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
1673
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
1674
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
1675
|
+
},
|
|
1676
|
+
'Uint8Array'() {
|
|
1677
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
1678
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
1679
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
1680
|
+
},
|
|
1681
|
+
'Custom comparator'() {
|
|
1682
|
+
class User {
|
|
1683
|
+
name;
|
|
1684
|
+
rand;
|
|
1685
|
+
constructor(name, rand = Math.random()) {
|
|
1686
|
+
this.name = name;
|
|
1687
|
+
this.rand = rand;
|
|
1688
|
+
}
|
|
1689
|
+
[Symbol.toPrimitive](mode) {
|
|
1690
|
+
return this.name;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
1694
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
1695
|
+
},
|
|
1696
|
+
});
|
|
1697
|
+
})($ || ($ = {}));
|
|
1698
|
+
//mol/compare/deep/deep.test.tsx
|
|
1699
|
+
;
|
|
1700
|
+
"use strict";
|
|
1701
|
+
var $;
|
|
1702
1702
|
(function ($) {
|
|
1703
1703
|
$mol_test({
|
|
1704
1704
|
'Primitives'() {
|