mirror of
https://github.com/Smaug123/WoofWare.PawPrint
synced 2025-10-05 22:28:38 +00:00
Remove local variable checks in tests (#98)
This commit is contained in:
@@ -30,5 +30,4 @@ type TestCase =
|
|||||||
FileName : string
|
FileName : string
|
||||||
ExpectedReturnCode : int
|
ExpectedReturnCode : int
|
||||||
NativeImpls : NativeImpls
|
NativeImpls : NativeImpls
|
||||||
LocalVariablesOfMain : CliType list option
|
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@ module TestImpureCases =
|
|||||||
FileName = "WriteLine.cs"
|
FileName = "WriteLine.cs"
|
||||||
ExpectedReturnCode = 1
|
ExpectedReturnCode = 1
|
||||||
NativeImpls = NativeImpls.PassThru ()
|
NativeImpls = NativeImpls.PassThru ()
|
||||||
LocalVariablesOfMain = [] |> Some
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -44,7 +43,6 @@ module TestImpureCases =
|
|||||||
ExecutionResult.Terminated (state, thread)
|
ExecutionResult.Terminated (state, thread)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LocalVariablesOfMain = [] |> Some
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -71,15 +69,6 @@ module TestImpureCases =
|
|||||||
| ret -> failwith $"expected program to return an int, but it returned %O{ret}"
|
| ret -> failwith $"expected program to return an int, but it returned %O{ret}"
|
||||||
|
|
||||||
exitCode |> shouldEqual case.ExpectedReturnCode
|
exitCode |> shouldEqual case.ExpectedReturnCode
|
||||||
|
|
||||||
let finalVariables =
|
|
||||||
terminalState.ThreadState.[terminatingThread].MethodState.LocalVariables
|
|
||||||
|> Seq.toList
|
|
||||||
|
|
||||||
match case.LocalVariablesOfMain with
|
|
||||||
| None -> ()
|
|
||||||
| Some expected -> finalVariables |> shouldEqual expected
|
|
||||||
|
|
||||||
with _ ->
|
with _ ->
|
||||||
for message in messages () do
|
for message in messages () do
|
||||||
System.Console.Error.WriteLine $"{message}"
|
System.Console.Error.WriteLine $"{message}"
|
||||||
|
@@ -17,73 +17,41 @@ module TestPureCases =
|
|||||||
FileName = "CrossAssemblyTypes.cs"
|
FileName = "CrossAssemblyTypes.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "InitializeArray.cs"
|
FileName = "InitializeArray.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "GenericEdgeCases.cs"
|
FileName = "GenericEdgeCases.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "Threads.cs"
|
FileName = "Threads.cs"
|
||||||
ExpectedReturnCode = 3
|
ExpectedReturnCode = 3
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = [] |> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "ComplexTryCatch.cs"
|
FileName = "ComplexTryCatch.cs"
|
||||||
ExpectedReturnCode = 14
|
ExpectedReturnCode = 14
|
||||||
NativeImpls = NativeImpls.PassThru ()
|
NativeImpls = NativeImpls.PassThru ()
|
||||||
LocalVariablesOfMain =
|
|
||||||
[
|
|
||||||
4
|
|
||||||
20
|
|
||||||
115
|
|
||||||
12
|
|
||||||
1
|
|
||||||
10
|
|
||||||
2
|
|
||||||
112
|
|
||||||
12
|
|
||||||
1111
|
|
||||||
42
|
|
||||||
99
|
|
||||||
25
|
|
||||||
50
|
|
||||||
123
|
|
||||||
20
|
|
||||||
35
|
|
||||||
5
|
|
||||||
11111
|
|
||||||
100001
|
|
||||||
]
|
|
||||||
|> List.map (fun i -> CliType.Numeric (CliNumericType.Int32 i))
|
|
||||||
|> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "ResizeArray.cs"
|
FileName = "ResizeArray.cs"
|
||||||
ExpectedReturnCode = 109
|
ExpectedReturnCode = 109
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = [ CliType.Numeric (CliNumericType.Int32 10) ] |> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "Sizeof.cs"
|
FileName = "Sizeof.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "LdtokenField.cs"
|
FileName = "LdtokenField.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -93,61 +61,36 @@ module TestPureCases =
|
|||||||
FileName = "NoOp.cs"
|
FileName = "NoOp.cs"
|
||||||
ExpectedReturnCode = 1
|
ExpectedReturnCode = 1
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = [ CliType.Numeric (CliNumericType.Int32 1) ] |> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "TestShl.cs"
|
FileName = "TestShl.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "TestShr.cs"
|
FileName = "TestShr.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "StaticVariables.cs"
|
FileName = "StaticVariables.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "Ldind.cs"
|
FileName = "Ldind.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain =
|
|
||||||
[
|
|
||||||
// `failures`
|
|
||||||
CliType.Numeric (CliNumericType.Int32 0)
|
|
||||||
// Return value
|
|
||||||
CliType.Numeric (CliNumericType.Int32 0)
|
|
||||||
]
|
|
||||||
|> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "CustomDelegate.cs"
|
FileName = "CustomDelegate.cs"
|
||||||
ExpectedReturnCode = 8
|
ExpectedReturnCode = 8
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain =
|
|
||||||
[
|
|
||||||
// filter
|
|
||||||
CliType.ObjectRef (Some (ManagedHeapAddress 2))
|
|
||||||
// result
|
|
||||||
CliType.ofBool true
|
|
||||||
// result, cloned for "if(result)" check
|
|
||||||
CliType.ofBool true
|
|
||||||
// ret
|
|
||||||
CliType.Numeric (CliNumericType.Int32 8)
|
|
||||||
]
|
|
||||||
|> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "ArgumentOrdering.cs"
|
FileName = "ArgumentOrdering.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "BasicLock.cs"
|
FileName = "BasicLock.cs"
|
||||||
@@ -158,92 +101,46 @@ module TestPureCases =
|
|||||||
{ mock with
|
{ mock with
|
||||||
System_Threading_Monitor = System_Threading_Monitor.passThru
|
System_Threading_Monitor = System_Threading_Monitor.passThru
|
||||||
}
|
}
|
||||||
LocalVariablesOfMain =
|
|
||||||
[
|
|
||||||
// Four variables:
|
|
||||||
// locker
|
|
||||||
CliType.ObjectRef (Some (ManagedHeapAddress 2))
|
|
||||||
// a copy of locker, taken so that the contents of the implicit `finally` have a stable copy
|
|
||||||
CliType.ObjectRef (Some (ManagedHeapAddress 2))
|
|
||||||
// out param of `ReliableEnter`
|
|
||||||
CliType.ofBool true
|
|
||||||
// return value
|
|
||||||
CliType.Numeric (CliNumericType.Int32 1)
|
|
||||||
]
|
|
||||||
|> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
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)
|
|
||||||
]
|
|
||||||
|> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "ExceptionWithNoOpFinally.cs"
|
FileName = "ExceptionWithNoOpFinally.cs"
|
||||||
ExpectedReturnCode = 3
|
ExpectedReturnCode = 3
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain =
|
|
||||||
[
|
|
||||||
// Variable 1 is `x`, variable 2 is the implicit return value
|
|
||||||
4
|
|
||||||
3
|
|
||||||
]
|
|
||||||
|> List.map (fun i -> CliType.Numeric (CliNumericType.Int32 i))
|
|
||||||
|> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "ExceptionWithNoOpCatch.cs"
|
FileName = "ExceptionWithNoOpCatch.cs"
|
||||||
ExpectedReturnCode = 10
|
ExpectedReturnCode = 10
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = [ CliType.Numeric (CliNumericType.Int32 10) ] |> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "Floats.cs"
|
FileName = "Floats.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "TryCatchWithThrowInBody.cs"
|
FileName = "TryCatchWithThrowInBody.cs"
|
||||||
ExpectedReturnCode = 4
|
ExpectedReturnCode = 4
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain =
|
|
||||||
[
|
|
||||||
// one variable is x, one variable is the return value which also happens to have the same value
|
|
||||||
4
|
|
||||||
4
|
|
||||||
]
|
|
||||||
|> List.map (fun i -> CliType.Numeric (CliNumericType.Int32 i))
|
|
||||||
|> Some
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "Ldelema.cs"
|
FileName = "Ldelema.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "TypeConcretization.cs"
|
FileName = "TypeConcretization.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FileName = "TestOr.cs"
|
FileName = "TestOr.cs"
|
||||||
ExpectedReturnCode = 0
|
ExpectedReturnCode = 0
|
||||||
NativeImpls = MockEnv.make ()
|
NativeImpls = MockEnv.make ()
|
||||||
LocalVariablesOfMain = None
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -274,14 +171,6 @@ module TestPureCases =
|
|||||||
exitCode |> shouldEqual realResult.ExitCode
|
exitCode |> shouldEqual realResult.ExitCode
|
||||||
|
|
||||||
exitCode |> shouldEqual case.ExpectedReturnCode
|
exitCode |> shouldEqual case.ExpectedReturnCode
|
||||||
|
|
||||||
let finalVariables =
|
|
||||||
terminalState.ThreadState.[terminatingThread].MethodState.LocalVariables
|
|
||||||
|> Seq.toList
|
|
||||||
|
|
||||||
match case.LocalVariablesOfMain with
|
|
||||||
| None -> ()
|
|
||||||
| Some expected -> finalVariables |> shouldEqual expected
|
|
||||||
with _ ->
|
with _ ->
|
||||||
for message in messages () do
|
for message in messages () do
|
||||||
System.Console.Error.WriteLine $"{message}"
|
System.Console.Error.WriteLine $"{message}"
|
||||||
|
Reference in New Issue
Block a user