mol_text_distance 0.0.301 → 0.0.302
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,21 +455,27 @@ var $;
|
|
|
455
455
|
//mol/dom/render/children/children.ts
|
|
456
456
|
;
|
|
457
457
|
"use strict";
|
|
458
|
-
//mol/type/
|
|
458
|
+
//mol/type/error/error.ts
|
|
459
459
|
;
|
|
460
460
|
"use strict";
|
|
461
|
-
//mol/type/
|
|
461
|
+
//mol/type/assert/assert.test.ts
|
|
462
462
|
;
|
|
463
463
|
"use strict";
|
|
464
464
|
//mol/type/assert/assert.ts
|
|
465
465
|
;
|
|
466
466
|
"use strict";
|
|
467
|
-
//mol/type/
|
|
467
|
+
//mol/type/equals/equals.test.ts
|
|
468
|
+
;
|
|
469
|
+
"use strict";
|
|
470
|
+
//mol/type/equals/equals.ts
|
|
468
471
|
;
|
|
469
472
|
"use strict";
|
|
470
473
|
//mol/type/partial/deep/deep.test.ts
|
|
471
474
|
;
|
|
472
475
|
"use strict";
|
|
476
|
+
//mol/type/partial/deep/deep.ts
|
|
477
|
+
;
|
|
478
|
+
"use strict";
|
|
473
479
|
var $;
|
|
474
480
|
(function ($) {
|
|
475
481
|
$mol_test({
|
|
@@ -914,6 +920,38 @@ var $;
|
|
|
914
920
|
;
|
|
915
921
|
"use strict";
|
|
916
922
|
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 $;
|
|
917
955
|
(function ($) {
|
|
918
956
|
function $mol_assert_ok(value) {
|
|
919
957
|
if (value)
|
|
@@ -1008,46 +1046,114 @@ var $;
|
|
|
1008
1046
|
;
|
|
1009
1047
|
"use strict";
|
|
1010
1048
|
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 $;
|
|
1011
1060
|
(function ($) {
|
|
1012
1061
|
$mol_test({
|
|
1013
|
-
'
|
|
1014
|
-
$
|
|
1062
|
+
'get'() {
|
|
1063
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1064
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1015
1065
|
},
|
|
1016
|
-
'
|
|
1017
|
-
$
|
|
1066
|
+
'has'() {
|
|
1067
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1068
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1018
1069
|
},
|
|
1019
|
-
'
|
|
1020
|
-
|
|
1070
|
+
'set'() {
|
|
1071
|
+
const target = { foo: 777 };
|
|
1072
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1073
|
+
proxy.foo = 123;
|
|
1074
|
+
$mol_assert_equal(target.foo, 123);
|
|
1021
1075
|
},
|
|
1022
|
-
'
|
|
1023
|
-
$
|
|
1076
|
+
'getOwnPropertyDescriptor'() {
|
|
1077
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1078
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1079
|
+
value: 777,
|
|
1080
|
+
writable: true,
|
|
1081
|
+
enumerable: true,
|
|
1082
|
+
configurable: true,
|
|
1083
|
+
});
|
|
1024
1084
|
},
|
|
1025
|
-
'
|
|
1026
|
-
$
|
|
1085
|
+
'ownKeys'() {
|
|
1086
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1087
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1027
1088
|
},
|
|
1028
|
-
'
|
|
1029
|
-
|
|
1089
|
+
'getPrototypeOf'() {
|
|
1090
|
+
class Foo {
|
|
1091
|
+
}
|
|
1092
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1093
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1030
1094
|
},
|
|
1031
|
-
'
|
|
1032
|
-
|
|
1095
|
+
'setPrototypeOf'() {
|
|
1096
|
+
class Foo {
|
|
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);
|
|
1033
1102
|
},
|
|
1034
|
-
'
|
|
1035
|
-
|
|
1103
|
+
'instanceof'() {
|
|
1104
|
+
class Foo {
|
|
1105
|
+
}
|
|
1106
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1107
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1108
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1109
|
+
},
|
|
1110
|
+
'autobind'() {
|
|
1111
|
+
class Foo {
|
|
1112
|
+
}
|
|
1113
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1114
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1115
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1036
1116
|
},
|
|
1037
1117
|
});
|
|
1038
1118
|
})($ || ($ = {}));
|
|
1039
|
-
//mol/
|
|
1119
|
+
//mol/delegate/delegate.test.ts
|
|
1040
1120
|
;
|
|
1041
1121
|
"use strict";
|
|
1042
1122
|
var $;
|
|
1043
1123
|
(function ($) {
|
|
1044
|
-
|
|
1045
|
-
function $
|
|
1046
|
-
|
|
1124
|
+
const instances = new WeakSet();
|
|
1125
|
+
function $mol_delegate(proto, target) {
|
|
1126
|
+
const proxy = new Proxy(proto, {
|
|
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;
|
|
1047
1150
|
}
|
|
1048
|
-
$.$
|
|
1151
|
+
$.$mol_delegate = $mol_delegate;
|
|
1152
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1153
|
+
value: (obj) => instances.has(obj),
|
|
1154
|
+
});
|
|
1049
1155
|
})($ || ($ = {}));
|
|
1050
|
-
//mol/
|
|
1156
|
+
//mol/delegate/delegate.ts
|
|
1051
1157
|
;
|
|
1052
1158
|
"use strict";
|
|
1053
1159
|
var $;
|
|
@@ -1106,16 +1212,10 @@ var $;
|
|
|
1106
1212
|
//mol/owning/owning.ts
|
|
1107
1213
|
;
|
|
1108
1214
|
"use strict";
|
|
1109
|
-
//mol/type/writable/writable.ts
|
|
1110
|
-
;
|
|
1111
|
-
"use strict";
|
|
1112
|
-
//mol/type/equals/equals.ts
|
|
1113
|
-
;
|
|
1114
|
-
"use strict";
|
|
1115
|
-
//mol/type/equals/equals.test.ts
|
|
1215
|
+
//mol/type/writable/writable.test.ts
|
|
1116
1216
|
;
|
|
1117
1217
|
"use strict";
|
|
1118
|
-
//mol/type/writable/writable.
|
|
1218
|
+
//mol/type/writable/writable.ts
|
|
1119
1219
|
;
|
|
1120
1220
|
"use strict";
|
|
1121
1221
|
var $;
|
|
@@ -1162,6 +1262,66 @@ var $;
|
|
|
1162
1262
|
;
|
|
1163
1263
|
"use strict";
|
|
1164
1264
|
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 $;
|
|
1165
1325
|
(function ($) {
|
|
1166
1326
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1167
1327
|
class $mol_tree extends $mol_object2 {
|
|
@@ -1492,163 +1652,17 @@ var $;
|
|
|
1492
1652
|
;
|
|
1493
1653
|
"use strict";
|
|
1494
1654
|
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 $;
|
|
1595
1655
|
(function ($_1) {
|
|
1596
1656
|
$mol_test({
|
|
1597
|
-
'
|
|
1598
|
-
|
|
1599
|
-
$mol_assert_equal(
|
|
1600
|
-
$mol_assert_equal(
|
|
1601
|
-
$mol_assert_equal(
|
|
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']);
|
|
1657
|
+
'FQN of anon function'($) {
|
|
1658
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
1659
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
1660
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
1661
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
1648
1662
|
},
|
|
1649
1663
|
});
|
|
1650
1664
|
})($ || ($ = {}));
|
|
1651
|
-
//mol/
|
|
1665
|
+
//mol/func/name/name.test.ts
|
|
1652
1666
|
;
|
|
1653
1667
|
"use strict";
|
|
1654
1668
|
var $;
|
|
@@ -1684,20 +1698,6 @@ var $;
|
|
|
1684
1698
|
;
|
|
1685
1699
|
"use strict";
|
|
1686
1700
|
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'() {
|