mam 1.11.810 → 1.11.811
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 +1 -7
- package/node.js.map +1 -1
- package/node.mjs +1 -7
- package/node.test.js +270 -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
|
}
|
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
|
}
|
|
@@ -7970,6 +7964,215 @@ var $;
|
|
|
7970
7964
|
$.$mol_test_complete = $mol_test_complete;
|
|
7971
7965
|
})($ || ($ = {}));
|
|
7972
7966
|
|
|
7967
|
+
;
|
|
7968
|
+
"use strict";
|
|
7969
|
+
var $;
|
|
7970
|
+
(function ($_1) {
|
|
7971
|
+
$mol_test({
|
|
7972
|
+
'FQN of anon function'($) {
|
|
7973
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
7974
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
7975
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
7976
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
7977
|
+
},
|
|
7978
|
+
});
|
|
7979
|
+
})($ || ($ = {}));
|
|
7980
|
+
|
|
7981
|
+
;
|
|
7982
|
+
"use strict";
|
|
7983
|
+
var $;
|
|
7984
|
+
(function ($) {
|
|
7985
|
+
$mol_test({
|
|
7986
|
+
'auto name'() {
|
|
7987
|
+
class Invalid extends $mol_error_mix {
|
|
7988
|
+
}
|
|
7989
|
+
const mix = new Invalid('foo');
|
|
7990
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
7991
|
+
},
|
|
7992
|
+
'simpe mix'() {
|
|
7993
|
+
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
7994
|
+
$mol_assert_equal(mix.message, 'foo');
|
|
7995
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
7996
|
+
},
|
|
7997
|
+
'provide additional info'() {
|
|
7998
|
+
class Invalid extends $mol_error_mix {
|
|
7999
|
+
}
|
|
8000
|
+
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' }));
|
|
8001
|
+
const hints = [];
|
|
8002
|
+
if (mix instanceof $mol_error_mix) {
|
|
8003
|
+
for (const er of mix.errors) {
|
|
8004
|
+
if (er instanceof Invalid) {
|
|
8005
|
+
hints.push(er.cause?.hint ?? '');
|
|
8006
|
+
}
|
|
8007
|
+
}
|
|
8008
|
+
}
|
|
8009
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
8010
|
+
},
|
|
8011
|
+
});
|
|
8012
|
+
})($ || ($ = {}));
|
|
8013
|
+
|
|
8014
|
+
;
|
|
8015
|
+
"use strict";
|
|
8016
|
+
|
|
8017
|
+
;
|
|
8018
|
+
"use strict";
|
|
8019
|
+
|
|
8020
|
+
;
|
|
8021
|
+
"use strict";
|
|
8022
|
+
|
|
8023
|
+
;
|
|
8024
|
+
"use strict";
|
|
8025
|
+
|
|
8026
|
+
;
|
|
8027
|
+
"use strict";
|
|
8028
|
+
|
|
8029
|
+
;
|
|
8030
|
+
"use strict";
|
|
8031
|
+
var $;
|
|
8032
|
+
(function ($_1) {
|
|
8033
|
+
$mol_test({
|
|
8034
|
+
'init with overload'() {
|
|
8035
|
+
class X extends $mol_object {
|
|
8036
|
+
foo() {
|
|
8037
|
+
return 1;
|
|
8038
|
+
}
|
|
8039
|
+
}
|
|
8040
|
+
var x = X.make({
|
|
8041
|
+
foo: () => 2,
|
|
8042
|
+
});
|
|
8043
|
+
$mol_assert_equal(x.foo(), 2);
|
|
8044
|
+
},
|
|
8045
|
+
'Context in instance inherits from class'($) {
|
|
8046
|
+
const custom = $.$mol_ambient({});
|
|
8047
|
+
class X extends $.$mol_object {
|
|
8048
|
+
static $ = custom;
|
|
8049
|
+
}
|
|
8050
|
+
$mol_assert_equal(new X().$, custom);
|
|
8051
|
+
},
|
|
8052
|
+
});
|
|
8053
|
+
})($ || ($ = {}));
|
|
8054
|
+
|
|
8055
|
+
;
|
|
8056
|
+
"use strict";
|
|
8057
|
+
var $;
|
|
8058
|
+
(function ($_1) {
|
|
8059
|
+
$mol_test({
|
|
8060
|
+
'test types'($) {
|
|
8061
|
+
class A {
|
|
8062
|
+
static a() {
|
|
8063
|
+
return Promise.resolve('');
|
|
8064
|
+
}
|
|
8065
|
+
static b() {
|
|
8066
|
+
return $mol_wire_sync(this).a();
|
|
8067
|
+
}
|
|
8068
|
+
}
|
|
8069
|
+
},
|
|
8070
|
+
async 'test method from host'($) {
|
|
8071
|
+
let count = 0;
|
|
8072
|
+
class A {
|
|
8073
|
+
static a() {
|
|
8074
|
+
return $mol_wire_sync(this).b();
|
|
8075
|
+
}
|
|
8076
|
+
static b() { return Promise.resolve(++count); }
|
|
8077
|
+
}
|
|
8078
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
8079
|
+
},
|
|
8080
|
+
async 'test function'($) {
|
|
8081
|
+
let count = 0;
|
|
8082
|
+
class A {
|
|
8083
|
+
static a() {
|
|
8084
|
+
return $mol_wire_sync(this.b)();
|
|
8085
|
+
}
|
|
8086
|
+
static b() { return Promise.resolve(++count); }
|
|
8087
|
+
}
|
|
8088
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
8089
|
+
},
|
|
8090
|
+
async 'test construct itself'($) {
|
|
8091
|
+
class A {
|
|
8092
|
+
static instances = [];
|
|
8093
|
+
static a() {
|
|
8094
|
+
const a = new ($mol_wire_sync(A))();
|
|
8095
|
+
this.instances.push(a);
|
|
8096
|
+
$mol_wire_sync(this).b();
|
|
8097
|
+
}
|
|
8098
|
+
static b() { return Promise.resolve(); }
|
|
8099
|
+
}
|
|
8100
|
+
await $mol_wire_async(A).a();
|
|
8101
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
8102
|
+
$mol_assert_equal(A.instances[0] instanceof A, true);
|
|
8103
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
8104
|
+
}
|
|
8105
|
+
});
|
|
8106
|
+
})($ || ($ = {}));
|
|
8107
|
+
|
|
8108
|
+
;
|
|
8109
|
+
"use strict";
|
|
8110
|
+
var $;
|
|
8111
|
+
(function ($_1) {
|
|
8112
|
+
$mol_test_mocks.push($ => {
|
|
8113
|
+
$.$mol_log3_come = () => { };
|
|
8114
|
+
$.$mol_log3_done = () => { };
|
|
8115
|
+
$.$mol_log3_fail = () => { };
|
|
8116
|
+
$.$mol_log3_warn = () => { };
|
|
8117
|
+
$.$mol_log3_rise = () => { };
|
|
8118
|
+
$.$mol_log3_area = () => () => { };
|
|
8119
|
+
});
|
|
8120
|
+
})($ || ($ = {}));
|
|
8121
|
+
|
|
8122
|
+
;
|
|
8123
|
+
"use strict";
|
|
8124
|
+
var $;
|
|
8125
|
+
(function ($_1) {
|
|
8126
|
+
$mol_test({
|
|
8127
|
+
async 'exec timeout auto kill child process'($) {
|
|
8128
|
+
let close_mock = () => { };
|
|
8129
|
+
const error_message = 'Run error, timeout';
|
|
8130
|
+
function mol_run_spawn_sync_mock() {
|
|
8131
|
+
return {
|
|
8132
|
+
output: [],
|
|
8133
|
+
stdout: error_message,
|
|
8134
|
+
stderr: '',
|
|
8135
|
+
status: 0,
|
|
8136
|
+
signal: null,
|
|
8137
|
+
pid: 123,
|
|
8138
|
+
};
|
|
8139
|
+
}
|
|
8140
|
+
function mol_run_spawn_mock() {
|
|
8141
|
+
return {
|
|
8142
|
+
on(name, cb) {
|
|
8143
|
+
if (name === 'exit')
|
|
8144
|
+
close_mock = cb;
|
|
8145
|
+
},
|
|
8146
|
+
kill() { close_mock(); }
|
|
8147
|
+
};
|
|
8148
|
+
}
|
|
8149
|
+
const context_mock = $.$mol_ambient({
|
|
8150
|
+
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
8151
|
+
$mol_run_spawn: mol_run_spawn_mock
|
|
8152
|
+
});
|
|
8153
|
+
class $mol_run_mock extends $mol_run {
|
|
8154
|
+
static get $() { return context_mock; }
|
|
8155
|
+
static async_enabled() {
|
|
8156
|
+
return true;
|
|
8157
|
+
}
|
|
8158
|
+
}
|
|
8159
|
+
let message = '';
|
|
8160
|
+
try {
|
|
8161
|
+
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
8162
|
+
command: 'sleep 10',
|
|
8163
|
+
dir: '.',
|
|
8164
|
+
timeout: 10,
|
|
8165
|
+
env: { 'MOL_RUN_ASYNC': '1' }
|
|
8166
|
+
});
|
|
8167
|
+
}
|
|
8168
|
+
catch (e) {
|
|
8169
|
+
message = e.message;
|
|
8170
|
+
}
|
|
8171
|
+
$mol_assert_equal(message, error_message);
|
|
8172
|
+
}
|
|
8173
|
+
});
|
|
8174
|
+
})($ || ($ = {}));
|
|
8175
|
+
|
|
7973
8176
|
;
|
|
7974
8177
|
"use strict";
|
|
7975
8178
|
var $;
|
|
@@ -8031,15 +8234,6 @@ var $;
|
|
|
8031
8234
|
;
|
|
8032
8235
|
"use strict";
|
|
8033
8236
|
|
|
8034
|
-
;
|
|
8035
|
-
"use strict";
|
|
8036
|
-
|
|
8037
|
-
;
|
|
8038
|
-
"use strict";
|
|
8039
|
-
|
|
8040
|
-
;
|
|
8041
|
-
"use strict";
|
|
8042
|
-
|
|
8043
8237
|
;
|
|
8044
8238
|
"use strict";
|
|
8045
8239
|
var $;
|
|
@@ -8796,45 +8990,11 @@ var $;
|
|
|
8796
8990
|
;
|
|
8797
8991
|
"use strict";
|
|
8798
8992
|
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) {
|
|
8993
|
+
(function ($) {
|
|
8820
8994
|
$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);
|
|
8995
|
+
'get'() {
|
|
8996
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
8997
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
8838
8998
|
},
|
|
8839
8999
|
'has'() {
|
|
8840
9000
|
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
@@ -9340,88 +9500,6 @@ var $;
|
|
|
9340
9500
|
});
|
|
9341
9501
|
})($ || ($ = {}));
|
|
9342
9502
|
|
|
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
9503
|
;
|
|
9426
9504
|
"use strict";
|
|
9427
9505
|
var $;
|
|
@@ -9453,59 +9531,6 @@ var $;
|
|
|
9453
9531
|
});
|
|
9454
9532
|
})($ || ($ = {}));
|
|
9455
9533
|
|
|
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
9534
|
;
|
|
9510
9535
|
"use strict";
|
|
9511
9536
|
var $;
|
|
@@ -9599,6 +9624,62 @@ var $;
|
|
|
9599
9624
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
9600
9625
|
})($ || ($ = {}));
|
|
9601
9626
|
|
|
9627
|
+
;
|
|
9628
|
+
"use strict";
|
|
9629
|
+
var $;
|
|
9630
|
+
(function ($_1) {
|
|
9631
|
+
$mol_test({
|
|
9632
|
+
'test types'($) {
|
|
9633
|
+
class A {
|
|
9634
|
+
static a() {
|
|
9635
|
+
return '';
|
|
9636
|
+
}
|
|
9637
|
+
static b() {
|
|
9638
|
+
return $mol_wire_async(this).a();
|
|
9639
|
+
}
|
|
9640
|
+
}
|
|
9641
|
+
},
|
|
9642
|
+
async 'Latest method calls wins'($) {
|
|
9643
|
+
class NameLogger extends $mol_object2 {
|
|
9644
|
+
static $ = $;
|
|
9645
|
+
static first = [];
|
|
9646
|
+
static last = [];
|
|
9647
|
+
static send(next) {
|
|
9648
|
+
$mol_wire_sync(this.first).push(next);
|
|
9649
|
+
$$.$mol_wait_timeout(0);
|
|
9650
|
+
this.last.push(next);
|
|
9651
|
+
}
|
|
9652
|
+
}
|
|
9653
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
9654
|
+
name('john');
|
|
9655
|
+
const promise = name('jin');
|
|
9656
|
+
$.$mol_after_mock_warp();
|
|
9657
|
+
await promise;
|
|
9658
|
+
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
9659
|
+
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
9660
|
+
},
|
|
9661
|
+
async 'Latest function calls wins'($) {
|
|
9662
|
+
const first = [];
|
|
9663
|
+
const last = [];
|
|
9664
|
+
function send_name(next) {
|
|
9665
|
+
$mol_wire_sync(first).push(next);
|
|
9666
|
+
$$.$mol_wait_timeout(0);
|
|
9667
|
+
last.push(next);
|
|
9668
|
+
}
|
|
9669
|
+
const name = $mol_wire_async(send_name);
|
|
9670
|
+
name('john');
|
|
9671
|
+
const promise = name('jin');
|
|
9672
|
+
$.$mol_after_mock_warp();
|
|
9673
|
+
await promise;
|
|
9674
|
+
$mol_assert_equal(first, ['john', 'jin']);
|
|
9675
|
+
$mol_assert_equal(last, ['jin']);
|
|
9676
|
+
},
|
|
9677
|
+
});
|
|
9678
|
+
})($ || ($ = {}));
|
|
9679
|
+
|
|
9680
|
+
;
|
|
9681
|
+
"use strict";
|
|
9682
|
+
|
|
9602
9683
|
;
|
|
9603
9684
|
"use strict";
|
|
9604
9685
|
var $;
|
|
@@ -10283,93 +10364,6 @@ var $;
|
|
|
10283
10364
|
});
|
|
10284
10365
|
})($ || ($ = {}));
|
|
10285
10366
|
|
|
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
10367
|
;
|
|
10374
10368
|
"use strict";
|
|
10375
10369
|
|