diff --git a/backend/src/langs.ts b/backend/src/langs.ts index d682e3e..5891ada 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -15,6 +15,7 @@ export interface LangConfig { run: string; helloInput?: string; hello?: string; + helloMaxLength?: number; runReplInput?: string; runReplOutput?: string; scope?: { @@ -675,6 +676,8 @@ output = "Hello, world!" main: "main.vge", compile: `mono /opt/entropy/entc.exe main.vge | grep -Ev 'WARNING:|Using default' > main.cs && mcs -lib:/opt/entropy -r:Rottytooth.Esolang.Entropy main.cs`, run: "MONO_PATH=/opt/entropy mono main.exe", + hello: `[F-J][c-g][j-n][j-n][m-q][*-.][\\x1e-"][u-y][m-q][p-t][j-n][b-f][\\x1f-#]`, + helloMaxLength: "Hello, world!".length, template: `Program MyNamespace MyProgram [ print "Hello, world!"; ] @@ -896,7 +899,7 @@ log('Hello, world!') aliases: ["i", "ick"], name: "INTERCAL", main: "main.i", - compile: "ick main.i", + compile: "ick -b main.i", run: "./main", template: `DO ,1 <- #14 PLEASE DO ,1 SUB #1 <- #238 @@ -1016,7 +1019,6 @@ PLEASE GIVE UP name: "LiveScript", repl: "lsc", main: "main.ls", - hello: "Hello World", run: "lsc -r ./main.ls; lsc", template: `console.log "Hello, world!" `, @@ -1063,6 +1065,7 @@ KTHXBYE name: "Malbolge", main: "main.mb", run: "malbolge main.mb", + hello: "Hello World!", template: " (=<`#9]~6ZY32Vx/4Rs+0No-&Jk)\"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc\n", }, @@ -1302,7 +1305,6 @@ end. repl: "php -a", input: "print 123 * 234;", main: "main.php", - hello: "Hello World!", run: "php -d auto_prepend_file=main.php -a", lsp: { start: "intelephense --stdio" }, template: ` { + waitForOutput = async (pattern: string, maxLength?: number) => { let output = ""; return await this.wait(`output ${JSON.stringify(pattern)}`, (msg: any) => { const prevLength = output.length; if (msg.event === "terminalOutput") { output += msg.output; } - return output.indexOf(pattern, prevLength - pattern.length) != -1; + if (typeof maxLength === "number") { + return ( + output + .substring(prevLength - maxLength) + .match(new RegExp(pattern)) !== null + ); + } else { + return output.indexOf(pattern, prevLength - pattern.length) != -1; + } }); }; @@ -175,7 +183,7 @@ class Test { throw new Error(`ensure failed with code ${code}`); } }; - testHello = async () => { + testRun = async () => { const pattern = this.config.hello || "Hello, world!"; this.send({ event: "runCode", code: this.config.template }); if (this.config.helloInput !== undefined) { @@ -184,7 +192,7 @@ class Test { input: forTTY(this.config.helloInput), }); } - await this.waitForOutput(pattern); + await this.waitForOutput(pattern, this.config.helloMaxLength); }; testRepl = async () => { const input = this.config.input || "123 * 234"; @@ -547,7 +555,7 @@ const testTypes: { ensure: { pred: ({ ensure }) => (ensure ? true : false), }, - hello: { pred: (config) => true }, + run: { pred: (config) => true }, repl: { pred: ({ repl }) => (repl ? true : false), }, @@ -653,8 +661,7 @@ async function main() { `FAILED: ${lang}/${type}\n` + test.getLog({ pretty: true }) + "\n" + - err.stack + - "\n" + (err.stack ? err.stack + "\n" : err ? `${err}` : "") ); }) .catch(console.error); @@ -671,8 +678,8 @@ async function main() { if (failed.size > 0) { console.error(`${failed.size} test${failed.size !== 1 ? "s" : ""} FAILED`); _.sortBy(Array.from(failed), [ - "lang", - "type", + ([{ lang }, _]: any) => lang, + ([{ type }, _]: any) => type, ]).forEach(([{ lang, type }, err]) => console.error(` - ${lang}/${type} (${err})`) ); diff --git a/package.json b/package.json index 1d89d3b..7550eb2 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,6 @@ "dev": "run-p backend-dev frontend-dev system-dev server-dev", "lsp-repl": "node backend/out/lsp-repl.js", "sandbox": "node backend/out/sandbox.js", - "test": "bash -c 'time node backend/out/test-runner.js'" + "test": "bash -c 'time node backend/out/test-runner.js \"$@\"' --" } } diff --git a/tsconfig.json b/tsconfig.json index c964b6b..a10f6ba 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "downlevelIteration": true, "outDir": "./backend/out", "resolveJsonModule": true, "rootDir": "./backend/src",