mol_plot_all 1.2.1221 → 1.2.1222
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.d.ts +63 -55
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +103 -85
- package/node.js.map +1 -1
- package/node.mjs +103 -85
- package/node.test.js +316 -272
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +43 -43
- package/web.deps.json +1 -1
package/node.test.js
CHANGED
|
@@ -2140,97 +2140,115 @@ var $;
|
|
|
2140
2140
|
class $mol_run_error extends $mol_error_mix {
|
|
2141
2141
|
}
|
|
2142
2142
|
$.$mol_run_error = $mol_run_error;
|
|
2143
|
-
|
|
2144
|
-
$.$
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
this
|
|
2151
|
-
|
|
2143
|
+
$.$mol_run_spawn = (...args) => $node['child_process'].spawn(...args);
|
|
2144
|
+
$.$mol_run_spawn_sync = (...args) => $node['child_process'].spawnSync(...args);
|
|
2145
|
+
class $mol_run extends $mol_object {
|
|
2146
|
+
static async_enabled() {
|
|
2147
|
+
return Boolean(this.$.$mol_env()['MOL_RUN_ASYNC']);
|
|
2148
|
+
}
|
|
2149
|
+
static spawn(options) {
|
|
2150
|
+
const sync = !this.async_enabled() || !Boolean($mol_wire_auto());
|
|
2151
|
+
const env = options.env ?? this.$.$mol_env();
|
|
2152
|
+
return $mol_wire_sync(this).spawn_async({ ...options, sync, env });
|
|
2153
|
+
}
|
|
2154
|
+
static spawn_async({ dir, sync, timeout, command, env }) {
|
|
2155
|
+
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
2156
|
+
const [app, ...args] = args_raw;
|
|
2157
|
+
const opts = { shell: true, cwd: dir, env };
|
|
2158
|
+
const log_object = {
|
|
2159
|
+
place: `${this}.spawn()`,
|
|
2152
2160
|
message: 'Run',
|
|
2153
2161
|
command: args_raw.join(' '),
|
|
2154
2162
|
dir: $node.path.relative('', dir),
|
|
2163
|
+
};
|
|
2164
|
+
if (sync) {
|
|
2165
|
+
this.$.$mol_log3_come({
|
|
2166
|
+
hint: 'Run inside fiber',
|
|
2167
|
+
...log_object
|
|
2168
|
+
});
|
|
2169
|
+
let error;
|
|
2170
|
+
let res;
|
|
2171
|
+
try {
|
|
2172
|
+
res = this.$.$mol_run_spawn_sync(app, args, opts);
|
|
2173
|
+
error = res.error;
|
|
2174
|
+
}
|
|
2175
|
+
catch (err) {
|
|
2176
|
+
error = err;
|
|
2177
|
+
}
|
|
2178
|
+
if (!res || error || res.status) {
|
|
2179
|
+
throw new $mol_run_error(this.error_message(res), { ...log_object, status: res?.status, signal: res?.signal }, ...(error ? [error] : []));
|
|
2180
|
+
}
|
|
2181
|
+
return res;
|
|
2182
|
+
}
|
|
2183
|
+
let sub;
|
|
2184
|
+
try {
|
|
2185
|
+
sub = this.$.$mol_run_spawn(app, args, {
|
|
2186
|
+
...opts,
|
|
2187
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
2188
|
+
});
|
|
2189
|
+
}
|
|
2190
|
+
catch (error) {
|
|
2191
|
+
throw new $mol_run_error(this.error_message(undefined), log_object, error);
|
|
2192
|
+
}
|
|
2193
|
+
const pid = sub.pid ?? 0;
|
|
2194
|
+
this.$.$mol_log3_come({
|
|
2195
|
+
...log_object,
|
|
2196
|
+
pid,
|
|
2155
2197
|
});
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
this.$mol_log3_come({
|
|
2167
|
-
place: '$mol_run_async',
|
|
2168
|
-
pid: sub.pid,
|
|
2169
|
-
message: 'Run',
|
|
2170
|
-
command: args_raw.join(' '),
|
|
2171
|
-
dir: $node.path.relative('', dir),
|
|
2172
|
-
});
|
|
2173
|
-
let killed = false;
|
|
2174
|
-
let timer;
|
|
2175
|
-
const std_data = [];
|
|
2176
|
-
const error_data = [];
|
|
2177
|
-
const add = (std_chunk, error_chunk) => {
|
|
2178
|
-
if (std_chunk)
|
|
2179
|
-
std_data.push(std_chunk);
|
|
2180
|
-
if (error_chunk)
|
|
2181
|
-
error_data.push(error_chunk);
|
|
2182
|
-
if (!timeout)
|
|
2183
|
-
return;
|
|
2184
|
-
clearTimeout(timer);
|
|
2185
|
-
timer = setTimeout(() => {
|
|
2186
|
-
const signal = killed ? 'SIGKILL' : 'SIGTERM';
|
|
2187
|
-
killed = true;
|
|
2188
|
-
add();
|
|
2189
|
-
sub.kill(signal);
|
|
2190
|
-
}, timeout);
|
|
2191
|
-
};
|
|
2192
|
-
add();
|
|
2193
|
-
sub.stdout?.on('data', data => add(data));
|
|
2194
|
-
sub.stderr?.on('data', data => add(undefined, data));
|
|
2195
|
-
const promise = new Promise((done, fail) => {
|
|
2196
|
-
const close = (error, status = null, signal = null) => {
|
|
2197
|
-
if (!timer && timeout)
|
|
2198
|
+
let timeout_kill = false;
|
|
2199
|
+
let timer;
|
|
2200
|
+
const std_data = [];
|
|
2201
|
+
const error_data = [];
|
|
2202
|
+
const add = (std_chunk, error_chunk) => {
|
|
2203
|
+
if (std_chunk)
|
|
2204
|
+
std_data.push(std_chunk);
|
|
2205
|
+
if (error_chunk)
|
|
2206
|
+
error_data.push(error_chunk);
|
|
2207
|
+
if (!timeout)
|
|
2198
2208
|
return;
|
|
2199
2209
|
clearTimeout(timer);
|
|
2200
|
-
timer =
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
signal
|
|
2205
|
-
|
|
2206
|
-
get stderr() { return Buffer.concat(error_data); }
|
|
2207
|
-
};
|
|
2208
|
-
this.$mol_log3_done({
|
|
2209
|
-
place: '$mol_run_async',
|
|
2210
|
-
pid: sub.pid,
|
|
2211
|
-
message: 'Run',
|
|
2212
|
-
status,
|
|
2213
|
-
command: args_raw.join(' '),
|
|
2214
|
-
dir: $node.path.relative('', dir),
|
|
2215
|
-
});
|
|
2216
|
-
if (error || status || killed)
|
|
2217
|
-
return fail(new $mol_run_error((res.stderr.toString() || res.stdout.toString() || 'Run error') + (killed ? ', timeout' : ''), { signal, timeout: killed }, ...error ? [error] : []));
|
|
2218
|
-
done(res);
|
|
2210
|
+
timer = setTimeout(() => {
|
|
2211
|
+
const signal = timeout_kill ? 'SIGKILL' : 'SIGTERM';
|
|
2212
|
+
timeout_kill = true;
|
|
2213
|
+
add();
|
|
2214
|
+
sub.kill(signal);
|
|
2215
|
+
}, timeout);
|
|
2219
2216
|
};
|
|
2220
|
-
|
|
2221
|
-
sub.on('
|
|
2222
|
-
sub.on('
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2217
|
+
add();
|
|
2218
|
+
sub.stdout?.on('data', data => add(data));
|
|
2219
|
+
sub.stderr?.on('data', data => add(undefined, data));
|
|
2220
|
+
const result_promise = new Promise((done, fail) => {
|
|
2221
|
+
const close = (error, status = null, signal = null) => {
|
|
2222
|
+
if (!timer && timeout)
|
|
2223
|
+
return;
|
|
2224
|
+
clearTimeout(timer);
|
|
2225
|
+
timer = undefined;
|
|
2226
|
+
const res = {
|
|
2227
|
+
pid,
|
|
2228
|
+
signal,
|
|
2229
|
+
get stdout() { return Buffer.concat(std_data); },
|
|
2230
|
+
get stderr() { return Buffer.concat(error_data); }
|
|
2231
|
+
};
|
|
2232
|
+
if (error || status || timeout_kill)
|
|
2233
|
+
return fail(new $mol_run_error(this.error_message(res) + (timeout_kill ? ', timeout' : ''), { ...log_object, pid, status, signal, timeout_kill }, ...error ? [error] : []));
|
|
2234
|
+
this.$.$mol_log3_done({
|
|
2235
|
+
...log_object,
|
|
2236
|
+
pid,
|
|
2237
|
+
});
|
|
2238
|
+
done(res);
|
|
2239
|
+
};
|
|
2240
|
+
sub.on('disconnect', () => close(new Error('Disconnected')));
|
|
2241
|
+
sub.on('error', err => close(err));
|
|
2242
|
+
sub.on('exit', (status, signal) => close(null, status, signal));
|
|
2243
|
+
});
|
|
2244
|
+
return Object.assign(result_promise, { destructor: () => {
|
|
2245
|
+
clearTimeout(timer);
|
|
2246
|
+
sub.kill('SIGKILL');
|
|
2247
|
+
} });
|
|
2248
|
+
}
|
|
2249
|
+
static error_message(res) {
|
|
2250
|
+
return res?.stderr.toString() || res?.stdout.toString() || 'Run error';
|
|
2251
|
+
}
|
|
2234
2252
|
}
|
|
2235
2253
|
$.$mol_run = $mol_run;
|
|
2236
2254
|
})($ || ($ = {}));
|
|
@@ -2240,7 +2258,7 @@ var $;
|
|
|
2240
2258
|
var $;
|
|
2241
2259
|
(function ($) {
|
|
2242
2260
|
function $mol_exec(dir, command, ...args) {
|
|
2243
|
-
return this.$mol_run({ command: [command, ...args], dir });
|
|
2261
|
+
return this.$mol_run.spawn({ command: [command, ...args], dir });
|
|
2244
2262
|
}
|
|
2245
2263
|
$.$mol_exec = $mol_exec;
|
|
2246
2264
|
})($ || ($ = {}));
|
|
@@ -6339,50 +6357,9 @@ var $;
|
|
|
6339
6357
|
|
|
6340
6358
|
;
|
|
6341
6359
|
"use strict";
|
|
6342
|
-
var $;
|
|
6343
|
-
(function ($) {
|
|
6344
|
-
$mol_test({
|
|
6345
|
-
'auto name'() {
|
|
6346
|
-
class Invalid extends $mol_error_mix {
|
|
6347
|
-
}
|
|
6348
|
-
const mix = new Invalid('foo');
|
|
6349
|
-
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
6350
|
-
},
|
|
6351
|
-
'simpe mix'() {
|
|
6352
|
-
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
6353
|
-
$mol_assert_equal(mix.message, 'foo');
|
|
6354
|
-
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
6355
|
-
},
|
|
6356
|
-
'provide additional info'() {
|
|
6357
|
-
class Invalid extends $mol_error_mix {
|
|
6358
|
-
}
|
|
6359
|
-
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' }));
|
|
6360
|
-
const hints = [];
|
|
6361
|
-
if (mix instanceof $mol_error_mix) {
|
|
6362
|
-
for (const er of mix.errors) {
|
|
6363
|
-
if (er instanceof Invalid) {
|
|
6364
|
-
hints.push(er.cause?.hint ?? '');
|
|
6365
|
-
}
|
|
6366
|
-
}
|
|
6367
|
-
}
|
|
6368
|
-
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
6369
|
-
},
|
|
6370
|
-
});
|
|
6371
|
-
})($ || ($ = {}));
|
|
6372
6360
|
|
|
6373
6361
|
;
|
|
6374
6362
|
"use strict";
|
|
6375
|
-
var $;
|
|
6376
|
-
(function ($_1) {
|
|
6377
|
-
$mol_test_mocks.push($ => {
|
|
6378
|
-
$.$mol_log3_come = () => { };
|
|
6379
|
-
$.$mol_log3_done = () => { };
|
|
6380
|
-
$.$mol_log3_fail = () => { };
|
|
6381
|
-
$.$mol_log3_warn = () => { };
|
|
6382
|
-
$.$mol_log3_rise = () => { };
|
|
6383
|
-
$.$mol_log3_area = () => () => { };
|
|
6384
|
-
});
|
|
6385
|
-
})($ || ($ = {}));
|
|
6386
6363
|
|
|
6387
6364
|
;
|
|
6388
6365
|
"use strict";
|
|
@@ -6399,93 +6376,6 @@ var $;
|
|
|
6399
6376
|
;
|
|
6400
6377
|
"use strict";
|
|
6401
6378
|
|
|
6402
|
-
;
|
|
6403
|
-
"use strict";
|
|
6404
|
-
var $;
|
|
6405
|
-
(function ($_1) {
|
|
6406
|
-
$mol_test({
|
|
6407
|
-
'test types'($) {
|
|
6408
|
-
class A {
|
|
6409
|
-
static a() {
|
|
6410
|
-
return Promise.resolve('');
|
|
6411
|
-
}
|
|
6412
|
-
static b() {
|
|
6413
|
-
return $mol_wire_sync(this).a();
|
|
6414
|
-
}
|
|
6415
|
-
}
|
|
6416
|
-
},
|
|
6417
|
-
async 'test method from host'($) {
|
|
6418
|
-
let count = 0;
|
|
6419
|
-
class A {
|
|
6420
|
-
static a() {
|
|
6421
|
-
return $mol_wire_sync(this).b();
|
|
6422
|
-
}
|
|
6423
|
-
static b() { return Promise.resolve(++count); }
|
|
6424
|
-
}
|
|
6425
|
-
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
6426
|
-
},
|
|
6427
|
-
async 'test function'($) {
|
|
6428
|
-
let count = 0;
|
|
6429
|
-
class A {
|
|
6430
|
-
static a() {
|
|
6431
|
-
return $mol_wire_sync(this.b)();
|
|
6432
|
-
}
|
|
6433
|
-
static b() { return Promise.resolve(++count); }
|
|
6434
|
-
}
|
|
6435
|
-
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
6436
|
-
},
|
|
6437
|
-
async 'test construct itself'($) {
|
|
6438
|
-
class A {
|
|
6439
|
-
static instances = [];
|
|
6440
|
-
static a() {
|
|
6441
|
-
const a = new ($mol_wire_sync(A))();
|
|
6442
|
-
this.instances.push(a);
|
|
6443
|
-
$mol_wire_sync(this).b();
|
|
6444
|
-
}
|
|
6445
|
-
static b() { return Promise.resolve(); }
|
|
6446
|
-
}
|
|
6447
|
-
await $mol_wire_async(A).a();
|
|
6448
|
-
$mol_assert_equal(A.instances.length, 2);
|
|
6449
|
-
$mol_assert_equal(A.instances[0] instanceof A);
|
|
6450
|
-
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
6451
|
-
}
|
|
6452
|
-
});
|
|
6453
|
-
})($ || ($ = {}));
|
|
6454
|
-
|
|
6455
|
-
;
|
|
6456
|
-
"use strict";
|
|
6457
|
-
var $;
|
|
6458
|
-
(function ($_1) {
|
|
6459
|
-
$mol_test({
|
|
6460
|
-
async 'exec timeout auto kill child process'($) {
|
|
6461
|
-
let close_mock = () => { };
|
|
6462
|
-
const context_mock = $.$mol_ambient({
|
|
6463
|
-
$mol_run_spawn: () => ({
|
|
6464
|
-
on(name, cb) {
|
|
6465
|
-
if (name === 'exit')
|
|
6466
|
-
close_mock = cb;
|
|
6467
|
-
},
|
|
6468
|
-
kill() { close_mock(); }
|
|
6469
|
-
})
|
|
6470
|
-
});
|
|
6471
|
-
let message = '';
|
|
6472
|
-
try {
|
|
6473
|
-
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10, env: { 'MOL_RUN_ASYNC': '1' } });
|
|
6474
|
-
}
|
|
6475
|
-
catch (e) {
|
|
6476
|
-
message = e.message;
|
|
6477
|
-
}
|
|
6478
|
-
$mol_assert_equal(message, 'Run error, timeout');
|
|
6479
|
-
}
|
|
6480
|
-
});
|
|
6481
|
-
})($ || ($ = {}));
|
|
6482
|
-
|
|
6483
|
-
;
|
|
6484
|
-
"use strict";
|
|
6485
|
-
|
|
6486
|
-
;
|
|
6487
|
-
"use strict";
|
|
6488
|
-
|
|
6489
6379
|
;
|
|
6490
6380
|
"use strict";
|
|
6491
6381
|
var $;
|
|
@@ -7257,6 +7147,20 @@ var $;
|
|
|
7257
7147
|
});
|
|
7258
7148
|
})($ || ($ = {}));
|
|
7259
7149
|
|
|
7150
|
+
;
|
|
7151
|
+
"use strict";
|
|
7152
|
+
var $;
|
|
7153
|
+
(function ($_1) {
|
|
7154
|
+
$mol_test_mocks.push($ => {
|
|
7155
|
+
$.$mol_log3_come = () => { };
|
|
7156
|
+
$.$mol_log3_done = () => { };
|
|
7157
|
+
$.$mol_log3_fail = () => { };
|
|
7158
|
+
$.$mol_log3_warn = () => { };
|
|
7159
|
+
$.$mol_log3_rise = () => { };
|
|
7160
|
+
$.$mol_log3_area = () => () => { };
|
|
7161
|
+
});
|
|
7162
|
+
})($ || ($ = {}));
|
|
7163
|
+
|
|
7260
7164
|
;
|
|
7261
7165
|
"use strict";
|
|
7262
7166
|
var $;
|
|
@@ -7504,6 +7408,58 @@ var $;
|
|
|
7504
7408
|
});
|
|
7505
7409
|
})($ || ($ = {}));
|
|
7506
7410
|
|
|
7411
|
+
;
|
|
7412
|
+
"use strict";
|
|
7413
|
+
var $;
|
|
7414
|
+
(function ($) {
|
|
7415
|
+
$mol_test({
|
|
7416
|
+
'init with overload'() {
|
|
7417
|
+
class X extends $mol_object {
|
|
7418
|
+
foo() {
|
|
7419
|
+
return 1;
|
|
7420
|
+
}
|
|
7421
|
+
}
|
|
7422
|
+
var x = X.make({
|
|
7423
|
+
foo: () => 2,
|
|
7424
|
+
});
|
|
7425
|
+
$mol_assert_equal(x.foo(), 2);
|
|
7426
|
+
},
|
|
7427
|
+
});
|
|
7428
|
+
})($ || ($ = {}));
|
|
7429
|
+
|
|
7430
|
+
;
|
|
7431
|
+
"use strict";
|
|
7432
|
+
var $;
|
|
7433
|
+
(function ($) {
|
|
7434
|
+
$mol_test({
|
|
7435
|
+
'auto name'() {
|
|
7436
|
+
class Invalid extends $mol_error_mix {
|
|
7437
|
+
}
|
|
7438
|
+
const mix = new Invalid('foo');
|
|
7439
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
7440
|
+
},
|
|
7441
|
+
'simpe mix'() {
|
|
7442
|
+
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
7443
|
+
$mol_assert_equal(mix.message, 'foo');
|
|
7444
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
7445
|
+
},
|
|
7446
|
+
'provide additional info'() {
|
|
7447
|
+
class Invalid extends $mol_error_mix {
|
|
7448
|
+
}
|
|
7449
|
+
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' }));
|
|
7450
|
+
const hints = [];
|
|
7451
|
+
if (mix instanceof $mol_error_mix) {
|
|
7452
|
+
for (const er of mix.errors) {
|
|
7453
|
+
if (er instanceof Invalid) {
|
|
7454
|
+
hints.push(er.cause?.hint ?? '');
|
|
7455
|
+
}
|
|
7456
|
+
}
|
|
7457
|
+
}
|
|
7458
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
7459
|
+
},
|
|
7460
|
+
});
|
|
7461
|
+
})($ || ($ = {}));
|
|
7462
|
+
|
|
7507
7463
|
;
|
|
7508
7464
|
"use strict";
|
|
7509
7465
|
var $;
|
|
@@ -7691,6 +7647,112 @@ var $;
|
|
|
7691
7647
|
});
|
|
7692
7648
|
})($ || ($ = {}));
|
|
7693
7649
|
|
|
7650
|
+
;
|
|
7651
|
+
"use strict";
|
|
7652
|
+
var $;
|
|
7653
|
+
(function ($_1) {
|
|
7654
|
+
$mol_test({
|
|
7655
|
+
'test types'($) {
|
|
7656
|
+
class A {
|
|
7657
|
+
static a() {
|
|
7658
|
+
return '';
|
|
7659
|
+
}
|
|
7660
|
+
static b() {
|
|
7661
|
+
return $mol_wire_async(this).a();
|
|
7662
|
+
}
|
|
7663
|
+
}
|
|
7664
|
+
},
|
|
7665
|
+
async 'Latest method calls wins'($) {
|
|
7666
|
+
class NameLogger extends $mol_object2 {
|
|
7667
|
+
static $ = $;
|
|
7668
|
+
static first = [];
|
|
7669
|
+
static last = [];
|
|
7670
|
+
static send(next) {
|
|
7671
|
+
$mol_wire_sync(this.first).push(next);
|
|
7672
|
+
$$.$mol_wait_timeout(0);
|
|
7673
|
+
this.last.push(next);
|
|
7674
|
+
}
|
|
7675
|
+
}
|
|
7676
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
7677
|
+
name('john');
|
|
7678
|
+
const promise = name('jin');
|
|
7679
|
+
$.$mol_after_mock_warp();
|
|
7680
|
+
await promise;
|
|
7681
|
+
$mol_assert_equal(NameLogger.first, ['john', 'jin']);
|
|
7682
|
+
$mol_assert_equal(NameLogger.last, ['jin']);
|
|
7683
|
+
},
|
|
7684
|
+
async 'Latest function calls wins'($) {
|
|
7685
|
+
const first = [];
|
|
7686
|
+
const last = [];
|
|
7687
|
+
function send_name(next) {
|
|
7688
|
+
$mol_wire_sync(first).push(next);
|
|
7689
|
+
$$.$mol_wait_timeout(0);
|
|
7690
|
+
last.push(next);
|
|
7691
|
+
}
|
|
7692
|
+
const name = $mol_wire_async(send_name);
|
|
7693
|
+
name('john');
|
|
7694
|
+
const promise = name('jin');
|
|
7695
|
+
$.$mol_after_mock_warp();
|
|
7696
|
+
await promise;
|
|
7697
|
+
$mol_assert_equal(first, ['john', 'jin']);
|
|
7698
|
+
$mol_assert_equal(last, ['jin']);
|
|
7699
|
+
},
|
|
7700
|
+
});
|
|
7701
|
+
})($ || ($ = {}));
|
|
7702
|
+
|
|
7703
|
+
;
|
|
7704
|
+
"use strict";
|
|
7705
|
+
var $;
|
|
7706
|
+
(function ($_1) {
|
|
7707
|
+
$mol_test({
|
|
7708
|
+
'test types'($) {
|
|
7709
|
+
class A {
|
|
7710
|
+
static a() {
|
|
7711
|
+
return Promise.resolve('');
|
|
7712
|
+
}
|
|
7713
|
+
static b() {
|
|
7714
|
+
return $mol_wire_sync(this).a();
|
|
7715
|
+
}
|
|
7716
|
+
}
|
|
7717
|
+
},
|
|
7718
|
+
async 'test method from host'($) {
|
|
7719
|
+
let count = 0;
|
|
7720
|
+
class A {
|
|
7721
|
+
static a() {
|
|
7722
|
+
return $mol_wire_sync(this).b();
|
|
7723
|
+
}
|
|
7724
|
+
static b() { return Promise.resolve(++count); }
|
|
7725
|
+
}
|
|
7726
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
7727
|
+
},
|
|
7728
|
+
async 'test function'($) {
|
|
7729
|
+
let count = 0;
|
|
7730
|
+
class A {
|
|
7731
|
+
static a() {
|
|
7732
|
+
return $mol_wire_sync(this.b)();
|
|
7733
|
+
}
|
|
7734
|
+
static b() { return Promise.resolve(++count); }
|
|
7735
|
+
}
|
|
7736
|
+
$mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
|
|
7737
|
+
},
|
|
7738
|
+
async 'test construct itself'($) {
|
|
7739
|
+
class A {
|
|
7740
|
+
static instances = [];
|
|
7741
|
+
static a() {
|
|
7742
|
+
const a = new ($mol_wire_sync(A))();
|
|
7743
|
+
this.instances.push(a);
|
|
7744
|
+
$mol_wire_sync(this).b();
|
|
7745
|
+
}
|
|
7746
|
+
static b() { return Promise.resolve(); }
|
|
7747
|
+
}
|
|
7748
|
+
await $mol_wire_async(A).a();
|
|
7749
|
+
$mol_assert_equal(A.instances.length, 2);
|
|
7750
|
+
$mol_assert_equal(A.instances[0] instanceof A);
|
|
7751
|
+
$mol_assert_equal(A.instances[0], A.instances[1]);
|
|
7752
|
+
}
|
|
7753
|
+
});
|
|
7754
|
+
})($ || ($ = {}));
|
|
7755
|
+
|
|
7694
7756
|
;
|
|
7695
7757
|
"use strict";
|
|
7696
7758
|
var $;
|
|
@@ -7817,70 +7879,52 @@ var $;
|
|
|
7817
7879
|
var $;
|
|
7818
7880
|
(function ($_1) {
|
|
7819
7881
|
$mol_test({
|
|
7820
|
-
'
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7882
|
+
async 'exec timeout auto kill child process'($) {
|
|
7883
|
+
let close_mock = () => { };
|
|
7884
|
+
const error_message = 'Run error, timeout';
|
|
7885
|
+
function mol_run_spawn_sync_mock() {
|
|
7886
|
+
return {
|
|
7887
|
+
output: [],
|
|
7888
|
+
stdout: error_message,
|
|
7889
|
+
stderr: '',
|
|
7890
|
+
status: 0,
|
|
7891
|
+
signal: null,
|
|
7892
|
+
pid: 123,
|
|
7893
|
+
};
|
|
7828
7894
|
}
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7895
|
+
function mol_run_spawn_mock() {
|
|
7896
|
+
return {
|
|
7897
|
+
on(name, cb) {
|
|
7898
|
+
if (name === 'exit')
|
|
7899
|
+
close_mock = cb;
|
|
7900
|
+
},
|
|
7901
|
+
kill() { close_mock(); }
|
|
7902
|
+
};
|
|
7903
|
+
}
|
|
7904
|
+
const context_mock = $.$mol_ambient({
|
|
7905
|
+
$mol_run_spawn_sync: mol_run_spawn_sync_mock,
|
|
7906
|
+
$mol_run_spawn: mol_run_spawn_mock
|
|
7907
|
+
});
|
|
7908
|
+
class $mol_run_mock extends $mol_run {
|
|
7909
|
+
static get $() { return context_mock; }
|
|
7910
|
+
static async_enabled() {
|
|
7911
|
+
return true;
|
|
7839
7912
|
}
|
|
7840
7913
|
}
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
async 'Latest function calls wins'($) {
|
|
7850
|
-
const first = [];
|
|
7851
|
-
const last = [];
|
|
7852
|
-
function send_name(next) {
|
|
7853
|
-
$mol_wire_sync(first).push(next);
|
|
7854
|
-
$$.$mol_wait_timeout(0);
|
|
7855
|
-
last.push(next);
|
|
7914
|
+
let message = '';
|
|
7915
|
+
try {
|
|
7916
|
+
const res = await $mol_wire_async($mol_run_mock).spawn({
|
|
7917
|
+
command: 'sleep 10',
|
|
7918
|
+
dir: '.',
|
|
7919
|
+
timeout: 10,
|
|
7920
|
+
env: { 'MOL_RUN_ASYNC': '1' }
|
|
7921
|
+
});
|
|
7856
7922
|
}
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
const promise = name('jin');
|
|
7860
|
-
$.$mol_after_mock_warp();
|
|
7861
|
-
await promise;
|
|
7862
|
-
$mol_assert_equal(first, ['john', 'jin']);
|
|
7863
|
-
$mol_assert_equal(last, ['jin']);
|
|
7864
|
-
},
|
|
7865
|
-
});
|
|
7866
|
-
})($ || ($ = {}));
|
|
7867
|
-
|
|
7868
|
-
;
|
|
7869
|
-
"use strict";
|
|
7870
|
-
var $;
|
|
7871
|
-
(function ($) {
|
|
7872
|
-
$mol_test({
|
|
7873
|
-
'init with overload'() {
|
|
7874
|
-
class X extends $mol_object {
|
|
7875
|
-
foo() {
|
|
7876
|
-
return 1;
|
|
7877
|
-
}
|
|
7923
|
+
catch (e) {
|
|
7924
|
+
message = e.message;
|
|
7878
7925
|
}
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
});
|
|
7882
|
-
$mol_assert_equal(x.foo(), 2);
|
|
7883
|
-
},
|
|
7926
|
+
$mol_assert_equal(message, error_message);
|
|
7927
|
+
}
|
|
7884
7928
|
});
|
|
7885
7929
|
})($ || ($ = {}));
|
|
7886
7930
|
|