@echo off
set prob=trolleys
set tested=md_wrong

echo Testing %prob%_%tested%.

echo Compiling checker...

copy ..\check.dpr check.dpr > nul
dcc32 -cc check.dpr

echo Compiling solution...

copy ..\%prob%_%tested%.java %prob%_%tested%.java > nul
copy ..\%prob%_%tested%.dpr %prob%_%tested%.dpr > nul
if exist %prob%_%tested%.java call javac %prob%_%tested%.java > nul
if exist %prob%_%tested%.dpr call dcc32 -cc %prob%_%tested%.dpr > nul

for %%i in (??) do (
  echo Testing test %%i
  copy %%i %prob%.in > nul
  if exist %prob%_%tested%.class call java -cp . %prob%_%tested%
  if exist %prob%_%tested%.exe %prob%_%tested%.exe
  check %%i %prob%.out %%i.a
)
del %prob%.in
del %prob%.out
if exist %prob%.aux del %prob%.aux
del %prob%_%tested%.*
if exist %prob%_%tested%$*.* del %prob%_%tested%$*.*
del check.*
