⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 latebindingtests2.vb

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 VB
📖 第 1 页 / 共 3 页
字号:
    End Sub    Private Class C13        Public Function F(ByVal o As Short, ByVal ParamArray arr() As Integer)            Return "Short,ParamArray arr() Integer"        End Function        Public Function F(ByVal o As Object, ByVal i1 As Integer, ByVal i2 As Integer)            Return "Object,Integer,Integer"        End Function    End Class    <Test()> _    Public Sub LateBind_Primitive_ParamArray1()        Dim o As Object = New C13        Assert.AreEqual("Short,ParamArray arr() Integer", o.F(b, i, i))        Assert.AreEqual("Object,Integer,Integer", o.F(l, i, i))    End Sub    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Primitive_ParamArray2()        Dim o As Object = New C13        o.F(b, l, l)    End Sub    Private Class C14        Public Function F(ByVal o1 As Object, ByVal o2 As Object)            Return "Object,Object"        End Function        Public Function F(ByVal o1 As String, ByVal o2 As String)            Return "String,String"        End Function    End Class    <Test()> _    Public Sub LateBind_Primitive_Object2()        Dim o As Object = New C14        Assert.AreEqual("Object,Object", o.F(i, c))    End Sub    Private Class C15        Public Function F(ByVal a1 As A, ByVal ParamArray b1() As BB)            Return "A,ParamArray arr() BB"        End Function        Public Function F(ByVal b1 As BB, ByVal b2 As A, ByVal b3 As BB)            Return "BB,A,BB"        End Function    End Class    <Test()> _    Public Sub LateBind_Complex_ParamArray20()        Dim o As Object = New C15        Assert.AreEqual("BB,A,BB", o.F(ccB, ccA, ccB))    End Sub    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Complex_ParamArray30()        Dim o As Object = New C15        o.F(ccB, ccB, ccB)    End Sub    Private Class C16        Public Function F(ByVal b1 As BB, ByVal s As Short)            Return "BB,Short"        End Function        Public Function F(ByVal a As A, ByVal l As Long)            Return "A,Long"        End Function    End Class    <Test()> _   Public Sub LateBind_Complex_Primitive10()        Dim o As Object = New C16        Assert.AreEqual("A,Long", o.F(ccB, i))    End Sub    Private Class C17        Public Function F(ByVal a As A, ByVal s As Integer)            Return "A,Integer"        End Function        Public Function F(ByVal b1 As BB, ByVal l As Long)            Return "BB,Long"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Complex_Primitive11()        Dim o As Object = New C17        o.F(ccB, i)    End Sub    Private Class C18        Public Function F(ByVal i As Integer, ByVal s As String)            Return "Integer,Short"        End Function        Public Function F(ByVal s As String, ByVal l As Long)            Return "String,Long"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _  Public Sub LateBind_Primitive_String10()        Dim o As Object = New C18        Assert.AreEqual("A,Long", o.F(i, i))    End Sub    Private Class C19        Public Function F(ByVal a As A)            Return "A"        End Function        Public Function F(ByVal b As BB)            Return "BB"        End Function    End Class    <Test()> _    Public Sub LateBind_Complex_20()        Dim o As Object = New C19        Assert.AreEqual("BB", o.F(ccc))    End Sub    Private Class C20        Public Function F(ByVal a As A, ByVal l As Long)            Return "A,Long"        End Function        Public Function F(ByVal b1 As BB, ByVal i As Integer)            Return "BB,Integer"        End Function    End Class    <Test()> _    Public Sub LateBind_Complex_21()        Dim o As Object = New C20        Assert.AreEqual("BB,Integer", o.F(ccc, i))        Assert.AreEqual("BB,Integer", o.F(ccc, s))        Assert.AreEqual("A,Long", o.F(ccc, l))    End Sub    Private Class C21        Public Function F(ByVal s As Short, ByVal i As Integer)            Return "Short,Integer"        End Function        Public Function F(ByVal s As Short, ByVal i As Long)            Return "Short,Long"        End Function        Public Function F(ByVal s As Short, ByVal i As Integer, ByVal s2 As Short)            Return "Short,Integer,Short"        End Function        Public Function F(ByVal s As Short, ByVal i As Long, ByVal i1 As Integer)            Return "Short,Long,Integer"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Primitive_50()        Dim o As Object = New C21        Assert.AreEqual("BB,Integer", o.F(i, i))    End Sub    Private Class C22        Public Function F(ByVal i1 As Long, ByVal i2 As Integer) As String            Return "Long,Integer"        End Function        Public Function F(ByVal i1 As Long, ByVal i2 As Long) As String            Return "Long,Long"        End Function        Public Function F(ByVal i1 As Integer, ByVal i2 As Long) As String            Return "Integer,Long"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _   Public Sub LateBind_Primitive_51()        Dim o As Object = New C22        Assert.AreEqual("Long,Integer", o.F(i, i))    End Sub    Private Class C41        Public Function F(ByVal a As A) As String            Return "A"        End Function        Public Function F(ByVal a As A, ByVal ParamArray args() As A) As String            Return "A,ParamArray A()"        End Function    End Class    <Test()> _    Public Sub LateBind_Complex_ParamArray41()        Dim o As Object = New C41        Assert.AreEqual("A", o.F(ccA))        Assert.AreEqual("A", o.F(ccB))        Assert.AreEqual("A", o.F(ccc))    End Sub    Private Class C42        Public Function F(ByVal a As Object) As String            Return "Object"        End Function        Public Function F(ByVal a As A, ByVal ParamArray args() As A) As String            Return "A,ParamArray A()"        End Function    End Class    <Test()> _    Public Sub LateBind_Complex_ParamArray42()        Dim o As Object = New C42        Assert.AreEqual("A,ParamArray A()", o.F(ccA))        Assert.AreEqual("A,ParamArray A()", o.F(ccB))        Assert.AreEqual("A,ParamArray A()", o.F(ccc))        Assert.AreEqual("A,ParamArray A()", o.F(ccA, ccA))        Assert.AreEqual("A,ParamArray A()", o.F(ccc, ccB))    End Sub    Private Class C43        Public Function F(ByVal a As A, ByVal b As Object) As String            Return "A,Object"        End Function        Public Function F(ByVal a As Object, ByVal ParamArray args() As A) As String            Return "Object,ParamArray A()"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Complex_ParamArray43()        Dim o As Object = New C43        o.F(ccA, ccA)    End Sub    Private Class C600        Public Function F(ByVal ParamArray args() As Integer) As Integer            Return args.Length        End Function    End Class    <Test()> _    Public Sub LateBind_Complex_ParamArray600()        Dim o As Object = New C600        Dim a As Integer() = {1, 2, 3}        Dim x As Integer = 10        Assert.AreEqual(3, o.F(a))        Assert.AreEqual(4, o.F(x, x, x, x))    End Sub    Private Class C601        Public Function F(ByVal ParamArray args() As Long) As Integer            Return args.Length        End Function        Public Function F(ByVal ParamArray args() As Integer) As Integer            Return args.Length        End Function    End Class    <Test()> _    Public Sub LateBind_Complex_ParamArray601()        Dim o As Object = New C601        Dim a As Long() = {1, 2, 3}        Assert.AreEqual(3, o.F(a))        Assert.AreEqual(4, o.F(10, 20, 30, 40))    End Sub    Private Class C602        Function F(ByVal ParamArray a As Object()) As Integer            Return 0        End Function        Function F()            Return 1        End Function        Function F(ByVal a As Object, ByVal b As Object)            Return 2        End Function        Function F(ByVal a As Object, ByVal b As Object, ByVal ParamArray c As Object())            Return 3        End Function    End Class    <Test()> _    Public Sub LateBind_Complex_ParamArray602()        Dim o As Object = New C602        Assert.AreEqual(1, o.F())        Assert.AreEqual(0, o.F(1))        Assert.AreEqual(2, o.F(1, 2))    End Sub#If NET_2_0 Then    'TargetJvmNotWorking - Ambiguous matching in method resolution    <Category("TargetJvmNotWorking")> _    <Test()> _    Public Sub LateBind_Complex_ParamArray603()#Else    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _    Public Sub LateBind_Complex_ParamArray603()#End If        Dim o As Object = New C602        o.F(1, 2, 3)    End Sub    Class C604        Function F(ByVal ParamArray args() As Integer) As Integer            Dim a As Integer            a = args.Length            Return a        End Function    End Class    <Test()> _    Public Sub LateBind_Complex_ParamArray604()        Dim o As Object = New C604        Dim a As Integer() = {1, 2, 3}        Dim b As Integer = 1        Assert.AreEqual(3, o.F(a))        Assert.AreEqual(4, o.F(10, b, 30, 40))        Assert.AreEqual(0, o.F())    End Sub#Region "MS BUG"    ' MS passes this test and fails in next that differs just by method ordering inside class    ' we should fail in both cases    Private Class C23        Public Function F(ByVal i1 As Long, ByVal i2 As Integer, ByVal i3 As Long) As String            Return "Long,Integer,Long"        End Function        Public Function F(ByVal i1 As Integer, ByVal i2 As Long, ByVal i3 As Integer) As String            Return "Integer,Long,Integer"        End Function        Public Function F(ByVal i1 As Long, ByVal i2 As Integer, ByVal i3 As Integer) As String            Return "Long,Integer,Integer"        End Function    End Class    'THIS TEST SHOULD FAIL IN MS    <Test(), ExpectedException(GetType(AmbiguousMatchException)), Category("NotDotNet")> _   Public Sub LateBind_MS_Bug_NoFail()        Dim o As Object = New C23        Assert.AreEqual("Long,Integer,Integer", o.F(i, i, i))    End Sub    Private Class C24        Public Function F(ByVal i1 As Integer, ByVal i2 As Long, ByVal i3 As Integer) As String            Return "Integer,Long,Integer"        End Function        Public Function F(ByVal i1 As Long, ByVal i2 As Integer, ByVal i3 As Integer) As String            Return "Long,Integer,Integer"        End Function        Public Function F(ByVal i1 As Long, ByVal i2 As Integer, ByVal i3 As Long) As String            Return "Long,Integer,Long"        End Function    End Class    <Test(), ExpectedException(GetType(AmbiguousMatchException))> _   Public Sub LateBind_MS_Bug_Fail()        Dim o As Object = New C24        o.F(i, i, i)    End Sub#End Region    Class C400        Public Function fun(ByVal i As Integer, ByVal ParamArray a() As Long)            Return 10        End Function        Public Function fun(ByVal ParamArray a() As Long)            Return 20        End Function    End Class    <Test()> _    Public Sub LateBind_TypeMembersM()        Dim o As Object = New C400        Dim a As Integer = o.fun(1, 2, 3)        Assert.AreEqual(10, a)    End Sub    Class C401        Public Function fun(ByVal i1 As Long, ByVal i2 As Long, ByVal i3 As Long)            Return 10        End Function        Public Function fun(ByVal i1 As Integer, ByVal ParamArray a() As Long)            Return 20        End Function    End Class    <Test()> _    Public Sub LateBind_TypeMembersM_1()        Dim o As Object = New C401        Dim a As Integer = o.fun(1, 2, 3)        Assert.AreEqual(20, a)    End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -