mol_mutable 0.0.49 → 0.0.50
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,24 +46,6 @@ 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";
|
|
67
49
|
var $;
|
|
68
50
|
(function ($) {
|
|
69
51
|
function $mol_fail(error) {
|
|
@@ -447,12 +429,27 @@ var $;
|
|
|
447
429
|
//mol/dom/render/children/children.ts
|
|
448
430
|
;
|
|
449
431
|
"use strict";
|
|
450
|
-
//mol/type/
|
|
432
|
+
//mol/type/error/error.ts
|
|
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
|
|
451
445
|
;
|
|
452
446
|
"use strict";
|
|
453
447
|
//mol/type/partial/deep/deep.test.ts
|
|
454
448
|
;
|
|
455
449
|
"use strict";
|
|
450
|
+
//mol/type/partial/deep/deep.ts
|
|
451
|
+
;
|
|
452
|
+
"use strict";
|
|
456
453
|
var $;
|
|
457
454
|
(function ($) {
|
|
458
455
|
$mol_test({
|
|
@@ -897,6 +894,38 @@ var $;
|
|
|
897
894
|
;
|
|
898
895
|
"use strict";
|
|
899
896
|
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 $;
|
|
900
929
|
(function ($) {
|
|
901
930
|
function $mol_assert_ok(value) {
|
|
902
931
|
if (value)
|
|
@@ -990,47 +1019,118 @@ var $;
|
|
|
990
1019
|
//mol/assert/assert.ts
|
|
991
1020
|
;
|
|
992
1021
|
"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";
|
|
993
1036
|
var $;
|
|
994
1037
|
(function ($) {
|
|
995
1038
|
$mol_test({
|
|
996
|
-
'
|
|
997
|
-
$
|
|
1039
|
+
'get'() {
|
|
1040
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1041
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
998
1042
|
},
|
|
999
|
-
'
|
|
1000
|
-
$
|
|
1043
|
+
'has'() {
|
|
1044
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1045
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1001
1046
|
},
|
|
1002
|
-
'
|
|
1003
|
-
|
|
1047
|
+
'set'() {
|
|
1048
|
+
const target = { foo: 777 };
|
|
1049
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1050
|
+
proxy.foo = 123;
|
|
1051
|
+
$mol_assert_equal(target.foo, 123);
|
|
1004
1052
|
},
|
|
1005
|
-
'
|
|
1006
|
-
$
|
|
1053
|
+
'getOwnPropertyDescriptor'() {
|
|
1054
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1055
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1056
|
+
value: 777,
|
|
1057
|
+
writable: true,
|
|
1058
|
+
enumerable: true,
|
|
1059
|
+
configurable: true,
|
|
1060
|
+
});
|
|
1007
1061
|
},
|
|
1008
|
-
'
|
|
1009
|
-
$
|
|
1062
|
+
'ownKeys'() {
|
|
1063
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1064
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1010
1065
|
},
|
|
1011
|
-
'
|
|
1012
|
-
|
|
1066
|
+
'getPrototypeOf'() {
|
|
1067
|
+
class Foo {
|
|
1068
|
+
}
|
|
1069
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1070
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1013
1071
|
},
|
|
1014
|
-
'
|
|
1015
|
-
|
|
1072
|
+
'setPrototypeOf'() {
|
|
1073
|
+
class Foo {
|
|
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);
|
|
1016
1079
|
},
|
|
1017
|
-
'
|
|
1018
|
-
|
|
1080
|
+
'instanceof'() {
|
|
1081
|
+
class Foo {
|
|
1082
|
+
}
|
|
1083
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1084
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1085
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1086
|
+
},
|
|
1087
|
+
'autobind'() {
|
|
1088
|
+
class Foo {
|
|
1089
|
+
}
|
|
1090
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1091
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1092
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1019
1093
|
},
|
|
1020
1094
|
});
|
|
1021
1095
|
})($ || ($ = {}));
|
|
1022
|
-
//mol/
|
|
1096
|
+
//mol/delegate/delegate.test.ts
|
|
1023
1097
|
;
|
|
1024
1098
|
"use strict";
|
|
1025
1099
|
var $;
|
|
1026
1100
|
(function ($) {
|
|
1027
|
-
|
|
1028
|
-
function $
|
|
1029
|
-
|
|
1101
|
+
const instances = new WeakSet();
|
|
1102
|
+
function $mol_delegate(proto, target) {
|
|
1103
|
+
const proxy = new Proxy(proto, {
|
|
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;
|
|
1030
1127
|
}
|
|
1031
|
-
$.$
|
|
1128
|
+
$.$mol_delegate = $mol_delegate;
|
|
1129
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1130
|
+
value: (obj) => instances.has(obj),
|
|
1131
|
+
});
|
|
1032
1132
|
})($ || ($ = {}));
|
|
1033
|
-
//mol/
|
|
1133
|
+
//mol/delegate/delegate.ts
|
|
1034
1134
|
;
|
|
1035
1135
|
"use strict";
|
|
1036
1136
|
var $;
|
|
@@ -1089,10 +1189,10 @@ var $;
|
|
|
1089
1189
|
//mol/owning/owning.ts
|
|
1090
1190
|
;
|
|
1091
1191
|
"use strict";
|
|
1092
|
-
//mol/type/writable/writable.ts
|
|
1192
|
+
//mol/type/writable/writable.test.ts
|
|
1093
1193
|
;
|
|
1094
1194
|
"use strict";
|
|
1095
|
-
//mol/type/writable/writable.
|
|
1195
|
+
//mol/type/writable/writable.ts
|
|
1096
1196
|
;
|
|
1097
1197
|
"use strict";
|
|
1098
1198
|
var $;
|
|
@@ -1139,6 +1239,66 @@ var $;
|
|
|
1139
1239
|
;
|
|
1140
1240
|
"use strict";
|
|
1141
1241
|
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 $;
|
|
1142
1302
|
(function ($) {
|
|
1143
1303
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1144
1304
|
class $mol_tree extends $mol_object2 {
|
|
@@ -1469,163 +1629,17 @@ var $;
|
|
|
1469
1629
|
;
|
|
1470
1630
|
"use strict";
|
|
1471
1631
|
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 $;
|
|
1572
1632
|
(function ($_1) {
|
|
1573
1633
|
$mol_test({
|
|
1574
|
-
'
|
|
1575
|
-
|
|
1576
|
-
$mol_assert_equal(
|
|
1577
|
-
$mol_assert_equal(
|
|
1578
|
-
$mol_assert_equal(
|
|
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']);
|
|
1634
|
+
'FQN of anon function'($) {
|
|
1635
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
1636
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
1637
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
1638
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
1625
1639
|
},
|
|
1626
1640
|
});
|
|
1627
1641
|
})($ || ($ = {}));
|
|
1628
|
-
//mol/
|
|
1642
|
+
//mol/func/name/name.test.ts
|
|
1629
1643
|
;
|
|
1630
1644
|
"use strict";
|
|
1631
1645
|
var $;
|
|
@@ -1661,20 +1675,6 @@ var $;
|
|
|
1661
1675
|
;
|
|
1662
1676
|
"use strict";
|
|
1663
1677
|
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'() {
|