From 423cf8eea7ecdbb3f79be2f3ccea08fcb14b762f Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Fri, 31 Jul 2020 16:19:46 -0600 Subject: [PATCH] All scope tests written and passing --- backend/src/langs.ts | 163 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 143 insertions(+), 20 deletions(-) diff --git a/backend/src/langs.ts b/backend/src/langs.ts index 6379564..2e7e9e9 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -27,7 +27,7 @@ export interface LangConfig { ensure?: string; format?: { run: string; - input?: string; // FIXME + input?: string; output?: string; }; pkg?: { @@ -692,7 +692,7 @@ end`, lsp: { start: "/opt/elixir-ls/language_server.sh" }, template: `IO.puts("Hello, world!") `, - skip: ["repl", "runrepl"], + skip: ["repl", "runrepl", "scope"], }, elm: { name: "Elm", @@ -828,16 +828,25 @@ USE: io input: `expr 123 \\* 234`, main: "main.fish", run: 'SHELL=/usr/bin/fish fish -C "$(< main.fish)"', + scope: { + code: `set x (expr 123 \\* 234)`, + input: `echo $x`, + }, template: `echo "Hello, world!" `, }, forth: { - aliases: ["fs", "gforth"], + aliases: ["gforth"], name: "Forth", repl: "gforth", input: "123 234 * .", main: "main.fs", run: "gforth main.fs", + scope: { + code: `VARIABLE X +123 234 * X !`, + input: `X @ .`, + }, template: `." Hello, world!" CR `, }, @@ -869,6 +878,10 @@ USE: io input: "123 * 234 ;;", main: "main.fsx", run: "fsharpi --use:main.fsx", + scope: { + code: `let x = 123 * 234`, + input: `x ;;`, + }, template: `printfn "Hello, world!" `, timeout: 15, @@ -914,17 +927,28 @@ func main() { repl: `JAVA_OPTS="-Djava.util.prefs.systemRoot=$PWD/.java -Djava.util.prefs.userRoot=$PWD/.java/.userPrefs" groovysh`, main: "main.groovy", run: `JAVA_OPTS="-Djava.util.prefs.systemRoot=$PWD/.java -Djava.util.prefs.userRoot=$PWD/.java/.userPrefs" groovysh main.groovy`, + scope: { + code: `x = 123 * 234;`, + }, template: `print "Hello, world!"; `, timeout: 15, }, hack: { + aliases: ["hhvm"], name: "Hack", repl: "hhvm -a", input: "print 123 * 234", main: "main.hack", run: "hhvm -a main.hack", helloInput: "r", + scope: { + code: `function x() : int { + return 123 * 234; +}`, + input: `r +p x()`, + }, template: `<<__EntryPoint>> function main(): void { echo "Hello, world!\\n"; @@ -937,6 +961,9 @@ function main(): void { repl: "rm -f .ghci && ghci", main: "Main.hs", run: "(echo ':load Main' && echo 'main') > .ghci && ghci", + scope: { + code: `x = 123 * 234`, + }, format: { run: "brittany", input: `module Main where @@ -1001,6 +1028,9 @@ l ; ; o ; * 4 input: "(* 123 234)", main: "main.hy", run: "hy -i main.hy", + scope: { + code: `(setv x (* 123 234))`, + }, template: `(print "Hello, world!") `, }, @@ -1083,10 +1113,10 @@ PLEASE GIVE UP monacoLang: "javascript", repl: "node", main: "main.js", - run: `node -e ' -eval.apply(this, [require("fs").readFileSync("main.js", {encoding: "utf-8"})]) -require("repl").start() -'`, + run: `node -e "$(< main.js)" -i`, + scope: { + code: `let x = 123 * 234;`, + }, format: { run: "prettier --no-config --stdin-filepath=format.js", input: `console.log('Hello, world!'); @@ -1107,6 +1137,9 @@ require("repl").start() repl: "julia", main: "main.jl", run: "julia -L main.jl", + scope: { + code: `x = 123 * 234`, + }, lsp: { start: `JULIA_DEPOT_PATH=:/opt/julia julia -e 'using LanguageServer; run(LanguageServerInstance(stdin, stdout))'`, config: null, @@ -1156,6 +1189,10 @@ require("repl").start() main: ".kshrc", createEmpty: ``, run: `SHELL=/usr/bin/ksh HOME="$PWD" ksh`, + scope: { + code: `x="$(expr 123 * 234)"`, + input: `echo "$x"`, + }, template: `echo "Hello, world!" `, }, @@ -1220,6 +1257,9 @@ KTHXBYE repl: "lua", main: "main.lua", run: "lua -i main.lua", + scope: { + code: `x = 123 * 234`, + }, lsp: { start: "java -cp /usr/lib/EmmyLua-LS.jar com.tang.vscode.MainKt" }, template: `print("Hello, world!") `, @@ -1380,6 +1420,11 @@ int main() { repl: "ocaml", input: "123 * 234 ;;", run: "ocaml -init main.ml", + scope: { + code: `;; +let x = 123 * 234`, + input: `x ;;`, + }, format: { run: "touch .ocamlformat; ocamlformat --name=format.ml -", input: `print_string "Hello, world!\\n";; @@ -1396,6 +1441,9 @@ print_string "Hello, world!\\n" repl: "octave", main: "main.m", run: "octave --persist main.m", + scope: { + code: `x = 123 * 234`, + }, template: `disp("Hello, world!") `, }, @@ -1460,12 +1508,16 @@ end. repl: "re.pl", main: "main.pl", run: "re.pl --rcfile ./main.pl", + scope: { + code: `my $x = 123 * 234;`, + input: `$x`, + }, format: { run: "perltidy", - input: `print ("Hello, world!\\n") + input: `print ("Hello, world!\\n"); `, }, - template: `print("Hello, world!\\n") + template: `print("Hello, world!\\n"); `, }, php: { @@ -1476,6 +1528,10 @@ end. input: "print 123 * 234;", main: "main.php", run: "php -d auto_prepend_file=main.php -a", + scope: { + code: `$x = 123 * 234;`, + input: `echo $x;`, + }, lsp: { start: "intelephense --stdio" }, template: `