diff --git a/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs b/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs index 680aa668..d59807d4 100644 --- a/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs +++ b/tests/ComputeSharp.Tests.SourceGenerators/DiagnosticsTests.cs @@ -1639,6 +1639,57 @@ public class DiagnosticsTests VerifyGeneratedDiagnostics(source, "CMPS0046"); } + [TestMethod] + public void MissingRequiresDoublePrecisionSupportAttribute() + { + const string source = """ + using ComputeSharp; + + namespace MyNamespace; + + [ThreadGroupSize(DefaultThreadGroupSizes.X)] + [GeneratedComputeShaderDescriptor] + internal readonly partial struct MyShader : IComputeShader + { + private readonly ReadWriteBuffer results; + private readonly float time; + + public void Execute() + { + results[ThreadIds.X] = (float)(Hlsl.Abs(time * 2.0)); + } + } + """; + + VerifyGeneratedDiagnostics(source, "CMPS0064"); + } + + [TestMethod] + public void UnnecessaryRequiresDoublePrecisionSupportAttribute() + { + const string source = """ + using ComputeSharp; + + namespace MyNamespace; + + [ThreadGroupSize(DefaultThreadGroupSizes.X)] + [RequiresDoublePrecisionSupport] + [GeneratedComputeShaderDescriptor] + internal readonly partial struct MyShader : IComputeShader + { + private readonly ReadWriteBuffer results; + private readonly float time; + + public void Execute() + { + results[ThreadIds.X] = (float)(time * 2.0f); + } + } + """; + + VerifyGeneratedDiagnostics(source, "CMPS0065"); + } + /// /// Verifies the output of a source generator. ///