mol_mutable 0.0.50 → 0.0.51
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.deps.json +1 -1
- package/node.js +13 -13
- package/node.js.map +1 -1
- package/node.mjs +13 -13
- package/node.mjs.map +1 -1
- package/node.test.js +377 -377
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.js +13 -13
- package/web.js.map +1 -1
- package/web.mjs +13 -13
- package/web.mjs.map +1 -1
- package/web.test.js +235 -235
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
Error.stackTraceLimit = 50;
|
|
4
|
+
var $;
|
|
5
|
+
(function ($) {
|
|
6
|
+
})($ || ($ = {}));
|
|
7
|
+
module.exports = $;
|
|
8
|
+
//mam.ts
|
|
9
|
+
;
|
|
2
10
|
"use strict"
|
|
3
11
|
|
|
4
12
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -11,14 +19,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
11
19
|
var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
|
|
12
20
|
$.$$ = $
|
|
13
21
|
|
|
14
|
-
;
|
|
15
|
-
"use strict";
|
|
16
|
-
Error.stackTraceLimit = 50;
|
|
17
|
-
var $;
|
|
18
|
-
(function ($) {
|
|
19
|
-
})($ || ($ = {}));
|
|
20
|
-
module.exports = $;
|
|
21
|
-
//mam.ts
|
|
22
22
|
;
|
|
23
23
|
"use strict";
|
|
24
24
|
//mol/type/immutable/deep/deep/deep.ts
|
|
@@ -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) {
|
|
@@ -67,16 +85,6 @@ var $;
|
|
|
67
85
|
;
|
|
68
86
|
"use strict";
|
|
69
87
|
var $;
|
|
70
|
-
(function ($) {
|
|
71
|
-
function $mol_test_complete() {
|
|
72
|
-
process.exit(0);
|
|
73
|
-
}
|
|
74
|
-
$.$mol_test_complete = $mol_test_complete;
|
|
75
|
-
})($ || ($ = {}));
|
|
76
|
-
//mol/test/test.node.test.ts
|
|
77
|
-
;
|
|
78
|
-
"use strict";
|
|
79
|
-
var $;
|
|
80
88
|
(function ($_1) {
|
|
81
89
|
function $mol_test(set) {
|
|
82
90
|
for (let name in set) {
|
|
@@ -164,6 +172,16 @@ var $;
|
|
|
164
172
|
;
|
|
165
173
|
"use strict";
|
|
166
174
|
var $;
|
|
175
|
+
(function ($) {
|
|
176
|
+
function $mol_test_complete() {
|
|
177
|
+
process.exit(0);
|
|
178
|
+
}
|
|
179
|
+
$.$mol_test_complete = $mol_test_complete;
|
|
180
|
+
})($ || ($ = {}));
|
|
181
|
+
//mol/test/test.node.test.ts
|
|
182
|
+
;
|
|
183
|
+
"use strict";
|
|
184
|
+
var $;
|
|
167
185
|
(function ($) {
|
|
168
186
|
})($ || ($ = {}));
|
|
169
187
|
//mol/dom/context/context.ts
|
|
@@ -429,115 +447,10 @@ var $;
|
|
|
429
447
|
//mol/dom/render/children/children.ts
|
|
430
448
|
;
|
|
431
449
|
"use strict";
|
|
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
|
|
445
|
-
;
|
|
446
|
-
"use strict";
|
|
447
|
-
//mol/type/partial/deep/deep.test.ts
|
|
448
|
-
;
|
|
449
|
-
"use strict";
|
|
450
450
|
//mol/type/partial/deep/deep.ts
|
|
451
451
|
;
|
|
452
452
|
"use strict";
|
|
453
|
-
|
|
454
|
-
(function ($) {
|
|
455
|
-
$mol_test({
|
|
456
|
-
'Make empty div'() {
|
|
457
|
-
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
458
|
-
},
|
|
459
|
-
'Define native field'() {
|
|
460
|
-
const dom = $mol_jsx("input", { value: '123' });
|
|
461
|
-
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
462
|
-
$mol_assert_equal(dom.value, '123');
|
|
463
|
-
},
|
|
464
|
-
'Define classes'() {
|
|
465
|
-
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
466
|
-
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
467
|
-
},
|
|
468
|
-
'Define styles'() {
|
|
469
|
-
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
470
|
-
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
471
|
-
},
|
|
472
|
-
'Define dataset'() {
|
|
473
|
-
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
474
|
-
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
475
|
-
},
|
|
476
|
-
'Define attributes'() {
|
|
477
|
-
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
478
|
-
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
479
|
-
},
|
|
480
|
-
'Define child nodes'() {
|
|
481
|
-
const dom = $mol_jsx("div", null,
|
|
482
|
-
"hello",
|
|
483
|
-
$mol_jsx("strong", null, "world"),
|
|
484
|
-
"!");
|
|
485
|
-
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
486
|
-
},
|
|
487
|
-
'Function as component'() {
|
|
488
|
-
const Button = (props, target) => {
|
|
489
|
-
return $mol_jsx("button", { title: props.hint }, target());
|
|
490
|
-
};
|
|
491
|
-
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
492
|
-
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
|
493
|
-
},
|
|
494
|
-
'Nested guid generation'() {
|
|
495
|
-
const Foo = () => {
|
|
496
|
-
return $mol_jsx("div", null,
|
|
497
|
-
$mol_jsx(Bar, { id: "bar" },
|
|
498
|
-
$mol_jsx("img", { id: "icon" })));
|
|
499
|
-
};
|
|
500
|
-
const Bar = (props, icon) => {
|
|
501
|
-
return $mol_jsx("span", null,
|
|
502
|
-
icon,
|
|
503
|
-
$mol_jsx("i", { id: "label" }));
|
|
504
|
-
};
|
|
505
|
-
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
506
|
-
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
|
507
|
-
},
|
|
508
|
-
'Fail on non unique ids'() {
|
|
509
|
-
const App = () => {
|
|
510
|
-
return $mol_jsx("div", null,
|
|
511
|
-
$mol_jsx("span", { id: "bar" }),
|
|
512
|
-
$mol_jsx("span", { id: "bar" }));
|
|
513
|
-
};
|
|
514
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
515
|
-
},
|
|
516
|
-
'Owner based guid generationn'() {
|
|
517
|
-
const Foo = () => {
|
|
518
|
-
return $mol_jsx("div", null,
|
|
519
|
-
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
520
|
-
};
|
|
521
|
-
const Bar = (props) => {
|
|
522
|
-
return $mol_jsx("span", null, props.icon());
|
|
523
|
-
};
|
|
524
|
-
const dom = $mol_jsx(Foo, { id: "app" });
|
|
525
|
-
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
|
526
|
-
},
|
|
527
|
-
'Fail on same ids from different caller'() {
|
|
528
|
-
const Foo = () => {
|
|
529
|
-
return $mol_jsx("div", null,
|
|
530
|
-
$mol_jsx("img", { id: "icon" }),
|
|
531
|
-
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
532
|
-
};
|
|
533
|
-
const Bar = (props) => {
|
|
534
|
-
return $mol_jsx("span", null, props.icon());
|
|
535
|
-
};
|
|
536
|
-
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
537
|
-
},
|
|
538
|
-
});
|
|
539
|
-
})($ || ($ = {}));
|
|
540
|
-
//mol/jsx/jsx.test.tsx
|
|
453
|
+
//mol/type/partial/deep/deep.test.ts
|
|
541
454
|
;
|
|
542
455
|
"use strict";
|
|
543
456
|
var $;
|
|
@@ -664,97 +577,91 @@ var $;
|
|
|
664
577
|
var $;
|
|
665
578
|
(function ($) {
|
|
666
579
|
$mol_test({
|
|
667
|
-
'
|
|
668
|
-
$
|
|
669
|
-
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
670
|
-
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
671
|
-
$mol_assert_not($mol_compare_deep({}, null));
|
|
580
|
+
'Make empty div'() {
|
|
581
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
672
582
|
},
|
|
673
|
-
'
|
|
674
|
-
$
|
|
675
|
-
$
|
|
676
|
-
$
|
|
677
|
-
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
678
|
-
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
583
|
+
'Define native field'() {
|
|
584
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
585
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
586
|
+
$mol_assert_equal(dom.value, '123');
|
|
679
587
|
},
|
|
680
|
-
'
|
|
681
|
-
$
|
|
682
|
-
$
|
|
683
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
684
|
-
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
685
|
-
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
686
|
-
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
588
|
+
'Define classes'() {
|
|
589
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
590
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
687
591
|
},
|
|
688
|
-
'
|
|
689
|
-
$
|
|
690
|
-
$
|
|
691
|
-
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
692
|
-
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
592
|
+
'Define styles'() {
|
|
593
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
594
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
693
595
|
},
|
|
694
|
-
'
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
698
|
-
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
699
|
-
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
596
|
+
'Define dataset'() {
|
|
597
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
598
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
700
599
|
},
|
|
701
|
-
'
|
|
702
|
-
const
|
|
703
|
-
|
|
704
|
-
const b = { foo: {} };
|
|
705
|
-
b['self'] = b;
|
|
706
|
-
$mol_assert_ok($mol_compare_deep(a, b));
|
|
600
|
+
'Define attributes'() {
|
|
601
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
602
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
707
603
|
},
|
|
708
|
-
'
|
|
709
|
-
$
|
|
710
|
-
|
|
604
|
+
'Define child nodes'() {
|
|
605
|
+
const dom = $mol_jsx("div", null,
|
|
606
|
+
"hello",
|
|
607
|
+
$mol_jsx("strong", null, "world"),
|
|
608
|
+
"!");
|
|
609
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
711
610
|
},
|
|
712
|
-
'
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
611
|
+
'Function as component'() {
|
|
612
|
+
const Button = (props, target) => {
|
|
613
|
+
return $mol_jsx("button", { title: props.hint }, target());
|
|
614
|
+
};
|
|
615
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
616
|
+
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
|
716
617
|
},
|
|
717
|
-
'
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
618
|
+
'Nested guid generation'() {
|
|
619
|
+
const Foo = () => {
|
|
620
|
+
return $mol_jsx("div", null,
|
|
621
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
622
|
+
$mol_jsx("img", { id: "icon" })));
|
|
623
|
+
};
|
|
624
|
+
const Bar = (props, icon) => {
|
|
625
|
+
return $mol_jsx("span", null,
|
|
626
|
+
icon,
|
|
627
|
+
$mol_jsx("i", { id: "label" }));
|
|
628
|
+
};
|
|
629
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
630
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
|
722
631
|
},
|
|
723
|
-
'
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
'Set'() {
|
|
731
|
-
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
732
|
-
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
733
|
-
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
632
|
+
'Fail on non unique ids'() {
|
|
633
|
+
const App = () => {
|
|
634
|
+
return $mol_jsx("div", null,
|
|
635
|
+
$mol_jsx("span", { id: "bar" }),
|
|
636
|
+
$mol_jsx("span", { id: "bar" }));
|
|
637
|
+
};
|
|
638
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
734
639
|
},
|
|
735
|
-
'
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
640
|
+
'Owner based guid generationn'() {
|
|
641
|
+
const Foo = () => {
|
|
642
|
+
return $mol_jsx("div", null,
|
|
643
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
644
|
+
};
|
|
645
|
+
const Bar = (props) => {
|
|
646
|
+
return $mol_jsx("span", null, props.icon());
|
|
647
|
+
};
|
|
648
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
649
|
+
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
|
739
650
|
},
|
|
740
|
-
'
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
753
|
-
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
651
|
+
'Fail on same ids from different caller'() {
|
|
652
|
+
const Foo = () => {
|
|
653
|
+
return $mol_jsx("div", null,
|
|
654
|
+
$mol_jsx("img", { id: "icon" }),
|
|
655
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
656
|
+
};
|
|
657
|
+
const Bar = (props) => {
|
|
658
|
+
return $mol_jsx("span", null, props.icon());
|
|
659
|
+
};
|
|
660
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
754
661
|
},
|
|
755
662
|
});
|
|
756
663
|
})($ || ($ = {}));
|
|
757
|
-
//mol/
|
|
664
|
+
//mol/jsx/jsx.test.tsx
|
|
758
665
|
;
|
|
759
666
|
"use strict";
|
|
760
667
|
var $;
|
|
@@ -883,46 +790,110 @@ var $;
|
|
|
883
790
|
;
|
|
884
791
|
"use strict";
|
|
885
792
|
var $;
|
|
886
|
-
(function ($) {
|
|
887
|
-
function $mol_dom_serialize(node) {
|
|
888
|
-
const serializer = new $mol_dom_context.XMLSerializer;
|
|
889
|
-
return serializer.serializeToString(node);
|
|
890
|
-
}
|
|
891
|
-
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
892
|
-
})($ || ($ = {}));
|
|
893
|
-
//mol/dom/serialize/serialize.ts
|
|
894
|
-
;
|
|
895
|
-
"use strict";
|
|
896
|
-
var $;
|
|
897
793
|
(function ($) {
|
|
898
794
|
$mol_test({
|
|
899
|
-
'
|
|
900
|
-
$
|
|
795
|
+
'nulls & undefineds'() {
|
|
796
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
797
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
798
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
799
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
901
800
|
},
|
|
902
|
-
'
|
|
903
|
-
$mol_assert_ok(1);
|
|
801
|
+
'number'() {
|
|
802
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
803
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
804
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
805
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
806
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
904
807
|
},
|
|
905
|
-
'
|
|
906
|
-
$
|
|
808
|
+
'POJO'() {
|
|
809
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
810
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
811
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
812
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
813
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
814
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
907
815
|
},
|
|
908
|
-
'
|
|
909
|
-
$
|
|
816
|
+
'Array'() {
|
|
817
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
818
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
819
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
820
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
910
821
|
},
|
|
911
|
-
'
|
|
912
|
-
|
|
822
|
+
'Non POJO are different'() {
|
|
823
|
+
class Thing extends Object {
|
|
824
|
+
}
|
|
825
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
826
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
827
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
913
828
|
},
|
|
914
|
-
'
|
|
915
|
-
|
|
829
|
+
'same POJOs with cyclic reference'() {
|
|
830
|
+
const a = { foo: {} };
|
|
831
|
+
a['self'] = a;
|
|
832
|
+
const b = { foo: {} };
|
|
833
|
+
b['self'] = b;
|
|
834
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
916
835
|
},
|
|
917
|
-
'
|
|
918
|
-
$
|
|
836
|
+
'Date'() {
|
|
837
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
838
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
919
839
|
},
|
|
920
|
-
'
|
|
921
|
-
$
|
|
840
|
+
'RegExp'() {
|
|
841
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
842
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
843
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
844
|
+
},
|
|
845
|
+
'Error'() {
|
|
846
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
847
|
+
const fail = (message) => new Error(message);
|
|
848
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
849
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
850
|
+
},
|
|
851
|
+
'Map'() {
|
|
852
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
853
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
854
|
+
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
855
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
856
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
857
|
+
},
|
|
858
|
+
'Set'() {
|
|
859
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
860
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
861
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
862
|
+
},
|
|
863
|
+
'Uint8Array'() {
|
|
864
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
865
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
866
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
867
|
+
},
|
|
868
|
+
'Custom comparator'() {
|
|
869
|
+
class User {
|
|
870
|
+
name;
|
|
871
|
+
rand;
|
|
872
|
+
constructor(name, rand = Math.random()) {
|
|
873
|
+
this.name = name;
|
|
874
|
+
this.rand = rand;
|
|
875
|
+
}
|
|
876
|
+
[Symbol.toPrimitive](mode) {
|
|
877
|
+
return this.name;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
881
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
922
882
|
},
|
|
923
883
|
});
|
|
924
884
|
})($ || ($ = {}));
|
|
925
|
-
//mol/
|
|
885
|
+
//mol/compare/deep/deep.test.tsx
|
|
886
|
+
;
|
|
887
|
+
"use strict";
|
|
888
|
+
var $;
|
|
889
|
+
(function ($) {
|
|
890
|
+
function $mol_dom_serialize(node) {
|
|
891
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
892
|
+
return serializer.serializeToString(node);
|
|
893
|
+
}
|
|
894
|
+
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
895
|
+
})($ || ($ = {}));
|
|
896
|
+
//mol/dom/serialize/serialize.ts
|
|
926
897
|
;
|
|
927
898
|
"use strict";
|
|
928
899
|
var $;
|
|
@@ -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,63 +1139,103 @@ var $;
|
|
|
1239
1139
|
;
|
|
1240
1140
|
"use strict";
|
|
1241
1141
|
var $;
|
|
1242
|
-
(function ($
|
|
1142
|
+
(function ($) {
|
|
1143
|
+
const instances = new WeakSet();
|
|
1144
|
+
function $mol_delegate(proto, target) {
|
|
1145
|
+
const proxy = new Proxy(proto, {
|
|
1146
|
+
get: (_, field) => {
|
|
1147
|
+
const obj = target();
|
|
1148
|
+
let val = Reflect.get(obj, field);
|
|
1149
|
+
if (typeof val === 'function') {
|
|
1150
|
+
val = val.bind(obj);
|
|
1151
|
+
}
|
|
1152
|
+
return val;
|
|
1153
|
+
},
|
|
1154
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
1155
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1156
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1157
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
1158
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1159
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1160
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
1161
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1162
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1163
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1164
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1165
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1166
|
+
});
|
|
1167
|
+
instances.add(proxy);
|
|
1168
|
+
return proxy;
|
|
1169
|
+
}
|
|
1170
|
+
$.$mol_delegate = $mol_delegate;
|
|
1171
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1172
|
+
value: (obj) => instances.has(obj),
|
|
1173
|
+
});
|
|
1174
|
+
})($ || ($ = {}));
|
|
1175
|
+
//mol/delegate/delegate.ts
|
|
1176
|
+
;
|
|
1177
|
+
"use strict";
|
|
1178
|
+
var $;
|
|
1179
|
+
(function ($) {
|
|
1243
1180
|
$mol_test({
|
|
1244
|
-
'
|
|
1245
|
-
$
|
|
1246
|
-
$mol_assert_equal(
|
|
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');
|
|
1181
|
+
'get'() {
|
|
1182
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1183
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1261
1184
|
},
|
|
1262
|
-
'
|
|
1263
|
-
$
|
|
1264
|
-
$mol_assert_equal(
|
|
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');
|
|
1185
|
+
'has'() {
|
|
1186
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1187
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1268
1188
|
},
|
|
1269
|
-
'
|
|
1270
|
-
|
|
1271
|
-
$
|
|
1272
|
-
|
|
1273
|
-
$mol_assert_equal(
|
|
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"}');
|
|
1189
|
+
'set'() {
|
|
1190
|
+
const target = { foo: 777 };
|
|
1191
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1192
|
+
proxy.foo = 123;
|
|
1193
|
+
$mol_assert_equal(target.foo, 123);
|
|
1275
1194
|
},
|
|
1276
|
-
'
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1279
|
-
|
|
1195
|
+
'getOwnPropertyDescriptor'() {
|
|
1196
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1197
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1198
|
+
value: 777,
|
|
1199
|
+
writable: true,
|
|
1200
|
+
enumerable: true,
|
|
1201
|
+
configurable: true,
|
|
1280
1202
|
});
|
|
1281
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1282
1203
|
},
|
|
1283
|
-
'
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1204
|
+
'ownKeys'() {
|
|
1205
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1206
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1207
|
+
},
|
|
1208
|
+
'getPrototypeOf'() {
|
|
1209
|
+
class Foo {
|
|
1289
1210
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1211
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1212
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1213
|
+
},
|
|
1214
|
+
'setPrototypeOf'() {
|
|
1215
|
+
class Foo {
|
|
1216
|
+
}
|
|
1217
|
+
const target = {};
|
|
1218
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1219
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1220
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1221
|
+
},
|
|
1222
|
+
'instanceof'() {
|
|
1223
|
+
class Foo {
|
|
1224
|
+
}
|
|
1225
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1226
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1227
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1228
|
+
},
|
|
1229
|
+
'autobind'() {
|
|
1230
|
+
class Foo {
|
|
1231
|
+
}
|
|
1232
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1233
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1234
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1295
1235
|
},
|
|
1296
1236
|
});
|
|
1297
1237
|
})($ || ($ = {}));
|
|
1298
|
-
//mol/
|
|
1238
|
+
//mol/delegate/delegate.test.ts
|
|
1299
1239
|
;
|
|
1300
1240
|
"use strict";
|
|
1301
1241
|
var $;
|
|
@@ -1631,15 +1571,61 @@ var $;
|
|
|
1631
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'() {
|