mol_compare_deep 0.0.403 → 0.0.404
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,6 +486,38 @@ 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 $;
|
|
489
521
|
(function ($) {
|
|
490
522
|
function $mol_assert_ok(value) {
|
|
491
523
|
if (value)
|
|
@@ -580,35 +612,17 @@ var $;
|
|
|
580
612
|
;
|
|
581
613
|
"use strict";
|
|
582
614
|
var $;
|
|
583
|
-
(function ($) {
|
|
615
|
+
(function ($_1) {
|
|
584
616
|
$mol_test({
|
|
585
|
-
'
|
|
586
|
-
$
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
$
|
|
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]);
|
|
617
|
+
'FQN of anon function'($) {
|
|
618
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
619
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
620
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
621
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
608
622
|
},
|
|
609
623
|
});
|
|
610
624
|
})($ || ($ = {}));
|
|
611
|
-
//mol/
|
|
625
|
+
//mol/func/name/name.test.ts
|
|
612
626
|
;
|
|
613
627
|
"use strict";
|
|
614
628
|
var $;
|
|
@@ -644,20 +658,6 @@ var $;
|
|
|
644
658
|
;
|
|
645
659
|
"use strict";
|
|
646
660
|
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,21 +712,27 @@ var $;
|
|
|
712
712
|
//mol/dom/render/children/children.ts
|
|
713
713
|
;
|
|
714
714
|
"use strict";
|
|
715
|
-
//mol/type/
|
|
715
|
+
//mol/type/error/error.ts
|
|
716
716
|
;
|
|
717
717
|
"use strict";
|
|
718
|
-
//mol/type/
|
|
718
|
+
//mol/type/assert/assert.test.ts
|
|
719
719
|
;
|
|
720
720
|
"use strict";
|
|
721
721
|
//mol/type/assert/assert.ts
|
|
722
722
|
;
|
|
723
723
|
"use strict";
|
|
724
|
-
//mol/type/
|
|
724
|
+
//mol/type/equals/equals.test.ts
|
|
725
|
+
;
|
|
726
|
+
"use strict";
|
|
727
|
+
//mol/type/equals/equals.ts
|
|
725
728
|
;
|
|
726
729
|
"use strict";
|
|
727
730
|
//mol/type/partial/deep/deep.test.ts
|
|
728
731
|
;
|
|
729
732
|
"use strict";
|
|
733
|
+
//mol/type/partial/deep/deep.ts
|
|
734
|
+
;
|
|
735
|
+
"use strict";
|
|
730
736
|
var $;
|
|
731
737
|
(function ($) {
|
|
732
738
|
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
@@ -739,6 +745,106 @@ var $;
|
|
|
739
745
|
;
|
|
740
746
|
"use strict";
|
|
741
747
|
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 $;
|
|
742
848
|
(function ($) {
|
|
743
849
|
$.$mol_owning_map = new WeakMap();
|
|
744
850
|
function $mol_owning_allow(having) {
|
|
@@ -794,16 +900,10 @@ var $;
|
|
|
794
900
|
//mol/owning/owning.ts
|
|
795
901
|
;
|
|
796
902
|
"use strict";
|
|
797
|
-
//mol/type/writable/writable.ts
|
|
798
|
-
;
|
|
799
|
-
"use strict";
|
|
800
|
-
//mol/type/equals/equals.ts
|
|
801
|
-
;
|
|
802
|
-
"use strict";
|
|
803
|
-
//mol/type/equals/equals.test.ts
|
|
903
|
+
//mol/type/writable/writable.test.ts
|
|
804
904
|
;
|
|
805
905
|
"use strict";
|
|
806
|
-
//mol/type/writable/writable.
|
|
906
|
+
//mol/type/writable/writable.ts
|
|
807
907
|
;
|
|
808
908
|
"use strict";
|
|
809
909
|
var $;
|
|
@@ -850,6 +950,66 @@ var $;
|
|
|
850
950
|
;
|
|
851
951
|
"use strict";
|
|
852
952
|
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 $;
|
|
853
1013
|
(function ($) {
|
|
854
1014
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
855
1015
|
class $mol_tree extends $mol_object2 {
|
|
@@ -1180,166 +1340,6 @@ var $;
|
|
|
1180
1340
|
;
|
|
1181
1341
|
"use strict";
|
|
1182
1342
|
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'() {
|