mol_dump_lib 0.0.908 → 0.0.910

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