1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Fixed Test4

This commit is contained in:
Brian Fiete 2020-07-19 11:07:18 -07:00
parent 230ff8270e
commit 1e446a655c
4 changed files with 35 additions and 12 deletions

View file

@ -4,6 +4,7 @@
ShowFile("src/Program.bf")
SetExpectError("Generic argument")
SetExpectError("Unable to implicitly cast")
Compile()
ExpectError()

View file

@ -3244,7 +3244,6 @@ namespace IDE
{
if (mScriptManager.IsErrorExpected(text))
{
DeleteAndNullify!(mScriptManager.mExpectingError);
OutputLine("Received expected error: {0}", text);
return null;
}

View file

@ -76,7 +76,7 @@ namespace IDE
public QueuedCmd mCurCmd;
public Stopwatch mTimeoutStopwatch ~ delete _;
public int mTimeoutMS;
public String mExpectingError ~ delete _;
public List<String> mExpectingErrors ~ DeleteContainerAndItems!(_);
public bool mHadExpectingError;
public int mDoneTicks;
public bool mIsBuildScript;
@ -192,9 +192,25 @@ namespace IDE
//gApp.mRunningTestScript = false;
}
public bool IsErrorExpected(StringView err)
public bool IsErrorExpected(StringView err, bool remove = true)
{
return (mExpectingError != null) && (err.Contains(mExpectingError));
if (mExpectingErrors == null)
return false;
for (let checkErr in mExpectingErrors)
{
if (err.Contains(checkErr))
{
if (remove)
{
delete checkErr;
@checkErr.Remove();
if (mExpectingErrors.IsEmpty)
DeleteAndNullify!(mExpectingErrors);
}
return true;
}
}
return false;
}
public void Fail(StringView fmt, params Object[] args)
@ -2321,24 +2337,31 @@ namespace IDE
[IDECommand]
public void SetExpectError(String error)
{
DeleteAndNullify!(ScriptManager.sActiveManager.mExpectingError);
ScriptManager.sActiveManager.mExpectingError = new String(error);
if (ScriptManager.sActiveManager.mExpectingErrors == null)
ScriptManager.sActiveManager.mExpectingErrors = new .();
ScriptManager.sActiveManager.mExpectingErrors.Add(new String(error));
ScriptManager.sActiveManager.mHadExpectingError = true;
}
[IDECommand]
public void ClearExpectError()
{
DeleteAndNullify!(ScriptManager.sActiveManager.mExpectingError);
if (ScriptManager.sActiveManager.mExpectingErrors != null)
{
DeleteContainerAndItems!(ScriptManager.sActiveManager.mExpectingErrors);
ScriptManager.sActiveManager.mExpectingErrors = null;
}
ScriptManager.sActiveManager.mHadExpectingError = false;
}
[IDECommand]
public void ExpectError()
{
if (ScriptManager.sActiveManager.mExpectingError != null)
if (ScriptManager.sActiveManager.mExpectingErrors != null)
{
DeleteAndNullify!(ScriptManager.sActiveManager.mExpectingError);
DeleteContainerAndItems!(ScriptManager.sActiveManager.mExpectingErrors);
ScriptManager.sActiveManager.mExpectingErrors = null;
mScriptManager.Fail("Expected error did not occur");
}
}

View file

@ -43,9 +43,9 @@ PUSHD %~dp0..\
@CALL :TEST
@IF !ERRORLEVEL! NEQ 0 GOTO HADERROR
@REM @SET TESTPATH=IDE\Tests\BugW004
@REM @CALL :TEST
@REM @IF !ERRORLEVEL! NEQ 0 GOTO HADERROR
@SET TESTPATH=IDE\Tests\BugW004
@CALL :TEST
@IF !ERRORLEVEL! NEQ 0 GOTO HADERROR
@SET TESTPATH=IDE\Tests\BugW005
@CALL :TEST