mol_key 0.0.390 → 0.0.392
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 +210 -210
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +46 -46
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -413,38 +413,6 @@ var $;
|
|
|
413
413
|
;
|
|
414
414
|
"use strict";
|
|
415
415
|
var $;
|
|
416
|
-
(function ($) {
|
|
417
|
-
$mol_test({
|
|
418
|
-
'must be false'() {
|
|
419
|
-
$mol_assert_not(0);
|
|
420
|
-
},
|
|
421
|
-
'must be true'() {
|
|
422
|
-
$mol_assert_ok(1);
|
|
423
|
-
},
|
|
424
|
-
'two must be equal'() {
|
|
425
|
-
$mol_assert_equal(2, 2);
|
|
426
|
-
},
|
|
427
|
-
'three must be equal'() {
|
|
428
|
-
$mol_assert_equal(2, 2, 2);
|
|
429
|
-
},
|
|
430
|
-
'two must be unique'() {
|
|
431
|
-
$mol_assert_unique([3], [3]);
|
|
432
|
-
},
|
|
433
|
-
'three must be unique'() {
|
|
434
|
-
$mol_assert_unique([3], [3], [3]);
|
|
435
|
-
},
|
|
436
|
-
'two must be alike'() {
|
|
437
|
-
$mol_assert_like([3], [3]);
|
|
438
|
-
},
|
|
439
|
-
'three must be alike'() {
|
|
440
|
-
$mol_assert_like([3], [3], [3]);
|
|
441
|
-
},
|
|
442
|
-
});
|
|
443
|
-
})($ || ($ = {}));
|
|
444
|
-
//mol/assert/assert.test.ts
|
|
445
|
-
;
|
|
446
|
-
"use strict";
|
|
447
|
-
var $;
|
|
448
416
|
(function ($) {
|
|
449
417
|
function $mol_assert_ok(value) {
|
|
450
418
|
if (value)
|
|
@@ -539,17 +507,35 @@ var $;
|
|
|
539
507
|
;
|
|
540
508
|
"use strict";
|
|
541
509
|
var $;
|
|
542
|
-
(function ($
|
|
510
|
+
(function ($) {
|
|
543
511
|
$mol_test({
|
|
544
|
-
'
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
$
|
|
512
|
+
'must be false'() {
|
|
513
|
+
$mol_assert_not(0);
|
|
514
|
+
},
|
|
515
|
+
'must be true'() {
|
|
516
|
+
$mol_assert_ok(1);
|
|
517
|
+
},
|
|
518
|
+
'two must be equal'() {
|
|
519
|
+
$mol_assert_equal(2, 2);
|
|
520
|
+
},
|
|
521
|
+
'three must be equal'() {
|
|
522
|
+
$mol_assert_equal(2, 2, 2);
|
|
523
|
+
},
|
|
524
|
+
'two must be unique'() {
|
|
525
|
+
$mol_assert_unique([3], [3]);
|
|
526
|
+
},
|
|
527
|
+
'three must be unique'() {
|
|
528
|
+
$mol_assert_unique([3], [3], [3]);
|
|
529
|
+
},
|
|
530
|
+
'two must be alike'() {
|
|
531
|
+
$mol_assert_like([3], [3]);
|
|
532
|
+
},
|
|
533
|
+
'three must be alike'() {
|
|
534
|
+
$mol_assert_like([3], [3], [3]);
|
|
549
535
|
},
|
|
550
536
|
});
|
|
551
537
|
})($ || ($ = {}));
|
|
552
|
-
//mol/
|
|
538
|
+
//mol/assert/assert.test.ts
|
|
553
539
|
;
|
|
554
540
|
"use strict";
|
|
555
541
|
var $;
|
|
@@ -585,6 +571,20 @@ var $;
|
|
|
585
571
|
;
|
|
586
572
|
"use strict";
|
|
587
573
|
var $;
|
|
574
|
+
(function ($_1) {
|
|
575
|
+
$mol_test({
|
|
576
|
+
'FQN of anon function'($) {
|
|
577
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
578
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
579
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
580
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
581
|
+
},
|
|
582
|
+
});
|
|
583
|
+
})($ || ($ = {}));
|
|
584
|
+
//mol/func/name/name.test.ts
|
|
585
|
+
;
|
|
586
|
+
"use strict";
|
|
587
|
+
var $;
|
|
588
588
|
(function ($) {
|
|
589
589
|
function $mol_dom_render_children(el, childNodes) {
|
|
590
590
|
const node_set = new Set(childNodes);
|
|
@@ -639,27 +639,21 @@ var $;
|
|
|
639
639
|
//mol/dom/render/children/children.ts
|
|
640
640
|
;
|
|
641
641
|
"use strict";
|
|
642
|
-
//mol/type/
|
|
642
|
+
//mol/type/partial/deep/deep.ts
|
|
643
643
|
;
|
|
644
644
|
"use strict";
|
|
645
|
-
//mol/type/
|
|
645
|
+
//mol/type/error/error.ts
|
|
646
646
|
;
|
|
647
647
|
"use strict";
|
|
648
648
|
//mol/type/assert/assert.ts
|
|
649
649
|
;
|
|
650
650
|
"use strict";
|
|
651
|
-
//mol/type/
|
|
652
|
-
;
|
|
653
|
-
"use strict";
|
|
654
|
-
//mol/type/equals/equals.ts
|
|
651
|
+
//mol/type/assert/assert.test.ts
|
|
655
652
|
;
|
|
656
653
|
"use strict";
|
|
657
654
|
//mol/type/partial/deep/deep.test.ts
|
|
658
655
|
;
|
|
659
656
|
"use strict";
|
|
660
|
-
//mol/type/partial/deep/deep.ts
|
|
661
|
-
;
|
|
662
|
-
"use strict";
|
|
663
657
|
var $;
|
|
664
658
|
(function ($) {
|
|
665
659
|
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
@@ -672,106 +666,6 @@ var $;
|
|
|
672
666
|
;
|
|
673
667
|
"use strict";
|
|
674
668
|
var $;
|
|
675
|
-
(function ($) {
|
|
676
|
-
$mol_test({
|
|
677
|
-
'get'() {
|
|
678
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
679
|
-
$mol_assert_equal(proxy.foo, 777);
|
|
680
|
-
},
|
|
681
|
-
'has'() {
|
|
682
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
683
|
-
$mol_assert_equal('foo' in proxy, true);
|
|
684
|
-
},
|
|
685
|
-
'set'() {
|
|
686
|
-
const target = { foo: 777 };
|
|
687
|
-
const proxy = $mol_delegate({}, () => target);
|
|
688
|
-
proxy.foo = 123;
|
|
689
|
-
$mol_assert_equal(target.foo, 123);
|
|
690
|
-
},
|
|
691
|
-
'getOwnPropertyDescriptor'() {
|
|
692
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
693
|
-
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
694
|
-
value: 777,
|
|
695
|
-
writable: true,
|
|
696
|
-
enumerable: true,
|
|
697
|
-
configurable: true,
|
|
698
|
-
});
|
|
699
|
-
},
|
|
700
|
-
'ownKeys'() {
|
|
701
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
702
|
-
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
703
|
-
},
|
|
704
|
-
'getPrototypeOf'() {
|
|
705
|
-
class Foo {
|
|
706
|
-
}
|
|
707
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
708
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
709
|
-
},
|
|
710
|
-
'setPrototypeOf'() {
|
|
711
|
-
class Foo {
|
|
712
|
-
}
|
|
713
|
-
const target = {};
|
|
714
|
-
const proxy = $mol_delegate({}, () => target);
|
|
715
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
716
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
717
|
-
},
|
|
718
|
-
'instanceof'() {
|
|
719
|
-
class Foo {
|
|
720
|
-
}
|
|
721
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
722
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
723
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
724
|
-
},
|
|
725
|
-
'autobind'() {
|
|
726
|
-
class Foo {
|
|
727
|
-
}
|
|
728
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
729
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
730
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
731
|
-
},
|
|
732
|
-
});
|
|
733
|
-
})($ || ($ = {}));
|
|
734
|
-
//mol/delegate/delegate.test.ts
|
|
735
|
-
;
|
|
736
|
-
"use strict";
|
|
737
|
-
var $;
|
|
738
|
-
(function ($) {
|
|
739
|
-
const instances = new WeakSet();
|
|
740
|
-
function $mol_delegate(proto, target) {
|
|
741
|
-
const proxy = new Proxy(proto, {
|
|
742
|
-
get: (_, field) => {
|
|
743
|
-
const obj = target();
|
|
744
|
-
let val = Reflect.get(obj, field);
|
|
745
|
-
if (typeof val === 'function') {
|
|
746
|
-
val = val.bind(obj);
|
|
747
|
-
}
|
|
748
|
-
return val;
|
|
749
|
-
},
|
|
750
|
-
has: (_, field) => Reflect.has(target(), field),
|
|
751
|
-
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
752
|
-
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
753
|
-
ownKeys: () => Reflect.ownKeys(target()),
|
|
754
|
-
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
755
|
-
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
756
|
-
isExtensible: () => Reflect.isExtensible(target()),
|
|
757
|
-
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
758
|
-
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
759
|
-
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
760
|
-
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
761
|
-
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
762
|
-
});
|
|
763
|
-
instances.add(proxy);
|
|
764
|
-
return proxy;
|
|
765
|
-
}
|
|
766
|
-
$.$mol_delegate = $mol_delegate;
|
|
767
|
-
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
768
|
-
value: (obj) => instances.has(obj),
|
|
769
|
-
});
|
|
770
|
-
})($ || ($ = {}));
|
|
771
|
-
//mol/delegate/delegate.ts
|
|
772
|
-
;
|
|
773
|
-
"use strict";
|
|
774
|
-
var $;
|
|
775
669
|
(function ($) {
|
|
776
670
|
$.$mol_owning_map = new WeakMap();
|
|
777
671
|
function $mol_owning_allow(having) {
|
|
@@ -827,10 +721,16 @@ var $;
|
|
|
827
721
|
//mol/owning/owning.ts
|
|
828
722
|
;
|
|
829
723
|
"use strict";
|
|
830
|
-
//mol/type/writable/writable.
|
|
724
|
+
//mol/type/writable/writable.ts
|
|
831
725
|
;
|
|
832
726
|
"use strict";
|
|
833
|
-
//mol/type/
|
|
727
|
+
//mol/type/equals/equals.ts
|
|
728
|
+
;
|
|
729
|
+
"use strict";
|
|
730
|
+
//mol/type/equals/equals.test.ts
|
|
731
|
+
;
|
|
732
|
+
"use strict";
|
|
733
|
+
//mol/type/writable/writable.test.ts
|
|
834
734
|
;
|
|
835
735
|
"use strict";
|
|
836
736
|
var $;
|
|
@@ -877,66 +777,6 @@ var $;
|
|
|
877
777
|
;
|
|
878
778
|
"use strict";
|
|
879
779
|
var $;
|
|
880
|
-
(function ($_1) {
|
|
881
|
-
$mol_test({
|
|
882
|
-
'tree parsing'() {
|
|
883
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
884
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
885
|
-
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
886
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
887
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
888
|
-
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
889
|
-
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
890
|
-
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
891
|
-
},
|
|
892
|
-
'inserting'() {
|
|
893
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
894
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
895
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
896
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
897
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
898
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
899
|
-
},
|
|
900
|
-
'fromJSON'() {
|
|
901
|
-
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
902
|
-
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
903
|
-
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
904
|
-
$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');
|
|
905
|
-
$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');
|
|
906
|
-
},
|
|
907
|
-
'toJSON'() {
|
|
908
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
909
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
910
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
911
|
-
$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"]');
|
|
912
|
-
$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"}');
|
|
913
|
-
},
|
|
914
|
-
'hack'() {
|
|
915
|
-
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
916
|
-
'': (tree, context) => [tree.hack(context)],
|
|
917
|
-
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
918
|
-
});
|
|
919
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
920
|
-
},
|
|
921
|
-
'errors handling'($) {
|
|
922
|
-
const errors = [];
|
|
923
|
-
class Tree extends $mol_tree {
|
|
924
|
-
static $ = $.$mol_ambient({
|
|
925
|
-
$mol_fail: error => errors.push(error.message)
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
Tree.fromString(`
|
|
929
|
-
\t \tfoo
|
|
930
|
-
bar \\data
|
|
931
|
-
`, 'test');
|
|
932
|
-
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
933
|
-
},
|
|
934
|
-
});
|
|
935
|
-
})($ || ($ = {}));
|
|
936
|
-
//mol/tree/tree.test.ts
|
|
937
|
-
;
|
|
938
|
-
"use strict";
|
|
939
|
-
var $;
|
|
940
780
|
(function ($) {
|
|
941
781
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
942
782
|
class $mol_tree extends $mol_object2 {
|
|
@@ -1267,6 +1107,166 @@ var $;
|
|
|
1267
1107
|
;
|
|
1268
1108
|
"use strict";
|
|
1269
1109
|
var $;
|
|
1110
|
+
(function ($) {
|
|
1111
|
+
const instances = new WeakSet();
|
|
1112
|
+
function $mol_delegate(proto, target) {
|
|
1113
|
+
const proxy = new Proxy(proto, {
|
|
1114
|
+
get: (_, field) => {
|
|
1115
|
+
const obj = target();
|
|
1116
|
+
let val = Reflect.get(obj, field);
|
|
1117
|
+
if (typeof val === 'function') {
|
|
1118
|
+
val = val.bind(obj);
|
|
1119
|
+
}
|
|
1120
|
+
return val;
|
|
1121
|
+
},
|
|
1122
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
1123
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1124
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1125
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
1126
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1127
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1128
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
1129
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1130
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1131
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1132
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1133
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1134
|
+
});
|
|
1135
|
+
instances.add(proxy);
|
|
1136
|
+
return proxy;
|
|
1137
|
+
}
|
|
1138
|
+
$.$mol_delegate = $mol_delegate;
|
|
1139
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1140
|
+
value: (obj) => instances.has(obj),
|
|
1141
|
+
});
|
|
1142
|
+
})($ || ($ = {}));
|
|
1143
|
+
//mol/delegate/delegate.ts
|
|
1144
|
+
;
|
|
1145
|
+
"use strict";
|
|
1146
|
+
var $;
|
|
1147
|
+
(function ($) {
|
|
1148
|
+
$mol_test({
|
|
1149
|
+
'get'() {
|
|
1150
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1151
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1152
|
+
},
|
|
1153
|
+
'has'() {
|
|
1154
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1155
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1156
|
+
},
|
|
1157
|
+
'set'() {
|
|
1158
|
+
const target = { foo: 777 };
|
|
1159
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1160
|
+
proxy.foo = 123;
|
|
1161
|
+
$mol_assert_equal(target.foo, 123);
|
|
1162
|
+
},
|
|
1163
|
+
'getOwnPropertyDescriptor'() {
|
|
1164
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1165
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1166
|
+
value: 777,
|
|
1167
|
+
writable: true,
|
|
1168
|
+
enumerable: true,
|
|
1169
|
+
configurable: true,
|
|
1170
|
+
});
|
|
1171
|
+
},
|
|
1172
|
+
'ownKeys'() {
|
|
1173
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1174
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1175
|
+
},
|
|
1176
|
+
'getPrototypeOf'() {
|
|
1177
|
+
class Foo {
|
|
1178
|
+
}
|
|
1179
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1180
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1181
|
+
},
|
|
1182
|
+
'setPrototypeOf'() {
|
|
1183
|
+
class Foo {
|
|
1184
|
+
}
|
|
1185
|
+
const target = {};
|
|
1186
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1187
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1188
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1189
|
+
},
|
|
1190
|
+
'instanceof'() {
|
|
1191
|
+
class Foo {
|
|
1192
|
+
}
|
|
1193
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1194
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1195
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1196
|
+
},
|
|
1197
|
+
'autobind'() {
|
|
1198
|
+
class Foo {
|
|
1199
|
+
}
|
|
1200
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1201
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1202
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1203
|
+
},
|
|
1204
|
+
});
|
|
1205
|
+
})($ || ($ = {}));
|
|
1206
|
+
//mol/delegate/delegate.test.ts
|
|
1207
|
+
;
|
|
1208
|
+
"use strict";
|
|
1209
|
+
var $;
|
|
1210
|
+
(function ($_1) {
|
|
1211
|
+
$mol_test({
|
|
1212
|
+
'tree parsing'() {
|
|
1213
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1214
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1215
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1216
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1217
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1218
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1219
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1220
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1221
|
+
},
|
|
1222
|
+
'inserting'() {
|
|
1223
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1224
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1225
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1226
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1227
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1228
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1229
|
+
},
|
|
1230
|
+
'fromJSON'() {
|
|
1231
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1232
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1233
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1234
|
+
$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');
|
|
1235
|
+
$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');
|
|
1236
|
+
},
|
|
1237
|
+
'toJSON'() {
|
|
1238
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1239
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1240
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1241
|
+
$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"]');
|
|
1242
|
+
$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"}');
|
|
1243
|
+
},
|
|
1244
|
+
'hack'() {
|
|
1245
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1246
|
+
'': (tree, context) => [tree.hack(context)],
|
|
1247
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1248
|
+
});
|
|
1249
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1250
|
+
},
|
|
1251
|
+
'errors handling'($) {
|
|
1252
|
+
const errors = [];
|
|
1253
|
+
class Tree extends $mol_tree {
|
|
1254
|
+
static $ = $.$mol_ambient({
|
|
1255
|
+
$mol_fail: error => errors.push(error.message)
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
Tree.fromString(`
|
|
1259
|
+
\t \tfoo
|
|
1260
|
+
bar \\data
|
|
1261
|
+
`, 'test');
|
|
1262
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1263
|
+
},
|
|
1264
|
+
});
|
|
1265
|
+
})($ || ($ = {}));
|
|
1266
|
+
//mol/tree/tree.test.ts
|
|
1267
|
+
;
|
|
1268
|
+
"use strict";
|
|
1269
|
+
var $;
|
|
1270
1270
|
(function ($) {
|
|
1271
1271
|
$mol_test({
|
|
1272
1272
|
'Make empty div'() {
|