mol_tree2 1.0.211 → 1.0.213
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.test.js +299 -299
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +246 -246
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1673,25 +1673,25 @@ var $;
|
|
|
1673
1673
|
//mol/dom/render/children/children.ts
|
|
1674
1674
|
;
|
|
1675
1675
|
"use strict";
|
|
1676
|
-
//mol/type/
|
|
1676
|
+
//mol/type/partial/deep/deep.ts
|
|
1677
1677
|
;
|
|
1678
1678
|
"use strict";
|
|
1679
|
-
//mol/type/
|
|
1679
|
+
//mol/type/error/error.ts
|
|
1680
1680
|
;
|
|
1681
1681
|
"use strict";
|
|
1682
1682
|
//mol/type/assert/assert.ts
|
|
1683
1683
|
;
|
|
1684
1684
|
"use strict";
|
|
1685
|
-
//mol/type/
|
|
1685
|
+
//mol/type/assert/assert.test.ts
|
|
1686
1686
|
;
|
|
1687
1687
|
"use strict";
|
|
1688
1688
|
//mol/type/equals/equals.ts
|
|
1689
1689
|
;
|
|
1690
1690
|
"use strict";
|
|
1691
|
-
//mol/type/
|
|
1691
|
+
//mol/type/equals/equals.test.ts
|
|
1692
1692
|
;
|
|
1693
1693
|
"use strict";
|
|
1694
|
-
//mol/type/partial/deep/deep.ts
|
|
1694
|
+
//mol/type/partial/deep/deep.test.ts
|
|
1695
1695
|
;
|
|
1696
1696
|
"use strict";
|
|
1697
1697
|
var $;
|
|
@@ -2138,38 +2138,6 @@ var $;
|
|
|
2138
2138
|
;
|
|
2139
2139
|
"use strict";
|
|
2140
2140
|
var $;
|
|
2141
|
-
(function ($) {
|
|
2142
|
-
$mol_test({
|
|
2143
|
-
'must be false'() {
|
|
2144
|
-
$mol_assert_not(0);
|
|
2145
|
-
},
|
|
2146
|
-
'must be true'() {
|
|
2147
|
-
$mol_assert_ok(1);
|
|
2148
|
-
},
|
|
2149
|
-
'two must be equal'() {
|
|
2150
|
-
$mol_assert_equal(2, 2);
|
|
2151
|
-
},
|
|
2152
|
-
'three must be equal'() {
|
|
2153
|
-
$mol_assert_equal(2, 2, 2);
|
|
2154
|
-
},
|
|
2155
|
-
'two must be unique'() {
|
|
2156
|
-
$mol_assert_unique([3], [3]);
|
|
2157
|
-
},
|
|
2158
|
-
'three must be unique'() {
|
|
2159
|
-
$mol_assert_unique([3], [3], [3]);
|
|
2160
|
-
},
|
|
2161
|
-
'two must be alike'() {
|
|
2162
|
-
$mol_assert_like([3], [3]);
|
|
2163
|
-
},
|
|
2164
|
-
'three must be alike'() {
|
|
2165
|
-
$mol_assert_like([3], [3], [3]);
|
|
2166
|
-
},
|
|
2167
|
-
});
|
|
2168
|
-
})($ || ($ = {}));
|
|
2169
|
-
//mol/assert/assert.test.ts
|
|
2170
|
-
;
|
|
2171
|
-
"use strict";
|
|
2172
|
-
var $;
|
|
2173
2141
|
(function ($) {
|
|
2174
2142
|
function $mol_assert_ok(value) {
|
|
2175
2143
|
if (value)
|
|
@@ -2264,6 +2232,84 @@ var $;
|
|
|
2264
2232
|
;
|
|
2265
2233
|
"use strict";
|
|
2266
2234
|
var $;
|
|
2235
|
+
(function ($) {
|
|
2236
|
+
$mol_test({
|
|
2237
|
+
'must be false'() {
|
|
2238
|
+
$mol_assert_not(0);
|
|
2239
|
+
},
|
|
2240
|
+
'must be true'() {
|
|
2241
|
+
$mol_assert_ok(1);
|
|
2242
|
+
},
|
|
2243
|
+
'two must be equal'() {
|
|
2244
|
+
$mol_assert_equal(2, 2);
|
|
2245
|
+
},
|
|
2246
|
+
'three must be equal'() {
|
|
2247
|
+
$mol_assert_equal(2, 2, 2);
|
|
2248
|
+
},
|
|
2249
|
+
'two must be unique'() {
|
|
2250
|
+
$mol_assert_unique([3], [3]);
|
|
2251
|
+
},
|
|
2252
|
+
'three must be unique'() {
|
|
2253
|
+
$mol_assert_unique([3], [3], [3]);
|
|
2254
|
+
},
|
|
2255
|
+
'two must be alike'() {
|
|
2256
|
+
$mol_assert_like([3], [3]);
|
|
2257
|
+
},
|
|
2258
|
+
'three must be alike'() {
|
|
2259
|
+
$mol_assert_like([3], [3], [3]);
|
|
2260
|
+
},
|
|
2261
|
+
});
|
|
2262
|
+
})($ || ($ = {}));
|
|
2263
|
+
//mol/assert/assert.test.ts
|
|
2264
|
+
;
|
|
2265
|
+
"use strict";
|
|
2266
|
+
var $;
|
|
2267
|
+
(function ($) {
|
|
2268
|
+
const named = new WeakSet();
|
|
2269
|
+
function $mol_func_name(func) {
|
|
2270
|
+
let name = func.name;
|
|
2271
|
+
if (name?.length > 1)
|
|
2272
|
+
return name;
|
|
2273
|
+
if (named.has(func))
|
|
2274
|
+
return name;
|
|
2275
|
+
for (let key in this) {
|
|
2276
|
+
try {
|
|
2277
|
+
if (this[key] !== func)
|
|
2278
|
+
continue;
|
|
2279
|
+
name = key;
|
|
2280
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
2281
|
+
break;
|
|
2282
|
+
}
|
|
2283
|
+
catch { }
|
|
2284
|
+
}
|
|
2285
|
+
named.add(func);
|
|
2286
|
+
return name;
|
|
2287
|
+
}
|
|
2288
|
+
$.$mol_func_name = $mol_func_name;
|
|
2289
|
+
function $mol_func_name_from(target, source) {
|
|
2290
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
2291
|
+
return target;
|
|
2292
|
+
}
|
|
2293
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
2294
|
+
})($ || ($ = {}));
|
|
2295
|
+
//mol/func/name/name.ts
|
|
2296
|
+
;
|
|
2297
|
+
"use strict";
|
|
2298
|
+
var $;
|
|
2299
|
+
(function ($_1) {
|
|
2300
|
+
$mol_test({
|
|
2301
|
+
'FQN of anon function'($) {
|
|
2302
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
2303
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
2304
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
2305
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
2306
|
+
},
|
|
2307
|
+
});
|
|
2308
|
+
})($ || ($ = {}));
|
|
2309
|
+
//mol/func/name/name.test.ts
|
|
2310
|
+
;
|
|
2311
|
+
"use strict";
|
|
2312
|
+
var $;
|
|
2267
2313
|
(function ($) {
|
|
2268
2314
|
$mol_test({
|
|
2269
2315
|
'get'() {
|
|
@@ -2330,200 +2376,24 @@ var $;
|
|
|
2330
2376
|
;
|
|
2331
2377
|
"use strict";
|
|
2332
2378
|
var $;
|
|
2333
|
-
(function ($
|
|
2334
|
-
$
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
'slice span - regular'($) {
|
|
2352
|
-
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
2353
|
-
const child = span.slice(1, 4);
|
|
2354
|
-
$mol_assert_equal(child.row, 1);
|
|
2355
|
-
$mol_assert_equal(child.col, 4);
|
|
2356
|
-
$mol_assert_equal(child.length, 3);
|
|
2357
|
-
const child2 = span.slice(2, 2);
|
|
2358
|
-
$mol_assert_equal(child2.col, 5);
|
|
2359
|
-
$mol_assert_equal(child2.length, 0);
|
|
2360
|
-
},
|
|
2361
|
-
'slice span - negative'($) {
|
|
2362
|
-
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
2363
|
-
const child = span.slice(-3, -1);
|
|
2364
|
-
$mol_assert_equal(child.row, 1);
|
|
2365
|
-
$mol_assert_equal(child.col, 5);
|
|
2366
|
-
$mol_assert_equal(child.length, 2);
|
|
2367
|
-
},
|
|
2368
|
-
'slice span - out of range'($) {
|
|
2369
|
-
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
2370
|
-
$mol_assert_fail(() => span.slice(-1, 3));
|
|
2371
|
-
$mol_assert_fail(() => span.slice(1, 6));
|
|
2372
|
-
$mol_assert_fail(() => span.slice(1, 10));
|
|
2373
|
-
},
|
|
2374
|
-
'error handling'($) {
|
|
2375
|
-
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
2376
|
-
const error = span.error('Some error\n');
|
|
2377
|
-
$mol_assert_equal(error.message, 'Some error\ntest.ts#1:3/4');
|
|
2378
|
-
}
|
|
2379
|
-
});
|
|
2380
|
-
})($ || ($ = {}));
|
|
2381
|
-
//mol/span/span.test.ts
|
|
2382
|
-
;
|
|
2383
|
-
"use strict";
|
|
2384
|
-
var $;
|
|
2385
|
-
(function ($_1) {
|
|
2386
|
-
$mol_test({
|
|
2387
|
-
'tree parsing'($) {
|
|
2388
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids.length, 2);
|
|
2389
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids[1].type, "bar");
|
|
2390
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo\n\n\n").kids.length, 1);
|
|
2391
|
-
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids.length, 2);
|
|
2392
|
-
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids[1].value, "bar");
|
|
2393
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
|
|
2394
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
|
|
2395
|
-
$mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
2396
|
-
},
|
|
2397
|
-
'Too many tabs'($) {
|
|
2398
|
-
const tree = `
|
|
2399
|
-
foo
|
|
2400
|
-
bar
|
|
2401
|
-
`;
|
|
2402
|
-
$mol_assert_fail(() => {
|
|
2403
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
2404
|
-
}, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
|
|
2405
|
-
},
|
|
2406
|
-
'Too few tabs'($) {
|
|
2407
|
-
const tree = `
|
|
2408
|
-
foo
|
|
2409
|
-
bar
|
|
2410
|
-
`;
|
|
2411
|
-
$mol_assert_fail(() => {
|
|
2412
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
2413
|
-
}, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
|
|
2414
|
-
},
|
|
2415
|
-
'Wrong nodes separator'($) {
|
|
2416
|
-
const tree = `foo bar\n`;
|
|
2417
|
-
$mol_assert_fail(() => {
|
|
2418
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
2419
|
-
}, 'Wrong nodes separator\ntest#1:4/2\n !!\nfoo bar');
|
|
2420
|
-
},
|
|
2421
|
-
'Undexpected EOF, LF required'($) {
|
|
2422
|
-
const tree = ` foo`;
|
|
2423
|
-
$mol_assert_fail(() => {
|
|
2424
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
2425
|
-
}, 'Undexpected EOF, LF required\ntest#1:5/1\n !\n foo');
|
|
2426
|
-
},
|
|
2427
|
-
'Errors skip and collect'($) {
|
|
2428
|
-
const tree = `foo bar`;
|
|
2429
|
-
const errors = [];
|
|
2430
|
-
const $$ = $.$mol_ambient({
|
|
2431
|
-
$mol_fail: (error) => {
|
|
2432
|
-
errors.push(error.message);
|
|
2433
|
-
return null;
|
|
2434
|
-
}
|
|
2435
|
-
});
|
|
2436
|
-
const res = $$.$mol_tree2_from_string(tree, 'test');
|
|
2437
|
-
$mol_assert_like(errors, [
|
|
2438
|
-
'Wrong nodes separator\ntest#1:4/2\n !!\nfoo bar',
|
|
2439
|
-
'Undexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
|
|
2440
|
-
]);
|
|
2441
|
-
$mol_assert_equal(res.toString(), 'foo bar\n');
|
|
2442
|
-
},
|
|
2443
|
-
});
|
|
2444
|
-
})($ || ($ = {}));
|
|
2445
|
-
//mol/tree2/from/string/string.test.ts
|
|
2446
|
-
;
|
|
2447
|
-
"use strict";
|
|
2448
|
-
var $;
|
|
2449
|
-
(function ($_1) {
|
|
2450
|
-
$mol_test({
|
|
2451
|
-
'tree parsing'() {
|
|
2452
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
2453
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
2454
|
-
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
2455
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
2456
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
2457
|
-
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
2458
|
-
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
2459
|
-
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
2460
|
-
},
|
|
2461
|
-
'inserting'() {
|
|
2462
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
2463
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
2464
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
2465
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
2466
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
2467
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
2468
|
-
},
|
|
2469
|
-
'fromJSON'() {
|
|
2470
|
-
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
2471
|
-
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
2472
|
-
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
2473
|
-
$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');
|
|
2474
|
-
$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');
|
|
2475
|
-
},
|
|
2476
|
-
'toJSON'() {
|
|
2477
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
2478
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
2479
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
2480
|
-
$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"]');
|
|
2481
|
-
$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"}');
|
|
2482
|
-
},
|
|
2483
|
-
'hack'() {
|
|
2484
|
-
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
2485
|
-
'': (tree, context) => [tree.hack(context)],
|
|
2486
|
-
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
2487
|
-
});
|
|
2488
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
2489
|
-
},
|
|
2490
|
-
'errors handling'($) {
|
|
2491
|
-
const errors = [];
|
|
2492
|
-
class Tree extends $mol_tree {
|
|
2493
|
-
static $ = $.$mol_ambient({
|
|
2494
|
-
$mol_fail: error => errors.push(error.message)
|
|
2495
|
-
});
|
|
2496
|
-
}
|
|
2497
|
-
Tree.fromString(`
|
|
2498
|
-
\t \tfoo
|
|
2499
|
-
bar \\data
|
|
2500
|
-
`, 'test');
|
|
2501
|
-
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
2502
|
-
},
|
|
2503
|
-
});
|
|
2504
|
-
})($ || ($ = {}));
|
|
2505
|
-
//mol/tree/tree.test.ts
|
|
2506
|
-
;
|
|
2507
|
-
"use strict";
|
|
2508
|
-
var $;
|
|
2509
|
-
(function ($) {
|
|
2510
|
-
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
2511
|
-
class $mol_tree extends $mol_object2 {
|
|
2512
|
-
type;
|
|
2513
|
-
data;
|
|
2514
|
-
sub;
|
|
2515
|
-
baseUri;
|
|
2516
|
-
row;
|
|
2517
|
-
col;
|
|
2518
|
-
length;
|
|
2519
|
-
constructor(config = {}) {
|
|
2520
|
-
super();
|
|
2521
|
-
this.type = config.type || '';
|
|
2522
|
-
if (config.value !== undefined) {
|
|
2523
|
-
var sub = $mol_tree.values(config.value);
|
|
2524
|
-
if (config.type || sub.length > 1) {
|
|
2525
|
-
this.sub = [...sub, ...(config.sub || [])];
|
|
2526
|
-
this.data = config.data || '';
|
|
2379
|
+
(function ($) {
|
|
2380
|
+
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
2381
|
+
class $mol_tree extends $mol_object2 {
|
|
2382
|
+
type;
|
|
2383
|
+
data;
|
|
2384
|
+
sub;
|
|
2385
|
+
baseUri;
|
|
2386
|
+
row;
|
|
2387
|
+
col;
|
|
2388
|
+
length;
|
|
2389
|
+
constructor(config = {}) {
|
|
2390
|
+
super();
|
|
2391
|
+
this.type = config.type || '';
|
|
2392
|
+
if (config.value !== undefined) {
|
|
2393
|
+
var sub = $mol_tree.values(config.value);
|
|
2394
|
+
if (config.type || sub.length > 1) {
|
|
2395
|
+
this.sub = [...sub, ...(config.sub || [])];
|
|
2396
|
+
this.data = config.data || '';
|
|
2527
2397
|
}
|
|
2528
2398
|
else {
|
|
2529
2399
|
this.data = sub[0].data;
|
|
@@ -2838,47 +2708,113 @@ var $;
|
|
|
2838
2708
|
var $;
|
|
2839
2709
|
(function ($_1) {
|
|
2840
2710
|
$mol_test({
|
|
2841
|
-
'
|
|
2842
|
-
|
|
2843
|
-
$mol_assert_equal(
|
|
2844
|
-
$mol_assert_equal(
|
|
2845
|
-
$mol_assert_equal(
|
|
2711
|
+
'tree parsing'() {
|
|
2712
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
2713
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
2714
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
2715
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
2716
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
2717
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
2718
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
2719
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
2720
|
+
},
|
|
2721
|
+
'inserting'() {
|
|
2722
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
2723
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
2724
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
2725
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
2726
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
2727
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
2728
|
+
},
|
|
2729
|
+
'fromJSON'() {
|
|
2730
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
2731
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
2732
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
2733
|
+
$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');
|
|
2734
|
+
$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');
|
|
2735
|
+
},
|
|
2736
|
+
'toJSON'() {
|
|
2737
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
2738
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
2739
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
2740
|
+
$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"]');
|
|
2741
|
+
$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"}');
|
|
2742
|
+
},
|
|
2743
|
+
'hack'() {
|
|
2744
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
2745
|
+
'': (tree, context) => [tree.hack(context)],
|
|
2746
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
2747
|
+
});
|
|
2748
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
2749
|
+
},
|
|
2750
|
+
'errors handling'($) {
|
|
2751
|
+
const errors = [];
|
|
2752
|
+
class Tree extends $mol_tree {
|
|
2753
|
+
static $ = $.$mol_ambient({
|
|
2754
|
+
$mol_fail: error => errors.push(error.message)
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
Tree.fromString(`
|
|
2758
|
+
\t \tfoo
|
|
2759
|
+
bar \\data
|
|
2760
|
+
`, 'test');
|
|
2761
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
2846
2762
|
},
|
|
2847
2763
|
});
|
|
2848
2764
|
})($ || ($ = {}));
|
|
2849
|
-
//mol/
|
|
2765
|
+
//mol/tree/tree.test.ts
|
|
2850
2766
|
;
|
|
2851
2767
|
"use strict";
|
|
2852
2768
|
var $;
|
|
2853
|
-
(function ($) {
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2769
|
+
(function ($_1) {
|
|
2770
|
+
$mol_test({
|
|
2771
|
+
'span for same uri'($) {
|
|
2772
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
2773
|
+
const child = span.span(4, 5, 8);
|
|
2774
|
+
$mol_assert_equal(child.uri, 'test.ts');
|
|
2775
|
+
$mol_assert_equal(child.row, 4);
|
|
2776
|
+
$mol_assert_equal(child.col, 5);
|
|
2777
|
+
$mol_assert_equal(child.length, 8);
|
|
2778
|
+
},
|
|
2779
|
+
'span after of given position'($) {
|
|
2780
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
2781
|
+
const child = span.after(11);
|
|
2782
|
+
$mol_assert_equal(child.uri, 'test.ts');
|
|
2783
|
+
$mol_assert_equal(child.row, 1);
|
|
2784
|
+
$mol_assert_equal(child.col, 7);
|
|
2785
|
+
$mol_assert_equal(child.length, 11);
|
|
2786
|
+
},
|
|
2787
|
+
'slice span - regular'($) {
|
|
2788
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
2789
|
+
const child = span.slice(1, 4);
|
|
2790
|
+
$mol_assert_equal(child.row, 1);
|
|
2791
|
+
$mol_assert_equal(child.col, 4);
|
|
2792
|
+
$mol_assert_equal(child.length, 3);
|
|
2793
|
+
const child2 = span.slice(2, 2);
|
|
2794
|
+
$mol_assert_equal(child2.col, 5);
|
|
2795
|
+
$mol_assert_equal(child2.length, 0);
|
|
2796
|
+
},
|
|
2797
|
+
'slice span - negative'($) {
|
|
2798
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
2799
|
+
const child = span.slice(-3, -1);
|
|
2800
|
+
$mol_assert_equal(child.row, 1);
|
|
2801
|
+
$mol_assert_equal(child.col, 5);
|
|
2802
|
+
$mol_assert_equal(child.length, 2);
|
|
2803
|
+
},
|
|
2804
|
+
'slice span - out of range'($) {
|
|
2805
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
2806
|
+
$mol_assert_fail(() => span.slice(-1, 3));
|
|
2807
|
+
$mol_assert_fail(() => span.slice(1, 6));
|
|
2808
|
+
$mol_assert_fail(() => span.slice(1, 10));
|
|
2809
|
+
},
|
|
2810
|
+
'error handling'($) {
|
|
2811
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
2812
|
+
const error = span.error('Some error\n');
|
|
2813
|
+
$mol_assert_equal(error.message, 'Some error\ntest.ts#1:3/4');
|
|
2870
2814
|
}
|
|
2871
|
-
|
|
2872
|
-
return name;
|
|
2873
|
-
}
|
|
2874
|
-
$.$mol_func_name = $mol_func_name;
|
|
2875
|
-
function $mol_func_name_from(target, source) {
|
|
2876
|
-
Object.defineProperty(target, 'name', { value: source.name });
|
|
2877
|
-
return target;
|
|
2878
|
-
}
|
|
2879
|
-
$.$mol_func_name_from = $mol_func_name_from;
|
|
2815
|
+
});
|
|
2880
2816
|
})($ || ($ = {}));
|
|
2881
|
-
//mol/
|
|
2817
|
+
//mol/span/span.test.ts
|
|
2882
2818
|
;
|
|
2883
2819
|
"use strict";
|
|
2884
2820
|
var $;
|
|
@@ -2939,25 +2875,102 @@ var $;
|
|
|
2939
2875
|
//mol/tree2/from/json/json.test.ts
|
|
2940
2876
|
;
|
|
2941
2877
|
"use strict";
|
|
2942
|
-
|
|
2878
|
+
var $;
|
|
2879
|
+
(function ($_1) {
|
|
2880
|
+
$mol_test({
|
|
2881
|
+
'tree parsing'($) {
|
|
2882
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids.length, 2);
|
|
2883
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids[1].type, "bar");
|
|
2884
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\n\n\n").kids.length, 1);
|
|
2885
|
+
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids.length, 2);
|
|
2886
|
+
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids[1].value, "bar");
|
|
2887
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
|
|
2888
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
|
|
2889
|
+
$mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
2890
|
+
},
|
|
2891
|
+
'Too many tabs'($) {
|
|
2892
|
+
const tree = `
|
|
2893
|
+
foo
|
|
2894
|
+
bar
|
|
2895
|
+
`;
|
|
2896
|
+
$mol_assert_fail(() => {
|
|
2897
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
2898
|
+
}, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
|
|
2899
|
+
},
|
|
2900
|
+
'Too few tabs'($) {
|
|
2901
|
+
const tree = `
|
|
2902
|
+
foo
|
|
2903
|
+
bar
|
|
2904
|
+
`;
|
|
2905
|
+
$mol_assert_fail(() => {
|
|
2906
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
2907
|
+
}, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
|
|
2908
|
+
},
|
|
2909
|
+
'Wrong nodes separator'($) {
|
|
2910
|
+
const tree = `foo bar\n`;
|
|
2911
|
+
$mol_assert_fail(() => {
|
|
2912
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
2913
|
+
}, 'Wrong nodes separator\ntest#1:4/2\n !!\nfoo bar');
|
|
2914
|
+
},
|
|
2915
|
+
'Undexpected EOF, LF required'($) {
|
|
2916
|
+
const tree = ` foo`;
|
|
2917
|
+
$mol_assert_fail(() => {
|
|
2918
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
2919
|
+
}, 'Undexpected EOF, LF required\ntest#1:5/1\n !\n foo');
|
|
2920
|
+
},
|
|
2921
|
+
'Errors skip and collect'($) {
|
|
2922
|
+
const tree = `foo bar`;
|
|
2923
|
+
const errors = [];
|
|
2924
|
+
const $$ = $.$mol_ambient({
|
|
2925
|
+
$mol_fail: (error) => {
|
|
2926
|
+
errors.push(error.message);
|
|
2927
|
+
return null;
|
|
2928
|
+
}
|
|
2929
|
+
});
|
|
2930
|
+
const res = $$.$mol_tree2_from_string(tree, 'test');
|
|
2931
|
+
$mol_assert_like(errors, [
|
|
2932
|
+
'Wrong nodes separator\ntest#1:4/2\n !!\nfoo bar',
|
|
2933
|
+
'Undexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
|
|
2934
|
+
]);
|
|
2935
|
+
$mol_assert_equal(res.toString(), 'foo bar\n');
|
|
2936
|
+
},
|
|
2937
|
+
});
|
|
2938
|
+
})($ || ($ = {}));
|
|
2939
|
+
//mol/tree2/from/string/string.test.ts
|
|
2943
2940
|
;
|
|
2944
2941
|
"use strict";
|
|
2945
|
-
//mol/type/
|
|
2942
|
+
//mol/type/unary/unary.ts
|
|
2946
2943
|
;
|
|
2947
2944
|
"use strict";
|
|
2948
2945
|
//mol/type/param/param.ts
|
|
2949
2946
|
;
|
|
2950
2947
|
"use strict";
|
|
2951
|
-
//mol/type/
|
|
2948
|
+
//mol/type/param/param.test.ts
|
|
2952
2949
|
;
|
|
2953
2950
|
"use strict";
|
|
2954
2951
|
//mol/type/tail/tail.ts
|
|
2955
2952
|
;
|
|
2956
2953
|
"use strict";
|
|
2954
|
+
//mol/type/tail/tail.test.ts
|
|
2955
|
+
;
|
|
2956
|
+
"use strict";
|
|
2957
2957
|
//mol/data/value/value.ts
|
|
2958
2958
|
;
|
|
2959
2959
|
"use strict";
|
|
2960
2960
|
var $;
|
|
2961
|
+
(function ($) {
|
|
2962
|
+
function $mol_data_setup(value, config) {
|
|
2963
|
+
return Object.assign(value, {
|
|
2964
|
+
config,
|
|
2965
|
+
Value: null
|
|
2966
|
+
});
|
|
2967
|
+
}
|
|
2968
|
+
$.$mol_data_setup = $mol_data_setup;
|
|
2969
|
+
})($ || ($ = {}));
|
|
2970
|
+
//mol/data/setup/setup.ts
|
|
2971
|
+
;
|
|
2972
|
+
"use strict";
|
|
2973
|
+
var $;
|
|
2961
2974
|
(function ($) {
|
|
2962
2975
|
$mol_test({
|
|
2963
2976
|
'config by value'() {
|
|
@@ -2971,15 +2984,12 @@ var $;
|
|
|
2971
2984
|
"use strict";
|
|
2972
2985
|
var $;
|
|
2973
2986
|
(function ($) {
|
|
2974
|
-
function $
|
|
2975
|
-
return Object.
|
|
2976
|
-
config,
|
|
2977
|
-
Value: null
|
|
2978
|
-
});
|
|
2987
|
+
function $mol_func_is_class(func) {
|
|
2988
|
+
return Object.getOwnPropertyDescriptor(func, 'prototype')?.writable === false;
|
|
2979
2989
|
}
|
|
2980
|
-
$.$
|
|
2990
|
+
$.$mol_func_is_class = $mol_func_is_class;
|
|
2981
2991
|
})($ || ($ = {}));
|
|
2982
|
-
//mol/
|
|
2992
|
+
//mol/func/is/class/class.ts
|
|
2983
2993
|
;
|
|
2984
2994
|
"use strict";
|
|
2985
2995
|
var $;
|
|
@@ -3010,26 +3020,31 @@ var $;
|
|
|
3010
3020
|
//mol/func/is/class/class.test.ts
|
|
3011
3021
|
;
|
|
3012
3022
|
"use strict";
|
|
3013
|
-
|
|
3014
|
-
(function ($) {
|
|
3015
|
-
function $mol_func_is_class(func) {
|
|
3016
|
-
return Object.getOwnPropertyDescriptor(func, 'prototype')?.writable === false;
|
|
3017
|
-
}
|
|
3018
|
-
$.$mol_func_is_class = $mol_func_is_class;
|
|
3019
|
-
})($ || ($ = {}));
|
|
3020
|
-
//mol/func/is/class/class.ts
|
|
3023
|
+
//mol/type/result/result.ts
|
|
3021
3024
|
;
|
|
3022
3025
|
"use strict";
|
|
3023
3026
|
//mol/type/result/result.test.ts
|
|
3024
3027
|
;
|
|
3025
3028
|
"use strict";
|
|
3026
|
-
//mol/type/
|
|
3029
|
+
//mol/type/foot/foot.ts
|
|
3027
3030
|
;
|
|
3028
3031
|
"use strict";
|
|
3029
3032
|
//mol/type/foot/foot.test.ts
|
|
3030
3033
|
;
|
|
3031
3034
|
"use strict";
|
|
3032
|
-
|
|
3035
|
+
var $;
|
|
3036
|
+
(function ($) {
|
|
3037
|
+
function $mol_data_pipe(...funcs) {
|
|
3038
|
+
return $mol_data_setup(function (input) {
|
|
3039
|
+
let value = input;
|
|
3040
|
+
for (const func of funcs)
|
|
3041
|
+
value = $mol_func_is_class(func) ? new func(value) : func.call(this, value);
|
|
3042
|
+
return value;
|
|
3043
|
+
}, { funcs });
|
|
3044
|
+
}
|
|
3045
|
+
$.$mol_data_pipe = $mol_data_pipe;
|
|
3046
|
+
})($ || ($ = {}));
|
|
3047
|
+
//mol/data/pipe/pipe.ts
|
|
3033
3048
|
;
|
|
3034
3049
|
"use strict";
|
|
3035
3050
|
var $;
|
|
@@ -3065,21 +3080,6 @@ var $;
|
|
|
3065
3080
|
;
|
|
3066
3081
|
"use strict";
|
|
3067
3082
|
var $;
|
|
3068
|
-
(function ($) {
|
|
3069
|
-
function $mol_data_pipe(...funcs) {
|
|
3070
|
-
return $mol_data_setup(function (input) {
|
|
3071
|
-
let value = input;
|
|
3072
|
-
for (const func of funcs)
|
|
3073
|
-
value = $mol_func_is_class(func) ? new func(value) : func.call(this, value);
|
|
3074
|
-
return value;
|
|
3075
|
-
}, { funcs });
|
|
3076
|
-
}
|
|
3077
|
-
$.$mol_data_pipe = $mol_data_pipe;
|
|
3078
|
-
})($ || ($ = {}));
|
|
3079
|
-
//mol/data/pipe/pipe.ts
|
|
3080
|
-
;
|
|
3081
|
-
"use strict";
|
|
3082
|
-
var $;
|
|
3083
3083
|
(function ($) {
|
|
3084
3084
|
const convert = $mol_data_pipe($mol_tree2_from_string, $mol_tree2_js_to_text, $mol_tree2_text_to_string);
|
|
3085
3085
|
$mol_test({
|