Skip to content

Commit

Permalink
Adding tests for #1159 related to inferred generic types with cast in…
Browse files Browse the repository at this point in the history
…teger values
  • Loading branch information
gaschd authored and GrahamTheCoder committed Jan 5, 2025
1 parent 67185b0 commit f4cc5c9
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Tests/CSharp/TypeCastTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,47 @@ private static T GenericFunctionWithCastThatExistsInCsharp<T>() where T : TestGe
}

[Fact]
public async Task TestInferringImplicitGenericTypesAsync()
{
await TestConversionVisualBasicToCSharpAsync(@"
Imports System
Imports System.Linq
Public Class TestClass
Public Sub GenerateFromConstants
Dim floatArr = Enumerable.Repeat(1.0F, 5).ToArray()
Dim doubleArr = Enumerable.Repeat(2.0, 5).ToArray()
Dim decimalArr = Enumerable.Repeat(3.0D, 5).ToArray()
Dim boolArr = Enumerable.Repeat(true, 5).ToArray()
Dim intArr = Enumerable.Repeat(1, 5).ToArray()
Dim uintArr = Enumerable.Repeat(1ui, 5).ToArray()
Dim longArr = Enumerable.Repeat(1l, 5).ToArray()
Dim ulongArr = Enumerable.Repeat(1ul, 5).ToArray()
Dim charArr = Enumerable.Repeat(""a""c, 5).ToArray()
Dim strArr = Enumerable.Repeat(""a"", 5).ToArray()
Dim objArr = Enumerable.Repeat(new object(), 5).ToArray()
End Sub
Public Sub GenerateFromCasts
Dim floatArr = Enumerable.Repeat(CSng(1), 5).ToArray()
Dim doubleArr = Enumerable.Repeat(CDbl(2), 5).ToArray()
Dim decimalArr = Enumerable.Repeat(CDec(3), 5).ToArray()
Dim boolArr = Enumerable.Repeat(CBool(1), 5).ToArray()
Dim intArr = Enumerable.Repeat(CInt(1.0), 5).ToArray()
Dim uintArr = Enumerable.Repeat(CUInt(1.0), 5).ToArray()
Dim longArr = Enumerable.Repeat(CLng(1.0), 5).ToArray()
Dim ulongArr = Enumerable.Repeat(CULng(1.0), 5).ToArray()
Dim charArr = Enumerable.Repeat(CChar(""a""), 5).ToArray()
Dim strArr = Enumerable.Repeat(CStr(""a""c), 5).ToArray()
Dim objArr1 = Enumerable.Repeat(CObj(""a""), 5).ToArray()
Dim objArr2 = Enumerable.Repeat(CType(""a"", object), 5).ToArray()
End Sub
End Class
", @"");
}


[Fact]
public async Task TestCTypeStringToEnumAsync()
{
await TestConversionVisualBasicToCSharpAsync(
Expand Down

0 comments on commit f4cc5c9

Please sign in to comment.