mirror of
https://github.com/Smaug123/WoofWare.PawPrint
synced 2025-10-11 16:48:41 +00:00
Assert contents of local variables in tests (#26)
This commit is contained in:
@@ -19,11 +19,13 @@ module TestCases =
|
|||||||
FileName = "Threads.cs"
|
FileName = "Threads.cs"
|
||||||
ExpectedReturnCode = 3
|
ExpectedReturnCode = 3
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
|
LocalVariablesOfMain = []
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "BasicException.cs"
|
FileName = "BasicException.cs"
|
||||||
ExpectedReturnCode = 10
|
ExpectedReturnCode = 10
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
|
LocalVariablesOfMain = []
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "BasicLock.cs"
|
FileName = "BasicLock.cs"
|
||||||
@@ -34,11 +36,13 @@ module TestCases =
|
|||||||
{ mock with
|
{ mock with
|
||||||
System_Threading_Monitor = System_Threading_Monitor.passThru
|
System_Threading_Monitor = System_Threading_Monitor.passThru
|
||||||
}
|
}
|
||||||
|
LocalVariablesOfMain = []
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "WriteLine.cs"
|
FileName = "WriteLine.cs"
|
||||||
ExpectedReturnCode = 1
|
ExpectedReturnCode = 1
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
|
LocalVariablesOfMain = []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -48,11 +52,23 @@ module TestCases =
|
|||||||
FileName = "NoOp.cs"
|
FileName = "NoOp.cs"
|
||||||
ExpectedReturnCode = 1
|
ExpectedReturnCode = 1
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
|
LocalVariablesOfMain = [ CliType.Numeric (CliNumericType.Int32 1) ]
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "TriangleNumber.cs"
|
FileName = "TriangleNumber.cs"
|
||||||
ExpectedReturnCode = 10
|
ExpectedReturnCode = 10
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
|
LocalVariablesOfMain =
|
||||||
|
[
|
||||||
|
// answer
|
||||||
|
CliType.Numeric (CliNumericType.Int32 10)
|
||||||
|
// i
|
||||||
|
CliType.Numeric (CliNumericType.Int32 5)
|
||||||
|
// End-loop condition
|
||||||
|
CliType.OfBool false
|
||||||
|
// Ret
|
||||||
|
CliType.Numeric (CliNumericType.Int32 10)
|
||||||
|
]
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "InstaQuit.cs"
|
FileName = "InstaQuit.cs"
|
||||||
@@ -75,6 +91,7 @@ module TestCases =
|
|||||||
ExecutionResult.Terminated (state, thread)
|
ExecutionResult.Terminated (state, thread)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LocalVariablesOfMain = []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -103,6 +120,12 @@ module TestCases =
|
|||||||
|
|
||||||
exitCode |> shouldEqual case.ExpectedReturnCode
|
exitCode |> shouldEqual case.ExpectedReturnCode
|
||||||
|
|
||||||
|
let finalVariables =
|
||||||
|
terminalState.ThreadState.[terminatingThread].MethodState.LocalVariables
|
||||||
|
|> Seq.toList
|
||||||
|
|
||||||
|
finalVariables |> shouldEqual case.LocalVariablesOfMain
|
||||||
|
|
||||||
with _ ->
|
with _ ->
|
||||||
for message in messages () do
|
for message in messages () do
|
||||||
System.Console.Error.WriteLine $"{message}"
|
System.Console.Error.WriteLine $"{message}"
|
||||||
|
@@ -30,4 +30,5 @@ type TestCase =
|
|||||||
FileName : string
|
FileName : string
|
||||||
ExpectedReturnCode : int
|
ExpectedReturnCode : int
|
||||||
NativeImpls : NativeImpls
|
NativeImpls : NativeImpls
|
||||||
|
LocalVariablesOfMain : CliType list
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user