Skip to content

Commit

Permalink
Add unit tests for new polyfill types
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Nov 22, 2023
1 parent 897ed98 commit 90c196a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/PolySharp.Tests/LanguageFeatures.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
Expand Down Expand Up @@ -102,6 +104,10 @@ public static void InitializeModule()
{
}

public void RefReadonlyMethod(ref readonly int x)
{
}

[Experimental("PS0001")]
public void ExperimentalMethod()
{
Expand Down Expand Up @@ -151,6 +157,30 @@ public static ReadOnlySpan<int> TestRange(ReadOnlySpan<int> numbers)
}
}

[CollectionBuilder(typeof(CollectionClass), nameof(Create))]
internal class CollectionClass : IEnumerable<int>
{
public CollectionClass Test()
{
return [1, 2, 3];
}

public static CollectionClass Create(ReadOnlySpan<int> values)
{
return new();
}

IEnumerator<int> IEnumerable<int>.GetEnumerator()
{
return null!;
}

IEnumerator IEnumerable.GetEnumerator()
{
return null!;
}
}

internal class AnotherTestClass
{
// CallerArgumentExpressionAttribute
Expand Down
15 changes: 15 additions & 0 deletions tests/PolySharp.Tests/RuntimeSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,19 @@ public void MakeUpSomeNewType()
public void ReferenceSomeAssemblyFile()
{
}
}

internal class AccessorApis
{
#pragma warning disable IDE0044
private int field;
#pragma warning restore IDE0044

[StackTraceHidden]
public void HideMe()
{
}

[UnsafeAccessor(UnsafeAccessorKind.Field, Name = nameof(field))]
public static extern ref int GetField(RandomApis obj);
}

0 comments on commit 90c196a

Please sign in to comment.