Skip to content

Commit 65e5a98

Browse files
Improve MyClass tests
1 parent 937dcc2 commit 65e5a98

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

Tests/CSharp/NamespaceLevelTests.cs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -903,48 +903,45 @@ public partial interface Foo
903903
[Fact]
904904
public async Task MyClassVirtualCallMethodAsync()
905905
{
906-
await TestConversionVisualBasicToCSharpAsync(@"Public Class A
907-
Overridable Function F1() As Integer
906+
await TestConversionVisualBasicToCSharpAsync(@"Public MustInherit Class A
907+
Overridable Function F1(x As Integer) As Integer ' Comment ends up out of order, but attached to correct method
908908
Return 1
909909
End Function
910910
MustOverride Function F2() As Integer
911911
Public Sub TestMethod()
912-
Dim w = MyClass.f1()"/* Intentionally access with the wrong case which is valid VB */ + @"
913-
Dim x = Me.F1()
912+
Dim w = MyClass.f1(1)"/* Intentionally access with the wrong case which is valid VB */ + @"
913+
Dim x = Me.F1(2)
914914
Dim y = MyClass.F2()
915915
Dim z = Me.F2()
916916
End Sub
917917
End Class",
918918
@"
919-
public partial class A
919+
public abstract partial class A
920920
{
921-
public int MyClassF1()
921+
public int MyClassF1(int x)
922922
{
923923
return 1;
924924
}
925925
926-
public virtual int F1() => MyClassF1();
926+
public virtual int F1(int x) => MyClassF1(x); // Comment ends up out of order, but attached to correct method
927927
public abstract int F2();
928928
929929
public void TestMethod()
930930
{
931-
int w = MyClassF1();
932-
int x = F1();
931+
int w = MyClassF1(1);
932+
int x = F1(2);
933933
int y = F2();
934934
int z = F2();
935935
}
936936
}
937-
2 source compilation errors:
938-
BC31411: 'A' must be declared 'MustInherit' because it contains methods declared 'MustOverride'.
939-
BC30614: 'MustOverride' method 'Public MustOverride Function F2() As Integer' cannot be called with 'MyClass'.
940-
1 target compilation errors:
941-
CS0513: 'A.F2()' is abstract but it is contained in non-abstract class 'A'");
937+
1 source compilation errors:
938+
BC30614: 'MustOverride' method 'Public MustOverride Function F2() As Integer' cannot be called with 'MyClass'.");
942939
}
943940

944941
[Fact]
945942
public async Task MyClassVirtualCallPropertyAsync()
946943
{
947-
await TestConversionVisualBasicToCSharpAsync(@"Public Class A
944+
await TestConversionVisualBasicToCSharpAsync(@"Public MustInherit Class A
948945
Overridable Property P1() As Integer = 1
949946
MustOverride Property P2() As Integer
950947
Public Sub TestMethod()
@@ -955,7 +952,7 @@ Public Sub TestMethod()
955952
End Sub
956953
End Class",
957954
@"
958-
public partial class A
955+
public abstract partial class A
959956
{
960957
public int MyClassP1 { get; set; } = 1;
961958
@@ -982,12 +979,8 @@ public void TestMethod()
982979
int z = P2;
983980
}
984981
}
985-
2 source compilation errors:
986-
BC31411: 'A' must be declared 'MustInherit' because it contains methods declared 'MustOverride'.
987-
BC30614: 'MustOverride' method 'Public MustOverride Property P2 As Integer' cannot be called with 'MyClass'.
988-
2 target compilation errors:
989-
CS0513: 'A.P2.get' is abstract but it is contained in non-abstract class 'A'
990-
CS0513: 'A.P2.set' is abstract but it is contained in non-abstract class 'A'");
982+
1 source compilation errors:
983+
BC30614: 'MustOverride' method 'Public MustOverride Property P2 As Integer' cannot be called with 'MyClass'.");
991984
}
992985
}
993986
}

0 commit comments

Comments
 (0)