diff --git a/tests/ComputeSharp.Tests/StaticFunctionsTests.cs b/tests/ComputeSharp.Tests/StaticFunctionsTests.cs index f1bea042..df10a105 100644 --- a/tests/ComputeSharp.Tests/StaticFunctionsTests.cs +++ b/tests/ComputeSharp.Tests/StaticFunctionsTests.cs @@ -149,5 +149,31 @@ namespace ComputeSharp.Tests Assert.IsTrue(MathF.Abs(result[0] - 9) < 0.0001f); } + + public static Func SquareFunc { get; } = x => x * x; + + [TestMethod] + public void StaticFunctionInSameClass() + { + using ReadWriteBuffer buffer = Gpu.Default.AllocateReadWriteBuffer(1); + + Gpu.Default.For(1, id => buffer[0] = SquareFunc(3)); + + float[] result = buffer.GetData(); + + Assert.IsTrue(MathF.Abs(result[0] - 9) < 0.0001f); + } + + [TestMethod] + public void StaticFunctionInExternalClass() + { + using ReadWriteBuffer buffer = Gpu.Default.AllocateReadWriteBuffer(1); + + Gpu.Default.For(1, id => buffer[0] = StaticPropertiesContainer.SquareFunc(3)); + + float[] result = buffer.GetData(); + + Assert.IsTrue(MathF.Abs(result[0] - 9) < 0.0001f); + } } } diff --git a/tests/ComputeSharp.Tests/StaticPropertiesTests.cs b/tests/ComputeSharp.Tests/StaticPropertiesTests.cs index 6290abf0..0d6d19d1 100644 --- a/tests/ComputeSharp.Tests/StaticPropertiesTests.cs +++ b/tests/ComputeSharp.Tests/StaticPropertiesTests.cs @@ -33,6 +33,11 @@ namespace ComputeSharp.Tests /// A property /// public static ReadOnlyBuffer StaticBuffer { get; set; } = Gpu.Default.AllocateReadOnlyBuffer(new[] { 3.14f, 7.77f }); + + /// + /// A property + /// + public static Func SquareFunc { get; } = x => x * x; } [TestClass]