mam 1.11.810 → 1.11.812
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node.deps.json +1 -1
- package/node.js +3 -7
- package/node.js.map +1 -1
- package/node.mjs +3 -7
- package/node.test.js +272 -276
- package/node.test.js.map +1 -1
- package/package.json +1 -1
package/node.mjs
CHANGED
|
@@ -2448,13 +2448,7 @@ var $node = new Proxy({ require }, {
|
|
|
2448
2448
|
target.require.resolve(name);
|
|
2449
2449
|
}
|
|
2450
2450
|
catch {
|
|
2451
|
-
|
|
2452
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
2453
|
-
}
|
|
2454
|
-
catch (e) {
|
|
2455
|
-
if ($$.$mol_promise_like(e))
|
|
2456
|
-
$$.$mol_fail_hidden(e);
|
|
2457
|
-
}
|
|
2451
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
2458
2452
|
try {
|
|
2459
2453
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
2460
2454
|
}
|
|
@@ -6887,6 +6881,8 @@ var $;
|
|
|
6887
6881
|
for (let dep of this.nodeDeps([path, exclude]).keys()) {
|
|
6888
6882
|
if ($node_internal_check(dep))
|
|
6889
6883
|
continue;
|
|
6884
|
+
if (dep === 'internal')
|
|
6885
|
+
continue;
|
|
6890
6886
|
json.dependencies[dep] ??= `*`;
|
|
6891
6887
|
}
|
|
6892
6888
|
json.keywords = [...this.graph([path, exclude]).nodes]
|
package/node.test.js
CHANGED
|
@@ -2439,13 +2439,7 @@ var $node = new Proxy({ require }, {
|
|
|
2439
2439
|
target.require.resolve(name);
|
|
2440
2440
|
}
|
|
2441
2441
|
catch {
|
|
2442
|
-
|
|
2443
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
2444
|
-
}
|
|
2445
|
-
catch (e) {
|
|
2446
|
-
if ($$.$mol_promise_like(e))
|
|
2447
|
-
$$.$mol_fail_hidden(e);
|
|
2448
|
-
}
|
|
2442
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
2449
2443
|
try {
|
|
2450
2444
|
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
2451
2445
|
}
|
|
@@ -6878,6 +6872,8 @@ var $;
|
|
|
6878
6872
|
for (let dep of this.nodeDeps([path, exclude]).keys()) {
|
|
6879
6873
|
if ($node_internal_check(dep))
|
|
6880
6874
|
continue;
|
|
6875
|
+
if (dep === 'internal')
|
|
6876
|
+
continue;
|
|
6881
6877
|
json.dependencies[dep] ??= `*`;
|
|
6882
6878
|
}
|
|
6883
6879
|
json.keywords = [...this.graph([path, exclude]).nodes]
|
|
@@ -7970,6 +7966,215 @@ var $;
|
|
|
7970
7966
|
$.$mol_test_complete = $mol_test_complete;
|
|
7971
7967
|
})($ || ($ = {}));
|
|
7972
7968
|
|
|
7969
|
+
;
|
|
7970
|
+
"use strict";
|
|
7971
|
+
var $;
|
|
7972
|
+
(function ($_1) {
|
|
7973
|
+
$mol_test({
|
|
7974
|
+
'FQN of anon function'($) {
|
|
7975
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
7976
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
7977
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
7978
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
7979
|
+
},
|
|
7980
|
+
});
|
|
7981
|
+
})($ || ($ = {}));
|
|
7982
|
+
|
|
7983
|
+
;
|
|
7984
|
+
"use strict";
|
|
7985
|
+
var $;
|
|
7986
|
+
(function ($) {
|
|
7987
|
+
$mol_test({
|
|
7988
|
+
'auto name'() {
|
|
7989
|
+
class Invalid extends $mol_error_mix {
|
|
7990
|
+
}
|
|
7991
|
+
const mix = new Invalid('foo');
|
|
7992
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
7993
|
+
},
|
|
7994
|
+
'simpe mix'() {
|
|
7995
|
+
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
7996
|
+
$mol_assert_equal(mix.message, 'foo');
|
|
7997
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
7998
|
+
},
|
|
7999
|
+
'provide additional info'() {
|
|
8000
|
+
class Invalid extends $mol_error_mix {
|
|
8001
|
+
}
|
|
8002
|
+
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' }));
|
|
8003
|
+
const hints = [];
|
|
8004
|
+
if (mix instanceof $mol_error_mix) {
|
|
8005
|
+
for (const er of mix.errors) {
|
|
8006
|
+
if (er instanceof Invalid) {
|
|
8007
|
+
hints.push(er.cause?.hint ?? '');
|
|
8008
|
+
}
|
|
8009
|
+
}
|
|
8010
|
+
}
|
|
8011
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
8012
|
+
},
|
|
8013
|
+
});
|
|
8014
|
+
})($ || ($ = {}));
|
|
8015
|
+
|
|
8016
|
+
;
|
|
8017
|
+
"use strict";
|
|
8018
|
+
|
|
8019
|
+
;
|
|
8020
|
+
"use strict";
|
|
8021
|
+
|
|
8022
|
+
;
|
|
8023
|
+
"use strict";
|
|
8024
|
+
|
|
8025
|
+
;
|
|
8026
|
+
"use strict";
|
|
8027
|
+
|
|
8028
|
+
;
|
|
8029
|
+
"use strict";
|
|
8030
|
+
|
|
8031
|
+
;
|
|
8032
|
+
"use strict";
|
|
8033
|
+
var $;
|
|
8034
|
+
(function ($_1) {
|
|
8035
|
+
$mol_test({
|
|
8036
|
+
'init with overload'() {
|
|
8037
|
+
class X extends $mol_object {
|
|
8038
|
+
foo() {
|
|
8039
|
+
return 1;
|
|
8040
|
+
}
|
|
8041
|
+
}
|
|
8042
|
+
var x = X.make({
|
|
8043
|
+
foo: () => 2,
|
|
8044
|
+
});
|
|
8045
|
+
$mol_assert_equal(x.foo(), 2);
|
|
8046
|
+
},
|
|
8047
|
+
'Context in instance inherits from class'($) {
|
|
8048
|
+
const custom = $.$mol_ambient({});
|
|
8049
|
+
class X extends $.$mol_object {
|
|
8050
|
+
static $ = custom;
|
|
8051
|
+
}
|
|
8052
|
+
$mol_assert_equal(new X().$, custom);
|
|
8053
|
+
},
|
|
8054
|
+
});
|
|
8055
|
+
})($ || ($ = {}));
|
|
8056
|
+
|
|
8057
|
+
;
|
|
8058
|
+
"use strict";
|
|
8059
|
+
var $;
|
|
8060
|
+
(function ($_1) {
|
|
8061
|
+
$mol_test({
|
|
8062
|
+
'test types'($) {
|
|
8063
|
+
class A {
|
|
8064
|
+
static a() {
|
|
8065
|
+
return Promise.resolve('');
|
|
8066
|
+
}
|
|
8067
|
+
static b() {
|
|
8068
|
+
return $mol_wire_sync(this).a();
|
|
8069
|
+
}
|
|
8070
|
+
}
|
|
8071
|
+
},
|
|
8072
|
+
async 'test method from host'($) {
|
|
8073
|
+
let count = 0;
|
|
8074
|
+
class A {
|
|
8075
|
+
static a() {
|
|
8076
|
+
return $mol_wire_sync(this).b();
|
|
8077
|
+
}
|
|
8078
|
+
static b() { return Promise.resolve(++count); }
|
|
8079
|
+
}
|
|
8080
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
8081
|
+
},
|
|
8082
|
+
async 'test function'($) {
|
|
8083
|
+
let count = 0;
|
|
8084
|
+
class A {
|
|
8085
|
+
static a() {
|
|
8086
|
+
return $mol_wire_sync(this.b)();
|
|
8087
|
+
}
|
|
8088
|
+
static b() { return Promise.resolve(++count); }
|
|
8089
|
+
}
|
|
8090
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
8091
|
+
},
|
|
8092
|
+
async 'test construct itself'($) {
|
|
8093
|
+
class A {
|
|
8094
|
+
static instances = [];
|
|
8095
|
+
static a() {
|
|
8096
|
+
const a = new ($mol_wire_sync(A))();
|
|
8097
|
+
this.instances.push(a);
|
|
8098
|
+
$mol_wire_sync(this).b();
|
|
8099
|
+
}
|
|
8100
|
+
static b() { return Promise.resolve(); }
|
|
8101
|
+
}
|
|
8102
|
+
await $mol_wire_async(A).a();
|
|
8103
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
8104
|
+
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
8105
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
8106
|
+
}
|
|
8107
|
+
});
|
|
8108
|
+
})($ || ($ = {}));
|
|
8109
|
+
|
|
8110
|
+
;
|
|
8111
|
+
"use strict";
|
|
8112
|
+
var $;
|
|
8113
|
+
(function ($_1) {
|
|
8114
|
+
$mol_test_mocks.push($ => {
|
|
8115
|
+
$.$mol_log3_come = () => { };
|
|
8116
|
+
$.$mol_log3_done = () => { };
|
|
8117
|
+
$.$mol_log3_fail = () => { };
|
|
8118
|
+
$.$mol_log3_warn = () => { };
|
|
8119
|
+
$.$mol_log3_rise = () => { };
|
|
8120
|
+
$.$mol_log3_area = () => () => { };
|
|
8121
|
+
});
|
|
8122
|
+
})($ || ($ = {}));
|
|
8123
|
+
|
|
8124
|
+
;
|
|
8125
|
+
"use strict";
|
|
8126
|
+
var $;
|
|
8127
|
+
(function ($_1) {
|
|
8128
|
+
$mol_test({
|
|
8129
|
+
async 'exec timeout auto kill child process'($) {
|
|
8130
|
+
let close_mock = () => { };
|
|
8131
|
+
const error_message = 'Run error, timeout';
|
|
8132
|
+
function mol_run_spawn_sync_mock() {
|
|
8133
|
+
return {
|
|
8134
|
+
output: [],
|
|
8135
|
+
stdout: error_message,
|
|
8136
|
+
stderr: '',
|
|
8137
|
+
status: 0,
|
|
8138
|
+
signal: null,
|
|
8139
|
+
pid: 123,
|
|
8140
|
+
};
|
|
8141
|
+
}
|
|
8142
|
+
function mol_run_spawn_mock() {
|
|
8143
|
+
return {
|
|
8144
|
+
on(name, cb) {
|
|
8145
|
+
if (name === 'exit')
|
|
8146
|
+
close_mock = cb;
|
|
8147
|
+
},
|
|
8148
|
+
kill() { close_mock(); }
|
|
8149
|
+
};
|
|
8150
|
+
}
|
|
8151
|
+
const context_mock = $.$mol_ambient({
|
|
8152
|
+
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
8153
|
+
$mol_run_spawn: mol_run_spawn_mock
|
|
8154
|
+
});
|
|
8155
|
+
class $mol_run_mock extends $mol_run {
|
|
8156
|
+
static get $() { return context_mock; }
|
|
8157
|
+
static async_enabled() {
|
|
8158
|
+
return true;
|
|
8159
|
+
}
|
|
8160
|
+
}
|
|
8161
|
+
let message = '';
|
|
8162
|
+
try {
|
|
8163
|
+
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
8164
|
+
command: 'sleep 10',
|
|
8165
|
+
dir: '.',
|
|
8166
|
+
timeout: 10,
|
|
8167
|
+
env: { 'MOL_RUN_ASYNC': '1' }
|
|
8168
|
+
});
|
|
8169
|
+
}
|
|
8170
|
+
catch (e) {
|
|
8171
|
+
message = e.message;
|
|
8172
|
+
}
|
|
8173
|
+
$mol_assert_equal(message, error_message);
|
|
8174
|
+
}
|
|
8175
|
+
});
|
|
8176
|
+
})($ || ($ = {}));
|
|
8177
|
+
|
|
7973
8178
|
;
|
|
7974
8179
|
"use strict";
|
|
7975
8180
|
var $;
|
|
@@ -8031,15 +8236,6 @@ var $;
|
|
|
8031
8236
|
;
|
|
8032
8237
|
"use strict";
|
|
8033
8238
|
|
|
8034
|
-
;
|
|
8035
|
-
"use strict";
|
|
8036
|
-
|
|
8037
|
-
;
|
|
8038
|
-
"use strict";
|
|
8039
|
-
|
|
8040
|
-
;
|
|
8041
|
-
"use strict";
|
|
8042
|
-
|
|
8043
8239
|
;
|
|
8044
8240
|
"use strict";
|
|
8045
8241
|
var $;
|
|
@@ -8796,45 +8992,11 @@ var $;
|
|
|
8796
8992
|
;
|
|
8797
8993
|
"use strict";
|
|
8798
8994
|
var $;
|
|
8799
|
-
(function ($
|
|
8800
|
-
$mol_test_mocks.push($ => {
|
|
8801
|
-
$.$mol_log3_come = () => { };
|
|
8802
|
-
$.$mol_log3_done = () => { };
|
|
8803
|
-
$.$mol_log3_fail = () => { };
|
|
8804
|
-
$.$mol_log3_warn = () => { };
|
|
8805
|
-
$.$mol_log3_rise = () => { };
|
|
8806
|
-
$.$mol_log3_area = () => () => { };
|
|
8807
|
-
});
|
|
8808
|
-
})($ || ($ = {}));
|
|
8809
|
-
|
|
8810
|
-
;
|
|
8811
|
-
"use strict";
|
|
8812
|
-
|
|
8813
|
-
;
|
|
8814
|
-
"use strict";
|
|
8815
|
-
|
|
8816
|
-
;
|
|
8817
|
-
"use strict";
|
|
8818
|
-
var $;
|
|
8819
|
-
(function ($_1) {
|
|
8995
|
+
(function ($) {
|
|
8820
8996
|
$mol_test({
|
|
8821
|
-
'
|
|
8822
|
-
const
|
|
8823
|
-
$mol_assert_equal(
|
|
8824
|
-
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
8825
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
8826
|
-
},
|
|
8827
|
-
});
|
|
8828
|
-
})($ || ($ = {}));
|
|
8829
|
-
|
|
8830
|
-
;
|
|
8831
|
-
"use strict";
|
|
8832
|
-
var $;
|
|
8833
|
-
(function ($) {
|
|
8834
|
-
$mol_test({
|
|
8835
|
-
'get'() {
|
|
8836
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
8837
|
-
$mol_assert_equal(proxy.foo, 777);
|
|
8997
|
+
'get'() {
|
|
8998
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
8999
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
8838
9000
|
},
|
|
8839
9001
|
'has'() {
|
|
8840
9002
|
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
@@ -9340,88 +9502,6 @@ var $;
|
|
|
9340
9502
|
});
|
|
9341
9503
|
})($ || ($ = {}));
|
|
9342
9504
|
|
|
9343
|
-
;
|
|
9344
|
-
"use strict";
|
|
9345
|
-
var $;
|
|
9346
|
-
(function ($_1) {
|
|
9347
|
-
$mol_test({
|
|
9348
|
-
'test types'($) {
|
|
9349
|
-
class A {
|
|
9350
|
-
static a() {
|
|
9351
|
-
return '';
|
|
9352
|
-
}
|
|
9353
|
-
static b() {
|
|
9354
|
-
return $mol_wire_async(this).a();
|
|
9355
|
-
}
|
|
9356
|
-
}
|
|
9357
|
-
},
|
|
9358
|
-
async 'Latest method calls wins'($) {
|
|
9359
|
-
class NameLogger extends $mol_object2 {
|
|
9360
|
-
static $ = $;
|
|
9361
|
-
static first = [];
|
|
9362
|
-
static last = [];
|
|
9363
|
-
static send(next) {
|
|
9364
|
-
$mol_wire_sync(this.first).push(next);
|
|
9365
|
-
$$.$mol_wait_timeout(0);
|
|
9366
|
-
this.last.push(next);
|
|
9367
|
-
}
|
|
9368
|
-
}
|
|
9369
|
-
const name = $mol_wire_async(NameLogger).send;
|
|
9370
|
-
name('john');
|
|
9371
|
-
const promise = name('jin');
|
|
9372
|
-
$.$mol_after_mock_warp();
|
|
9373
|
-
await promise;
|
|
9374
|
-
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
9375
|
-
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
9376
|
-
},
|
|
9377
|
-
async 'Latest function calls wins'($) {
|
|
9378
|
-
const first = [];
|
|
9379
|
-
const last = [];
|
|
9380
|
-
function send_name(next) {
|
|
9381
|
-
$mol_wire_sync(first).push(next);
|
|
9382
|
-
$$.$mol_wait_timeout(0);
|
|
9383
|
-
last.push(next);
|
|
9384
|
-
}
|
|
9385
|
-
const name = $mol_wire_async(send_name);
|
|
9386
|
-
name('john');
|
|
9387
|
-
const promise = name('jin');
|
|
9388
|
-
$.$mol_after_mock_warp();
|
|
9389
|
-
await promise;
|
|
9390
|
-
$mol_assert_equal(first, ['john', 'jin']);
|
|
9391
|
-
$mol_assert_equal(last, ['jin']);
|
|
9392
|
-
},
|
|
9393
|
-
});
|
|
9394
|
-
})($ || ($ = {}));
|
|
9395
|
-
|
|
9396
|
-
;
|
|
9397
|
-
"use strict";
|
|
9398
|
-
var $;
|
|
9399
|
-
(function ($_1) {
|
|
9400
|
-
$mol_test({
|
|
9401
|
-
'init with overload'() {
|
|
9402
|
-
class X extends $mol_object {
|
|
9403
|
-
foo() {
|
|
9404
|
-
return 1;
|
|
9405
|
-
}
|
|
9406
|
-
}
|
|
9407
|
-
var x = X.make({
|
|
9408
|
-
foo: () => 2,
|
|
9409
|
-
});
|
|
9410
|
-
$mol_assert_equal(x.foo(), 2);
|
|
9411
|
-
},
|
|
9412
|
-
'Context in instance inherits from class'($) {
|
|
9413
|
-
const custom = $.$mol_ambient({});
|
|
9414
|
-
class X extends $.$mol_object {
|
|
9415
|
-
static $ = custom;
|
|
9416
|
-
}
|
|
9417
|
-
$mol_assert_equal(new X().$, custom);
|
|
9418
|
-
},
|
|
9419
|
-
});
|
|
9420
|
-
})($ || ($ = {}));
|
|
9421
|
-
|
|
9422
|
-
;
|
|
9423
|
-
"use strict";
|
|
9424
|
-
|
|
9425
9505
|
;
|
|
9426
9506
|
"use strict";
|
|
9427
9507
|
var $;
|
|
@@ -9453,59 +9533,6 @@ var $;
|
|
|
9453
9533
|
});
|
|
9454
9534
|
})($ || ($ = {}));
|
|
9455
9535
|
|
|
9456
|
-
;
|
|
9457
|
-
"use strict";
|
|
9458
|
-
var $;
|
|
9459
|
-
(function ($_1) {
|
|
9460
|
-
$mol_test({
|
|
9461
|
-
'test types'($) {
|
|
9462
|
-
class A {
|
|
9463
|
-
static a() {
|
|
9464
|
-
return Promise.resolve('');
|
|
9465
|
-
}
|
|
9466
|
-
static b() {
|
|
9467
|
-
return $mol_wire_sync(this).a();
|
|
9468
|
-
}
|
|
9469
|
-
}
|
|
9470
|
-
},
|
|
9471
|
-
async 'test method from host'($) {
|
|
9472
|
-
let count = 0;
|
|
9473
|
-
class A {
|
|
9474
|
-
static a() {
|
|
9475
|
-
return $mol_wire_sync(this).b();
|
|
9476
|
-
}
|
|
9477
|
-
static b() { return Promise.resolve(++count); }
|
|
9478
|
-
}
|
|
9479
|
-
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
9480
|
-
},
|
|
9481
|
-
async 'test function'($) {
|
|
9482
|
-
let count = 0;
|
|
9483
|
-
class A {
|
|
9484
|
-
static a() {
|
|
9485
|
-
return $mol_wire_sync(this.b)();
|
|
9486
|
-
}
|
|
9487
|
-
static b() { return Promise.resolve(++count); }
|
|
9488
|
-
}
|
|
9489
|
-
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
9490
|
-
},
|
|
9491
|
-
async 'test construct itself'($) {
|
|
9492
|
-
class A {
|
|
9493
|
-
static instances = [];
|
|
9494
|
-
static a() {
|
|
9495
|
-
const a = new ($mol_wire_sync(A))();
|
|
9496
|
-
this.instances.push(a);
|
|
9497
|
-
$mol_wire_sync(this).b();
|
|
9498
|
-
}
|
|
9499
|
-
static b() { return Promise.resolve(); }
|
|
9500
|
-
}
|
|
9501
|
-
await $mol_wire_async(A).a();
|
|
9502
|
-
$mol_assert_equal(A.instances.length, 2);
|
|
9503
|
-
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
9504
|
-
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
9505
|
-
}
|
|
9506
|
-
});
|
|
9507
|
-
})($ || ($ = {}));
|
|
9508
|
-
|
|
9509
9536
|
;
|
|
9510
9537
|
"use strict";
|
|
9511
9538
|
var $;
|
|
@@ -9599,6 +9626,62 @@ var $;
|
|
|
9599
9626
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
9600
9627
|
})($ || ($ = {}));
|
|
9601
9628
|
|
|
9629
|
+
;
|
|
9630
|
+
"use strict";
|
|
9631
|
+
var $;
|
|
9632
|
+
(function ($_1) {
|
|
9633
|
+
$mol_test({
|
|
9634
|
+
'test types'($) {
|
|
9635
|
+
class A {
|
|
9636
|
+
static a() {
|
|
9637
|
+
return '';
|
|
9638
|
+
}
|
|
9639
|
+
static b() {
|
|
9640
|
+
return $mol_wire_async(this).a();
|
|
9641
|
+
}
|
|
9642
|
+
}
|
|
9643
|
+
},
|
|
9644
|
+
async 'Latest method calls wins'($) {
|
|
9645
|
+
class NameLogger extends $mol_object2 {
|
|
9646
|
+
static $ = $;
|
|
9647
|
+
static first = [];
|
|
9648
|
+
static last = [];
|
|
9649
|
+
static send(next) {
|
|
9650
|
+
$mol_wire_sync(this.first).push(next);
|
|
9651
|
+
$$.$mol_wait_timeout(0);
|
|
9652
|
+
this.last.push(next);
|
|
9653
|
+
}
|
|
9654
|
+
}
|
|
9655
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
9656
|
+
name('john');
|
|
9657
|
+
const promise = name('jin');
|
|
9658
|
+
$.$mol_after_mock_warp();
|
|
9659
|
+
await promise;
|
|
9660
|
+
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
9661
|
+
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
9662
|
+
},
|
|
9663
|
+
async 'Latest function calls wins'($) {
|
|
9664
|
+
const first = [];
|
|
9665
|
+
const last = [];
|
|
9666
|
+
function send_name(next) {
|
|
9667
|
+
$mol_wire_sync(first).push(next);
|
|
9668
|
+
$$.$mol_wait_timeout(0);
|
|
9669
|
+
last.push(next);
|
|
9670
|
+
}
|
|
9671
|
+
const name = $mol_wire_async(send_name);
|
|
9672
|
+
name('john');
|
|
9673
|
+
const promise = name('jin');
|
|
9674
|
+
$.$mol_after_mock_warp();
|
|
9675
|
+
await promise;
|
|
9676
|
+
$mol_assert_equal(first, ['john', 'jin']);
|
|
9677
|
+
$mol_assert_equal(last, ['jin']);
|
|
9678
|
+
},
|
|
9679
|
+
});
|
|
9680
|
+
})($ || ($ = {}));
|
|
9681
|
+
|
|
9682
|
+
;
|
|
9683
|
+
"use strict";
|
|
9684
|
+
|
|
9602
9685
|
;
|
|
9603
9686
|
"use strict";
|
|
9604
9687
|
var $;
|
|
@@ -10283,93 +10366,6 @@ var $;
|
|
|
10283
10366
|
});
|
|
10284
10367
|
})($ || ($ = {}));
|
|
10285
10368
|
|
|
10286
|
-
;
|
|
10287
|
-
"use strict";
|
|
10288
|
-
var $;
|
|
10289
|
-
(function ($) {
|
|
10290
|
-
$mol_test({
|
|
10291
|
-
'auto name'() {
|
|
10292
|
-
class Invalid extends $mol_error_mix {
|
|
10293
|
-
}
|
|
10294
|
-
const mix = new Invalid('foo');
|
|
10295
|
-
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
10296
|
-
},
|
|
10297
|
-
'simpe mix'() {
|
|
10298
|
-
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
10299
|
-
$mol_assert_equal(mix.message, 'foo');
|
|
10300
|
-
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
10301
|
-
},
|
|
10302
|
-
'provide additional info'() {
|
|
10303
|
-
class Invalid extends $mol_error_mix {
|
|
10304
|
-
}
|
|
10305
|
-
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' }));
|
|
10306
|
-
const hints = [];
|
|
10307
|
-
if (mix instanceof $mol_error_mix) {
|
|
10308
|
-
for (const er of mix.errors) {
|
|
10309
|
-
if (er instanceof Invalid) {
|
|
10310
|
-
hints.push(er.cause?.hint ?? '');
|
|
10311
|
-
}
|
|
10312
|
-
}
|
|
10313
|
-
}
|
|
10314
|
-
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
10315
|
-
},
|
|
10316
|
-
});
|
|
10317
|
-
})($ || ($ = {}));
|
|
10318
|
-
|
|
10319
|
-
;
|
|
10320
|
-
"use strict";
|
|
10321
|
-
var $;
|
|
10322
|
-
(function ($_1) {
|
|
10323
|
-
$mol_test({
|
|
10324
|
-
async 'exec timeout auto kill child process'($) {
|
|
10325
|
-
let close_mock = () => { };
|
|
10326
|
-
const error_message = 'Run error, timeout';
|
|
10327
|
-
function mol_run_spawn_sync_mock() {
|
|
10328
|
-
return {
|
|
10329
|
-
output: [],
|
|
10330
|
-
stdout: error_message,
|
|
10331
|
-
stderr: '',
|
|
10332
|
-
status: 0,
|
|
10333
|
-
signal: null,
|
|
10334
|
-
pid: 123,
|
|
10335
|
-
};
|
|
10336
|
-
}
|
|
10337
|
-
function mol_run_spawn_mock() {
|
|
10338
|
-
return {
|
|
10339
|
-
on(name, cb) {
|
|
10340
|
-
if (name === 'exit')
|
|
10341
|
-
close_mock = cb;
|
|
10342
|
-
},
|
|
10343
|
-
kill() { close_mock(); }
|
|
10344
|
-
};
|
|
10345
|
-
}
|
|
10346
|
-
const context_mock = $.$mol_ambient({
|
|
10347
|
-
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
10348
|
-
$mol_run_spawn: mol_run_spawn_mock
|
|
10349
|
-
});
|
|
10350
|
-
class $mol_run_mock extends $mol_run {
|
|
10351
|
-
static get $() { return context_mock; }
|
|
10352
|
-
static async_enabled() {
|
|
10353
|
-
return true;
|
|
10354
|
-
}
|
|
10355
|
-
}
|
|
10356
|
-
let message = '';
|
|
10357
|
-
try {
|
|
10358
|
-
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
10359
|
-
command: 'sleep 10',
|
|
10360
|
-
dir: '.',
|
|
10361
|
-
timeout: 10,
|
|
10362
|
-
env: { 'MOL_RUN_ASYNC': '1' }
|
|
10363
|
-
});
|
|
10364
|
-
}
|
|
10365
|
-
catch (e) {
|
|
10366
|
-
message = e.message;
|
|
10367
|
-
}
|
|
10368
|
-
$mol_assert_equal(message, error_message);
|
|
10369
|
-
}
|
|
10370
|
-
});
|
|
10371
|
-
})($ || ($ = {}));
|
|
10372
|
-
|
|
10373
10369
|
;
|
|
10374
10370
|
"use strict";
|
|
10375
10371
|
|