ソースを参照

Added more tests Statements

svn path=/trunk/mcs/; revision=33224
Sachin Kumar 21 年 前
コミット
fa9d4df017

+ 10 - 0
mcs/btests/ChangeLog

@@ -1,3 +1,13 @@
+2004-09-02 Sachin Kumar <[email protected]>
+	* ControlFlowA.vb;
+	* ControlFlowC1.vb:
+	* SyncLock1.vb:
+	* SyncLockA.vb:
+	* SyncLockC1.vb:
+	* SyncLockC2.vb:
+	* SyncLockC3.vb:
+	* Test.Sources: added more tests
+
 2004-09-01 Sachin Kumar <[email protected]>
 	* Array1.vb:
 	* Array2.vb:

+ 36 - 0
mcs/btests/ControlFlowA.vb

@@ -0,0 +1,36 @@
+Imports System
+
+Module ControlFlowA
+    Dim result As Integer
+
+    Sub F1()
+	Dim i As Integer
+        For i = 0 To 4
+            Stop
+            result += i
+            If i = 3 Then
+                Exit Sub
+            End If 
+        Next i
+        result = 4
+    End Sub
+
+    Sub main()
+
+        F1()
+        If result <> 6 Then
+            Throw New Exception("#CFA1 - Exit Statement failed")
+        End If
+        Console.WriteLine(result)
+        Try
+            End
+            Console.WriteLine("After Stop Statement")
+        Catch e As Exception
+            Console.WriteLine(e.Message)
+        Finally
+            Throw New Exception("#CFA2 - End Statement failed")
+        End Try
+
+    End Sub
+
+End Module

+ 20 - 0
mcs/btests/ControlFlowC1.vb

@@ -0,0 +1,20 @@
+REM LineNo: 14
+REM ExpectedError: BC30240
+REM ErrorMessage: 'Exit' must be followed by 'Sub', 'Function', 'Property', 
+REM               'Do', 'For', 'While', 'Select', or 'Try'.
+
+Imports System
+
+Module ControlFlowC1
+
+    Sub main()
+        Dim i As Integer = 0
+        If i = 0 Then
+            i = 2
+            Exit
+            i = 4
+        End If
+
+    End Sub
+
+End Module

+ 23 - 0
mcs/btests/SyncLock1.vb

@@ -0,0 +1,23 @@
+' Unhandled Exception: System.ArgumentException: 'SyncLock' operand cannot 
+' be of type 'Boolean' because 'Boolean' is not a reference type.
+
+Imports System
+
+Module SyncLock1
+    Class C
+        Private Shared count = 0
+
+        Sub IncrementCount()
+            SyncLock count = 0
+                count += 1
+                Console.WriteLine(count)
+            End SyncLock
+        End Sub
+    End Class
+
+    Sub Main()
+        Dim c As New C()
+        c.IncrementCount()
+    End Sub
+
+End Module

+ 35 - 0
mcs/btests/SyncLockA.vb

@@ -0,0 +1,35 @@
+REM LineNo: 14
+REM ExpectedError: BC30752
+REM ErrorMessage: 'On Error' statements are not valid within 'SyncLock' statements.
+
+Imports System
+
+Module SyncLockA
+
+    Class C
+
+        Private Shared count = 0
+
+        Sub IncrementCount()
+            Console.WriteLine("Before acquiring lock, Count is {0}", count)
+            SyncLock GetType(C)
+                System.Threading.Thread.Sleep(1000)
+                count += 1
+                Console.WriteLine(count)
+            End SyncLock
+            Console.WriteLine("After releasing lock, Count is {0}", count)
+        End Sub
+
+    End Class
+
+    Sub Main()
+        Dim c As New C()
+
+        Dim td1 As New System.Threading.Thread( _
+                    AddressOf c.IncrementCount)
+        td1.Start()
+
+        c.IncrementCount()
+    End Sub
+
+End Module

+ 31 - 0
mcs/btests/SyncLockC1.vb

@@ -0,0 +1,31 @@
+REM LineNo: 15
+REM ExpectedError: BC30755
+REM ErrorMessage: 'Goto label' is not valid because 'label' is inside a 'SyncLock' 
+REM               statement that does not contain this statement.
+
+Imports System
+
+Module SyncLockC1
+    Class C
+
+        Private Shared count = 0
+
+        Sub IncrementCount()
+            Console.WriteLine(count)
+            GoTo label
+            SyncLock GetType(C)
+label:
+                count += 1
+                Console.WriteLine(count)
+            End SyncLock
+        End Sub
+
+
+    End Class
+
+    Sub Main()
+        Dim c As New C()
+        c.IncrementCount()
+    End Sub
+
+End Module

+ 30 - 0
mcs/btests/SyncLockC2.vb

@@ -0,0 +1,30 @@
+REM LineNo: 14
+REM ExpectedError: BC30752
+REM ErrorMessage: 'On Error' statements are not valid within 'SyncLock' statements.
+
+Imports System
+
+Module SyncLockC2
+
+    Class C
+
+        Sub f4()
+            Dim i As Integer = 0
+            SyncLock GetType(C)
+                On Error GoTo ErrorHandler
+                i = 5 / i
+            End SyncLock
+            Exit Sub
+ErrorHandler:
+            i = 5
+            Resume   ' Execution resumes with the statement that caused the error
+        End Sub
+
+    End Class
+
+    Sub Main()
+        Dim c As New C()
+        c.f4()
+    End Sub
+
+End Module

+ 25 - 0
mcs/btests/SyncLockC3.vb

@@ -0,0 +1,25 @@
+REM LineNo: 13
+REM ExpectedError: BC30582
+REM ErrorMessage: 'SyncLock' operand cannot be of type 'Boolean' because 'Boolean' is not a reference type.
+
+Imports System
+
+Module SyncLockC3
+    Class C
+        Private Shared count = 0
+
+        Sub IncrementCount()
+            Dim i As Integer
+            SyncLock i = 0
+                count += 1
+                Console.WriteLine(count)
+            End SyncLock
+        End Sub
+    End Class
+
+    Sub Main()
+        Dim c As New C()
+        c.IncrementCount()
+    End Sub
+
+End Module

+ 10 - 3
mcs/btests/Test.Sources

@@ -221,7 +221,9 @@ LoopStatementsA \
 ExceptionHandlingA \
 ExceptionHandlingB \
 ExceptionHandlingC \
-InvocationStatementA
+InvocationStatementA \
+ControlFlowA \
+SyncLockA
 
 # All negetive test cases which should
 # fail during compilation goes here
@@ -486,7 +488,11 @@ ExceptionHandlingC13 \
 ExceptionHandlingC14 \
 ExceptionHandlingC15 \
 ExceptionHandlingC16 \
-ExceptionHandlingC17
+ExceptionHandlingC17 \
+ControlFlowC1 \
+SyncLockC1 \
+SyncLockC2 \
+SyncLockC3
 
 # All negetive test cases which should fail at
 # runtime goes here
@@ -523,6 +529,7 @@ ConditionalStatements1 \
 LoopStatements1 \
 Array1 \
 Array2 \
-Array3
+Array3 \
+SyncLock1