From 84f2ad3068cb77247ee6a263b2d375685b28b850 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Tue, 1 Dec 2020 21:09:08 -0800 Subject: [PATCH] add test for --eval; fix a minor bug (#16224) --- compiler/commands.nim | 1 + tests/misc/trunner.nim | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/compiler/commands.nim b/compiler/commands.nim index 916dfd66b6..11bf628b42 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -450,6 +450,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; conf.projectIsCmd = true conf.cmdInput = arg # can be empty (a nim file with empty content is valid too) if conf.cmd == cmdNone: + conf.command = "e" conf.setCmd cmdNimscript # better than `cmdCrun` as a default conf.implicitCmd = true of "path", "p": diff --git a/tests/misc/trunner.nim b/tests/misc/trunner.nim index 018916e674..e288a56c7a 100644 --- a/tests/misc/trunner.nim +++ b/tests/misc/trunner.nim @@ -216,3 +216,9 @@ mmain.html let file = testsDir / "misc/mimportc.nim" let cmd = fmt"{nim} r -b:cpp --hints:off --nimcache:{nimcache} --warningAsError:ProveInit {file}" check execCmdEx(cmd) == ("witness\n", 0) + + block: # nim --eval + let opt = "--hints:off" + check fmt"""{nim} {opt} --eval:"echo defined(nimscript)"""".execCmdEx == ("true\n", 0) + check fmt"""{nim} r {opt} --eval:"echo defined(c)"""".execCmdEx == ("true\n", 0) + check fmt"""{nim} r -b:js {opt} --eval:"echo defined(js)"""".execCmdEx == ("true\n", 0)