Aetheria/tests/Aetheria.Shared.Tests/GravityShaderTests.cs
Meta Vens 13c7a08707 Gravity.cginc is generated: GravityShader.Source() is its one author, a test pins the committed file to it byte for byte
The mirror test compared a normalised reading of two spellings and was beaten twice (a statement before the return, gravityHeight's sum). GravityShader writes the whole file (potential, zero-strength guard, reference term, height sum) from GravityField's constant (TailOffset); GravityShaderTests fails on any difference. GravityShaderMirrorTests deleted. GravityFieldParityVerify opens Main Menu.unity: no ZoneRenderer there, its Fog Surface Displacement camera is the menu's own brush presentation (layers 9 and 10) by spec.

Builds not yet verified on this commit; verified at the final merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 08:44:11 +02:00

23 lines
1.2 KiB
C#

using System;
using System.IO;
using Xunit;
// potential-owns-gravity (aetheria-gravity, cut grid-lowering): Assets/Shaders/Gravity.cginc is the output of
// GravityShader.Source(), which reads GravityField's constants and writes the one lowering of the potential, the
// zero-strength guard, each well's reference and gravityHeight's sum. The committed file must equal it, character for
// character (line ends aside): any added statement, respelling, flipped sign, swapped argument or macro fails here.
// To change the shader, change GravityShader and run once with AETHERIA_REGENERATE_GRAVITY_CGINC=1.
public sealed class GravityShaderTests
{
[Fact]
public void TheCommittedShaderIsTheGeneratedOne()
{
var path = Path.Combine(RunStartTests.FindRepoRoot(), GravityShader.Path);
if (Environment.GetEnvironmentVariable("AETHERIA_REGENERATE_GRAVITY_CGINC") == "1")
File.WriteAllText(path, GravityShader.Source());
var generated = GravityShader.Source();
// The law was generated, not an empty template agreeing with an empty file.
Assert.Contains("log(r / R) + 0.5", generated);
Assert.Equal(generated, File.ReadAllText(path).Replace("\r\n", "\n"));
}
}