Skip to content

Commit

Permalink
restore tests lost in merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Timur Kelman authored and Timur Kelman committed Jul 23, 2024
1 parent 257aae9 commit abf9fdb
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions Tests/CSharp/MemberTests/MemberTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4092,4 +4092,86 @@ public void M([Optional, DefaultParameterValue(""a"")] string a, [Optional, Defa
}
}");
}

[Fact]
public async Task TestRefConstArgumentAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class RefConstArgument
Const a As String = ""a""
Sub S()
Const b As String = ""b""
MO(a)
MS(b)
End Sub
Sub MO(ByRef s As Object) : End Sub
Sub MS(ByRef s As String) : End Sub
End Class", @"
internal partial class RefConstArgument
{
private const string a = ""a"";
public void S()
{
const string b = ""b"";
object args = a;
MO(ref args);
string args1 = b;
MS(ref args1);
}
public void MO(ref object s)
{
}
public void MS(ref string s)
{
}
}");
}

[Fact]
public async Task TestMissingByRefArgumentWithNoExplicitDefaultValueAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Imports System.Runtime.InteropServices
Class MissingByRefArgumentWithNoExplicitDefaultValue
Sub S()
ByRefNoDefault()
OptionalByRefNoDefault()
OptionalByRefWithDefault()
End Sub
Private Sub ByRefNoDefault(ByRef str1 As String) : End Sub
Private Sub OptionalByRefNoDefault(<[Optional]> ByRef str2 As String) : End Sub
Private Sub OptionalByRefWithDefault(<[Optional], DefaultParameterValue(""a"")> ByRef str3 As String) : End Sub
End Class", @"using System.Runtime.InteropServices;
internal partial class MissingByRefArgumentWithNoExplicitDefaultValue
{
public void S()
{
ByRefNoDefault();
string argstr2 = default;
OptionalByRefNoDefault(str2: ref argstr2);
string argstr3 = ""a"";
OptionalByRefWithDefault(str3: ref argstr3);
}
private void ByRefNoDefault(ref string str1)
{
}
private void OptionalByRefNoDefault([Optional] ref string str2)
{
}
private void OptionalByRefWithDefault([Optional][DefaultParameterValue(""a"")] ref string str3)
{
}
}
3 source compilation errors:
BC30455: Argument not specified for parameter 'str1' of 'Private Sub ByRefNoDefault(ByRef str1 As String)'.
BC30455: Argument not specified for parameter 'str2' of 'Private Sub OptionalByRefNoDefault(ByRef str2 As String)'.
BC30455: Argument not specified for parameter 'str3' of 'Private Sub OptionalByRefWithDefault(ByRef str3 As String)'.
1 target compilation errors:
CS7036: There is no argument given that corresponds to the required formal parameter 'str1' of 'MissingByRefArgumentWithNoExplicitDefaultValue.ByRefNoDefault(ref string)'
");
}
}

0 comments on commit abf9fdb

Please sign in to comment.