diff --git a/prettier.config.js b/prettier.config.js index c319b6e..038b7db 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -4,10 +4,8 @@ module.exports = { semi: true, tabWidth: 2, trailingComma: "all", - importOrder: [ - "", - "^[./]", - ], + plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")], + importOrder: ["", "^[./]"], importOrderSeparation: true, importOrderSortSpecifiers: true, importOrderParserPlugins: ["decorators-legacy", "typescript"], diff --git a/src/components/Communicator.ts b/src/components/Communicator.ts index 6282196..5bb28dc 100644 --- a/src/components/Communicator.ts +++ b/src/components/Communicator.ts @@ -1,15 +1,15 @@ -import { Driver } from "../typings/Driver"; -import { Invoke } from "./Invoke"; - -import { serializeError } from "../utils/internal/serializeError"; import { + ConditionVariable, + DomainError, HashMap, Pair, - ConditionVariable, RuntimeError, - DomainError, } from "tstl"; +import { Driver } from "../typings/Driver"; +import { serializeError } from "../utils/internal/serializeError"; +import { Invoke } from "./Invoke"; + /** * The basic communicator. * diff --git a/src/protocols/internal/AcceptorBase.ts b/src/protocols/internal/AcceptorBase.ts index ca2be5c..d403cf9 100644 --- a/src/protocols/internal/AcceptorBase.ts +++ b/src/protocols/internal/AcceptorBase.ts @@ -1,4 +1,5 @@ import { DomainError, RuntimeError } from "tstl"; + import { Communicator } from "../../components/Communicator"; /** diff --git a/src/protocols/internal/ConnectorBase.ts b/src/protocols/internal/ConnectorBase.ts index baa4346..9340375 100644 --- a/src/protocols/internal/ConnectorBase.ts +++ b/src/protocols/internal/ConnectorBase.ts @@ -1,4 +1,5 @@ import { DomainError, RuntimeError } from "tstl"; + import { Communicator } from "../../components/Communicator"; /** diff --git a/src/protocols/web/WebAcceptor.ts b/src/protocols/web/WebAcceptor.ts index 7b6326c..651f9b3 100644 --- a/src/protocols/web/WebAcceptor.ts +++ b/src/protocols/web/WebAcceptor.ts @@ -1,13 +1,11 @@ import type http from "http"; -import type WebSocket from "ws"; import { DomainError } from "tstl"; - -import { AcceptorBase } from "../internal/AcceptorBase"; -import { IWebCommunicator } from "./internal/IWebCommunicator"; +import type WebSocket from "ws"; import { Invoke } from "../../components/Invoke"; - +import { AcceptorBase } from "../internal/AcceptorBase"; import { WebError } from "./WebError"; +import { IWebCommunicator } from "./internal/IWebCommunicator"; /** * Web Socket Acceptor. diff --git a/src/protocols/web/WebConnector.ts b/src/protocols/web/WebConnector.ts index f18c6cd..4d47d59 100644 --- a/src/protocols/web/WebConnector.ts +++ b/src/protocols/web/WebConnector.ts @@ -1,12 +1,12 @@ -import { Invoke } from "../../components/Invoke"; -import { WebError } from "./WebError"; +import { DomainError, is_node, sleep_for } from "tstl"; +import { Invoke } from "../../components/Invoke"; import { ConnectorBase } from "../internal/ConnectorBase"; import { IHeaderWrapper } from "../internal/IHeaderWrapper"; -import { IWebCommunicator } from "./internal/IWebCommunicator"; import { once } from "../internal/once"; +import { WebError } from "./WebError"; +import { IWebCommunicator } from "./internal/IWebCommunicator"; import { WebSocketPolyfill } from "./internal/WebSocketPolyfill"; -import { DomainError, is_node, sleep_for } from "tstl"; /** * Web Socket Connector. diff --git a/src/protocols/web/WebServer.ts b/src/protocols/web/WebServer.ts index 1186ea5..390a17d 100644 --- a/src/protocols/web/WebServer.ts +++ b/src/protocols/web/WebServer.ts @@ -1,14 +1,13 @@ import type http from "http"; import type https from "https"; import type net from "net"; +import { DomainError, RuntimeError, is_node } from "tstl"; import type WebSocket from "ws"; -import { WebAcceptor } from "./WebAcceptor"; -import { IServer } from "../internal/IServer"; - -import { IHeaderWrapper } from "../internal/IHeaderWrapper"; import { NodeModule } from "../../utils/internal/NodeModule"; -import { is_node, DomainError, RuntimeError } from "tstl"; +import { IHeaderWrapper } from "../internal/IHeaderWrapper"; +import { IServer } from "../internal/IServer"; +import { WebAcceptor } from "./WebAcceptor"; /** * Web Socket Server. diff --git a/src/protocols/workers/SharedWorkerAcceptor.ts b/src/protocols/workers/SharedWorkerAcceptor.ts index 90123b5..ce98d72 100644 --- a/src/protocols/workers/SharedWorkerAcceptor.ts +++ b/src/protocols/workers/SharedWorkerAcceptor.ts @@ -1,9 +1,9 @@ -import { AcceptorBase } from "../internal/AcceptorBase"; -import { IWorkerSystem } from "./internal/IWorkerSystem"; +import { DomainError } from "tstl"; import { Invoke } from "../../components/Invoke"; +import { AcceptorBase } from "../internal/AcceptorBase"; import { IReject } from "./internal/IReject"; -import { DomainError } from "tstl"; +import { IWorkerSystem } from "./internal/IWorkerSystem"; /** * SharedWorker acceptor for client. diff --git a/src/protocols/workers/SharedWorkerConnector.ts b/src/protocols/workers/SharedWorkerConnector.ts index 7b6971f..0852b84 100644 --- a/src/protocols/workers/SharedWorkerConnector.ts +++ b/src/protocols/workers/SharedWorkerConnector.ts @@ -1,12 +1,12 @@ -import { ConnectorBase } from "../internal/ConnectorBase"; -import { IWorkerSystem } from "./internal/IWorkerSystem"; +import { DomainError, RuntimeError, sleep_until } from "tstl"; import { Invoke } from "../../components/Invoke"; +import { ConnectorBase } from "../internal/ConnectorBase"; import { IHeaderWrapper } from "../internal/IHeaderWrapper"; +import { once } from "../internal/once"; import { IReject } from "./internal/IReject"; +import { IWorkerSystem } from "./internal/IWorkerSystem"; import { WebWorkerCompiler } from "./internal/WebWorkerCompiler"; -import { once } from "../internal/once"; -import { DomainError, RuntimeError, sleep_until } from "tstl"; /** * SharedWorker Connector diff --git a/src/protocols/workers/SharedWorkerServer.ts b/src/protocols/workers/SharedWorkerServer.ts index 086e389..302a163 100644 --- a/src/protocols/workers/SharedWorkerServer.ts +++ b/src/protocols/workers/SharedWorkerServer.ts @@ -1,9 +1,9 @@ -import { IServer } from "../internal/IServer"; -import { SharedWorkerAcceptor } from "./SharedWorkerAcceptor"; +import { DomainError, HashSet, is_node } from "tstl"; import { IHeaderWrapper } from "../internal/IHeaderWrapper"; +import { IServer } from "../internal/IServer"; import { once } from "../internal/once"; -import { HashSet, is_node, DomainError } from "tstl"; +import { SharedWorkerAcceptor } from "./SharedWorkerAcceptor"; /** * SharedWorker server. diff --git a/src/protocols/workers/WorkerConnector.ts b/src/protocols/workers/WorkerConnector.ts index c347b7f..ef72f1a 100644 --- a/src/protocols/workers/WorkerConnector.ts +++ b/src/protocols/workers/WorkerConnector.ts @@ -1,13 +1,13 @@ -import { Invoke } from "../../components/Invoke"; +import { DomainError, Singleton, is_node, sleep_until } from "tstl"; +import { Invoke } from "../../components/Invoke"; +import { ConnectorBase } from "../internal/ConnectorBase"; import { IHeaderWrapper } from "../internal/IHeaderWrapper"; +import { once } from "../internal/once"; import { IWorkerCompiler } from "./internal/IWorkerCompiler"; import { IWorkerSystem } from "./internal/IWorkerSystem"; -import { ConnectorBase } from "../internal/ConnectorBase"; import { NodeWorkerCompiler } from "./internal/NodeWorkerCompiler"; import { WebWorkerCompiler } from "./internal/WebWorkerCompiler"; -import { once } from "../internal/once"; -import { Singleton, is_node, DomainError, sleep_until } from "tstl"; /** * Worker Connector. diff --git a/src/protocols/workers/WorkerServer.ts b/src/protocols/workers/WorkerServer.ts index d07353d..724a11c 100644 --- a/src/protocols/workers/WorkerServer.ts +++ b/src/protocols/workers/WorkerServer.ts @@ -1,21 +1,20 @@ -import { Communicator } from "../../components/Communicator"; -import { IServer } from "../internal/IServer"; -import { IWorkerSystem } from "./internal/IWorkerSystem"; - -import { Invoke } from "../../components/Invoke"; -import { IHeaderWrapper } from "../internal/IHeaderWrapper"; -import { once } from "../internal/once"; - -import { ThreadPort } from "./internal/threads/ThreadPort"; -import { ProcessChannel } from "./internal/processes/ProcessChannel"; import { + DomainError, + RuntimeError, Singleton, is_node, - DomainError, sleep_until, - RuntimeError, } from "tstl"; +import { Communicator } from "../../components/Communicator"; +import { Invoke } from "../../components/Invoke"; +import { IHeaderWrapper } from "../internal/IHeaderWrapper"; +import { IServer } from "../internal/IServer"; +import { once } from "../internal/once"; +import { IWorkerSystem } from "./internal/IWorkerSystem"; +import { ProcessChannel } from "./internal/processes/ProcessChannel"; +import { ThreadPort } from "./internal/threads/ThreadPort"; + /** * Worker Server. * diff --git a/src/protocols/workers/internal/FileSystem.ts b/src/protocols/workers/internal/FileSystem.ts index 82c6951..aea32d9 100644 --- a/src/protocols/workers/internal/FileSystem.ts +++ b/src/protocols/workers/internal/FileSystem.ts @@ -1,4 +1,5 @@ import type fs from "fs"; + import { NodeModule } from "../../../utils/internal/NodeModule"; /** diff --git a/src/protocols/workers/internal/NodeWorkerCompiler.ts b/src/protocols/workers/internal/NodeWorkerCompiler.ts index ab88e92..016ea57 100644 --- a/src/protocols/workers/internal/NodeWorkerCompiler.ts +++ b/src/protocols/workers/internal/NodeWorkerCompiler.ts @@ -1,5 +1,4 @@ import { NodeModule } from "../../../utils/internal/NodeModule"; - import { FileSystem } from "./FileSystem"; import { IWorkerCompiler } from "./IWorkerCompiler"; import { ProcessWorker } from "./processes/ProcessWorker"; diff --git a/src/protocols/workers/internal/processes/ProcessWorker.ts b/src/protocols/workers/internal/processes/ProcessWorker.ts index 5250485..19112df 100644 --- a/src/protocols/workers/internal/processes/ProcessWorker.ts +++ b/src/protocols/workers/internal/processes/ProcessWorker.ts @@ -1,4 +1,5 @@ import type cp from "child_process"; + import { NodeModule } from "../../../../utils/internal/NodeModule"; import { IWorkerCompiler } from "../IWorkerCompiler"; diff --git a/src/protocols/workers/internal/threads/ThreadPort.ts b/src/protocols/workers/internal/threads/ThreadPort.ts index 30b79af..6598228 100644 --- a/src/protocols/workers/internal/threads/ThreadPort.ts +++ b/src/protocols/workers/internal/threads/ThreadPort.ts @@ -1,4 +1,5 @@ //================================================================ + /** @module tgrid.protocols.workers */ //================================================================ import { NodeModule } from "../../../../utils/internal/NodeModule"; diff --git a/src/protocols/workers/internal/threads/ThreadWorker.ts b/src/protocols/workers/internal/threads/ThreadWorker.ts index e997761..3c2578f 100644 --- a/src/protocols/workers/internal/threads/ThreadWorker.ts +++ b/src/protocols/workers/internal/threads/ThreadWorker.ts @@ -1,7 +1,9 @@ //================================================================ + /** @module tgrid.protocols.workers */ //================================================================ import type thread from "worker_threads"; + import { NodeModule } from "../../../../utils/internal/NodeModule"; import { IWorkerCompiler } from "../IWorkerCompiler"; diff --git a/src/utils/internal/NodeModule.ts b/src/utils/internal/NodeModule.ts index 375a215..833af79 100644 --- a/src/utils/internal/NodeModule.ts +++ b/src/utils/internal/NodeModule.ts @@ -2,13 +2,12 @@ import type * as __cp from "child_process"; import type * as __fs from "fs"; import type * as __http from "http"; import type * as __https from "https"; +import import2 from "import2"; import type * as __os from "os"; -import type * as __thread from "worker_threads"; -import type * as __ws from "ws"; import type * as __process from "process"; - -import import2 from "import2"; import { Singleton } from "tstl"; +import type * as __thread from "worker_threads"; +import type * as __ws from "ws"; export namespace NodeModule { export const cp: Singleton> = new Singleton(() => diff --git a/test/browser/index.ts b/test/browser/index.ts index dedcbcf..e702764 100644 --- a/test/browser/index.ts +++ b/test/browser/index.ts @@ -1,5 +1,7 @@ import * as puppeteer from "puppeteer"; + import { TestBundler } from "./TestBundler"; + const HttpServer = require("local-web-server"); const PORT = 37792; diff --git a/test/browser/shared-worker-client.ts b/test/browser/shared-worker-client.ts index 6152393..c8b06da 100644 --- a/test/browser/shared-worker-client.ts +++ b/test/browser/shared-worker-client.ts @@ -1,4 +1,5 @@ import { SharedWorkerConnector } from "tgrid"; + import { ICalculator } from "../controllers/ICalculator"; import { complete } from "./internal"; diff --git a/test/browser/shared-worker-server.ts b/test/browser/shared-worker-server.ts index c5137ec..5e443aa 100644 --- a/test/browser/shared-worker-server.ts +++ b/test/browser/shared-worker-server.ts @@ -1,4 +1,5 @@ import { SharedWorkerServer } from "tgrid"; + import { Calculator } from "../providers/Calculator"; /// chrome://inspect/#workers diff --git a/test/browser/web-client.ts b/test/browser/web-client.ts index ea1e9cd..d6aa5e3 100644 --- a/test/browser/web-client.ts +++ b/test/browser/web-client.ts @@ -1,8 +1,8 @@ +import { Driver, WebConnector } from "tgrid"; import { InvalidArgument } from "tstl"; import { ICalculator } from "../controllers/ICalculator"; import { complete } from "./internal"; -import { Driver, WebConnector } from "tgrid"; window.onload = async () => { for (let i: number = 0; i < 5; ++i) { diff --git a/test/browser/web-server.ts b/test/browser/web-server.ts index 7ac6293..d5a9801 100644 --- a/test/browser/web-server.ts +++ b/test/browser/web-server.ts @@ -1,4 +1,5 @@ import { WebServer } from "tgrid"; + import { Calculator } from "../providers/Calculator"; async function main(): Promise { diff --git a/test/browser/worker-client.ts b/test/browser/worker-client.ts index 7e6fc76..f672ad8 100644 --- a/test/browser/worker-client.ts +++ b/test/browser/worker-client.ts @@ -1,8 +1,8 @@ +import { WorkerConnector } from "tgrid"; import "whatwg-fetch"; import { ICalculator } from "../controllers/ICalculator"; import { complete } from "./internal"; -import { WorkerConnector } from "tgrid"; async function get_source(): Promise { let url: string = location.href; diff --git a/test/browser/worker-server.ts b/test/browser/worker-server.ts index bcabf65..1de4f92 100644 --- a/test/browser/worker-server.ts +++ b/test/browser/worker-server.ts @@ -1,4 +1,5 @@ import { WorkerServer } from "tgrid"; + import { Calculator } from "../providers/Calculator"; async function main(): Promise { diff --git a/test/controllers/ICalculator.ts b/test/controllers/ICalculator.ts index fa5b1f5..47b41cf 100644 --- a/test/controllers/ICalculator.ts +++ b/test/controllers/ICalculator.ts @@ -1,6 +1,7 @@ +import { Driver } from "tgrid"; import { DomainError, InvalidArgument, randint } from "tstl"; + import { Calculator } from "../providers/Calculator"; -import { Driver } from "tgrid"; export interface ICalculator extends ISimple { scientific: IScientific; diff --git a/test/controllers/IScript.ts b/test/controllers/IScript.ts index 4428192..c601a50 100644 --- a/test/controllers/IScript.ts +++ b/test/controllers/IScript.ts @@ -1,4 +1,4 @@ -import { LengthError, DomainError } from "tstl"; +import { DomainError, LengthError } from "tstl"; export interface IScript { name: string; diff --git a/test/controllers/IVector.ts b/test/controllers/IVector.ts index 28085a4..ae0c7b6 100644 --- a/test/controllers/IVector.ts +++ b/test/controllers/IVector.ts @@ -1,5 +1,5 @@ import { Driver } from "tgrid"; -import { randint, DomainError } from "tstl"; +import { DomainError, randint } from "tstl"; export interface IVector { size(): T; diff --git a/test/node/components/test_pseudo.ts b/test/node/components/test_pseudo.ts index c0b38d9..b25dd9f 100644 --- a/test/node/components/test_pseudo.ts +++ b/test/node/components/test_pseudo.ts @@ -1,8 +1,8 @@ -import { Communicator, Invoke, Driver } from "tgrid"; +import { Communicator, Driver, Invoke } from "tgrid"; import { InvalidArgument } from "tstl"; -import { Calculator } from "../../providers/Calculator"; import { ICalculator } from "../../controllers/ICalculator"; +import { Calculator } from "../../providers/Calculator"; class PseudoCommunicator extends Communicator { private sender_: (invoke: Invoke) => void; diff --git a/test/node/index.ts b/test/node/index.ts index e219375..3c31b1d 100644 --- a/test/node/index.ts +++ b/test/node/index.ts @@ -1,7 +1,7 @@ -const EXTENSION = __filename.substr(-2); -if (EXTENSION === "js") require("source-map-support").install(); +import fs from "fs"; -import fs from "fs"; +const EXTENSION = __filename.substr(-2); +if (EXTENSION === "js") require("source-map-support").install(); interface IModule { [key: string]: () => Promise; diff --git a/test/node/protocols/web/test_web_calculator.ts b/test/node/protocols/web/test_web_calculator.ts index 572b3a2..75253a4 100644 --- a/test/node/protocols/web/test_web_calculator.ts +++ b/test/node/protocols/web/test_web_calculator.ts @@ -1,9 +1,9 @@ -import { Calculator } from "../../../providers/Calculator"; +import { Driver, WebConnector, WebServer } from "tgrid"; +import { Vector } from "tstl"; + import { ICalculator } from "../../../controllers/ICalculator"; import { IVector } from "../../../controllers/IVector"; - -import { Vector } from "tstl"; -import { Driver, WebConnector, WebServer } from "tgrid"; +import { Calculator } from "../../../providers/Calculator"; const PORT: number = 10101; diff --git a/test/node/protocols/web/test_web_chat.ts b/test/node/protocols/web/test_web_chat.ts index 48c6d4c..16cbe37 100644 --- a/test/node/protocols/web/test_web_chat.ts +++ b/test/node/protocols/web/test_web_chat.ts @@ -1,9 +1,9 @@ import { Driver, WebConnector, WebServer } from "tgrid"; import { sleep_for } from "tstl"; -import { IScript } from "../../../controllers/IScript"; import { IChatPrinter } from "../../../controllers/IChatPrinter"; import { IChatService } from "../../../controllers/IChatService"; +import { IScript } from "../../../controllers/IScript"; import { ChatService } from "../../../providers/ChatService"; const PORT = 10101; diff --git a/test/node/protocols/web/test_web_mutex.ts b/test/node/protocols/web/test_web_mutex.ts index f86e4a5..ffc546b 100644 --- a/test/node/protocols/web/test_web_mutex.ts +++ b/test/node/protocols/web/test_web_mutex.ts @@ -1,11 +1,11 @@ import { Driver, WebConnector, WebServer } from "tgrid"; import { + DomainError, Mutex, - Vector, - sleep_for, RuntimeError, + Vector, is_sorted, - DomainError, + sleep_for, } from "tstl"; const PORT: number = 10101; diff --git a/test/node/protocols/workers/internal/calculator.ts b/test/node/protocols/workers/internal/calculator.ts index 4508520..d02ca40 100644 --- a/test/node/protocols/workers/internal/calculator.ts +++ b/test/node/protocols/workers/internal/calculator.ts @@ -1,7 +1,8 @@ -import { Simple } from "../../../../providers/Calculator"; -import { IScientific, IStatistics } from "../../../../controllers/ICalculator"; import { Driver, WorkerConnector, WorkerServer } from "tgrid"; +import { IScientific, IStatistics } from "../../../../controllers/ICalculator"; +import { Simple } from "../../../../providers/Calculator"; + class HierarchicalCalculator extends Simple { // REMOTE CALCULATOR public scientific!: Driver; diff --git a/test/node/protocols/workers/internal/chat-child.ts b/test/node/protocols/workers/internal/chat-child.ts index 7a4a006..a5f86eb 100644 --- a/test/node/protocols/workers/internal/chat-child.ts +++ b/test/node/protocols/workers/internal/chat-child.ts @@ -1,8 +1,8 @@ -import { IScript } from "../../../../controllers/IScript"; -import { IChatService } from "../../../../controllers/IChatService"; - -import { sleep_for } from "tstl"; import { Driver, WorkerServer } from "tgrid"; +import { sleep_for } from "tstl"; + +import { IChatService } from "../../../../controllers/IChatService"; +import { IScript } from "../../../../controllers/IScript"; async function main(): Promise { //---- diff --git a/test/node/protocols/workers/internal/error.ts b/test/node/protocols/workers/internal/error.ts new file mode 100644 index 0000000..c0549f1 --- /dev/null +++ b/test/node/protocols/workers/internal/error.ts @@ -0,0 +1,13 @@ +import { WorkerServer } from "tgrid"; + +import { ErrorService } from "../../../../providers/ErrorService"; + +async function main(): Promise { + const server: WorkerServer = new WorkerServer(); + await server.open(new ErrorService()); + await server.join(); +} +main().catch((exp) => { + console.log(exp); + process.exit(-1); +}); diff --git a/test/node/protocols/workers/internal/scientific.ts b/test/node/protocols/workers/internal/scientific.ts index d1fb87d..7e65b2e 100644 --- a/test/node/protocols/workers/internal/scientific.ts +++ b/test/node/protocols/workers/internal/scientific.ts @@ -1,4 +1,5 @@ import { WorkerServer } from "tgrid"; + import { Scientific } from "../../../../providers/Calculator"; async function main(): Promise { diff --git a/test/node/protocols/workers/internal/statistics.ts b/test/node/protocols/workers/internal/statistics.ts index 24823e4..ce7f7b4 100644 --- a/test/node/protocols/workers/internal/statistics.ts +++ b/test/node/protocols/workers/internal/statistics.ts @@ -1,4 +1,5 @@ import { WorkerServer } from "tgrid"; + import { Statistics } from "../../../../providers/Calculator"; async function main(): Promise { diff --git a/test/node/protocols/workers/test_hierarchical_workers.ts b/test/node/protocols/workers/test_hierarchical_workers.ts index 336cfbe..8be0229 100644 --- a/test/node/protocols/workers/test_hierarchical_workers.ts +++ b/test/node/protocols/workers/test_hierarchical_workers.ts @@ -1,4 +1,5 @@ import { Driver, WorkerConnector } from "tgrid"; + import { ICalculator } from "../../../controllers/ICalculator"; export async function test_hierarchical_workers(): Promise { diff --git a/test/node/protocols/workers/test_worker.ts b/test/node/protocols/workers/test_worker.ts index 0a6eea2..b6797b7 100644 --- a/test/node/protocols/workers/test_worker.ts +++ b/test/node/protocols/workers/test_worker.ts @@ -1,4 +1,5 @@ import { WorkerConnector } from "tgrid"; + import { IScientific } from "../../../controllers/ICalculator"; export async function test_worker(): Promise { diff --git a/test/node/protocols/workers/test_worker_chat.ts b/test/node/protocols/workers/test_worker_chat.ts index 9b289f9..f1743e6 100644 --- a/test/node/protocols/workers/test_worker_chat.ts +++ b/test/node/protocols/workers/test_worker_chat.ts @@ -1,4 +1,4 @@ -import { LengthError, DomainError } from "tstl"; +import { DomainError, LengthError } from "tstl"; export interface IScript { name: string; diff --git a/test/node/protocols/workers/test_worker_compiler.ts b/test/node/protocols/workers/test_worker_compiler.ts index 9c1bf51..2569496 100644 --- a/test/node/protocols/workers/test_worker_compiler.ts +++ b/test/node/protocols/workers/test_worker_compiler.ts @@ -1,8 +1,8 @@ import fs from "fs"; - -import { ICalculator } from "../../../controllers/ICalculator"; import { WorkerConnector } from "tgrid"; + import { TestBundler } from "../../../browser/TestBundler"; +import { ICalculator } from "../../../controllers/ICalculator"; export async function test_worker_compiler(): Promise { const PATH = __dirname + "/../../../../../bundle/worker-server.js"; diff --git a/test/node/protocols/workers/test_worker_error.ts b/test/node/protocols/workers/test_worker_error.ts new file mode 100644 index 0000000..0d0951d --- /dev/null +++ b/test/node/protocols/workers/test_worker_error.ts @@ -0,0 +1,18 @@ +import { WorkerConnector } from "tgrid"; + +import { ErrorService } from "../../../providers/ErrorService"; + +export async function test_worker_error(): Promise { + const worker = new WorkerConnector(null, null, "process"); + await worker.connect(`${__dirname}/internal/error.js`); + + const service = worker.getDriver(); + try { + await service.generate(); + } catch { + return; + } finally { + await worker.close(); + } + throw new Error("Failed to catch error"); +} diff --git a/test/providers/Calculator.ts b/test/providers/Calculator.ts index 24e08c9..9a0e252 100644 --- a/test/providers/Calculator.ts +++ b/test/providers/Calculator.ts @@ -1,7 +1,7 @@ import { ICalculator, - ISimple, IScientific, + ISimple, IStatistics, } from "../controllers/ICalculator"; diff --git a/test/providers/ChatService.ts b/test/providers/ChatService.ts index 0873618..6c67606 100644 --- a/test/providers/ChatService.ts +++ b/test/providers/ChatService.ts @@ -1,10 +1,9 @@ -import { IChatService } from "../controllers/IChatService"; +import { Driver } from "tgrid"; +import { DomainError, HashMap } from "tstl"; import { IChatPrinter } from "../controllers/IChatPrinter"; - +import { IChatService } from "../controllers/IChatService"; import { IScript } from "../controllers/IScript"; -import { Driver } from "tgrid"; -import { HashMap, DomainError } from "tstl"; export class ChatService implements IChatService { private static participants_: HashMap> = diff --git a/test/providers/ErrorService.ts b/test/providers/ErrorService.ts new file mode 100644 index 0000000..c677bf8 --- /dev/null +++ b/test/providers/ErrorService.ts @@ -0,0 +1,5 @@ +export class ErrorService { + public generate(): void { + throw new TypeError("Something is wrong"); + } +}