mol_compare_deep 0.0.402 → 0.0.403
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
|
@@ -486,38 +486,6 @@ var $;
|
|
|
486
486
|
;
|
|
487
487
|
"use strict";
|
|
488
488
|
var $;
|
|
489
|
-
(function ($) {
|
|
490
|
-
$mol_test({
|
|
491
|
-
'must be false'() {
|
|
492
|
-
$mol_assert_not(0);
|
|
493
|
-
},
|
|
494
|
-
'must be true'() {
|
|
495
|
-
$mol_assert_ok(1);
|
|
496
|
-
},
|
|
497
|
-
'two must be equal'() {
|
|
498
|
-
$mol_assert_equal(2, 2);
|
|
499
|
-
},
|
|
500
|
-
'three must be equal'() {
|
|
501
|
-
$mol_assert_equal(2, 2, 2);
|
|
502
|
-
},
|
|
503
|
-
'two must be unique'() {
|
|
504
|
-
$mol_assert_unique([3], [3]);
|
|
505
|
-
},
|
|
506
|
-
'three must be unique'() {
|
|
507
|
-
$mol_assert_unique([3], [3], [3]);
|
|
508
|
-
},
|
|
509
|
-
'two must be alike'() {
|
|
510
|
-
$mol_assert_like([3], [3]);
|
|
511
|
-
},
|
|
512
|
-
'three must be alike'() {
|
|
513
|
-
$mol_assert_like([3], [3], [3]);
|
|
514
|
-
},
|
|
515
|
-
});
|
|
516
|
-
})($ || ($ = {}));
|
|
517
|
-
//mol/assert/assert.test.ts
|
|
518
|
-
;
|
|
519
|
-
"use strict";
|
|
520
|
-
var $;
|
|
521
489
|
(function ($) {
|
|
522
490
|
function $mol_assert_ok(value) {
|
|
523
491
|
if (value)
|
|
@@ -612,17 +580,35 @@ var $;
|
|
|
612
580
|
;
|
|
613
581
|
"use strict";
|
|
614
582
|
var $;
|
|
615
|
-
(function ($
|
|
583
|
+
(function ($) {
|
|
616
584
|
$mol_test({
|
|
617
|
-
'
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
$
|
|
585
|
+
'must be false'() {
|
|
586
|
+
$mol_assert_not(0);
|
|
587
|
+
},
|
|
588
|
+
'must be true'() {
|
|
589
|
+
$mol_assert_ok(1);
|
|
590
|
+
},
|
|
591
|
+
'two must be equal'() {
|
|
592
|
+
$mol_assert_equal(2, 2);
|
|
593
|
+
},
|
|
594
|
+
'three must be equal'() {
|
|
595
|
+
$mol_assert_equal(2, 2, 2);
|
|
596
|
+
},
|
|
597
|
+
'two must be unique'() {
|
|
598
|
+
$mol_assert_unique([3], [3]);
|
|
599
|
+
},
|
|
600
|
+
'three must be unique'() {
|
|
601
|
+
$mol_assert_unique([3], [3], [3]);
|
|
602
|
+
},
|
|
603
|
+
'two must be alike'() {
|
|
604
|
+
$mol_assert_like([3], [3]);
|
|
605
|
+
},
|
|
606
|
+
'three must be alike'() {
|
|
607
|
+
$mol_assert_like([3], [3], [3]);
|
|
622
608
|
},
|
|
623
609
|
});
|
|
624
610
|
})($ || ($ = {}));
|
|
625
|
-
//mol/
|
|
611
|
+
//mol/assert/assert.test.ts
|
|
626
612
|
;
|
|
627
613
|
"use strict";
|
|
628
614
|
var $;
|
|
@@ -658,6 +644,20 @@ var $;
|
|
|
658
644
|
;
|
|
659
645
|
"use strict";
|
|
660
646
|
var $;
|
|
647
|
+
(function ($_1) {
|
|
648
|
+
$mol_test({
|
|
649
|
+
'FQN of anon function'($) {
|
|
650
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
651
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
652
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
653
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
654
|
+
},
|
|
655
|
+
});
|
|
656
|
+
})($ || ($ = {}));
|
|
657
|
+
//mol/func/name/name.test.ts
|
|
658
|
+
;
|
|
659
|
+
"use strict";
|
|
660
|
+
var $;
|
|
661
661
|
(function ($) {
|
|
662
662
|
function $mol_dom_render_children(el, childNodes) {
|
|
663
663
|
const node_set = new Set(childNodes);
|
|
@@ -712,27 +712,21 @@ var $;
|
|
|
712
712
|
//mol/dom/render/children/children.ts
|
|
713
713
|
;
|
|
714
714
|
"use strict";
|
|
715
|
-
//mol/type/
|
|
715
|
+
//mol/type/partial/deep/deep.ts
|
|
716
716
|
;
|
|
717
717
|
"use strict";
|
|
718
|
-
//mol/type/
|
|
718
|
+
//mol/type/error/error.ts
|
|
719
719
|
;
|
|
720
720
|
"use strict";
|
|
721
721
|
//mol/type/assert/assert.ts
|
|
722
722
|
;
|
|
723
723
|
"use strict";
|
|
724
|
-
//mol/type/
|
|
725
|
-
;
|
|
726
|
-
"use strict";
|
|
727
|
-
//mol/type/equals/equals.ts
|
|
724
|
+
//mol/type/assert/assert.test.ts
|
|
728
725
|
;
|
|
729
726
|
"use strict";
|
|
730
727
|
//mol/type/partial/deep/deep.test.ts
|
|
731
728
|
;
|
|
732
729
|
"use strict";
|
|
733
|
-
//mol/type/partial/deep/deep.ts
|
|
734
|
-
;
|
|
735
|
-
"use strict";
|
|
736
730
|
var $;
|
|
737
731
|
(function ($) {
|
|
738
732
|
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
@@ -745,106 +739,6 @@ var $;
|
|
|
745
739
|
;
|
|
746
740
|
"use strict";
|
|
747
741
|
var $;
|
|
748
|
-
(function ($) {
|
|
749
|
-
$mol_test({
|
|
750
|
-
'get'() {
|
|
751
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
752
|
-
$mol_assert_equal(proxy.foo, 777);
|
|
753
|
-
},
|
|
754
|
-
'has'() {
|
|
755
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
756
|
-
$mol_assert_equal('foo' in proxy, true);
|
|
757
|
-
},
|
|
758
|
-
'set'() {
|
|
759
|
-
const target = { foo: 777 };
|
|
760
|
-
const proxy = $mol_delegate({}, () => target);
|
|
761
|
-
proxy.foo = 123;
|
|
762
|
-
$mol_assert_equal(target.foo, 123);
|
|
763
|
-
},
|
|
764
|
-
'getOwnPropertyDescriptor'() {
|
|
765
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
766
|
-
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
767
|
-
value: 777,
|
|
768
|
-
writable: true,
|
|
769
|
-
enumerable: true,
|
|
770
|
-
configurable: true,
|
|
771
|
-
});
|
|
772
|
-
},
|
|
773
|
-
'ownKeys'() {
|
|
774
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
775
|
-
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
776
|
-
},
|
|
777
|
-
'getPrototypeOf'() {
|
|
778
|
-
class Foo {
|
|
779
|
-
}
|
|
780
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
781
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
782
|
-
},
|
|
783
|
-
'setPrototypeOf'() {
|
|
784
|
-
class Foo {
|
|
785
|
-
}
|
|
786
|
-
const target = {};
|
|
787
|
-
const proxy = $mol_delegate({}, () => target);
|
|
788
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
789
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
790
|
-
},
|
|
791
|
-
'instanceof'() {
|
|
792
|
-
class Foo {
|
|
793
|
-
}
|
|
794
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
795
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
796
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
797
|
-
},
|
|
798
|
-
'autobind'() {
|
|
799
|
-
class Foo {
|
|
800
|
-
}
|
|
801
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
802
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
803
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
804
|
-
},
|
|
805
|
-
});
|
|
806
|
-
})($ || ($ = {}));
|
|
807
|
-
//mol/delegate/delegate.test.ts
|
|
808
|
-
;
|
|
809
|
-
"use strict";
|
|
810
|
-
var $;
|
|
811
|
-
(function ($) {
|
|
812
|
-
const instances = new WeakSet();
|
|
813
|
-
function $mol_delegate(proto, target) {
|
|
814
|
-
const proxy = new Proxy(proto, {
|
|
815
|
-
get: (_, field) => {
|
|
816
|
-
const obj = target();
|
|
817
|
-
let val = Reflect.get(obj, field);
|
|
818
|
-
if (typeof val === 'function') {
|
|
819
|
-
val = val.bind(obj);
|
|
820
|
-
}
|
|
821
|
-
return val;
|
|
822
|
-
},
|
|
823
|
-
has: (_, field) => Reflect.has(target(), field),
|
|
824
|
-
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
825
|
-
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
826
|
-
ownKeys: () => Reflect.ownKeys(target()),
|
|
827
|
-
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
828
|
-
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
829
|
-
isExtensible: () => Reflect.isExtensible(target()),
|
|
830
|
-
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
831
|
-
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
832
|
-
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
833
|
-
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
834
|
-
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
835
|
-
});
|
|
836
|
-
instances.add(proxy);
|
|
837
|
-
return proxy;
|
|
838
|
-
}
|
|
839
|
-
$.$mol_delegate = $mol_delegate;
|
|
840
|
-
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
841
|
-
value: (obj) => instances.has(obj),
|
|
842
|
-
});
|
|
843
|
-
})($ || ($ = {}));
|
|
844
|
-
//mol/delegate/delegate.ts
|
|
845
|
-
;
|
|
846
|
-
"use strict";
|
|
847
|
-
var $;
|
|
848
742
|
(function ($) {
|
|
849
743
|
$.$mol_owning_map = new WeakMap();
|
|
850
744
|
function $mol_owning_allow(having) {
|
|
@@ -900,10 +794,16 @@ var $;
|
|
|
900
794
|
//mol/owning/owning.ts
|
|
901
795
|
;
|
|
902
796
|
"use strict";
|
|
903
|
-
//mol/type/writable/writable.
|
|
797
|
+
//mol/type/writable/writable.ts
|
|
904
798
|
;
|
|
905
799
|
"use strict";
|
|
906
|
-
//mol/type/
|
|
800
|
+
//mol/type/equals/equals.ts
|
|
801
|
+
;
|
|
802
|
+
"use strict";
|
|
803
|
+
//mol/type/equals/equals.test.ts
|
|
804
|
+
;
|
|
805
|
+
"use strict";
|
|
806
|
+
//mol/type/writable/writable.test.ts
|
|
907
807
|
;
|
|
908
808
|
"use strict";
|
|
909
809
|
var $;
|
|
@@ -950,66 +850,6 @@ var $;
|
|
|
950
850
|
;
|
|
951
851
|
"use strict";
|
|
952
852
|
var $;
|
|
953
|
-
(function ($_1) {
|
|
954
|
-
$mol_test({
|
|
955
|
-
'tree parsing'() {
|
|
956
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
957
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
958
|
-
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
959
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
960
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
961
|
-
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
962
|
-
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
963
|
-
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
964
|
-
},
|
|
965
|
-
'inserting'() {
|
|
966
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
967
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
968
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
969
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
970
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
971
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
972
|
-
},
|
|
973
|
-
'fromJSON'() {
|
|
974
|
-
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
975
|
-
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
976
|
-
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
977
|
-
$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');
|
|
978
|
-
$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');
|
|
979
|
-
},
|
|
980
|
-
'toJSON'() {
|
|
981
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
982
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
983
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
984
|
-
$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"]');
|
|
985
|
-
$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"}');
|
|
986
|
-
},
|
|
987
|
-
'hack'() {
|
|
988
|
-
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
989
|
-
'': (tree, context) => [tree.hack(context)],
|
|
990
|
-
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
991
|
-
});
|
|
992
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
993
|
-
},
|
|
994
|
-
'errors handling'($) {
|
|
995
|
-
const errors = [];
|
|
996
|
-
class Tree extends $mol_tree {
|
|
997
|
-
static $ = $.$mol_ambient({
|
|
998
|
-
$mol_fail: error => errors.push(error.message)
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
Tree.fromString(`
|
|
1002
|
-
\t \tfoo
|
|
1003
|
-
bar \\data
|
|
1004
|
-
`, 'test');
|
|
1005
|
-
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1006
|
-
},
|
|
1007
|
-
});
|
|
1008
|
-
})($ || ($ = {}));
|
|
1009
|
-
//mol/tree/tree.test.ts
|
|
1010
|
-
;
|
|
1011
|
-
"use strict";
|
|
1012
|
-
var $;
|
|
1013
853
|
(function ($) {
|
|
1014
854
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1015
855
|
class $mol_tree extends $mol_object2 {
|
|
@@ -1340,6 +1180,166 @@ var $;
|
|
|
1340
1180
|
;
|
|
1341
1181
|
"use strict";
|
|
1342
1182
|
var $;
|
|
1183
|
+
(function ($) {
|
|
1184
|
+
const instances = new WeakSet();
|
|
1185
|
+
function $mol_delegate(proto, target) {
|
|
1186
|
+
const proxy = new Proxy(proto, {
|
|
1187
|
+
get: (_, field) => {
|
|
1188
|
+
const obj = target();
|
|
1189
|
+
let val = Reflect.get(obj, field);
|
|
1190
|
+
if (typeof val === 'function') {
|
|
1191
|
+
val = val.bind(obj);
|
|
1192
|
+
}
|
|
1193
|
+
return val;
|
|
1194
|
+
},
|
|
1195
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
1196
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1197
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1198
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
1199
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1200
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1201
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
1202
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1203
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1204
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1205
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1206
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1207
|
+
});
|
|
1208
|
+
instances.add(proxy);
|
|
1209
|
+
return proxy;
|
|
1210
|
+
}
|
|
1211
|
+
$.$mol_delegate = $mol_delegate;
|
|
1212
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1213
|
+
value: (obj) => instances.has(obj),
|
|
1214
|
+
});
|
|
1215
|
+
})($ || ($ = {}));
|
|
1216
|
+
//mol/delegate/delegate.ts
|
|
1217
|
+
;
|
|
1218
|
+
"use strict";
|
|
1219
|
+
var $;
|
|
1220
|
+
(function ($) {
|
|
1221
|
+
$mol_test({
|
|
1222
|
+
'get'() {
|
|
1223
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1224
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1225
|
+
},
|
|
1226
|
+
'has'() {
|
|
1227
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1228
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1229
|
+
},
|
|
1230
|
+
'set'() {
|
|
1231
|
+
const target = { foo: 777 };
|
|
1232
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1233
|
+
proxy.foo = 123;
|
|
1234
|
+
$mol_assert_equal(target.foo, 123);
|
|
1235
|
+
},
|
|
1236
|
+
'getOwnPropertyDescriptor'() {
|
|
1237
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1238
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1239
|
+
value: 777,
|
|
1240
|
+
writable: true,
|
|
1241
|
+
enumerable: true,
|
|
1242
|
+
configurable: true,
|
|
1243
|
+
});
|
|
1244
|
+
},
|
|
1245
|
+
'ownKeys'() {
|
|
1246
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1247
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1248
|
+
},
|
|
1249
|
+
'getPrototypeOf'() {
|
|
1250
|
+
class Foo {
|
|
1251
|
+
}
|
|
1252
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1253
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1254
|
+
},
|
|
1255
|
+
'setPrototypeOf'() {
|
|
1256
|
+
class Foo {
|
|
1257
|
+
}
|
|
1258
|
+
const target = {};
|
|
1259
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1260
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1261
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1262
|
+
},
|
|
1263
|
+
'instanceof'() {
|
|
1264
|
+
class Foo {
|
|
1265
|
+
}
|
|
1266
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1267
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1268
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1269
|
+
},
|
|
1270
|
+
'autobind'() {
|
|
1271
|
+
class Foo {
|
|
1272
|
+
}
|
|
1273
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1274
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1275
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1276
|
+
},
|
|
1277
|
+
});
|
|
1278
|
+
})($ || ($ = {}));
|
|
1279
|
+
//mol/delegate/delegate.test.ts
|
|
1280
|
+
;
|
|
1281
|
+
"use strict";
|
|
1282
|
+
var $;
|
|
1283
|
+
(function ($_1) {
|
|
1284
|
+
$mol_test({
|
|
1285
|
+
'tree parsing'() {
|
|
1286
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1287
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1288
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1289
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1290
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1291
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1292
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1293
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1294
|
+
},
|
|
1295
|
+
'inserting'() {
|
|
1296
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1297
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1298
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1299
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1300
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1301
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1302
|
+
},
|
|
1303
|
+
'fromJSON'() {
|
|
1304
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1305
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1306
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1307
|
+
$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');
|
|
1308
|
+
$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');
|
|
1309
|
+
},
|
|
1310
|
+
'toJSON'() {
|
|
1311
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1312
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1313
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1314
|
+
$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"]');
|
|
1315
|
+
$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"}');
|
|
1316
|
+
},
|
|
1317
|
+
'hack'() {
|
|
1318
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1319
|
+
'': (tree, context) => [tree.hack(context)],
|
|
1320
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1321
|
+
});
|
|
1322
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1323
|
+
},
|
|
1324
|
+
'errors handling'($) {
|
|
1325
|
+
const errors = [];
|
|
1326
|
+
class Tree extends $mol_tree {
|
|
1327
|
+
static $ = $.$mol_ambient({
|
|
1328
|
+
$mol_fail: error => errors.push(error.message)
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
Tree.fromString(`
|
|
1332
|
+
\t \tfoo
|
|
1333
|
+
bar \\data
|
|
1334
|
+
`, 'test');
|
|
1335
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1336
|
+
},
|
|
1337
|
+
});
|
|
1338
|
+
})($ || ($ = {}));
|
|
1339
|
+
//mol/tree/tree.test.ts
|
|
1340
|
+
;
|
|
1341
|
+
"use strict";
|
|
1342
|
+
var $;
|
|
1343
1343
|
(function ($) {
|
|
1344
1344
|
$mol_test({
|
|
1345
1345
|
'Make empty div'() {
|