From 656026e092191d70a5acb77b91418333b563da2b Mon Sep 17 00:00:00 2001 From: Marla Schulz Date: Mon, 2 Oct 2023 16:06:13 -0600 Subject: [PATCH] Add RenderProgram unit test file, see: https://github.com/phetsims/alpenglow/issues/2 --- js/alpenglow-tests.js | 1 + js/render-program/RenderProgram.ts | 4 ++++ js/render-program/RenderProgramTests.ts | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 js/render-program/RenderProgramTests.ts diff --git a/js/alpenglow-tests.js b/js/alpenglow-tests.js index c94b7e3e..1f7868fe 100644 --- a/js/alpenglow-tests.js +++ b/js/alpenglow-tests.js @@ -15,6 +15,7 @@ import './clip/PolygonClippingTests.js'; import './parallel/ParallelTests.js'; import './webgpu/SnippetTests.js'; import './webgpu/ExampleTests.js'; +import './render-program/RenderProgramTests.js'; // Since our tests are loaded asynchronously, we must direct QUnit to begin the tests qunitStart(); \ No newline at end of file diff --git a/js/render-program/RenderProgram.ts b/js/render-program/RenderProgram.ts index 34fbe479..c522b20f 100644 --- a/js/render-program/RenderProgram.ts +++ b/js/render-program/RenderProgram.ts @@ -116,6 +116,10 @@ export default abstract class RenderProgram { } } + // REVIEW: Documentation here would be helpful. I see that this is getting overridden, but when are we getting + // a RenderProgram and when are we getting null? What does the difference of that return value tell us? + // Is this what is actually doing the simplification based on the type of RenderProgram we are? + // Is null essentially saying that this RenderProgram cannot be simplified? protected getSimplified( children: RenderProgram[] ): RenderProgram | null { return null; } diff --git a/js/render-program/RenderProgramTests.ts b/js/render-program/RenderProgramTests.ts new file mode 100644 index 00000000..3076ec39 --- /dev/null +++ b/js/render-program/RenderProgramTests.ts @@ -0,0 +1,19 @@ +// Copyright 2023, University of Colorado Boulder + +/** + * Testing for RenderProgram vs a simplified RenderProgram + * + * @author Marla Schulz (PhET Interactive Simulations) + * + */ + +import { RenderColor } from '../imports.js'; +import Vector4 from '../../../dot/js/Vector4.js'; + +QUnit.module( 'RenderProgram' ); + +QUnit.test( 'color', assert => { + const renderColorProgram = new RenderColor( new Vector4( 245, 40, 145, 0.8 ) ); + + assert.equal( renderColorProgram.getName(), 'RenderColor' ); +} ); \ No newline at end of file