Implement the lock keyword (#35)

This commit is contained in:
Patrick Stevens
2025-06-02 00:00:52 +01:00
committed by GitHub
parent 3b1349a076
commit efd94e5cea
7 changed files with 65 additions and 62 deletions

View File

@@ -50,17 +50,6 @@ module TestCases =
]
|> List.map (fun i -> CliType.Numeric (CliNumericType.Int32 i))
}
{
FileName = "BasicLock.cs"
ExpectedReturnCode = 10
NativeImpls =
let mock = MockEnv.make ()
{ mock with
System_Threading_Monitor = System_Threading_Monitor.passThru
}
LocalVariablesOfMain = []
}
{
FileName = "WriteLine.cs"
ExpectedReturnCode = 1
@@ -77,6 +66,28 @@ module TestCases =
NativeImpls = MockEnv.make ()
LocalVariablesOfMain = [ CliType.Numeric (CliNumericType.Int32 1) ]
}
{
FileName = "BasicLock.cs"
ExpectedReturnCode = 1
NativeImpls =
let mock = MockEnv.make ()
{ mock with
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)
]
}
{
FileName = "TriangleNumber.cs"
ExpectedReturnCode = 10