mol_text_distance 0.0.300 → 0.0.301
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 +199 -199
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +53 -53
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -455,27 +455,21 @@ var $;
|
|
|
455
455
|
//mol/dom/render/children/children.ts
|
|
456
456
|
;
|
|
457
457
|
"use strict";
|
|
458
|
-
//mol/type/
|
|
458
|
+
//mol/type/partial/deep/deep.ts
|
|
459
459
|
;
|
|
460
460
|
"use strict";
|
|
461
|
-
//mol/type/
|
|
461
|
+
//mol/type/error/error.ts
|
|
462
462
|
;
|
|
463
463
|
"use strict";
|
|
464
464
|
//mol/type/assert/assert.ts
|
|
465
465
|
;
|
|
466
466
|
"use strict";
|
|
467
|
-
//mol/type/
|
|
468
|
-
;
|
|
469
|
-
"use strict";
|
|
470
|
-
//mol/type/equals/equals.ts
|
|
467
|
+
//mol/type/assert/assert.test.ts
|
|
471
468
|
;
|
|
472
469
|
"use strict";
|
|
473
470
|
//mol/type/partial/deep/deep.test.ts
|
|
474
471
|
;
|
|
475
472
|
"use strict";
|
|
476
|
-
//mol/type/partial/deep/deep.ts
|
|
477
|
-
;
|
|
478
|
-
"use strict";
|
|
479
473
|
var $;
|
|
480
474
|
(function ($) {
|
|
481
475
|
$mol_test({
|
|
@@ -920,38 +914,6 @@ var $;
|
|
|
920
914
|
;
|
|
921
915
|
"use strict";
|
|
922
916
|
var $;
|
|
923
|
-
(function ($) {
|
|
924
|
-
$mol_test({
|
|
925
|
-
'must be false'() {
|
|
926
|
-
$mol_assert_not(0);
|
|
927
|
-
},
|
|
928
|
-
'must be true'() {
|
|
929
|
-
$mol_assert_ok(1);
|
|
930
|
-
},
|
|
931
|
-
'two must be equal'() {
|
|
932
|
-
$mol_assert_equal(2, 2);
|
|
933
|
-
},
|
|
934
|
-
'three must be equal'() {
|
|
935
|
-
$mol_assert_equal(2, 2, 2);
|
|
936
|
-
},
|
|
937
|
-
'two must be unique'() {
|
|
938
|
-
$mol_assert_unique([3], [3]);
|
|
939
|
-
},
|
|
940
|
-
'three must be unique'() {
|
|
941
|
-
$mol_assert_unique([3], [3], [3]);
|
|
942
|
-
},
|
|
943
|
-
'two must be alike'() {
|
|
944
|
-
$mol_assert_like([3], [3]);
|
|
945
|
-
},
|
|
946
|
-
'three must be alike'() {
|
|
947
|
-
$mol_assert_like([3], [3], [3]);
|
|
948
|
-
},
|
|
949
|
-
});
|
|
950
|
-
})($ || ($ = {}));
|
|
951
|
-
//mol/assert/assert.test.ts
|
|
952
|
-
;
|
|
953
|
-
"use strict";
|
|
954
|
-
var $;
|
|
955
917
|
(function ($) {
|
|
956
918
|
function $mol_assert_ok(value) {
|
|
957
919
|
if (value)
|
|
@@ -1046,114 +1008,46 @@ var $;
|
|
|
1046
1008
|
;
|
|
1047
1009
|
"use strict";
|
|
1048
1010
|
var $;
|
|
1049
|
-
(function ($) {
|
|
1050
|
-
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
1051
|
-
function $mol_ambient(overrides) {
|
|
1052
|
-
return Object.setPrototypeOf(overrides, this || $);
|
|
1053
|
-
}
|
|
1054
|
-
$.$mol_ambient = $mol_ambient;
|
|
1055
|
-
})($ || ($ = {}));
|
|
1056
|
-
//mol/ambient/ambient.ts
|
|
1057
|
-
;
|
|
1058
|
-
"use strict";
|
|
1059
|
-
var $;
|
|
1060
1011
|
(function ($) {
|
|
1061
1012
|
$mol_test({
|
|
1062
|
-
'
|
|
1063
|
-
|
|
1064
|
-
$mol_assert_equal(proxy.foo, 777);
|
|
1065
|
-
},
|
|
1066
|
-
'has'() {
|
|
1067
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1068
|
-
$mol_assert_equal('foo' in proxy, true);
|
|
1013
|
+
'must be false'() {
|
|
1014
|
+
$mol_assert_not(0);
|
|
1069
1015
|
},
|
|
1070
|
-
'
|
|
1071
|
-
|
|
1072
|
-
const proxy = $mol_delegate({}, () => target);
|
|
1073
|
-
proxy.foo = 123;
|
|
1074
|
-
$mol_assert_equal(target.foo, 123);
|
|
1016
|
+
'must be true'() {
|
|
1017
|
+
$mol_assert_ok(1);
|
|
1075
1018
|
},
|
|
1076
|
-
'
|
|
1077
|
-
|
|
1078
|
-
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1079
|
-
value: 777,
|
|
1080
|
-
writable: true,
|
|
1081
|
-
enumerable: true,
|
|
1082
|
-
configurable: true,
|
|
1083
|
-
});
|
|
1019
|
+
'two must be equal'() {
|
|
1020
|
+
$mol_assert_equal(2, 2);
|
|
1084
1021
|
},
|
|
1085
|
-
'
|
|
1086
|
-
|
|
1087
|
-
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1022
|
+
'three must be equal'() {
|
|
1023
|
+
$mol_assert_equal(2, 2, 2);
|
|
1088
1024
|
},
|
|
1089
|
-
'
|
|
1090
|
-
|
|
1091
|
-
}
|
|
1092
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1093
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1025
|
+
'two must be unique'() {
|
|
1026
|
+
$mol_assert_unique([3], [3]);
|
|
1094
1027
|
},
|
|
1095
|
-
'
|
|
1096
|
-
|
|
1097
|
-
}
|
|
1098
|
-
const target = {};
|
|
1099
|
-
const proxy = $mol_delegate({}, () => target);
|
|
1100
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1101
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1028
|
+
'three must be unique'() {
|
|
1029
|
+
$mol_assert_unique([3], [3], [3]);
|
|
1102
1030
|
},
|
|
1103
|
-
'
|
|
1104
|
-
|
|
1105
|
-
}
|
|
1106
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1107
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
1108
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1031
|
+
'two must be alike'() {
|
|
1032
|
+
$mol_assert_like([3], [3]);
|
|
1109
1033
|
},
|
|
1110
|
-
'
|
|
1111
|
-
|
|
1112
|
-
}
|
|
1113
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1114
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
1115
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1034
|
+
'three must be alike'() {
|
|
1035
|
+
$mol_assert_like([3], [3], [3]);
|
|
1116
1036
|
},
|
|
1117
1037
|
});
|
|
1118
1038
|
})($ || ($ = {}));
|
|
1119
|
-
//mol/
|
|
1039
|
+
//mol/assert/assert.test.ts
|
|
1120
1040
|
;
|
|
1121
1041
|
"use strict";
|
|
1122
1042
|
var $;
|
|
1123
1043
|
(function ($) {
|
|
1124
|
-
|
|
1125
|
-
function $
|
|
1126
|
-
|
|
1127
|
-
get: (_, field) => {
|
|
1128
|
-
const obj = target();
|
|
1129
|
-
let val = Reflect.get(obj, field);
|
|
1130
|
-
if (typeof val === 'function') {
|
|
1131
|
-
val = val.bind(obj);
|
|
1132
|
-
}
|
|
1133
|
-
return val;
|
|
1134
|
-
},
|
|
1135
|
-
has: (_, field) => Reflect.has(target(), field),
|
|
1136
|
-
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1137
|
-
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1138
|
-
ownKeys: () => Reflect.ownKeys(target()),
|
|
1139
|
-
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1140
|
-
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1141
|
-
isExtensible: () => Reflect.isExtensible(target()),
|
|
1142
|
-
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1143
|
-
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1144
|
-
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1145
|
-
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1146
|
-
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1147
|
-
});
|
|
1148
|
-
instances.add(proxy);
|
|
1149
|
-
return proxy;
|
|
1044
|
+
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
1045
|
+
function $mol_ambient(overrides) {
|
|
1046
|
+
return Object.setPrototypeOf(overrides, this || $);
|
|
1150
1047
|
}
|
|
1151
|
-
$.$
|
|
1152
|
-
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1153
|
-
value: (obj) => instances.has(obj),
|
|
1154
|
-
});
|
|
1048
|
+
$.$mol_ambient = $mol_ambient;
|
|
1155
1049
|
})($ || ($ = {}));
|
|
1156
|
-
//mol/
|
|
1050
|
+
//mol/ambient/ambient.ts
|
|
1157
1051
|
;
|
|
1158
1052
|
"use strict";
|
|
1159
1053
|
var $;
|
|
@@ -1212,10 +1106,16 @@ var $;
|
|
|
1212
1106
|
//mol/owning/owning.ts
|
|
1213
1107
|
;
|
|
1214
1108
|
"use strict";
|
|
1215
|
-
//mol/type/writable/writable.
|
|
1109
|
+
//mol/type/writable/writable.ts
|
|
1216
1110
|
;
|
|
1217
1111
|
"use strict";
|
|
1218
|
-
//mol/type/
|
|
1112
|
+
//mol/type/equals/equals.ts
|
|
1113
|
+
;
|
|
1114
|
+
"use strict";
|
|
1115
|
+
//mol/type/equals/equals.test.ts
|
|
1116
|
+
;
|
|
1117
|
+
"use strict";
|
|
1118
|
+
//mol/type/writable/writable.test.ts
|
|
1219
1119
|
;
|
|
1220
1120
|
"use strict";
|
|
1221
1121
|
var $;
|
|
@@ -1262,66 +1162,6 @@ var $;
|
|
|
1262
1162
|
;
|
|
1263
1163
|
"use strict";
|
|
1264
1164
|
var $;
|
|
1265
|
-
(function ($_1) {
|
|
1266
|
-
$mol_test({
|
|
1267
|
-
'tree parsing'() {
|
|
1268
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1269
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1270
|
-
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1271
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1272
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1273
|
-
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1274
|
-
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1275
|
-
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1276
|
-
},
|
|
1277
|
-
'inserting'() {
|
|
1278
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1279
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1280
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1281
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1282
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1283
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1284
|
-
},
|
|
1285
|
-
'fromJSON'() {
|
|
1286
|
-
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1287
|
-
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1288
|
-
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1289
|
-
$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');
|
|
1290
|
-
$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');
|
|
1291
|
-
},
|
|
1292
|
-
'toJSON'() {
|
|
1293
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1294
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1295
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1296
|
-
$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"]');
|
|
1297
|
-
$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"}');
|
|
1298
|
-
},
|
|
1299
|
-
'hack'() {
|
|
1300
|
-
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1301
|
-
'': (tree, context) => [tree.hack(context)],
|
|
1302
|
-
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1303
|
-
});
|
|
1304
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1305
|
-
},
|
|
1306
|
-
'errors handling'($) {
|
|
1307
|
-
const errors = [];
|
|
1308
|
-
class Tree extends $mol_tree {
|
|
1309
|
-
static $ = $.$mol_ambient({
|
|
1310
|
-
$mol_fail: error => errors.push(error.message)
|
|
1311
|
-
});
|
|
1312
|
-
}
|
|
1313
|
-
Tree.fromString(`
|
|
1314
|
-
\t \tfoo
|
|
1315
|
-
bar \\data
|
|
1316
|
-
`, 'test');
|
|
1317
|
-
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1318
|
-
},
|
|
1319
|
-
});
|
|
1320
|
-
})($ || ($ = {}));
|
|
1321
|
-
//mol/tree/tree.test.ts
|
|
1322
|
-
;
|
|
1323
|
-
"use strict";
|
|
1324
|
-
var $;
|
|
1325
1165
|
(function ($) {
|
|
1326
1166
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1327
1167
|
class $mol_tree extends $mol_object2 {
|
|
@@ -1652,17 +1492,163 @@ var $;
|
|
|
1652
1492
|
;
|
|
1653
1493
|
"use strict";
|
|
1654
1494
|
var $;
|
|
1495
|
+
(function ($) {
|
|
1496
|
+
const instances = new WeakSet();
|
|
1497
|
+
function $mol_delegate(proto, target) {
|
|
1498
|
+
const proxy = new Proxy(proto, {
|
|
1499
|
+
get: (_, field) => {
|
|
1500
|
+
const obj = target();
|
|
1501
|
+
let val = Reflect.get(obj, field);
|
|
1502
|
+
if (typeof val === 'function') {
|
|
1503
|
+
val = val.bind(obj);
|
|
1504
|
+
}
|
|
1505
|
+
return val;
|
|
1506
|
+
},
|
|
1507
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
1508
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1509
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1510
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
1511
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1512
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1513
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
1514
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1515
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1516
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1517
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1518
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1519
|
+
});
|
|
1520
|
+
instances.add(proxy);
|
|
1521
|
+
return proxy;
|
|
1522
|
+
}
|
|
1523
|
+
$.$mol_delegate = $mol_delegate;
|
|
1524
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1525
|
+
value: (obj) => instances.has(obj),
|
|
1526
|
+
});
|
|
1527
|
+
})($ || ($ = {}));
|
|
1528
|
+
//mol/delegate/delegate.ts
|
|
1529
|
+
;
|
|
1530
|
+
"use strict";
|
|
1531
|
+
var $;
|
|
1532
|
+
(function ($) {
|
|
1533
|
+
$mol_test({
|
|
1534
|
+
'get'() {
|
|
1535
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1536
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1537
|
+
},
|
|
1538
|
+
'has'() {
|
|
1539
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1540
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1541
|
+
},
|
|
1542
|
+
'set'() {
|
|
1543
|
+
const target = { foo: 777 };
|
|
1544
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1545
|
+
proxy.foo = 123;
|
|
1546
|
+
$mol_assert_equal(target.foo, 123);
|
|
1547
|
+
},
|
|
1548
|
+
'getOwnPropertyDescriptor'() {
|
|
1549
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1550
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1551
|
+
value: 777,
|
|
1552
|
+
writable: true,
|
|
1553
|
+
enumerable: true,
|
|
1554
|
+
configurable: true,
|
|
1555
|
+
});
|
|
1556
|
+
},
|
|
1557
|
+
'ownKeys'() {
|
|
1558
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1559
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1560
|
+
},
|
|
1561
|
+
'getPrototypeOf'() {
|
|
1562
|
+
class Foo {
|
|
1563
|
+
}
|
|
1564
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1565
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1566
|
+
},
|
|
1567
|
+
'setPrototypeOf'() {
|
|
1568
|
+
class Foo {
|
|
1569
|
+
}
|
|
1570
|
+
const target = {};
|
|
1571
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1572
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1573
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1574
|
+
},
|
|
1575
|
+
'instanceof'() {
|
|
1576
|
+
class Foo {
|
|
1577
|
+
}
|
|
1578
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1579
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1580
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1581
|
+
},
|
|
1582
|
+
'autobind'() {
|
|
1583
|
+
class Foo {
|
|
1584
|
+
}
|
|
1585
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1586
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1587
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1588
|
+
},
|
|
1589
|
+
});
|
|
1590
|
+
})($ || ($ = {}));
|
|
1591
|
+
//mol/delegate/delegate.test.ts
|
|
1592
|
+
;
|
|
1593
|
+
"use strict";
|
|
1594
|
+
var $;
|
|
1655
1595
|
(function ($_1) {
|
|
1656
1596
|
$mol_test({
|
|
1657
|
-
'
|
|
1658
|
-
|
|
1659
|
-
$mol_assert_equal(
|
|
1660
|
-
$mol_assert_equal(
|
|
1661
|
-
$mol_assert_equal(
|
|
1597
|
+
'tree parsing'() {
|
|
1598
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1599
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1600
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1601
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1602
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1603
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1604
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1605
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1606
|
+
},
|
|
1607
|
+
'inserting'() {
|
|
1608
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1609
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1610
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1611
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1612
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1613
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1614
|
+
},
|
|
1615
|
+
'fromJSON'() {
|
|
1616
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1617
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1618
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1619
|
+
$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');
|
|
1620
|
+
$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');
|
|
1621
|
+
},
|
|
1622
|
+
'toJSON'() {
|
|
1623
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1624
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1625
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1626
|
+
$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"]');
|
|
1627
|
+
$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"}');
|
|
1628
|
+
},
|
|
1629
|
+
'hack'() {
|
|
1630
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1631
|
+
'': (tree, context) => [tree.hack(context)],
|
|
1632
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1633
|
+
});
|
|
1634
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1635
|
+
},
|
|
1636
|
+
'errors handling'($) {
|
|
1637
|
+
const errors = [];
|
|
1638
|
+
class Tree extends $mol_tree {
|
|
1639
|
+
static $ = $.$mol_ambient({
|
|
1640
|
+
$mol_fail: error => errors.push(error.message)
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
Tree.fromString(`
|
|
1644
|
+
\t \tfoo
|
|
1645
|
+
bar \\data
|
|
1646
|
+
`, 'test');
|
|
1647
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1662
1648
|
},
|
|
1663
1649
|
});
|
|
1664
1650
|
})($ || ($ = {}));
|
|
1665
|
-
//mol/
|
|
1651
|
+
//mol/tree/tree.test.ts
|
|
1666
1652
|
;
|
|
1667
1653
|
"use strict";
|
|
1668
1654
|
var $;
|
|
@@ -1698,6 +1684,20 @@ var $;
|
|
|
1698
1684
|
;
|
|
1699
1685
|
"use strict";
|
|
1700
1686
|
var $;
|
|
1687
|
+
(function ($_1) {
|
|
1688
|
+
$mol_test({
|
|
1689
|
+
'FQN of anon function'($) {
|
|
1690
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
1691
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
1692
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
1693
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
1694
|
+
},
|
|
1695
|
+
});
|
|
1696
|
+
})($ || ($ = {}));
|
|
1697
|
+
//mol/func/name/name.test.ts
|
|
1698
|
+
;
|
|
1699
|
+
"use strict";
|
|
1700
|
+
var $;
|
|
1701
1701
|
(function ($) {
|
|
1702
1702
|
$mol_test({
|
|
1703
1703
|
'Same text'() {
|