mol_mutable 0.0.47 → 0.0.49
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 +209 -209
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +65 -65
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -46,6 +46,24 @@ var $;
|
|
|
46
46
|
//mol/mutable/mutable.ts
|
|
47
47
|
;
|
|
48
48
|
"use strict";
|
|
49
|
+
//mol/type/error/error.ts
|
|
50
|
+
;
|
|
51
|
+
"use strict";
|
|
52
|
+
//mol/type/assert/assert.ts
|
|
53
|
+
;
|
|
54
|
+
"use strict";
|
|
55
|
+
//mol/type/assert/assert.test.ts
|
|
56
|
+
;
|
|
57
|
+
"use strict";
|
|
58
|
+
//mol/type/equals/equals.ts
|
|
59
|
+
;
|
|
60
|
+
"use strict";
|
|
61
|
+
//mol/type/equals/equals.test.ts
|
|
62
|
+
;
|
|
63
|
+
"use strict";
|
|
64
|
+
//mol/type/immutable/deep/deep/deep.test.ts
|
|
65
|
+
;
|
|
66
|
+
"use strict";
|
|
49
67
|
var $;
|
|
50
68
|
(function ($) {
|
|
51
69
|
function $mol_fail(error) {
|
|
@@ -429,27 +447,12 @@ var $;
|
|
|
429
447
|
//mol/dom/render/children/children.ts
|
|
430
448
|
;
|
|
431
449
|
"use strict";
|
|
432
|
-
//mol/type/
|
|
433
|
-
;
|
|
434
|
-
"use strict";
|
|
435
|
-
//mol/type/assert/assert.test.ts
|
|
436
|
-
;
|
|
437
|
-
"use strict";
|
|
438
|
-
//mol/type/assert/assert.ts
|
|
439
|
-
;
|
|
440
|
-
"use strict";
|
|
441
|
-
//mol/type/equals/equals.test.ts
|
|
442
|
-
;
|
|
443
|
-
"use strict";
|
|
444
|
-
//mol/type/equals/equals.ts
|
|
450
|
+
//mol/type/partial/deep/deep.ts
|
|
445
451
|
;
|
|
446
452
|
"use strict";
|
|
447
453
|
//mol/type/partial/deep/deep.test.ts
|
|
448
454
|
;
|
|
449
455
|
"use strict";
|
|
450
|
-
//mol/type/partial/deep/deep.ts
|
|
451
|
-
;
|
|
452
|
-
"use strict";
|
|
453
456
|
var $;
|
|
454
457
|
(function ($) {
|
|
455
458
|
$mol_test({
|
|
@@ -894,38 +897,6 @@ var $;
|
|
|
894
897
|
;
|
|
895
898
|
"use strict";
|
|
896
899
|
var $;
|
|
897
|
-
(function ($) {
|
|
898
|
-
$mol_test({
|
|
899
|
-
'must be false'() {
|
|
900
|
-
$mol_assert_not(0);
|
|
901
|
-
},
|
|
902
|
-
'must be true'() {
|
|
903
|
-
$mol_assert_ok(1);
|
|
904
|
-
},
|
|
905
|
-
'two must be equal'() {
|
|
906
|
-
$mol_assert_equal(2, 2);
|
|
907
|
-
},
|
|
908
|
-
'three must be equal'() {
|
|
909
|
-
$mol_assert_equal(2, 2, 2);
|
|
910
|
-
},
|
|
911
|
-
'two must be unique'() {
|
|
912
|
-
$mol_assert_unique([3], [3]);
|
|
913
|
-
},
|
|
914
|
-
'three must be unique'() {
|
|
915
|
-
$mol_assert_unique([3], [3], [3]);
|
|
916
|
-
},
|
|
917
|
-
'two must be alike'() {
|
|
918
|
-
$mol_assert_like([3], [3]);
|
|
919
|
-
},
|
|
920
|
-
'three must be alike'() {
|
|
921
|
-
$mol_assert_like([3], [3], [3]);
|
|
922
|
-
},
|
|
923
|
-
});
|
|
924
|
-
})($ || ($ = {}));
|
|
925
|
-
//mol/assert/assert.test.ts
|
|
926
|
-
;
|
|
927
|
-
"use strict";
|
|
928
|
-
var $;
|
|
929
900
|
(function ($) {
|
|
930
901
|
function $mol_assert_ok(value) {
|
|
931
902
|
if (value)
|
|
@@ -1019,118 +990,47 @@ var $;
|
|
|
1019
990
|
//mol/assert/assert.ts
|
|
1020
991
|
;
|
|
1021
992
|
"use strict";
|
|
1022
|
-
//mol/type/immutable/deep/deep/deep.test.ts
|
|
1023
|
-
;
|
|
1024
|
-
"use strict";
|
|
1025
|
-
var $;
|
|
1026
|
-
(function ($) {
|
|
1027
|
-
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
1028
|
-
function $mol_ambient(overrides) {
|
|
1029
|
-
return Object.setPrototypeOf(overrides, this || $);
|
|
1030
|
-
}
|
|
1031
|
-
$.$mol_ambient = $mol_ambient;
|
|
1032
|
-
})($ || ($ = {}));
|
|
1033
|
-
//mol/ambient/ambient.ts
|
|
1034
|
-
;
|
|
1035
|
-
"use strict";
|
|
1036
993
|
var $;
|
|
1037
994
|
(function ($) {
|
|
1038
995
|
$mol_test({
|
|
1039
|
-
'
|
|
1040
|
-
|
|
1041
|
-
$mol_assert_equal(proxy.foo, 777);
|
|
1042
|
-
},
|
|
1043
|
-
'has'() {
|
|
1044
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1045
|
-
$mol_assert_equal('foo' in proxy, true);
|
|
996
|
+
'must be false'() {
|
|
997
|
+
$mol_assert_not(0);
|
|
1046
998
|
},
|
|
1047
|
-
'
|
|
1048
|
-
|
|
1049
|
-
const proxy = $mol_delegate({}, () => target);
|
|
1050
|
-
proxy.foo = 123;
|
|
1051
|
-
$mol_assert_equal(target.foo, 123);
|
|
999
|
+
'must be true'() {
|
|
1000
|
+
$mol_assert_ok(1);
|
|
1052
1001
|
},
|
|
1053
|
-
'
|
|
1054
|
-
|
|
1055
|
-
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1056
|
-
value: 777,
|
|
1057
|
-
writable: true,
|
|
1058
|
-
enumerable: true,
|
|
1059
|
-
configurable: true,
|
|
1060
|
-
});
|
|
1002
|
+
'two must be equal'() {
|
|
1003
|
+
$mol_assert_equal(2, 2);
|
|
1061
1004
|
},
|
|
1062
|
-
'
|
|
1063
|
-
|
|
1064
|
-
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1005
|
+
'three must be equal'() {
|
|
1006
|
+
$mol_assert_equal(2, 2, 2);
|
|
1065
1007
|
},
|
|
1066
|
-
'
|
|
1067
|
-
|
|
1068
|
-
}
|
|
1069
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1070
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1008
|
+
'two must be unique'() {
|
|
1009
|
+
$mol_assert_unique([3], [3]);
|
|
1071
1010
|
},
|
|
1072
|
-
'
|
|
1073
|
-
|
|
1074
|
-
}
|
|
1075
|
-
const target = {};
|
|
1076
|
-
const proxy = $mol_delegate({}, () => target);
|
|
1077
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1078
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1011
|
+
'three must be unique'() {
|
|
1012
|
+
$mol_assert_unique([3], [3], [3]);
|
|
1079
1013
|
},
|
|
1080
|
-
'
|
|
1081
|
-
|
|
1082
|
-
}
|
|
1083
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1084
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
1085
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1014
|
+
'two must be alike'() {
|
|
1015
|
+
$mol_assert_like([3], [3]);
|
|
1086
1016
|
},
|
|
1087
|
-
'
|
|
1088
|
-
|
|
1089
|
-
}
|
|
1090
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1091
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
1092
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1017
|
+
'three must be alike'() {
|
|
1018
|
+
$mol_assert_like([3], [3], [3]);
|
|
1093
1019
|
},
|
|
1094
1020
|
});
|
|
1095
1021
|
})($ || ($ = {}));
|
|
1096
|
-
//mol/
|
|
1022
|
+
//mol/assert/assert.test.ts
|
|
1097
1023
|
;
|
|
1098
1024
|
"use strict";
|
|
1099
1025
|
var $;
|
|
1100
1026
|
(function ($) {
|
|
1101
|
-
|
|
1102
|
-
function $
|
|
1103
|
-
|
|
1104
|
-
get: (_, field) => {
|
|
1105
|
-
const obj = target();
|
|
1106
|
-
let val = Reflect.get(obj, field);
|
|
1107
|
-
if (typeof val === 'function') {
|
|
1108
|
-
val = val.bind(obj);
|
|
1109
|
-
}
|
|
1110
|
-
return val;
|
|
1111
|
-
},
|
|
1112
|
-
has: (_, field) => Reflect.has(target(), field),
|
|
1113
|
-
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1114
|
-
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1115
|
-
ownKeys: () => Reflect.ownKeys(target()),
|
|
1116
|
-
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1117
|
-
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1118
|
-
isExtensible: () => Reflect.isExtensible(target()),
|
|
1119
|
-
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1120
|
-
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1121
|
-
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1122
|
-
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1123
|
-
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1124
|
-
});
|
|
1125
|
-
instances.add(proxy);
|
|
1126
|
-
return proxy;
|
|
1027
|
+
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
1028
|
+
function $mol_ambient(overrides) {
|
|
1029
|
+
return Object.setPrototypeOf(overrides, this || $);
|
|
1127
1030
|
}
|
|
1128
|
-
$.$
|
|
1129
|
-
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1130
|
-
value: (obj) => instances.has(obj),
|
|
1131
|
-
});
|
|
1031
|
+
$.$mol_ambient = $mol_ambient;
|
|
1132
1032
|
})($ || ($ = {}));
|
|
1133
|
-
//mol/
|
|
1033
|
+
//mol/ambient/ambient.ts
|
|
1134
1034
|
;
|
|
1135
1035
|
"use strict";
|
|
1136
1036
|
var $;
|
|
@@ -1189,10 +1089,10 @@ var $;
|
|
|
1189
1089
|
//mol/owning/owning.ts
|
|
1190
1090
|
;
|
|
1191
1091
|
"use strict";
|
|
1192
|
-
//mol/type/writable/writable.
|
|
1092
|
+
//mol/type/writable/writable.ts
|
|
1193
1093
|
;
|
|
1194
1094
|
"use strict";
|
|
1195
|
-
//mol/type/writable/writable.ts
|
|
1095
|
+
//mol/type/writable/writable.test.ts
|
|
1196
1096
|
;
|
|
1197
1097
|
"use strict";
|
|
1198
1098
|
var $;
|
|
@@ -1239,66 +1139,6 @@ var $;
|
|
|
1239
1139
|
;
|
|
1240
1140
|
"use strict";
|
|
1241
1141
|
var $;
|
|
1242
|
-
(function ($_1) {
|
|
1243
|
-
$mol_test({
|
|
1244
|
-
'tree parsing'() {
|
|
1245
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1246
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1247
|
-
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1248
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1249
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1250
|
-
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1251
|
-
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1252
|
-
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1253
|
-
},
|
|
1254
|
-
'inserting'() {
|
|
1255
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1256
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1257
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1258
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1259
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1260
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1261
|
-
},
|
|
1262
|
-
'fromJSON'() {
|
|
1263
|
-
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1264
|
-
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1265
|
-
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1266
|
-
$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');
|
|
1267
|
-
$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');
|
|
1268
|
-
},
|
|
1269
|
-
'toJSON'() {
|
|
1270
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1271
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1272
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1273
|
-
$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"]');
|
|
1274
|
-
$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"}');
|
|
1275
|
-
},
|
|
1276
|
-
'hack'() {
|
|
1277
|
-
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1278
|
-
'': (tree, context) => [tree.hack(context)],
|
|
1279
|
-
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1280
|
-
});
|
|
1281
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1282
|
-
},
|
|
1283
|
-
'errors handling'($) {
|
|
1284
|
-
const errors = [];
|
|
1285
|
-
class Tree extends $mol_tree {
|
|
1286
|
-
static $ = $.$mol_ambient({
|
|
1287
|
-
$mol_fail: error => errors.push(error.message)
|
|
1288
|
-
});
|
|
1289
|
-
}
|
|
1290
|
-
Tree.fromString(`
|
|
1291
|
-
\t \tfoo
|
|
1292
|
-
bar \\data
|
|
1293
|
-
`, 'test');
|
|
1294
|
-
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1295
|
-
},
|
|
1296
|
-
});
|
|
1297
|
-
})($ || ($ = {}));
|
|
1298
|
-
//mol/tree/tree.test.ts
|
|
1299
|
-
;
|
|
1300
|
-
"use strict";
|
|
1301
|
-
var $;
|
|
1302
1142
|
(function ($) {
|
|
1303
1143
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1304
1144
|
class $mol_tree extends $mol_object2 {
|
|
@@ -1629,17 +1469,163 @@ var $;
|
|
|
1629
1469
|
;
|
|
1630
1470
|
"use strict";
|
|
1631
1471
|
var $;
|
|
1472
|
+
(function ($) {
|
|
1473
|
+
const instances = new WeakSet();
|
|
1474
|
+
function $mol_delegate(proto, target) {
|
|
1475
|
+
const proxy = new Proxy(proto, {
|
|
1476
|
+
get: (_, field) => {
|
|
1477
|
+
const obj = target();
|
|
1478
|
+
let val = Reflect.get(obj, field);
|
|
1479
|
+
if (typeof val === 'function') {
|
|
1480
|
+
val = val.bind(obj);
|
|
1481
|
+
}
|
|
1482
|
+
return val;
|
|
1483
|
+
},
|
|
1484
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
1485
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1486
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1487
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
1488
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1489
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1490
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
1491
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1492
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1493
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1494
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1495
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1496
|
+
});
|
|
1497
|
+
instances.add(proxy);
|
|
1498
|
+
return proxy;
|
|
1499
|
+
}
|
|
1500
|
+
$.$mol_delegate = $mol_delegate;
|
|
1501
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1502
|
+
value: (obj) => instances.has(obj),
|
|
1503
|
+
});
|
|
1504
|
+
})($ || ($ = {}));
|
|
1505
|
+
//mol/delegate/delegate.ts
|
|
1506
|
+
;
|
|
1507
|
+
"use strict";
|
|
1508
|
+
var $;
|
|
1509
|
+
(function ($) {
|
|
1510
|
+
$mol_test({
|
|
1511
|
+
'get'() {
|
|
1512
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1513
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1514
|
+
},
|
|
1515
|
+
'has'() {
|
|
1516
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1517
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1518
|
+
},
|
|
1519
|
+
'set'() {
|
|
1520
|
+
const target = { foo: 777 };
|
|
1521
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1522
|
+
proxy.foo = 123;
|
|
1523
|
+
$mol_assert_equal(target.foo, 123);
|
|
1524
|
+
},
|
|
1525
|
+
'getOwnPropertyDescriptor'() {
|
|
1526
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1527
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1528
|
+
value: 777,
|
|
1529
|
+
writable: true,
|
|
1530
|
+
enumerable: true,
|
|
1531
|
+
configurable: true,
|
|
1532
|
+
});
|
|
1533
|
+
},
|
|
1534
|
+
'ownKeys'() {
|
|
1535
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1536
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1537
|
+
},
|
|
1538
|
+
'getPrototypeOf'() {
|
|
1539
|
+
class Foo {
|
|
1540
|
+
}
|
|
1541
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1542
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1543
|
+
},
|
|
1544
|
+
'setPrototypeOf'() {
|
|
1545
|
+
class Foo {
|
|
1546
|
+
}
|
|
1547
|
+
const target = {};
|
|
1548
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1549
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1550
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1551
|
+
},
|
|
1552
|
+
'instanceof'() {
|
|
1553
|
+
class Foo {
|
|
1554
|
+
}
|
|
1555
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1556
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1557
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1558
|
+
},
|
|
1559
|
+
'autobind'() {
|
|
1560
|
+
class Foo {
|
|
1561
|
+
}
|
|
1562
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1563
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1564
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1565
|
+
},
|
|
1566
|
+
});
|
|
1567
|
+
})($ || ($ = {}));
|
|
1568
|
+
//mol/delegate/delegate.test.ts
|
|
1569
|
+
;
|
|
1570
|
+
"use strict";
|
|
1571
|
+
var $;
|
|
1632
1572
|
(function ($_1) {
|
|
1633
1573
|
$mol_test({
|
|
1634
|
-
'
|
|
1635
|
-
|
|
1636
|
-
$mol_assert_equal(
|
|
1637
|
-
$mol_assert_equal(
|
|
1638
|
-
$mol_assert_equal(
|
|
1574
|
+
'tree parsing'() {
|
|
1575
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1576
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1577
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1578
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1579
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1580
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1581
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1582
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1583
|
+
},
|
|
1584
|
+
'inserting'() {
|
|
1585
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1586
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1587
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1588
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1589
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1590
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1591
|
+
},
|
|
1592
|
+
'fromJSON'() {
|
|
1593
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1594
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1595
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1596
|
+
$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');
|
|
1597
|
+
$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');
|
|
1598
|
+
},
|
|
1599
|
+
'toJSON'() {
|
|
1600
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1601
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1602
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1603
|
+
$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"]');
|
|
1604
|
+
$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"}');
|
|
1605
|
+
},
|
|
1606
|
+
'hack'() {
|
|
1607
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1608
|
+
'': (tree, context) => [tree.hack(context)],
|
|
1609
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1610
|
+
});
|
|
1611
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1612
|
+
},
|
|
1613
|
+
'errors handling'($) {
|
|
1614
|
+
const errors = [];
|
|
1615
|
+
class Tree extends $mol_tree {
|
|
1616
|
+
static $ = $.$mol_ambient({
|
|
1617
|
+
$mol_fail: error => errors.push(error.message)
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
Tree.fromString(`
|
|
1621
|
+
\t \tfoo
|
|
1622
|
+
bar \\data
|
|
1623
|
+
`, 'test');
|
|
1624
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1639
1625
|
},
|
|
1640
1626
|
});
|
|
1641
1627
|
})($ || ($ = {}));
|
|
1642
|
-
//mol/
|
|
1628
|
+
//mol/tree/tree.test.ts
|
|
1643
1629
|
;
|
|
1644
1630
|
"use strict";
|
|
1645
1631
|
var $;
|
|
@@ -1675,6 +1661,20 @@ var $;
|
|
|
1675
1661
|
;
|
|
1676
1662
|
"use strict";
|
|
1677
1663
|
var $;
|
|
1664
|
+
(function ($_1) {
|
|
1665
|
+
$mol_test({
|
|
1666
|
+
'FQN of anon function'($) {
|
|
1667
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
1668
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
1669
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
1670
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
1671
|
+
},
|
|
1672
|
+
});
|
|
1673
|
+
})($ || ($ = {}));
|
|
1674
|
+
//mol/func/name/name.test.ts
|
|
1675
|
+
;
|
|
1676
|
+
"use strict";
|
|
1677
|
+
var $;
|
|
1678
1678
|
(function ($) {
|
|
1679
1679
|
$mol_test({
|
|
1680
1680
|
'Wrap & unwrap'() {
|