mol_dump_lib 0.0.918 → 0.0.920

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 CHANGED
@@ -140,13 +140,7 @@ var $node = new Proxy({ require }, {
140
140
  target.require.resolve(name);
141
141
  }
142
142
  catch {
143
- try {
144
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
145
- }
146
- catch (e) {
147
- if ($$.$mol_promise_like(e))
148
- $$.$mol_fail_hidden(e);
149
- }
143
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
150
144
  try {
151
145
  $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
152
146
  }
@@ -7719,24 +7713,68 @@ var $;
7719
7713
  $.$mol_test_complete = $mol_test_complete;
7720
7714
  })($ || ($ = {}));
7721
7715
 
7722
- ;
7723
- "use strict";
7724
-
7725
- ;
7726
- "use strict";
7727
-
7728
- ;
7729
- "use strict";
7730
-
7731
7716
  ;
7732
7717
  "use strict";
7733
7718
  var $;
7734
7719
  (function ($) {
7735
- function $mol_dom_serialize(node) {
7736
- const serializer = new $mol_dom_context.XMLSerializer;
7737
- return serializer.serializeToString(node);
7720
+ function $mol_assert_ok(value) {
7721
+ if (value)
7722
+ return;
7723
+ $mol_fail(new Error(`${value} ≠ true`));
7738
7724
  }
7739
- $.$mol_dom_serialize = $mol_dom_serialize;
7725
+ $.$mol_assert_ok = $mol_assert_ok;
7726
+ function $mol_assert_not(value) {
7727
+ if (!value)
7728
+ return;
7729
+ $mol_fail(new Error(`${value} ≠ false`));
7730
+ }
7731
+ $.$mol_assert_not = $mol_assert_not;
7732
+ function $mol_assert_fail(handler, ErrorRight) {
7733
+ const fail = $.$mol_fail;
7734
+ try {
7735
+ $.$mol_fail = $.$mol_fail_hidden;
7736
+ handler();
7737
+ }
7738
+ catch (error) {
7739
+ $.$mol_fail = fail;
7740
+ if (typeof ErrorRight === 'string') {
7741
+ $mol_assert_equal(error.message ?? error, ErrorRight);
7742
+ }
7743
+ else {
7744
+ $mol_assert_equal(error instanceof ErrorRight, true);
7745
+ }
7746
+ return error;
7747
+ }
7748
+ finally {
7749
+ $.$mol_fail = fail;
7750
+ }
7751
+ $mol_fail(new Error('Not failed'));
7752
+ }
7753
+ $.$mol_assert_fail = $mol_assert_fail;
7754
+ function $mol_assert_like(...args) {
7755
+ $mol_assert_equal(...args);
7756
+ }
7757
+ $.$mol_assert_like = $mol_assert_like;
7758
+ function $mol_assert_unique(...args) {
7759
+ for (let i = 0; i < args.length; ++i) {
7760
+ for (let j = 0; j < args.length; ++j) {
7761
+ if (i === j)
7762
+ continue;
7763
+ if (!$mol_compare_deep(args[i], args[j]))
7764
+ continue;
7765
+ return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
7766
+ }
7767
+ }
7768
+ }
7769
+ $.$mol_assert_unique = $mol_assert_unique;
7770
+ function $mol_assert_equal(...args) {
7771
+ for (let i = 1; i < args.length; ++i) {
7772
+ if ($mol_compare_deep(args[0], args[i]))
7773
+ continue;
7774
+ return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
7775
+ }
7776
+ }
7777
+ $.$mol_assert_equal = $mol_assert_equal;
7740
7778
  })($ || ($ = {}));
7741
7779
 
7742
7780
  ;
@@ -7744,516 +7782,371 @@ var $;
7744
7782
  var $;
7745
7783
  (function ($) {
7746
7784
  $mol_test({
7747
- 'Make empty div'() {
7748
- $mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
7749
- },
7750
- 'Define native field'() {
7751
- const dom = $mol_jsx("input", { value: '123' });
7752
- $mol_assert_equal(dom.outerHTML, '<input value="123">');
7753
- $mol_assert_equal(dom.value, '123');
7754
- },
7755
- 'Define classes'() {
7756
- const dom = $mol_jsx("div", { class: 'foo bar' });
7757
- $mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
7758
- },
7759
- 'Define styles'() {
7760
- const dom = $mol_jsx("div", { style: { color: 'red' } });
7761
- $mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
7785
+ 'must be false'() {
7786
+ $mol_assert_not(0);
7762
7787
  },
7763
- 'Define dataset'() {
7764
- const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
7765
- $mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
7788
+ 'must be true'() {
7789
+ $mol_assert_ok(1);
7766
7790
  },
7767
- 'Define attributes'() {
7768
- const dom = $mol_jsx("div", { lang: "ru", hidden: true });
7769
- $mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
7791
+ 'two must be equal'() {
7792
+ $mol_assert_equal(2, 2);
7770
7793
  },
7771
- 'Define child nodes'() {
7772
- const dom = $mol_jsx("div", null,
7773
- "hello",
7774
- $mol_jsx("strong", null, "world"),
7775
- "!");
7776
- $mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
7794
+ 'three must be equal'() {
7795
+ $mol_assert_equal(2, 2, 2);
7777
7796
  },
7778
- 'Make fragment'() {
7779
- const dom = $mol_jsx($mol_jsx_frag, null,
7780
- $mol_jsx("br", null),
7781
- $mol_jsx("hr", null));
7782
- $mol_assert_equal($mol_dom_serialize(dom), '<br xmlns="http://www.w3.org/1999/xhtml" /><hr xmlns="http://www.w3.org/1999/xhtml" />');
7797
+ 'two must be unique'() {
7798
+ $mol_assert_unique([2], [3]);
7783
7799
  },
7784
- 'Spread fragment'() {
7785
- const dom = $mol_jsx("div", null,
7786
- $mol_jsx($mol_jsx_frag, null,
7787
- $mol_jsx("br", null),
7788
- $mol_jsx("hr", null)));
7789
- $mol_assert_equal(dom.outerHTML, '<div><br><hr></div>');
7800
+ 'three must be unique'() {
7801
+ $mol_assert_unique([1], [2], [3]);
7790
7802
  },
7791
- 'Function as component'() {
7792
- const Button = (props, target) => {
7793
- return $mol_jsx("button", { title: props.hint }, target());
7794
- };
7795
- const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
7796
- $mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
7803
+ 'two must be alike'() {
7804
+ $mol_assert_equal([3], [3]);
7797
7805
  },
7798
- 'Nested guid generation'() {
7799
- const Foo = () => {
7800
- return $mol_jsx("div", null,
7801
- $mol_jsx(Bar, { id: "bar" },
7802
- $mol_jsx("img", { id: "icon" })));
7803
- };
7804
- const Bar = (props, icon) => {
7805
- return $mol_jsx("span", null,
7806
- icon,
7807
- $mol_jsx("i", { id: "label" }));
7808
- };
7809
- const dom = $mol_jsx(Foo, { id: "foo" });
7810
- $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>');
7806
+ 'three must be alike'() {
7807
+ $mol_assert_equal([3], [3], [3]);
7811
7808
  },
7812
- 'Fail on non unique ids'() {
7813
- const App = () => {
7814
- return $mol_jsx("div", null,
7815
- $mol_jsx("span", { id: "bar" }),
7816
- $mol_jsx("span", { id: "bar" }));
7817
- };
7818
- $mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
7809
+ 'two object must be alike'() {
7810
+ $mol_assert_equal({ a: 1 }, { a: 1 });
7819
7811
  },
7820
- 'Owner based guid generationn'() {
7821
- const Foo = () => {
7822
- return $mol_jsx("div", null,
7823
- $mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
7824
- };
7825
- const Bar = (props) => {
7826
- return $mol_jsx("span", null, props.icon());
7827
- };
7828
- const dom = $mol_jsx(Foo, { id: "app" });
7829
- $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>');
7812
+ 'three object must be alike'() {
7813
+ $mol_assert_equal({ a: 1 }, { a: 1 }, { a: 1 });
7830
7814
  },
7831
- 'Fail on same ids from different caller'() {
7832
- const Foo = () => {
7833
- return $mol_jsx("div", null,
7834
- $mol_jsx("img", { id: "icon" }),
7835
- $mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
7836
- };
7837
- const Bar = (props) => {
7838
- return $mol_jsx("span", null, props.icon());
7839
- };
7840
- $mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
7815
+ });
7816
+ })($ || ($ = {}));
7817
+
7818
+ ;
7819
+ "use strict";
7820
+ var $;
7821
+ (function ($) {
7822
+ $mol_test({
7823
+ 'return result without errors'() {
7824
+ $mol_assert_equal($mol_try(() => false), false);
7841
7825
  },
7842
7826
  });
7843
7827
  })($ || ($ = {}));
7844
7828
 
7829
+ ;
7830
+ "use strict";
7831
+ var $;
7832
+ (function ($_1) {
7833
+ $mol_test_mocks.push($ => $.$mol_fail_log = () => false);
7834
+ })($ || ($ = {}));
7835
+
7836
+ ;
7837
+ "use strict";
7838
+ var $;
7839
+ (function ($_1) {
7840
+ $mol_test_mocks.push($ => {
7841
+ $.$mol_log3_come = () => { };
7842
+ $.$mol_log3_done = () => { };
7843
+ $.$mol_log3_fail = () => { };
7844
+ $.$mol_log3_warn = () => { };
7845
+ $.$mol_log3_rise = () => { };
7846
+ $.$mol_log3_area = () => () => { };
7847
+ });
7848
+ })($ || ($ = {}));
7849
+
7850
+ ;
7851
+ "use strict";
7852
+
7853
+ ;
7854
+ "use strict";
7855
+
7856
+ ;
7857
+ "use strict";
7858
+
7859
+ ;
7860
+ "use strict";
7861
+
7845
7862
  ;
7846
7863
  "use strict";
7847
7864
  var $;
7848
7865
  (function ($) {
7849
- function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
7850
- const source = typeof item === 'function' ? new $mol_range2_array() : item;
7851
- if (typeof item !== 'function') {
7852
- item = index => source[index];
7853
- size = () => source.length;
7854
- }
7855
- return new Proxy(source, {
7856
- get(target, field) {
7857
- if (typeof field === 'string') {
7858
- if (field === 'length')
7859
- return size();
7860
- const index = Number(field);
7861
- if (index < 0)
7862
- return undefined;
7863
- if (index >= size())
7864
- return undefined;
7865
- if (index === Math.trunc(index))
7866
- return item(index);
7867
- }
7868
- return $mol_range2_array.prototype[field];
7869
- },
7870
- set(target, field) {
7871
- return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
7872
- },
7873
- ownKeys(target) {
7874
- return [...Array(size())].map((v, i) => String(i)).concat('length');
7875
- },
7876
- getOwnPropertyDescriptor(target, field) {
7877
- if (field === "length")
7878
- return {
7879
- value: size(),
7880
- writable: true,
7881
- enumerable: false,
7882
- configurable: false,
7883
- };
7884
- const index = Number(field);
7885
- if (index === Math.trunc(index))
7886
- return {
7887
- get: () => this.get(target, field, this),
7888
- enumerable: true,
7889
- configurable: true,
7890
- };
7891
- return Object.getOwnPropertyDescriptor(target, field);
7892
- }
7893
- });
7894
- }
7895
- $.$mol_range2 = $mol_range2;
7896
- class $mol_range2_array extends Array {
7897
- concat(...tail) {
7898
- if (tail.length === 0)
7899
- return this;
7900
- if (tail.length > 1) {
7901
- let list = this;
7902
- for (let item of tail)
7903
- list = list.concat(item);
7904
- return list;
7905
- }
7906
- return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
7907
- }
7908
- filter(check, context) {
7909
- const filtered = [];
7910
- let cursor = -1;
7911
- return $mol_range2(index => {
7912
- while (cursor < this.length && index >= filtered.length - 1) {
7913
- const val = this[++cursor];
7914
- if (check(val, cursor, this))
7915
- filtered.push(val);
7916
- }
7917
- return filtered[index];
7918
- }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
7919
- }
7920
- forEach(proceed, context) {
7921
- for (let [key, value] of this.entries())
7922
- proceed.call(context, value, key, this);
7923
- }
7924
- map(proceed, context) {
7925
- return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
7926
- }
7927
- reduce(merge, result) {
7928
- let index = 0;
7929
- if (arguments.length === 1) {
7930
- result = this[index++];
7866
+ $mol_test({
7867
+ 'get'() {
7868
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
7869
+ $mol_assert_equal(proxy.foo, 777);
7870
+ },
7871
+ 'has'() {
7872
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
7873
+ $mol_assert_equal('foo' in proxy, true);
7874
+ },
7875
+ 'set'() {
7876
+ const target = { foo: 777 };
7877
+ const proxy = $mol_delegate({}, () => target);
7878
+ proxy.foo = 123;
7879
+ $mol_assert_equal(target.foo, 123);
7880
+ },
7881
+ 'getOwnPropertyDescriptor'() {
7882
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
7883
+ $mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
7884
+ value: 777,
7885
+ writable: true,
7886
+ enumerable: true,
7887
+ configurable: true,
7888
+ });
7889
+ },
7890
+ 'ownKeys'() {
7891
+ const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
7892
+ $mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
7893
+ },
7894
+ 'getPrototypeOf'() {
7895
+ class Foo {
7931
7896
  }
7932
- for (; index < this.length; ++index) {
7933
- result = merge(result, this[index], index, this);
7897
+ const proxy = $mol_delegate({}, () => new Foo);
7898
+ $mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
7899
+ },
7900
+ 'setPrototypeOf'() {
7901
+ class Foo {
7934
7902
  }
7935
- return result;
7936
- }
7937
- toReversed() {
7938
- return $mol_range2(index => this[this.length - 1 - index], () => this.length);
7939
- }
7940
- slice(from = 0, to = this.length) {
7941
- return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
7942
- }
7943
- some(check, context) {
7944
- for (let index = 0; index < this.length; ++index) {
7945
- if (check.call(context, this[index], index, this))
7946
- return true;
7903
+ const target = {};
7904
+ const proxy = $mol_delegate({}, () => target);
7905
+ Object.setPrototypeOf(proxy, Foo.prototype);
7906
+ $mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
7907
+ },
7908
+ 'instanceof'() {
7909
+ class Foo {
7947
7910
  }
7948
- return false;
7949
- }
7950
- every(check, context) {
7951
- for (let index = 0; index < this.length; ++index) {
7952
- if (!check.call(context, this[index], index, this))
7953
- return false;
7911
+ const proxy = $mol_delegate({}, () => new Foo);
7912
+ $mol_assert_ok(proxy instanceof Foo);
7913
+ $mol_assert_ok(proxy instanceof $mol_delegate);
7914
+ },
7915
+ 'autobind'() {
7916
+ class Foo {
7954
7917
  }
7955
- return true;
7956
- }
7957
- reverse() {
7958
- return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
7959
- }
7960
- sort() {
7961
- return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
7962
- }
7963
- indexOf(needle) {
7964
- return this.findIndex(item => item === needle);
7965
- }
7966
- [Symbol.toPrimitive]() {
7967
- return $mol_guid();
7968
- }
7969
- }
7970
- $.$mol_range2_array = $mol_range2_array;
7918
+ const proxy = $mol_delegate({}, () => new Foo);
7919
+ $mol_assert_ok(proxy instanceof Foo);
7920
+ $mol_assert_ok(proxy instanceof $mol_delegate);
7921
+ },
7922
+ });
7971
7923
  })($ || ($ = {}));
7972
7924
 
7973
7925
  ;
7974
7926
  "use strict";
7975
7927
  var $;
7976
- (function ($) {
7928
+ (function ($_1) {
7977
7929
  $mol_test({
7978
- 'lazy calls'() {
7979
- let calls = 0;
7980
- const list = $mol_range2(index => (++calls, index), () => 10);
7981
- $mol_assert_equal(true, list instanceof Array);
7982
- $mol_assert_equal(list.length, 10);
7983
- $mol_assert_equal(list[-1], undefined);
7984
- $mol_assert_equal(list[0], 0);
7985
- $mol_assert_equal(list[9], 9);
7986
- $mol_assert_equal(list[9.5], undefined);
7987
- $mol_assert_equal(list[10], undefined);
7988
- $mol_assert_equal(calls, 2);
7989
- },
7990
- 'infinity list'() {
7991
- let calls = 0;
7992
- const list = $mol_range2(index => (++calls, index));
7993
- $mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
7994
- $mol_assert_equal(list[0], 0);
7995
- $mol_assert_equal(list[4], 4);
7996
- $mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
7997
- $mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
7998
- $mol_assert_equal(calls, 3);
7999
- },
8000
- 'stringify'() {
8001
- const list = $mol_range2(i => i, () => 5);
8002
- $mol_assert_equal(list.toString(), '0,1,2,3,4');
8003
- $mol_assert_equal(list.join(';'), '0;1;2;3;4');
7930
+ 'span for same uri'($) {
7931
+ const span = new $mol_span('test.ts', '', 1, 3, 4);
7932
+ const child = span.span(4, 5, 8);
7933
+ $mol_assert_equal(child.uri, 'test.ts');
7934
+ $mol_assert_equal(child.row, 4);
7935
+ $mol_assert_equal(child.col, 5);
7936
+ $mol_assert_equal(child.length, 8);
8004
7937
  },
8005
- 'for-of'() {
8006
- let log = '';
8007
- for (let i of $mol_range2(i => i + 1, () => 5)) {
8008
- log += i;
8009
- }
8010
- $mol_assert_equal(log, '12345');
7938
+ 'span after of given position'($) {
7939
+ const span = new $mol_span('test.ts', '', 1, 3, 4);
7940
+ const child = span.after(11);
7941
+ $mol_assert_equal(child.uri, 'test.ts');
7942
+ $mol_assert_equal(child.row, 1);
7943
+ $mol_assert_equal(child.col, 7);
7944
+ $mol_assert_equal(child.length, 11);
8011
7945
  },
8012
- 'for-in'() {
8013
- let log = '';
8014
- for (let i in $mol_range2(i => i, () => 5)) {
8015
- log += i;
8016
- }
8017
- $mol_assert_equal(log, '01234');
7946
+ 'slice span - regular'($) {
7947
+ const span = new $mol_span('test.ts', '', 1, 3, 5);
7948
+ const child = span.slice(1, 4);
7949
+ $mol_assert_equal(child.row, 1);
7950
+ $mol_assert_equal(child.col, 4);
7951
+ $mol_assert_equal(child.length, 3);
7952
+ const child2 = span.slice(2, 2);
7953
+ $mol_assert_equal(child2.col, 5);
7954
+ $mol_assert_equal(child2.length, 0);
8018
7955
  },
8019
- 'forEach'() {
8020
- let log = '';
8021
- $mol_range2(i => i, () => 5).forEach(i => log += i);
8022
- $mol_assert_equal(log, '01234');
7956
+ 'slice span - negative'($) {
7957
+ const span = new $mol_span('test.ts', '', 1, 3, 5);
7958
+ const child = span.slice(-3, -1);
7959
+ $mol_assert_equal(child.row, 1);
7960
+ $mol_assert_equal(child.col, 5);
7961
+ $mol_assert_equal(child.length, 2);
8023
7962
  },
8024
- 'reduce'() {
8025
- let calls = 0;
8026
- const list = $mol_range2().slice(1, 6);
8027
- $mol_assert_equal(list.reduce((s, v) => s + v), 15);
8028
- $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
7963
+ 'slice span - out of range'($) {
7964
+ const span = new $mol_span('test.ts', '', 1, 3, 5);
7965
+ $mol_assert_fail(() => span.slice(-1, 3), `End value '3' can't be less than begin value (test.ts#1:3/5)`);
7966
+ $mol_assert_fail(() => span.slice(1, 6), `End value '6' out of range (test.ts#1:3/5)`);
7967
+ $mol_assert_fail(() => span.slice(1, 10), `End value '10' out of range (test.ts#1:3/5)`);
8029
7968
  },
8030
- 'lazy concat'() {
8031
- let calls1 = 0;
8032
- let calls2 = 0;
8033
- const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
8034
- $mol_assert_equal(true, list instanceof Array);
8035
- $mol_assert_equal(list.length, 15);
8036
- $mol_assert_equal(list[0], 0);
8037
- $mol_assert_equal(list[4], 4);
8038
- $mol_assert_equal(list[5], 0);
8039
- $mol_assert_equal(list[9], 4);
8040
- $mol_assert_equal(list[10], 0);
8041
- $mol_assert_equal(list[14], 4);
8042
- $mol_assert_equal(list[15], undefined);
8043
- $mol_assert_equal(calls1, 2);
8044
- $mol_assert_equal(calls2, 2);
7969
+ 'error handling'($) {
7970
+ const span = new $mol_span('test.ts', '', 1, 3, 4);
7971
+ const error = span.error('Some error');
7972
+ $mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
7973
+ }
7974
+ });
7975
+ })($ || ($ = {}));
7976
+
7977
+ ;
7978
+ "use strict";
7979
+ var $;
7980
+ (function ($) {
7981
+ $mol_test({
7982
+ 'all cases of using maybe'() {
7983
+ $mol_assert_equal($mol_maybe(0)[0], 0);
7984
+ $mol_assert_equal($mol_maybe(false)[0], false);
7985
+ $mol_assert_equal($mol_maybe(null)[0], void 0);
7986
+ $mol_assert_equal($mol_maybe(void 0)[0], void 0);
7987
+ $mol_assert_equal($mol_maybe(void 0).map(v => v.toString())[0], void 0);
7988
+ $mol_assert_equal($mol_maybe(0).map(v => v.toString())[0], '0');
8045
7989
  },
8046
- 'lazy filter'() {
8047
- let calls = 0;
8048
- const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
8049
- $mol_assert_equal(true, list instanceof Array);
8050
- $mol_assert_equal(list.length, 3);
8051
- $mol_assert_equal(list[0], 1);
8052
- $mol_assert_equal(list[2], 5);
8053
- $mol_assert_equal(list[3], undefined);
8054
- $mol_assert_equal(calls, 8);
8055
- },
8056
- 'lazy reverse'() {
8057
- let calls = 0;
8058
- const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
8059
- $mol_assert_equal(true, list instanceof Array);
8060
- $mol_assert_equal(list.length, 3);
8061
- $mol_assert_equal(list[0], 9);
8062
- $mol_assert_equal(list[2], 7);
8063
- $mol_assert_equal(list[3], undefined);
8064
- $mol_assert_equal(calls, 2);
8065
- },
8066
- 'lazy map'() {
8067
- let calls1 = 0;
8068
- let calls2 = 0;
8069
- const source = $mol_range2(index => (++calls1, index), () => 5);
8070
- const target = source.map((item, index, self) => {
8071
- ++calls2;
8072
- $mol_assert_equal(source, self);
8073
- return index + 10;
8074
- }, () => 5);
8075
- $mol_assert_equal(true, target instanceof Array);
8076
- $mol_assert_equal(target.length, 5);
8077
- $mol_assert_equal(target[0], 10);
8078
- $mol_assert_equal(target[4], 14);
8079
- $mol_assert_equal(target[5], undefined);
8080
- $mol_assert_equal(calls1, 2);
8081
- $mol_assert_equal(calls2, 2);
8082
- },
8083
- 'lazy slice'() {
8084
- let calls = 0;
8085
- const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
8086
- $mol_assert_equal(true, list instanceof Array);
8087
- $mol_assert_equal(list.length, 4);
8088
- $mol_assert_equal(list[0], 3);
8089
- $mol_assert_equal(list[3], 6);
8090
- $mol_assert_equal(list[4], undefined);
8091
- $mol_assert_equal(calls, 2);
7990
+ });
7991
+ })($ || ($ = {}));
7992
+
7993
+ ;
7994
+ "use strict";
7995
+ var $;
7996
+ (function ($_1) {
7997
+ function check(tree, ideal) {
7998
+ $mol_assert_equal(tree.toString(), $$.$mol_tree2_from_string(ideal).toString());
7999
+ }
8000
+ $mol_test({
8001
+ 'inserting'($) {
8002
+ check($.$mol_tree2_from_string(`
8003
+ a b c d
8004
+ `).insert($mol_tree2.struct('x'), 'a', 'b', 'c'), `
8005
+ a b x
8006
+ `);
8007
+ check($.$mol_tree2_from_string(`
8008
+ a b
8009
+ `).insert($mol_tree2.struct('x'), 'a', 'b', 'c', 'd'), `
8010
+ a b c x
8011
+ `);
8012
+ check($.$mol_tree2_from_string(`
8013
+ a b c d
8014
+ `)
8015
+ .insert($mol_tree2.struct('x'), 0, 0, 0), `
8016
+ a b x
8017
+ `);
8018
+ check($.$mol_tree2_from_string(`
8019
+ a b
8020
+ `)
8021
+ .insert($mol_tree2.struct('x'), 0, 0, 0, 0), `
8022
+ a b \\
8023
+ x
8024
+ `);
8025
+ check($.$mol_tree2_from_string(`
8026
+ a b c d
8027
+ `)
8028
+ .insert($mol_tree2.struct('x'), null, null, null), `
8029
+ a b x
8030
+ `);
8031
+ check($.$mol_tree2_from_string(`
8032
+ a b
8033
+ `)
8034
+ .insert($mol_tree2.struct('x'), null, null, null, null), `
8035
+ a b \\
8036
+ x
8037
+ `);
8092
8038
  },
8093
- 'lazy some'() {
8094
- let calls = 0;
8095
- $mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
8096
- $mol_assert_equal(calls, 3);
8097
- $mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
8098
- $mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
8039
+ 'updating'($) {
8040
+ check($.$mol_tree2_from_string(`
8041
+ a b c d
8042
+ `).update([], 'a', 'b', 'c')[0], `
8043
+ a b
8044
+ `);
8045
+ check($.$mol_tree2_from_string(`
8046
+ a b c d
8047
+ `).update([$mol_tree2.struct('x')])[0], `
8048
+ x
8049
+ `);
8050
+ check($.$mol_tree2_from_string(`
8051
+ a b c d
8052
+ `).update([$mol_tree2.struct('x'), $mol_tree2.struct('y')], 'a', 'b', 'c')[0], `
8053
+ a b
8054
+ x
8055
+ y
8056
+ `);
8099
8057
  },
8100
- 'lazy every'() {
8101
- let calls = 0;
8102
- $mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
8103
- $mol_assert_equal(calls, 3);
8104
- $mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
8105
- $mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
8058
+ 'deleting'($) {
8059
+ const base = $.$mol_tree2_from_string(`
8060
+ a b c d
8061
+ `);
8062
+ check(base.insert(null, 'a', 'b', 'c'), `
8063
+ a b
8064
+ `);
8065
+ check(base.update(base.select('a', 'b', 'c', null).kids, 'a', 'b', 'c')[0], `
8066
+ a b d
8067
+ `);
8068
+ check(base.insert(null, 0, 0, 0), `
8069
+ a b
8070
+ `);
8106
8071
  },
8107
- 'lazyfy'() {
8108
- let calls = 0;
8109
- const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
8110
- $mol_assert_equal(true, list instanceof Array);
8111
- $mol_assert_equal(list.length, 4);
8112
- $mol_assert_equal(calls, 0);
8113
- $mol_assert_equal(list[0], 12);
8114
- $mol_assert_equal(list[3], 15);
8115
- $mol_assert_equal(list[4], undefined);
8116
- $mol_assert_equal(calls, 2);
8072
+ 'hack'($) {
8073
+ const res = $.$mol_tree2_from_string(`
8074
+ foo bar xxx
8075
+ `)
8076
+ .hack({
8077
+ 'bar': (input, belt) => [input.struct('777', input.hack(belt))],
8078
+ });
8079
+ $mol_assert_equal(res.map(String), ['foo 777 xxx\n']);
8117
8080
  },
8118
- 'prevent modification'() {
8119
- const list = $mol_range2(i => i, () => 5);
8120
- $mol_assert_fail(() => list.push(4), TypeError);
8121
- $mol_assert_fail(() => list.pop(), TypeError);
8122
- $mol_assert_fail(() => list.unshift(4), TypeError);
8123
- $mol_assert_fail(() => list.shift(), TypeError);
8124
- $mol_assert_fail(() => list.splice(1, 2), TypeError);
8125
- $mol_assert_fail(() => list[1] = 2, TypeError);
8126
- $mol_assert_fail(() => list.reverse(), TypeError);
8127
- $mol_assert_fail(() => list.sort(), TypeError);
8128
- $mol_assert_equal(list.toString(), '0,1,2,3,4');
8129
- }
8130
8081
  });
8131
8082
  })($ || ($ = {}));
8132
8083
 
8133
8084
  ;
8134
8085
  "use strict";
8135
8086
  var $;
8136
- (function ($) {
8087
+ (function ($_1) {
8137
8088
  $mol_test({
8138
- 'nulls & undefineds'() {
8139
- $mol_assert_ok($mol_compare_deep(null, null));
8140
- $mol_assert_ok($mol_compare_deep(undefined, undefined));
8141
- $mol_assert_not($mol_compare_deep(undefined, null));
8142
- $mol_assert_not($mol_compare_deep({}, null));
8143
- },
8144
- 'number'() {
8145
- $mol_assert_ok($mol_compare_deep(1, 1));
8146
- $mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
8147
- $mol_assert_not($mol_compare_deep(1, 2));
8148
- $mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
8149
- $mol_assert_not($mol_compare_deep(Object(1), Object(2)));
8089
+ 'tree parsing'($) {
8090
+ $mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids.length, 2);
8091
+ $mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids[1].type, "bar");
8092
+ $mol_assert_equal($.$mol_tree2_from_string("foo\n\n\n").kids.length, 1);
8093
+ $mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids.length, 2);
8094
+ $mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids[1].value, "bar");
8095
+ $mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
8096
+ $mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
8097
+ $mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
8150
8098
  },
8151
- 'POJO'() {
8152
- $mol_assert_ok($mol_compare_deep({}, {}));
8153
- $mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
8154
- $mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
8155
- $mol_assert_not($mol_compare_deep({}, { a: undefined }));
8156
- $mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
8157
- $mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
8158
- $mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
8099
+ 'Too many tabs'($) {
8100
+ const tree = `
8101
+ foo
8102
+ bar
8103
+ `;
8104
+ $mol_assert_fail(() => {
8105
+ $.$mol_tree2_from_string(tree, 'test');
8106
+ }, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
8159
8107
  },
8160
- 'Array'() {
8161
- $mol_assert_ok($mol_compare_deep([], []));
8162
- $mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
8163
- $mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
8164
- $mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
8165
- $mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
8166
- $mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
8108
+ 'Too few tabs'($) {
8109
+ const tree = `
8110
+ foo
8111
+ bar
8112
+ `;
8113
+ $mol_assert_fail(() => {
8114
+ $.$mol_tree2_from_string(tree, 'test');
8115
+ }, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
8167
8116
  },
8168
- 'Non POJO are different'() {
8169
- class Thing extends Object {
8170
- }
8171
- $mol_assert_not($mol_compare_deep(new Thing, new Thing));
8172
- $mol_assert_not($mol_compare_deep(() => 1, () => 1));
8173
- $mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
8117
+ 'Wrong nodes separator at start'($) {
8118
+ const tree = `foo\n \tbar\n`;
8119
+ $mol_assert_fail(() => {
8120
+ $.$mol_tree2_from_string(tree, 'test');
8121
+ }, 'Wrong nodes separator\ntest#2:1/2\n!!\n \tbar');
8174
8122
  },
8175
- 'POJO with symbols'() {
8176
- const sym = Symbol();
8177
- $mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
8178
- $mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
8123
+ 'Wrong nodes separator in the middle'($) {
8124
+ const tree = `foo bar\n`;
8125
+ $mol_assert_fail(() => {
8126
+ $.$mol_tree2_from_string(tree, 'test');
8127
+ }, 'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar');
8179
8128
  },
8180
- 'same POJOs with cyclic reference'() {
8181
- const a = { foo: {} };
8182
- a['self'] = a;
8183
- const b = { foo: {} };
8184
- b['self'] = b;
8185
- $mol_assert_ok($mol_compare_deep(a, b));
8129
+ 'Unexpected EOF, LF required'($) {
8130
+ const tree = ` foo`;
8131
+ $mol_assert_fail(() => {
8132
+ $.$mol_tree2_from_string(tree, 'test');
8133
+ }, 'Unexpected EOF, LF required\ntest#1:5/1\n !\n foo');
8186
8134
  },
8187
- 'same POJOs with cyclic reference with cache warmup'() {
8188
- const obj1 = { test: 1, obj3: null };
8189
- const obj1_copy = { test: 1, obj3: null };
8190
- const obj2 = { test: 2, obj1 };
8191
- const obj2_copy = { test: 2, obj1: obj1_copy };
8192
- const obj3 = { test: 3, obj2 };
8193
- const obj3_copy = { test: 3, obj2: obj2_copy };
8194
- obj1.obj3 = obj3;
8195
- obj1_copy.obj3 = obj3_copy;
8196
- $mol_assert_not($mol_compare_deep(obj1, {}));
8197
- $mol_assert_not($mol_compare_deep(obj2, {}));
8198
- $mol_assert_not($mol_compare_deep(obj3, {}));
8199
- $mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
8200
- },
8201
- 'Date'() {
8202
- $mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
8203
- $mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
8204
- },
8205
- 'RegExp'() {
8206
- $mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
8207
- $mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
8208
- $mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
8209
- },
8210
- 'Error'() {
8211
- $mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
8212
- const fail = (message) => new Error(message);
8213
- $mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
8214
- $mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
8215
- },
8216
- 'Map'() {
8217
- $mol_assert_ok($mol_compare_deep(new Map, new Map));
8218
- $mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
8219
- $mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
8220
- $mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
8221
- $mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
8222
- },
8223
- 'Set'() {
8224
- $mol_assert_ok($mol_compare_deep(new Set, new Set));
8225
- $mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
8226
- $mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
8227
- },
8228
- 'Uint8Array'() {
8229
- $mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
8230
- $mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
8231
- $mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
8232
- },
8233
- 'DataView'() {
8234
- $mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
8235
- $mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
8236
- $mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
8237
- },
8238
- 'Serializale'() {
8239
- class User {
8240
- name;
8241
- rand;
8242
- constructor(name, rand = Math.random()) {
8243
- this.name = name;
8244
- this.rand = rand;
8245
- }
8246
- [Symbol.toPrimitive](mode) {
8247
- return this.name;
8135
+ 'Errors skip and collect'($) {
8136
+ const tree = `foo bar`;
8137
+ const errors = [];
8138
+ const $$ = $.$mol_ambient({
8139
+ $mol_fail: (error) => {
8140
+ errors.push(error.message);
8141
+ return null;
8248
8142
  }
8249
- }
8250
- $mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
8251
- $mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
8252
- },
8253
- 'Iterable'() {
8254
- $mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
8255
- $mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
8256
- $mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
8143
+ });
8144
+ const res = $$.$mol_tree2_from_string(tree, 'test');
8145
+ $mol_assert_like(errors, [
8146
+ 'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar',
8147
+ 'Unexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
8148
+ ]);
8149
+ $mol_assert_equal(res.toString(), 'foo bar\n');
8257
8150
  },
8258
8151
  });
8259
8152
  })($ || ($ = {}));
@@ -8262,100 +8155,61 @@ var $;
8262
8155
  "use strict";
8263
8156
  var $;
8264
8157
  (function ($) {
8265
- function $mol_assert_ok(value) {
8266
- if (value)
8267
- return;
8268
- $mol_fail(new Error(`${value} true`));
8269
- }
8270
- $.$mol_assert_ok = $mol_assert_ok;
8271
- function $mol_assert_not(value) {
8272
- if (!value)
8273
- return;
8274
- $mol_fail(new Error(`${value} ≠ false`));
8275
- }
8276
- $.$mol_assert_not = $mol_assert_not;
8277
- function $mol_assert_fail(handler, ErrorRight) {
8278
- const fail = $.$mol_fail;
8279
- try {
8280
- $.$mol_fail = $.$mol_fail_hidden;
8281
- handler();
8282
- }
8283
- catch (error) {
8284
- $.$mol_fail = fail;
8285
- if (typeof ErrorRight === 'string') {
8286
- $mol_assert_equal(error.message ?? error, ErrorRight);
8287
- }
8288
- else {
8289
- $mol_assert_equal(error instanceof ErrorRight, true);
8290
- }
8291
- return error;
8292
- }
8293
- finally {
8294
- $.$mol_fail = fail;
8295
- }
8296
- $mol_fail(new Error('Not failed'));
8297
- }
8298
- $.$mol_assert_fail = $mol_assert_fail;
8299
- function $mol_assert_like(...args) {
8300
- $mol_assert_equal(...args);
8301
- }
8302
- $.$mol_assert_like = $mol_assert_like;
8303
- function $mol_assert_unique(...args) {
8304
- for (let i = 0; i < args.length; ++i) {
8305
- for (let j = 0; j < args.length; ++j) {
8306
- if (i === j)
8307
- continue;
8308
- if (!$mol_compare_deep(args[i], args[j]))
8309
- continue;
8310
- return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
8311
- }
8312
- }
8313
- }
8314
- $.$mol_assert_unique = $mol_assert_unique;
8315
- function $mol_assert_equal(...args) {
8316
- for (let i = 1; i < args.length; ++i) {
8317
- if ($mol_compare_deep(args[0], args[i]))
8318
- continue;
8319
- return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
8320
- }
8321
- }
8322
- $.$mol_assert_equal = $mol_assert_equal;
8158
+ $mol_test({
8159
+ 'fromJSON'() {
8160
+ $mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
8161
+ $mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
8162
+ $mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
8163
+ $mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
8164
+ $mol_assert_equal($mol_tree2_from_json(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
8165
+ $mol_assert_equal($mol_tree2_from_json({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
8166
+ },
8167
+ });
8323
8168
  })($ || ($ = {}));
8324
8169
 
8325
8170
  ;
8326
8171
  "use strict";
8327
8172
  var $;
8328
- (function ($) {
8173
+ (function ($_1) {
8329
8174
  $mol_test({
8330
- 'must be false'() {
8331
- $mol_assert_not(0);
8332
- },
8333
- 'must be true'() {
8334
- $mol_assert_ok(1);
8335
- },
8336
- 'two must be equal'() {
8337
- $mol_assert_equal(2, 2);
8338
- },
8339
- 'three must be equal'() {
8340
- $mol_assert_equal(2, 2, 2);
8341
- },
8342
- 'two must be unique'() {
8343
- $mol_assert_unique([2], [3]);
8344
- },
8345
- 'three must be unique'() {
8346
- $mol_assert_unique([1], [2], [3]);
8347
- },
8348
- 'two must be alike'() {
8349
- $mol_assert_equal([3], [3]);
8175
+ 'FQN of anon function'($) {
8176
+ const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
8177
+ $mol_assert_equal($$.$mol_func_name_test.name, '');
8178
+ $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
8179
+ $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
8350
8180
  },
8351
- 'three must be alike'() {
8352
- $mol_assert_equal([3], [3], [3]);
8181
+ });
8182
+ })($ || ($ = {}));
8183
+
8184
+ ;
8185
+ "use strict";
8186
+ var $;
8187
+ (function ($) {
8188
+ $mol_test({
8189
+ 'auto name'() {
8190
+ class Invalid extends $mol_error_mix {
8191
+ }
8192
+ const mix = new Invalid('foo');
8193
+ $mol_assert_equal(mix.name, 'Invalid_Error');
8353
8194
  },
8354
- 'two object must be alike'() {
8355
- $mol_assert_equal({ a: 1 }, { a: 1 });
8195
+ 'simpe mix'() {
8196
+ const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
8197
+ $mol_assert_equal(mix.message, 'foo');
8198
+ $mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
8356
8199
  },
8357
- 'three object must be alike'() {
8358
- $mol_assert_equal({ a: 1 }, { a: 1 }, { a: 1 });
8200
+ 'provide additional info'() {
8201
+ class Invalid extends $mol_error_mix {
8202
+ }
8203
+ const mix = new $mol_error_mix('Wrong password', {}, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
8204
+ const hints = [];
8205
+ if (mix instanceof $mol_error_mix) {
8206
+ for (const er of mix.errors) {
8207
+ if (er instanceof Invalid) {
8208
+ hints.push(er.cause?.hint ?? '');
8209
+ }
8210
+ }
8211
+ }
8212
+ $mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
8359
8213
  },
8360
8214
  });
8361
8215
  })($ || ($ = {}));
@@ -8364,81 +8218,82 @@ var $;
8364
8218
  "use strict";
8365
8219
  var $;
8366
8220
  (function ($_1) {
8367
- $mol_test_mocks.push($ => {
8368
- $.$mol_log3_come = () => { };
8369
- $.$mol_log3_done = () => { };
8370
- $.$mol_log3_fail = () => { };
8371
- $.$mol_log3_warn = () => { };
8372
- $.$mol_log3_rise = () => { };
8373
- $.$mol_log3_area = () => () => { };
8221
+ $mol_test({
8222
+ 'init with overload'() {
8223
+ class X extends $mol_object {
8224
+ foo() {
8225
+ return 1;
8226
+ }
8227
+ }
8228
+ var x = X.make({
8229
+ foo: () => 2,
8230
+ });
8231
+ $mol_assert_equal(x.foo(), 2);
8232
+ },
8233
+ 'Context in instance inherits from class'($) {
8234
+ const custom = $.$mol_ambient({});
8235
+ class X extends $.$mol_object {
8236
+ static $ = custom;
8237
+ }
8238
+ $mol_assert_equal(new X().$, custom);
8239
+ },
8374
8240
  });
8375
8241
  })($ || ($ = {}));
8376
8242
 
8377
- ;
8378
- "use strict";
8379
-
8380
- ;
8381
- "use strict";
8382
-
8383
8243
  ;
8384
8244
  "use strict";
8385
8245
  var $;
8386
- (function ($) {
8246
+ (function ($_1) {
8387
8247
  $mol_test({
8388
- 'get'() {
8389
- const proxy = $mol_delegate({}, () => ({ foo: 777 }));
8390
- $mol_assert_equal(proxy.foo, 777);
8391
- },
8392
- 'has'() {
8393
- const proxy = $mol_delegate({}, () => ({ foo: 777 }));
8394
- $mol_assert_equal('foo' in proxy, true);
8395
- },
8396
- 'set'() {
8397
- const target = { foo: 777 };
8398
- const proxy = $mol_delegate({}, () => target);
8399
- proxy.foo = 123;
8400
- $mol_assert_equal(target.foo, 123);
8401
- },
8402
- 'getOwnPropertyDescriptor'() {
8403
- const proxy = $mol_delegate({}, () => ({ foo: 777 }));
8404
- $mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
8405
- value: 777,
8406
- writable: true,
8407
- enumerable: true,
8408
- configurable: true,
8409
- });
8410
- },
8411
- 'ownKeys'() {
8412
- const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
8413
- $mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
8414
- },
8415
- 'getPrototypeOf'() {
8416
- class Foo {
8248
+ 'Collect deps'() {
8249
+ const pub1 = new $mol_wire_pub;
8250
+ const pub2 = new $mol_wire_pub;
8251
+ const sub = new $mol_wire_pub_sub;
8252
+ const bu1 = sub.track_on();
8253
+ try {
8254
+ pub1.promote();
8255
+ pub2.promote();
8256
+ pub2.promote();
8417
8257
  }
8418
- const proxy = $mol_delegate({}, () => new Foo);
8419
- $mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
8420
- },
8421
- 'setPrototypeOf'() {
8422
- class Foo {
8258
+ finally {
8259
+ sub.track_cut();
8260
+ sub.track_off(bu1);
8423
8261
  }
8424
- const target = {};
8425
- const proxy = $mol_delegate({}, () => target);
8426
- Object.setPrototypeOf(proxy, Foo.prototype);
8427
- $mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
8428
- },
8429
- 'instanceof'() {
8430
- class Foo {
8262
+ pub1.emit();
8263
+ pub2.emit();
8264
+ $mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
8265
+ const bu2 = sub.track_on();
8266
+ try {
8267
+ pub1.promote();
8268
+ pub1.promote();
8269
+ pub2.promote();
8431
8270
  }
8432
- const proxy = $mol_delegate({}, () => new Foo);
8433
- $mol_assert_ok(proxy instanceof Foo);
8434
- $mol_assert_ok(proxy instanceof $mol_delegate);
8271
+ finally {
8272
+ sub.track_cut();
8273
+ sub.track_off(bu2);
8274
+ }
8275
+ pub1.emit();
8276
+ pub2.emit();
8277
+ $mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
8435
8278
  },
8436
- 'autobind'() {
8437
- class Foo {
8279
+ 'cyclic detection'($) {
8280
+ const sub1 = new $mol_wire_pub_sub;
8281
+ const sub2 = new $mol_wire_pub_sub;
8282
+ const bu1 = sub1.track_on();
8283
+ try {
8284
+ const bu2 = sub2.track_on();
8285
+ try {
8286
+ $mol_assert_fail(() => sub1.promote(), 'Circular subscription');
8287
+ }
8288
+ finally {
8289
+ sub2.track_cut();
8290
+ sub2.track_off(bu2);
8291
+ }
8292
+ }
8293
+ finally {
8294
+ sub1.track_cut();
8295
+ sub1.track_off(bu1);
8438
8296
  }
8439
- const proxy = $mol_delegate({}, () => new Foo);
8440
- $mol_assert_ok(proxy instanceof Foo);
8441
- $mol_assert_ok(proxy instanceof $mol_delegate);
8442
8297
  },
8443
8298
  });
8444
8299
  })($ || ($ = {}));
@@ -8446,52 +8301,47 @@ var $;
8446
8301
  ;
8447
8302
  "use strict";
8448
8303
  var $;
8449
- (function ($_1) {
8450
- $mol_test({
8451
- 'span for same uri'($) {
8452
- const span = new $mol_span('test.ts', '', 1, 3, 4);
8453
- const child = span.span(4, 5, 8);
8454
- $mol_assert_equal(child.uri, 'test.ts');
8455
- $mol_assert_equal(child.row, 4);
8456
- $mol_assert_equal(child.col, 5);
8457
- $mol_assert_equal(child.length, 8);
8458
- },
8459
- 'span after of given position'($) {
8460
- const span = new $mol_span('test.ts', '', 1, 3, 4);
8461
- const child = span.after(11);
8462
- $mol_assert_equal(child.uri, 'test.ts');
8463
- $mol_assert_equal(child.row, 1);
8464
- $mol_assert_equal(child.col, 7);
8465
- $mol_assert_equal(child.length, 11);
8466
- },
8467
- 'slice span - regular'($) {
8468
- const span = new $mol_span('test.ts', '', 1, 3, 5);
8469
- const child = span.slice(1, 4);
8470
- $mol_assert_equal(child.row, 1);
8471
- $mol_assert_equal(child.col, 4);
8472
- $mol_assert_equal(child.length, 3);
8473
- const child2 = span.slice(2, 2);
8474
- $mol_assert_equal(child2.col, 5);
8475
- $mol_assert_equal(child2.length, 0);
8476
- },
8477
- 'slice span - negative'($) {
8478
- const span = new $mol_span('test.ts', '', 1, 3, 5);
8479
- const child = span.slice(-3, -1);
8480
- $mol_assert_equal(child.row, 1);
8481
- $mol_assert_equal(child.col, 5);
8482
- $mol_assert_equal(child.length, 2);
8483
- },
8484
- 'slice span - out of range'($) {
8485
- const span = new $mol_span('test.ts', '', 1, 3, 5);
8486
- $mol_assert_fail(() => span.slice(-1, 3), `End value '3' can't be less than begin value (test.ts#1:3/5)`);
8487
- $mol_assert_fail(() => span.slice(1, 6), `End value '6' out of range (test.ts#1:3/5)`);
8488
- $mol_assert_fail(() => span.slice(1, 10), `End value '10' out of range (test.ts#1:3/5)`);
8489
- },
8490
- 'error handling'($) {
8491
- const span = new $mol_span('test.ts', '', 1, 3, 4);
8492
- const error = span.error('Some error');
8493
- $mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
8304
+ (function ($) {
8305
+ $.$mol_after_mock_queue = [];
8306
+ function $mol_after_mock_warp() {
8307
+ const queue = $.$mol_after_mock_queue.splice(0);
8308
+ for (const task of queue)
8309
+ task();
8310
+ }
8311
+ $.$mol_after_mock_warp = $mol_after_mock_warp;
8312
+ class $mol_after_mock_commmon extends $mol_object2 {
8313
+ task;
8314
+ promise = Promise.resolve();
8315
+ cancelled = false;
8316
+ id;
8317
+ constructor(task) {
8318
+ super();
8319
+ this.task = task;
8320
+ $.$mol_after_mock_queue.push(task);
8321
+ }
8322
+ destructor() {
8323
+ const index = $.$mol_after_mock_queue.indexOf(this.task);
8324
+ if (index >= 0)
8325
+ $.$mol_after_mock_queue.splice(index, 1);
8326
+ }
8327
+ }
8328
+ $.$mol_after_mock_commmon = $mol_after_mock_commmon;
8329
+ class $mol_after_mock_timeout extends $mol_after_mock_commmon {
8330
+ delay;
8331
+ constructor(delay, task) {
8332
+ super(task);
8333
+ this.delay = delay;
8494
8334
  }
8335
+ }
8336
+ $.$mol_after_mock_timeout = $mol_after_mock_timeout;
8337
+ })($ || ($ = {}));
8338
+
8339
+ ;
8340
+ "use strict";
8341
+ var $;
8342
+ (function ($_1) {
8343
+ $mol_test_mocks.push($ => {
8344
+ $.$mol_after_tick = $mol_after_mock_commmon;
8495
8345
  });
8496
8346
  })($ || ($ = {}));
8497
8347
 
@@ -8500,13 +8350,79 @@ var $;
8500
8350
  var $;
8501
8351
  (function ($) {
8502
8352
  $mol_test({
8503
- 'all cases of using maybe'() {
8504
- $mol_assert_equal($mol_maybe(0)[0], 0);
8505
- $mol_assert_equal($mol_maybe(false)[0], false);
8506
- $mol_assert_equal($mol_maybe(null)[0], void 0);
8507
- $mol_assert_equal($mol_maybe(void 0)[0], void 0);
8508
- $mol_assert_equal($mol_maybe(void 0).map(v => v.toString())[0], void 0);
8509
- $mol_assert_equal($mol_maybe(0).map(v => v.toString())[0], '0');
8353
+ 'Sync execution'() {
8354
+ class Sync extends $mol_object2 {
8355
+ static calc(a, b) {
8356
+ return a + b;
8357
+ }
8358
+ }
8359
+ __decorate([
8360
+ $mol_wire_method
8361
+ ], Sync, "calc", null);
8362
+ $mol_assert_equal(Sync.calc(1, 2), 3);
8363
+ },
8364
+ async 'async <=> sync'() {
8365
+ class SyncAsync extends $mol_object2 {
8366
+ static async val(a) {
8367
+ return a;
8368
+ }
8369
+ static sum(a, b) {
8370
+ const syn = $mol_wire_sync(this);
8371
+ return syn.val(a) + syn.val(b);
8372
+ }
8373
+ static async calc(a, b) {
8374
+ return 5 + await $mol_wire_async(this).sum(a, b);
8375
+ }
8376
+ }
8377
+ $mol_assert_equal(await SyncAsync.calc(1, 2), 8);
8378
+ },
8379
+ async 'Idempotence control'() {
8380
+ class Idempotence extends $mol_object2 {
8381
+ static logs_idemp = 0;
8382
+ static logs_unidemp = 0;
8383
+ static log_idemp() {
8384
+ this.logs_idemp += 1;
8385
+ }
8386
+ static log_unidemp() {
8387
+ this.logs_unidemp += 1;
8388
+ }
8389
+ static async val(a) {
8390
+ return a;
8391
+ }
8392
+ static sum(a, b) {
8393
+ this.log_idemp();
8394
+ this.log_unidemp();
8395
+ const syn = $mol_wire_sync(this);
8396
+ return syn.val(a) + syn.val(b);
8397
+ }
8398
+ static async calc(a, b) {
8399
+ return 5 + await $mol_wire_async(this).sum(a, b);
8400
+ }
8401
+ }
8402
+ __decorate([
8403
+ $mol_wire_method
8404
+ ], Idempotence, "log_idemp", null);
8405
+ $mol_assert_equal(await Idempotence.calc(1, 2), 8);
8406
+ $mol_assert_equal(Idempotence.logs_idemp, 1);
8407
+ $mol_assert_equal(Idempotence.logs_unidemp, 3);
8408
+ },
8409
+ async 'Error handling'() {
8410
+ class Handle extends $mol_object2 {
8411
+ static async sum(a, b) {
8412
+ $mol_fail(new Error('test error ' + (a + b)));
8413
+ }
8414
+ static check() {
8415
+ try {
8416
+ return $mol_wire_sync(Handle).sum(1, 2);
8417
+ }
8418
+ catch (error) {
8419
+ if ($mol_promise_like(error))
8420
+ $mol_fail_hidden(error);
8421
+ $mol_assert_equal(error.message, 'test error 3');
8422
+ }
8423
+ }
8424
+ }
8425
+ await $mol_wire_async(Handle).check();
8510
8426
  },
8511
8427
  });
8512
8428
  })($ || ($ = {}));
@@ -8515,89 +8431,51 @@ var $;
8515
8431
  "use strict";
8516
8432
  var $;
8517
8433
  (function ($_1) {
8518
- function check(tree, ideal) {
8519
- $mol_assert_equal(tree.toString(), $$.$mol_tree2_from_string(ideal).toString());
8520
- }
8521
8434
  $mol_test({
8522
- 'inserting'($) {
8523
- check($.$mol_tree2_from_string(`
8524
- a b c d
8525
- `).insert($mol_tree2.struct('x'), 'a', 'b', 'c'), `
8526
- a b x
8527
- `);
8528
- check($.$mol_tree2_from_string(`
8529
- a b
8530
- `).insert($mol_tree2.struct('x'), 'a', 'b', 'c', 'd'), `
8531
- a b c x
8532
- `);
8533
- check($.$mol_tree2_from_string(`
8534
- a b c d
8535
- `)
8536
- .insert($mol_tree2.struct('x'), 0, 0, 0), `
8537
- a b x
8538
- `);
8539
- check($.$mol_tree2_from_string(`
8540
- a b
8541
- `)
8542
- .insert($mol_tree2.struct('x'), 0, 0, 0, 0), `
8543
- a b \\
8544
- x
8545
- `);
8546
- check($.$mol_tree2_from_string(`
8547
- a b c d
8548
- `)
8549
- .insert($mol_tree2.struct('x'), null, null, null), `
8550
- a b x
8551
- `);
8552
- check($.$mol_tree2_from_string(`
8553
- a b
8554
- `)
8555
- .insert($mol_tree2.struct('x'), null, null, null, null), `
8556
- a b \\
8557
- x
8558
- `);
8559
- },
8560
- 'updating'($) {
8561
- check($.$mol_tree2_from_string(`
8562
- a b c d
8563
- `).update([], 'a', 'b', 'c')[0], `
8564
- a b
8565
- `);
8566
- check($.$mol_tree2_from_string(`
8567
- a b c d
8568
- `).update([$mol_tree2.struct('x')])[0], `
8569
- x
8570
- `);
8571
- check($.$mol_tree2_from_string(`
8572
- a b c d
8573
- `).update([$mol_tree2.struct('x'), $mol_tree2.struct('y')], 'a', 'b', 'c')[0], `
8574
- a b
8575
- x
8576
- y
8577
- `);
8435
+ 'test types'($) {
8436
+ class A {
8437
+ static a() {
8438
+ return '';
8439
+ }
8440
+ static b() {
8441
+ return $mol_wire_async(this).a();
8442
+ }
8443
+ }
8578
8444
  },
8579
- 'deleting'($) {
8580
- const base = $.$mol_tree2_from_string(`
8581
- a b c d
8582
- `);
8583
- check(base.insert(null, 'a', 'b', 'c'), `
8584
- a b
8585
- `);
8586
- check(base.update(base.select('a', 'b', 'c', null).kids, 'a', 'b', 'c')[0], `
8587
- a b d
8588
- `);
8589
- check(base.insert(null, 0, 0, 0), `
8590
- a b
8591
- `);
8445
+ async 'Latest method calls wins'($) {
8446
+ class NameLogger extends $mol_object2 {
8447
+ static $ = $;
8448
+ static first = [];
8449
+ static last = [];
8450
+ static send(next) {
8451
+ $mol_wire_sync(this.first).push(next);
8452
+ $$.$mol_wait_timeout(0);
8453
+ this.last.push(next);
8454
+ }
8455
+ }
8456
+ const name = $mol_wire_async(NameLogger).send;
8457
+ name('john');
8458
+ const promise = name('jin');
8459
+ $.$mol_after_mock_warp();
8460
+ await promise;
8461
+ $mol_assert_equal(NameLogger.first, ['john', 'jin']);
8462
+ $mol_assert_equal(NameLogger.last, ['jin']);
8592
8463
  },
8593
- 'hack'($) {
8594
- const res = $.$mol_tree2_from_string(`
8595
- foo bar xxx
8596
- `)
8597
- .hack({
8598
- 'bar': (input, belt) => [input.struct('777', input.hack(belt))],
8599
- });
8600
- $mol_assert_equal(res.map(String), ['foo 777 xxx\n']);
8464
+ async 'Latest function calls wins'($) {
8465
+ const first = [];
8466
+ const last = [];
8467
+ function send_name(next) {
8468
+ $mol_wire_sync(first).push(next);
8469
+ $$.$mol_wait_timeout(0);
8470
+ last.push(next);
8471
+ }
8472
+ const name = $mol_wire_async(send_name);
8473
+ name('john');
8474
+ const promise = name('jin');
8475
+ $.$mol_after_mock_warp();
8476
+ await promise;
8477
+ $mol_assert_equal(first, ['john', 'jin']);
8478
+ $mol_assert_equal(last, ['jin']);
8601
8479
  },
8602
8480
  });
8603
8481
  })($ || ($ = {}));
@@ -8607,158 +8485,154 @@ var $;
8607
8485
  var $;
8608
8486
  (function ($_1) {
8609
8487
  $mol_test({
8610
- 'tree parsing'($) {
8611
- $mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids.length, 2);
8612
- $mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids[1].type, "bar");
8613
- $mol_assert_equal($.$mol_tree2_from_string("foo\n\n\n").kids.length, 1);
8614
- $mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids.length, 2);
8615
- $mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids[1].value, "bar");
8616
- $mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
8617
- $mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
8618
- $mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
8619
- },
8620
- 'Too many tabs'($) {
8621
- const tree = `
8622
- foo
8623
- bar
8624
- `;
8625
- $mol_assert_fail(() => {
8626
- $.$mol_tree2_from_string(tree, 'test');
8627
- }, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
8628
- },
8629
- 'Too few tabs'($) {
8630
- const tree = `
8631
- foo
8632
- bar
8633
- `;
8634
- $mol_assert_fail(() => {
8635
- $.$mol_tree2_from_string(tree, 'test');
8636
- }, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
8637
- },
8638
- 'Wrong nodes separator at start'($) {
8639
- const tree = `foo\n \tbar\n`;
8640
- $mol_assert_fail(() => {
8641
- $.$mol_tree2_from_string(tree, 'test');
8642
- }, 'Wrong nodes separator\ntest#2:1/2\n!!\n \tbar');
8643
- },
8644
- 'Wrong nodes separator in the middle'($) {
8645
- const tree = `foo bar\n`;
8646
- $mol_assert_fail(() => {
8647
- $.$mol_tree2_from_string(tree, 'test');
8648
- }, 'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar');
8488
+ 'test types'($) {
8489
+ class A {
8490
+ static a() {
8491
+ return Promise.resolve('');
8492
+ }
8493
+ static b() {
8494
+ return $mol_wire_sync(this).a();
8495
+ }
8496
+ }
8649
8497
  },
8650
- 'Unexpected EOF, LF required'($) {
8651
- const tree = ` foo`;
8652
- $mol_assert_fail(() => {
8653
- $.$mol_tree2_from_string(tree, 'test');
8654
- }, 'Unexpected EOF, LF required\ntest#1:5/1\n !\n foo');
8498
+ async 'test method from host'($) {
8499
+ let count = 0;
8500
+ class A {
8501
+ static a() {
8502
+ return $mol_wire_sync(this).b();
8503
+ }
8504
+ static b() { return Promise.resolve(++count); }
8505
+ }
8506
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
8655
8507
  },
8656
- 'Errors skip and collect'($) {
8657
- const tree = `foo bar`;
8658
- const errors = [];
8659
- const $$ = $.$mol_ambient({
8660
- $mol_fail: (error) => {
8661
- errors.push(error.message);
8662
- return null;
8508
+ async 'test function'($) {
8509
+ let count = 0;
8510
+ class A {
8511
+ static a() {
8512
+ return $mol_wire_sync(this.b)();
8663
8513
  }
8664
- });
8665
- const res = $$.$mol_tree2_from_string(tree, 'test');
8666
- $mol_assert_like(errors, [
8667
- 'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar',
8668
- 'Unexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
8669
- ]);
8670
- $mol_assert_equal(res.toString(), 'foo bar\n');
8514
+ static b() { return Promise.resolve(++count); }
8515
+ }
8516
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
8671
8517
  },
8518
+ async 'test construct itself'($) {
8519
+ class A {
8520
+ static instances = [];
8521
+ static a() {
8522
+ const a = new ($mol_wire_sync(A))();
8523
+ this.instances.push(a);
8524
+ $mol_wire_sync(this).b();
8525
+ }
8526
+ static b() { return Promise.resolve(); }
8527
+ }
8528
+ await $mol_wire_async(A).a();
8529
+ $mol_assert_equal(A.instances.length, 2);
8530
+ $mol_assert_equal(A.instances[0] instanceof A, true);
8531
+ $mol_assert_equal(A.instances[0], A.instances[1]);
8532
+ }
8672
8533
  });
8673
8534
  })($ || ($ = {}));
8674
8535
 
8675
8536
  ;
8676
8537
  "use strict";
8677
8538
  var $;
8678
- (function ($) {
8679
- $mol_test({
8680
- 'fromJSON'() {
8681
- $mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
8682
- $mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
8683
- $mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
8684
- $mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
8685
- $mol_assert_equal($mol_tree2_from_json(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
8686
- $mol_assert_equal($mol_tree2_from_json({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
8687
- },
8539
+ (function ($_1) {
8540
+ $mol_test_mocks.push($ => {
8541
+ $.$mol_after_timeout = $mol_after_mock_timeout;
8688
8542
  });
8689
8543
  })($ || ($ = {}));
8690
8544
 
8691
8545
  ;
8692
8546
  "use strict";
8693
8547
  var $;
8694
- (function ($_1) {
8695
- $mol_test({
8696
- 'FQN of anon function'($) {
8697
- const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
8698
- $mol_assert_equal($$.$mol_func_name_test.name, '');
8699
- $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
8700
- $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
8701
- },
8702
- });
8548
+ (function ($) {
8549
+ class $mol_after_work extends $mol_object2 {
8550
+ delay;
8551
+ task;
8552
+ id;
8553
+ constructor(delay, task) {
8554
+ super();
8555
+ this.delay = delay;
8556
+ this.task = task;
8557
+ this.id = requestIdleCallback(task, { timeout: delay });
8558
+ }
8559
+ destructor() {
8560
+ cancelIdleCallback(this.id);
8561
+ }
8562
+ }
8563
+ $.$mol_after_work = $mol_after_work;
8564
+ if (typeof requestIdleCallback !== 'function') {
8565
+ $.$mol_after_work = $mol_after_timeout;
8566
+ }
8703
8567
  })($ || ($ = {}));
8704
8568
 
8705
8569
  ;
8706
8570
  "use strict";
8707
8571
  var $;
8708
- (function ($) {
8709
- $mol_test({
8710
- 'auto name'() {
8711
- class Invalid extends $mol_error_mix {
8712
- }
8713
- const mix = new Invalid('foo');
8714
- $mol_assert_equal(mix.name, 'Invalid_Error');
8715
- },
8716
- 'simpe mix'() {
8717
- const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
8718
- $mol_assert_equal(mix.message, 'foo');
8719
- $mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
8720
- },
8721
- 'provide additional info'() {
8722
- class Invalid extends $mol_error_mix {
8723
- }
8724
- const mix = new $mol_error_mix('Wrong password', {}, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
8725
- const hints = [];
8726
- if (mix instanceof $mol_error_mix) {
8727
- for (const er of mix.errors) {
8728
- if (er instanceof Invalid) {
8729
- hints.push(er.cause?.hint ?? '');
8730
- }
8731
- }
8732
- }
8733
- $mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
8734
- },
8572
+ (function ($_1) {
8573
+ $mol_test_mocks.push($ => {
8574
+ $.$mol_after_work = $mol_after_mock_timeout;
8735
8575
  });
8736
8576
  })($ || ($ = {}));
8737
8577
 
8578
+ ;
8579
+ "use strict";
8580
+ var $;
8581
+ (function ($) {
8582
+ function $mol_wait_rest_async() {
8583
+ return new Promise(done => {
8584
+ new this.$mol_after_work(16, () => done(null));
8585
+ });
8586
+ }
8587
+ $.$mol_wait_rest_async = $mol_wait_rest_async;
8588
+ function $mol_wait_rest() {
8589
+ return this.$mol_wire_sync(this).$mol_wait_rest_async();
8590
+ }
8591
+ $.$mol_wait_rest = $mol_wait_rest;
8592
+ })($ || ($ = {}));
8593
+
8738
8594
  ;
8739
8595
  "use strict";
8740
8596
  var $;
8741
8597
  (function ($_1) {
8742
- $mol_test({
8743
- 'init with overload'() {
8744
- class X extends $mol_object {
8745
- foo() {
8746
- return 1;
8747
- }
8748
- }
8749
- var x = X.make({
8750
- foo: () => 2,
8751
- });
8752
- $mol_assert_equal(x.foo(), 2);
8753
- },
8754
- 'Context in instance inherits from class'($) {
8755
- const custom = $.$mol_ambient({});
8756
- class X extends $.$mol_object {
8757
- static $ = custom;
8758
- }
8759
- $mol_assert_equal(new X().$, custom);
8760
- },
8761
- });
8598
+ var $$;
8599
+ (function ($$) {
8600
+ $mol_test_mocks.push($ => {
8601
+ $.$mol_wait_timeout = function $mol_wait_timeout_mock(timeout) { };
8602
+ $.$mol_wait_timeout_async = async function $mol_wait_timeout_async_mock(timeout) { };
8603
+ });
8604
+ })($$ = $_1.$$ || ($_1.$$ = {}));
8605
+ })($ || ($ = {}));
8606
+
8607
+ ;
8608
+ "use strict";
8609
+ var $;
8610
+ (function ($) {
8611
+ function $mol_wait_timeout_async(timeout) {
8612
+ const promise = new $mol_promise();
8613
+ const task = new this.$mol_after_timeout(timeout, () => promise.done());
8614
+ return Object.assign(promise, {
8615
+ destructor: () => task.destructor()
8616
+ });
8617
+ }
8618
+ $.$mol_wait_timeout_async = $mol_wait_timeout_async;
8619
+ function $mol_wait_timeout(timeout) {
8620
+ return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
8621
+ }
8622
+ $.$mol_wait_timeout = $mol_wait_timeout;
8623
+ })($ || ($ = {}));
8624
+
8625
+ ;
8626
+ "use strict";
8627
+ var $;
8628
+ (function ($_1) {
8629
+ var $$;
8630
+ (function ($$) {
8631
+ $mol_test_mocks.push($ => {
8632
+ $.$mol_wait_rest = function $mol_wait_rest_mock() { };
8633
+ $.$mol_wait_rest_async = async function $mol_wait_rest_async_mock() { };
8634
+ });
8635
+ })($$ = $_1.$$ || ($_1.$$ = {}));
8762
8636
  })($ || ($ = {}));
8763
8637
 
8764
8638
  ;
@@ -8766,104 +8640,67 @@ var $;
8766
8640
  var $;
8767
8641
  (function ($_1) {
8768
8642
  $mol_test({
8769
- 'Collect deps'() {
8770
- const pub1 = new $mol_wire_pub;
8771
- const pub2 = new $mol_wire_pub;
8772
- const sub = new $mol_wire_pub_sub;
8773
- const bu1 = sub.track_on();
8774
- try {
8775
- pub1.promote();
8776
- pub2.promote();
8777
- pub2.promote();
8778
- }
8779
- finally {
8780
- sub.track_cut();
8781
- sub.track_off(bu1);
8643
+ async 'exec timeout auto kill child process'($) {
8644
+ let close_mock = () => { };
8645
+ const error_message = 'Run error, timeout';
8646
+ function mol_run_spawn_sync_mock() {
8647
+ return {
8648
+ output: [],
8649
+ stdout: error_message,
8650
+ stderr: '',
8651
+ status: 0,
8652
+ signal: null,
8653
+ pid: 123,
8654
+ };
8782
8655
  }
8783
- pub1.emit();
8784
- pub2.emit();
8785
- $mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
8786
- const bu2 = sub.track_on();
8787
- try {
8788
- pub1.promote();
8789
- pub1.promote();
8790
- pub2.promote();
8656
+ function mol_run_spawn_mock() {
8657
+ return {
8658
+ on(name, cb) {
8659
+ if (name === 'exit')
8660
+ close_mock = cb;
8661
+ },
8662
+ kill() { close_mock(); }
8663
+ };
8791
8664
  }
8792
- finally {
8793
- sub.track_cut();
8794
- sub.track_off(bu2);
8665
+ const context_mock = $.$mol_ambient({
8666
+ $mol_run_spawn_sync: mol_run_spawn_sync_mock,
8667
+ $mol_run_spawn: mol_run_spawn_mock
8668
+ });
8669
+ class $mol_run_mock extends $mol_run {
8670
+ static get $() { return context_mock; }
8671
+ static async_enabled() {
8672
+ return true;
8673
+ }
8795
8674
  }
8796
- pub1.emit();
8797
- pub2.emit();
8798
- $mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
8799
- },
8800
- 'cyclic detection'($) {
8801
- const sub1 = new $mol_wire_pub_sub;
8802
- const sub2 = new $mol_wire_pub_sub;
8803
- const bu1 = sub1.track_on();
8675
+ let message = '';
8804
8676
  try {
8805
- const bu2 = sub2.track_on();
8806
- try {
8807
- $mol_assert_fail(() => sub1.promote(), 'Circular subscription');
8808
- }
8809
- finally {
8810
- sub2.track_cut();
8811
- sub2.track_off(bu2);
8812
- }
8677
+ const res = await $mol_wire_async($mol_run_mock).spawn({
8678
+ command: 'sleep 10',
8679
+ dir: '.',
8680
+ timeout: 10,
8681
+ env: { 'MOL_RUN_ASYNC': '1' }
8682
+ });
8813
8683
  }
8814
- finally {
8815
- sub1.track_cut();
8816
- sub1.track_off(bu1);
8684
+ catch (e) {
8685
+ message = e.message;
8817
8686
  }
8818
- },
8687
+ $mol_assert_equal(message, error_message);
8688
+ }
8819
8689
  });
8820
8690
  })($ || ($ = {}));
8821
8691
 
8822
8692
  ;
8823
8693
  "use strict";
8824
- var $;
8825
- (function ($) {
8826
- $.$mol_after_mock_queue = [];
8827
- function $mol_after_mock_warp() {
8828
- const queue = $.$mol_after_mock_queue.splice(0);
8829
- for (const task of queue)
8830
- task();
8831
- }
8832
- $.$mol_after_mock_warp = $mol_after_mock_warp;
8833
- class $mol_after_mock_commmon extends $mol_object2 {
8834
- task;
8835
- promise = Promise.resolve();
8836
- cancelled = false;
8837
- id;
8838
- constructor(task) {
8839
- super();
8840
- this.task = task;
8841
- $.$mol_after_mock_queue.push(task);
8842
- }
8843
- destructor() {
8844
- const index = $.$mol_after_mock_queue.indexOf(this.task);
8845
- if (index >= 0)
8846
- $.$mol_after_mock_queue.splice(index, 1);
8847
- }
8848
- }
8849
- $.$mol_after_mock_commmon = $mol_after_mock_commmon;
8850
- class $mol_after_mock_timeout extends $mol_after_mock_commmon {
8851
- delay;
8852
- constructor(delay, task) {
8853
- super(task);
8854
- this.delay = delay;
8855
- }
8856
- }
8857
- $.$mol_after_mock_timeout = $mol_after_mock_timeout;
8858
- })($ || ($ = {}));
8859
8694
 
8860
8695
  ;
8861
8696
  "use strict";
8862
8697
  var $;
8863
- (function ($_1) {
8864
- $mol_test_mocks.push($ => {
8865
- $.$mol_after_tick = $mol_after_mock_commmon;
8866
- });
8698
+ (function ($) {
8699
+ function $mol_dom_serialize(node) {
8700
+ const serializer = new $mol_dom_context.XMLSerializer;
8701
+ return serializer.serializeToString(node);
8702
+ }
8703
+ $.$mol_dom_serialize = $mol_dom_serialize;
8867
8704
  })($ || ($ = {}));
8868
8705
 
8869
8706
  ;
@@ -8871,195 +8708,101 @@ var $;
8871
8708
  var $;
8872
8709
  (function ($) {
8873
8710
  $mol_test({
8874
- 'Sync execution'() {
8875
- class Sync extends $mol_object2 {
8876
- static calc(a, b) {
8877
- return a + b;
8878
- }
8879
- }
8880
- __decorate([
8881
- $mol_wire_method
8882
- ], Sync, "calc", null);
8883
- $mol_assert_equal(Sync.calc(1, 2), 3);
8884
- },
8885
- async 'async <=> sync'() {
8886
- class SyncAsync extends $mol_object2 {
8887
- static async val(a) {
8888
- return a;
8889
- }
8890
- static sum(a, b) {
8891
- const syn = $mol_wire_sync(this);
8892
- return syn.val(a) + syn.val(b);
8893
- }
8894
- static async calc(a, b) {
8895
- return 5 + await $mol_wire_async(this).sum(a, b);
8896
- }
8897
- }
8898
- $mol_assert_equal(await SyncAsync.calc(1, 2), 8);
8711
+ 'Make empty div'() {
8712
+ $mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
8899
8713
  },
8900
- async 'Idempotence control'() {
8901
- class Idempotence extends $mol_object2 {
8902
- static logs_idemp = 0;
8903
- static logs_unidemp = 0;
8904
- static log_idemp() {
8905
- this.logs_idemp += 1;
8906
- }
8907
- static log_unidemp() {
8908
- this.logs_unidemp += 1;
8909
- }
8910
- static async val(a) {
8911
- return a;
8912
- }
8913
- static sum(a, b) {
8914
- this.log_idemp();
8915
- this.log_unidemp();
8916
- const syn = $mol_wire_sync(this);
8917
- return syn.val(a) + syn.val(b);
8918
- }
8919
- static async calc(a, b) {
8920
- return 5 + await $mol_wire_async(this).sum(a, b);
8921
- }
8922
- }
8923
- __decorate([
8924
- $mol_wire_method
8925
- ], Idempotence, "log_idemp", null);
8926
- $mol_assert_equal(await Idempotence.calc(1, 2), 8);
8927
- $mol_assert_equal(Idempotence.logs_idemp, 1);
8928
- $mol_assert_equal(Idempotence.logs_unidemp, 3);
8714
+ 'Define native field'() {
8715
+ const dom = $mol_jsx("input", { value: '123' });
8716
+ $mol_assert_equal(dom.outerHTML, '<input value="123">');
8717
+ $mol_assert_equal(dom.value, '123');
8929
8718
  },
8930
- async 'Error handling'() {
8931
- class Handle extends $mol_object2 {
8932
- static async sum(a, b) {
8933
- $mol_fail(new Error('test error ' + (a + b)));
8934
- }
8935
- static check() {
8936
- try {
8937
- return $mol_wire_sync(Handle).sum(1, 2);
8938
- }
8939
- catch (error) {
8940
- if ($mol_promise_like(error))
8941
- $mol_fail_hidden(error);
8942
- $mol_assert_equal(error.message, 'test error 3');
8943
- }
8944
- }
8945
- }
8946
- await $mol_wire_async(Handle).check();
8719
+ 'Define classes'() {
8720
+ const dom = $mol_jsx("div", { class: 'foo bar' });
8721
+ $mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
8947
8722
  },
8948
- });
8949
- })($ || ($ = {}));
8950
-
8951
- ;
8952
- "use strict";
8953
- var $;
8954
- (function ($_1) {
8955
- $mol_test({
8956
- 'test types'($) {
8957
- class A {
8958
- static a() {
8959
- return '';
8960
- }
8961
- static b() {
8962
- return $mol_wire_async(this).a();
8963
- }
8964
- }
8723
+ 'Define styles'() {
8724
+ const dom = $mol_jsx("div", { style: { color: 'red' } });
8725
+ $mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
8965
8726
  },
8966
- async 'Latest method calls wins'($) {
8967
- class NameLogger extends $mol_object2 {
8968
- static $ = $;
8969
- static first = [];
8970
- static last = [];
8971
- static send(next) {
8972
- $mol_wire_sync(this.first).push(next);
8973
- $$.$mol_wait_timeout(0);
8974
- this.last.push(next);
8975
- }
8976
- }
8977
- const name = $mol_wire_async(NameLogger).send;
8978
- name('john');
8979
- const promise = name('jin');
8980
- $.$mol_after_mock_warp();
8981
- await promise;
8982
- $mol_assert_equal(NameLogger.first, ['john', 'jin']);
8983
- $mol_assert_equal(NameLogger.last, ['jin']);
8727
+ 'Define dataset'() {
8728
+ const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
8729
+ $mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
8984
8730
  },
8985
- async 'Latest function calls wins'($) {
8986
- const first = [];
8987
- const last = [];
8988
- function send_name(next) {
8989
- $mol_wire_sync(first).push(next);
8990
- $$.$mol_wait_timeout(0);
8991
- last.push(next);
8992
- }
8993
- const name = $mol_wire_async(send_name);
8994
- name('john');
8995
- const promise = name('jin');
8996
- $.$mol_after_mock_warp();
8997
- await promise;
8998
- $mol_assert_equal(first, ['john', 'jin']);
8999
- $mol_assert_equal(last, ['jin']);
8731
+ 'Define attributes'() {
8732
+ const dom = $mol_jsx("div", { lang: "ru", hidden: true });
8733
+ $mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
9000
8734
  },
9001
- });
9002
- })($ || ($ = {}));
9003
-
9004
- ;
9005
- "use strict";
9006
- var $;
9007
- (function ($_1) {
9008
- $mol_test({
9009
- 'test types'($) {
9010
- class A {
9011
- static a() {
9012
- return Promise.resolve('');
9013
- }
9014
- static b() {
9015
- return $mol_wire_sync(this).a();
9016
- }
9017
- }
8735
+ 'Define child nodes'() {
8736
+ const dom = $mol_jsx("div", null,
8737
+ "hello",
8738
+ $mol_jsx("strong", null, "world"),
8739
+ "!");
8740
+ $mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
9018
8741
  },
9019
- async 'test method from host'($) {
9020
- let count = 0;
9021
- class A {
9022
- static a() {
9023
- return $mol_wire_sync(this).b();
9024
- }
9025
- static b() { return Promise.resolve(++count); }
9026
- }
9027
- $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
8742
+ 'Make fragment'() {
8743
+ const dom = $mol_jsx($mol_jsx_frag, null,
8744
+ $mol_jsx("br", null),
8745
+ $mol_jsx("hr", null));
8746
+ $mol_assert_equal($mol_dom_serialize(dom), '<br xmlns="http://www.w3.org/1999/xhtml" /><hr xmlns="http://www.w3.org/1999/xhtml" />');
9028
8747
  },
9029
- async 'test function'($) {
9030
- let count = 0;
9031
- class A {
9032
- static a() {
9033
- return $mol_wire_sync(this.b)();
9034
- }
9035
- static b() { return Promise.resolve(++count); }
9036
- }
9037
- $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
8748
+ 'Spread fragment'() {
8749
+ const dom = $mol_jsx("div", null,
8750
+ $mol_jsx($mol_jsx_frag, null,
8751
+ $mol_jsx("br", null),
8752
+ $mol_jsx("hr", null)));
8753
+ $mol_assert_equal(dom.outerHTML, '<div><br><hr></div>');
8754
+ },
8755
+ 'Function as component'() {
8756
+ const Button = (props, target) => {
8757
+ return $mol_jsx("button", { title: props.hint }, target());
8758
+ };
8759
+ const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
8760
+ $mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
8761
+ },
8762
+ 'Nested guid generation'() {
8763
+ const Foo = () => {
8764
+ return $mol_jsx("div", null,
8765
+ $mol_jsx(Bar, { id: "bar" },
8766
+ $mol_jsx("img", { id: "icon" })));
8767
+ };
8768
+ const Bar = (props, icon) => {
8769
+ return $mol_jsx("span", null,
8770
+ icon,
8771
+ $mol_jsx("i", { id: "label" }));
8772
+ };
8773
+ const dom = $mol_jsx(Foo, { id: "foo" });
8774
+ $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>');
8775
+ },
8776
+ 'Fail on non unique ids'() {
8777
+ const App = () => {
8778
+ return $mol_jsx("div", null,
8779
+ $mol_jsx("span", { id: "bar" }),
8780
+ $mol_jsx("span", { id: "bar" }));
8781
+ };
8782
+ $mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
8783
+ },
8784
+ 'Owner based guid generationn'() {
8785
+ const Foo = () => {
8786
+ return $mol_jsx("div", null,
8787
+ $mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
8788
+ };
8789
+ const Bar = (props) => {
8790
+ return $mol_jsx("span", null, props.icon());
8791
+ };
8792
+ const dom = $mol_jsx(Foo, { id: "app" });
8793
+ $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>');
8794
+ },
8795
+ 'Fail on same ids from different caller'() {
8796
+ const Foo = () => {
8797
+ return $mol_jsx("div", null,
8798
+ $mol_jsx("img", { id: "icon" }),
8799
+ $mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
8800
+ };
8801
+ const Bar = (props) => {
8802
+ return $mol_jsx("span", null, props.icon());
8803
+ };
8804
+ $mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
9038
8805
  },
9039
- async 'test construct itself'($) {
9040
- class A {
9041
- static instances = [];
9042
- static a() {
9043
- const a = new ($mol_wire_sync(A))();
9044
- this.instances.push(a);
9045
- $mol_wire_sync(this).b();
9046
- }
9047
- static b() { return Promise.resolve(); }
9048
- }
9049
- await $mol_wire_async(A).a();
9050
- $mol_assert_equal(A.instances.length, 2);
9051
- $mol_assert_equal(A.instances[0] instanceof A, true);
9052
- $mol_assert_equal(A.instances[0], A.instances[1]);
9053
- }
9054
- });
9055
- })($ || ($ = {}));
9056
-
9057
- ;
9058
- "use strict";
9059
- var $;
9060
- (function ($_1) {
9061
- $mol_test_mocks.push($ => {
9062
- $.$mol_after_timeout = $mol_after_mock_timeout;
9063
8806
  });
9064
8807
  })($ || ($ = {}));
9065
8808
 
@@ -9067,145 +8810,286 @@ var $;
9067
8810
  "use strict";
9068
8811
  var $;
9069
8812
  (function ($) {
9070
- class $mol_after_work extends $mol_object2 {
9071
- delay;
9072
- task;
9073
- id;
9074
- constructor(delay, task) {
9075
- super();
9076
- this.delay = delay;
9077
- this.task = task;
9078
- this.id = requestIdleCallback(task, { timeout: delay });
9079
- }
9080
- destructor() {
9081
- cancelIdleCallback(this.id);
8813
+ function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
8814
+ const source = typeof item === 'function' ? new $mol_range2_array() : item;
8815
+ if (typeof item !== 'function') {
8816
+ item = index => source[index];
8817
+ size = () => source.length;
9082
8818
  }
9083
- }
9084
- $.$mol_after_work = $mol_after_work;
9085
- if (typeof requestIdleCallback !== 'function') {
9086
- $.$mol_after_work = $mol_after_timeout;
9087
- }
9088
- })($ || ($ = {}));
9089
-
9090
- ;
9091
- "use strict";
9092
- var $;
9093
- (function ($_1) {
9094
- $mol_test_mocks.push($ => {
9095
- $.$mol_after_work = $mol_after_mock_timeout;
9096
- });
9097
- })($ || ($ = {}));
9098
-
9099
- ;
9100
- "use strict";
9101
- var $;
9102
- (function ($) {
9103
- function $mol_wait_rest_async() {
9104
- return new Promise(done => {
9105
- new this.$mol_after_work(16, () => done(null));
8819
+ return new Proxy(source, {
8820
+ get(target, field) {
8821
+ if (typeof field === 'string') {
8822
+ if (field === 'length')
8823
+ return size();
8824
+ const index = Number(field);
8825
+ if (index < 0)
8826
+ return undefined;
8827
+ if (index >= size())
8828
+ return undefined;
8829
+ if (index === Math.trunc(index))
8830
+ return item(index);
8831
+ }
8832
+ return $mol_range2_array.prototype[field];
8833
+ },
8834
+ set(target, field) {
8835
+ return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
8836
+ },
8837
+ ownKeys(target) {
8838
+ return [...Array(size())].map((v, i) => String(i)).concat('length');
8839
+ },
8840
+ getOwnPropertyDescriptor(target, field) {
8841
+ if (field === "length")
8842
+ return {
8843
+ value: size(),
8844
+ writable: true,
8845
+ enumerable: false,
8846
+ configurable: false,
8847
+ };
8848
+ const index = Number(field);
8849
+ if (index === Math.trunc(index))
8850
+ return {
8851
+ get: () => this.get(target, field, this),
8852
+ enumerable: true,
8853
+ configurable: true,
8854
+ };
8855
+ return Object.getOwnPropertyDescriptor(target, field);
8856
+ }
9106
8857
  });
9107
8858
  }
9108
- $.$mol_wait_rest_async = $mol_wait_rest_async;
9109
- function $mol_wait_rest() {
9110
- return this.$mol_wire_sync(this).$mol_wait_rest_async();
8859
+ $.$mol_range2 = $mol_range2;
8860
+ class $mol_range2_array extends Array {
8861
+ concat(...tail) {
8862
+ if (tail.length === 0)
8863
+ return this;
8864
+ if (tail.length > 1) {
8865
+ let list = this;
8866
+ for (let item of tail)
8867
+ list = list.concat(item);
8868
+ return list;
8869
+ }
8870
+ return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
8871
+ }
8872
+ filter(check, context) {
8873
+ const filtered = [];
8874
+ let cursor = -1;
8875
+ return $mol_range2(index => {
8876
+ while (cursor < this.length && index >= filtered.length - 1) {
8877
+ const val = this[++cursor];
8878
+ if (check(val, cursor, this))
8879
+ filtered.push(val);
8880
+ }
8881
+ return filtered[index];
8882
+ }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
8883
+ }
8884
+ forEach(proceed, context) {
8885
+ for (let [key, value] of this.entries())
8886
+ proceed.call(context, value, key, this);
8887
+ }
8888
+ map(proceed, context) {
8889
+ return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
8890
+ }
8891
+ reduce(merge, result) {
8892
+ let index = 0;
8893
+ if (arguments.length === 1) {
8894
+ result = this[index++];
8895
+ }
8896
+ for (; index < this.length; ++index) {
8897
+ result = merge(result, this[index], index, this);
8898
+ }
8899
+ return result;
8900
+ }
8901
+ toReversed() {
8902
+ return $mol_range2(index => this[this.length - 1 - index], () => this.length);
8903
+ }
8904
+ slice(from = 0, to = this.length) {
8905
+ return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
8906
+ }
8907
+ some(check, context) {
8908
+ for (let index = 0; index < this.length; ++index) {
8909
+ if (check.call(context, this[index], index, this))
8910
+ return true;
8911
+ }
8912
+ return false;
8913
+ }
8914
+ every(check, context) {
8915
+ for (let index = 0; index < this.length; ++index) {
8916
+ if (!check.call(context, this[index], index, this))
8917
+ return false;
8918
+ }
8919
+ return true;
8920
+ }
8921
+ reverse() {
8922
+ return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
8923
+ }
8924
+ sort() {
8925
+ return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
8926
+ }
8927
+ indexOf(needle) {
8928
+ return this.findIndex(item => item === needle);
8929
+ }
8930
+ [Symbol.toPrimitive]() {
8931
+ return $mol_guid();
8932
+ }
9111
8933
  }
9112
- $.$mol_wait_rest = $mol_wait_rest;
9113
- })($ || ($ = {}));
9114
-
9115
- ;
9116
- "use strict";
9117
- var $;
9118
- (function ($_1) {
9119
- var $$;
9120
- (function ($$) {
9121
- $mol_test_mocks.push($ => {
9122
- $.$mol_wait_timeout = function $mol_wait_timeout_mock(timeout) { };
9123
- $.$mol_wait_timeout_async = async function $mol_wait_timeout_async_mock(timeout) { };
9124
- });
9125
- })($$ = $_1.$$ || ($_1.$$ = {}));
8934
+ $.$mol_range2_array = $mol_range2_array;
9126
8935
  })($ || ($ = {}));
9127
8936
 
9128
8937
  ;
9129
8938
  "use strict";
9130
8939
  var $;
9131
8940
  (function ($) {
9132
- function $mol_wait_timeout_async(timeout) {
9133
- const promise = new $mol_promise();
9134
- const task = new this.$mol_after_timeout(timeout, () => promise.done());
9135
- return Object.assign(promise, {
9136
- destructor: () => task.destructor()
9137
- });
9138
- }
9139
- $.$mol_wait_timeout_async = $mol_wait_timeout_async;
9140
- function $mol_wait_timeout(timeout) {
9141
- return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
9142
- }
9143
- $.$mol_wait_timeout = $mol_wait_timeout;
9144
- })($ || ($ = {}));
9145
-
9146
- ;
9147
- "use strict";
9148
- var $;
9149
- (function ($_1) {
9150
- var $$;
9151
- (function ($$) {
9152
- $mol_test_mocks.push($ => {
9153
- $.$mol_wait_rest = function $mol_wait_rest_mock() { };
9154
- $.$mol_wait_rest_async = async function $mol_wait_rest_async_mock() { };
9155
- });
9156
- })($$ = $_1.$$ || ($_1.$$ = {}));
9157
- })($ || ($ = {}));
9158
-
9159
- ;
9160
- "use strict";
9161
- var $;
9162
- (function ($_1) {
9163
8941
  $mol_test({
9164
- async 'exec timeout auto kill child process'($) {
9165
- let close_mock = () => { };
9166
- const error_message = 'Run error, timeout';
9167
- function mol_run_spawn_sync_mock() {
9168
- return {
9169
- output: [],
9170
- stdout: error_message,
9171
- stderr: '',
9172
- status: 0,
9173
- signal: null,
9174
- pid: 123,
9175
- };
9176
- }
9177
- function mol_run_spawn_mock() {
9178
- return {
9179
- on(name, cb) {
9180
- if (name === 'exit')
9181
- close_mock = cb;
9182
- },
9183
- kill() { close_mock(); }
9184
- };
9185
- }
9186
- const context_mock = $.$mol_ambient({
9187
- $mol_run_spawn_sync: mol_run_spawn_sync_mock,
9188
- $mol_run_spawn: mol_run_spawn_mock
9189
- });
9190
- class $mol_run_mock extends $mol_run {
9191
- static get $() { return context_mock; }
9192
- static async_enabled() {
9193
- return true;
9194
- }
9195
- }
9196
- let message = '';
9197
- try {
9198
- const res = await $mol_wire_async($mol_run_mock).spawn({
9199
- command: 'sleep 10',
9200
- dir: '.',
9201
- timeout: 10,
9202
- env: { 'MOL_RUN_ASYNC': '1' }
9203
- });
8942
+ 'lazy calls'() {
8943
+ let calls = 0;
8944
+ const list = $mol_range2(index => (++calls, index), () => 10);
8945
+ $mol_assert_equal(true, list instanceof Array);
8946
+ $mol_assert_equal(list.length, 10);
8947
+ $mol_assert_equal(list[-1], undefined);
8948
+ $mol_assert_equal(list[0], 0);
8949
+ $mol_assert_equal(list[9], 9);
8950
+ $mol_assert_equal(list[9.5], undefined);
8951
+ $mol_assert_equal(list[10], undefined);
8952
+ $mol_assert_equal(calls, 2);
8953
+ },
8954
+ 'infinity list'() {
8955
+ let calls = 0;
8956
+ const list = $mol_range2(index => (++calls, index));
8957
+ $mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
8958
+ $mol_assert_equal(list[0], 0);
8959
+ $mol_assert_equal(list[4], 4);
8960
+ $mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
8961
+ $mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
8962
+ $mol_assert_equal(calls, 3);
8963
+ },
8964
+ 'stringify'() {
8965
+ const list = $mol_range2(i => i, () => 5);
8966
+ $mol_assert_equal(list.toString(), '0,1,2,3,4');
8967
+ $mol_assert_equal(list.join(';'), '0;1;2;3;4');
8968
+ },
8969
+ 'for-of'() {
8970
+ let log = '';
8971
+ for (let i of $mol_range2(i => i + 1, () => 5)) {
8972
+ log += i;
9204
8973
  }
9205
- catch (e) {
9206
- message = e.message;
8974
+ $mol_assert_equal(log, '12345');
8975
+ },
8976
+ 'for-in'() {
8977
+ let log = '';
8978
+ for (let i in $mol_range2(i => i, () => 5)) {
8979
+ log += i;
9207
8980
  }
9208
- $mol_assert_equal(message, error_message);
8981
+ $mol_assert_equal(log, '01234');
8982
+ },
8983
+ 'forEach'() {
8984
+ let log = '';
8985
+ $mol_range2(i => i, () => 5).forEach(i => log += i);
8986
+ $mol_assert_equal(log, '01234');
8987
+ },
8988
+ 'reduce'() {
8989
+ let calls = 0;
8990
+ const list = $mol_range2().slice(1, 6);
8991
+ $mol_assert_equal(list.reduce((s, v) => s + v), 15);
8992
+ $mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
8993
+ },
8994
+ 'lazy concat'() {
8995
+ let calls1 = 0;
8996
+ let calls2 = 0;
8997
+ const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
8998
+ $mol_assert_equal(true, list instanceof Array);
8999
+ $mol_assert_equal(list.length, 15);
9000
+ $mol_assert_equal(list[0], 0);
9001
+ $mol_assert_equal(list[4], 4);
9002
+ $mol_assert_equal(list[5], 0);
9003
+ $mol_assert_equal(list[9], 4);
9004
+ $mol_assert_equal(list[10], 0);
9005
+ $mol_assert_equal(list[14], 4);
9006
+ $mol_assert_equal(list[15], undefined);
9007
+ $mol_assert_equal(calls1, 2);
9008
+ $mol_assert_equal(calls2, 2);
9009
+ },
9010
+ 'lazy filter'() {
9011
+ let calls = 0;
9012
+ const list = $mol_range2(index => (++calls, index), () => 15).filter(v => v % 2).slice(0, 3);
9013
+ $mol_assert_equal(true, list instanceof Array);
9014
+ $mol_assert_equal(list.length, 3);
9015
+ $mol_assert_equal(list[0], 1);
9016
+ $mol_assert_equal(list[2], 5);
9017
+ $mol_assert_equal(list[3], undefined);
9018
+ $mol_assert_equal(calls, 8);
9019
+ },
9020
+ 'lazy reverse'() {
9021
+ let calls = 0;
9022
+ const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
9023
+ $mol_assert_equal(true, list instanceof Array);
9024
+ $mol_assert_equal(list.length, 3);
9025
+ $mol_assert_equal(list[0], 9);
9026
+ $mol_assert_equal(list[2], 7);
9027
+ $mol_assert_equal(list[3], undefined);
9028
+ $mol_assert_equal(calls, 2);
9029
+ },
9030
+ 'lazy map'() {
9031
+ let calls1 = 0;
9032
+ let calls2 = 0;
9033
+ const source = $mol_range2(index => (++calls1, index), () => 5);
9034
+ const target = source.map((item, index, self) => {
9035
+ ++calls2;
9036
+ $mol_assert_equal(source, self);
9037
+ return index + 10;
9038
+ }, () => 5);
9039
+ $mol_assert_equal(true, target instanceof Array);
9040
+ $mol_assert_equal(target.length, 5);
9041
+ $mol_assert_equal(target[0], 10);
9042
+ $mol_assert_equal(target[4], 14);
9043
+ $mol_assert_equal(target[5], undefined);
9044
+ $mol_assert_equal(calls1, 2);
9045
+ $mol_assert_equal(calls2, 2);
9046
+ },
9047
+ 'lazy slice'() {
9048
+ let calls = 0;
9049
+ const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
9050
+ $mol_assert_equal(true, list instanceof Array);
9051
+ $mol_assert_equal(list.length, 4);
9052
+ $mol_assert_equal(list[0], 3);
9053
+ $mol_assert_equal(list[3], 6);
9054
+ $mol_assert_equal(list[4], undefined);
9055
+ $mol_assert_equal(calls, 2);
9056
+ },
9057
+ 'lazy some'() {
9058
+ let calls = 0;
9059
+ $mol_assert_equal(true, $mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
9060
+ $mol_assert_equal(calls, 3);
9061
+ $mol_assert_equal(false, $mol_range2(i => i, () => 0).some(v => true));
9062
+ $mol_assert_equal(true, $mol_range2(i => i).some(v => v > 5));
9063
+ },
9064
+ 'lazy every'() {
9065
+ let calls = 0;
9066
+ $mol_assert_equal(false, $mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
9067
+ $mol_assert_equal(calls, 3);
9068
+ $mol_assert_equal(true, $mol_range2(i => i, () => 0).every(v => false));
9069
+ $mol_assert_equal(false, $mol_range2(i => i).every(v => v < 5));
9070
+ },
9071
+ 'lazyfy'() {
9072
+ let calls = 0;
9073
+ const list = $mol_range2([0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
9074
+ $mol_assert_equal(true, list instanceof Array);
9075
+ $mol_assert_equal(list.length, 4);
9076
+ $mol_assert_equal(calls, 0);
9077
+ $mol_assert_equal(list[0], 12);
9078
+ $mol_assert_equal(list[3], 15);
9079
+ $mol_assert_equal(list[4], undefined);
9080
+ $mol_assert_equal(calls, 2);
9081
+ },
9082
+ 'prevent modification'() {
9083
+ const list = $mol_range2(i => i, () => 5);
9084
+ $mol_assert_fail(() => list.push(4), TypeError);
9085
+ $mol_assert_fail(() => list.pop(), TypeError);
9086
+ $mol_assert_fail(() => list.unshift(4), TypeError);
9087
+ $mol_assert_fail(() => list.shift(), TypeError);
9088
+ $mol_assert_fail(() => list.splice(1, 2), TypeError);
9089
+ $mol_assert_fail(() => list[1] = 2, TypeError);
9090
+ $mol_assert_fail(() => list.reverse(), TypeError);
9091
+ $mol_assert_fail(() => list.sort(), TypeError);
9092
+ $mol_assert_equal(list.toString(), '0,1,2,3,4');
9209
9093
  }
9210
9094
  });
9211
9095
  })($ || ($ = {}));
@@ -9215,19 +9099,129 @@ var $;
9215
9099
  var $;
9216
9100
  (function ($) {
9217
9101
  $mol_test({
9218
- 'return result without errors'() {
9219
- $mol_assert_equal($mol_try(() => false), false);
9102
+ 'nulls & undefineds'() {
9103
+ $mol_assert_ok($mol_compare_deep(null, null));
9104
+ $mol_assert_ok($mol_compare_deep(undefined, undefined));
9105
+ $mol_assert_not($mol_compare_deep(undefined, null));
9106
+ $mol_assert_not($mol_compare_deep({}, null));
9107
+ },
9108
+ 'number'() {
9109
+ $mol_assert_ok($mol_compare_deep(1, 1));
9110
+ $mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
9111
+ $mol_assert_not($mol_compare_deep(1, 2));
9112
+ $mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
9113
+ $mol_assert_not($mol_compare_deep(Object(1), Object(2)));
9114
+ },
9115
+ 'POJO'() {
9116
+ $mol_assert_ok($mol_compare_deep({}, {}));
9117
+ $mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
9118
+ $mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
9119
+ $mol_assert_not($mol_compare_deep({}, { a: undefined }));
9120
+ $mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
9121
+ $mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
9122
+ $mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
9123
+ },
9124
+ 'Array'() {
9125
+ $mol_assert_ok($mol_compare_deep([], []));
9126
+ $mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
9127
+ $mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
9128
+ $mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
9129
+ $mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
9130
+ $mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
9131
+ },
9132
+ 'Non POJO are different'() {
9133
+ class Thing extends Object {
9134
+ }
9135
+ $mol_assert_not($mol_compare_deep(new Thing, new Thing));
9136
+ $mol_assert_not($mol_compare_deep(() => 1, () => 1));
9137
+ $mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
9138
+ },
9139
+ 'POJO with symbols'() {
9140
+ const sym = Symbol();
9141
+ $mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
9142
+ $mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
9143
+ },
9144
+ 'same POJOs with cyclic reference'() {
9145
+ const a = { foo: {} };
9146
+ a['self'] = a;
9147
+ const b = { foo: {} };
9148
+ b['self'] = b;
9149
+ $mol_assert_ok($mol_compare_deep(a, b));
9150
+ },
9151
+ 'same POJOs with cyclic reference with cache warmup'() {
9152
+ const obj1 = { test: 1, obj3: null };
9153
+ const obj1_copy = { test: 1, obj3: null };
9154
+ const obj2 = { test: 2, obj1 };
9155
+ const obj2_copy = { test: 2, obj1: obj1_copy };
9156
+ const obj3 = { test: 3, obj2 };
9157
+ const obj3_copy = { test: 3, obj2: obj2_copy };
9158
+ obj1.obj3 = obj3;
9159
+ obj1_copy.obj3 = obj3_copy;
9160
+ $mol_assert_not($mol_compare_deep(obj1, {}));
9161
+ $mol_assert_not($mol_compare_deep(obj2, {}));
9162
+ $mol_assert_not($mol_compare_deep(obj3, {}));
9163
+ $mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
9164
+ },
9165
+ 'Date'() {
9166
+ $mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
9167
+ $mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
9168
+ },
9169
+ 'RegExp'() {
9170
+ $mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
9171
+ $mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
9172
+ $mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
9173
+ },
9174
+ 'Error'() {
9175
+ $mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
9176
+ const fail = (message) => new Error(message);
9177
+ $mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
9178
+ $mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
9179
+ },
9180
+ 'Map'() {
9181
+ $mol_assert_ok($mol_compare_deep(new Map, new Map));
9182
+ $mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
9183
+ $mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
9184
+ $mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
9185
+ $mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
9186
+ },
9187
+ 'Set'() {
9188
+ $mol_assert_ok($mol_compare_deep(new Set, new Set));
9189
+ $mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
9190
+ $mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
9191
+ },
9192
+ 'Uint8Array'() {
9193
+ $mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
9194
+ $mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
9195
+ $mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
9196
+ },
9197
+ 'DataView'() {
9198
+ $mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
9199
+ $mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
9200
+ $mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
9201
+ },
9202
+ 'Serializale'() {
9203
+ class User {
9204
+ name;
9205
+ rand;
9206
+ constructor(name, rand = Math.random()) {
9207
+ this.name = name;
9208
+ this.rand = rand;
9209
+ }
9210
+ [Symbol.toPrimitive](mode) {
9211
+ return this.name;
9212
+ }
9213
+ }
9214
+ $mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
9215
+ $mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
9216
+ },
9217
+ 'Iterable'() {
9218
+ $mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
9219
+ $mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
9220
+ $mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
9220
9221
  },
9221
9222
  });
9222
9223
  })($ || ($ = {}));
9223
9224
 
9224
- ;
9225
- "use strict";
9226
- var $;
9227
- (function ($_1) {
9228
- $mol_test_mocks.push($ => $.$mol_fail_log = () => false);
9229
- })($ || ($ = {}));
9230
-
9231
9225
  ;
9232
9226
  "use strict";
9233
9227