aether-shards/test/utils/SimplexNoise.test.js

32 lines
977 B
JavaScript
Raw Permalink Normal View History

import { expect } from "@esm-bundle/chai";
import { SimplexNoise } from "../../src/utils/SimplexNoise.js";
describe("Utility: Custom Simplex Noise", () => {
it("CoA 1: Should be deterministic with the same seed", () => {
const gen1 = new SimplexNoise(12345);
const val1 = gen1.noise2D(0.5, 0.5);
const gen2 = new SimplexNoise(12345);
const val2 = gen2.noise2D(0.5, 0.5);
expect(val1).to.equal(val2);
});
it("CoA 2: Should produce different values for different seeds", () => {
const gen1 = new SimplexNoise(12345);
const val1 = gen1.noise2D(0.5, 0.5);
const gen2 = new SimplexNoise(99999);
const val2 = gen2.noise2D(0.5, 0.5);
expect(val1).to.not.equal(val2);
});
it("CoA 3: Should output values within expected range (approx -1 to 1)", () => {
const gen = new SimplexNoise(123);
const val = gen.noise2D(10, 10);
expect(val).to.be.within(-1.2, 1.2); // Simplex can technically slightly exceed 1.0
});
});