Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Dec 23, 2024
1 parent bc0fabe commit ca34032
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions test/math/Spline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ describe('Spline', () => {
.addPoint(-0.44, -0.12)
.addPoint(-0.18, -0.12)

expect(spline.compute(-1.6)).toEqual(0.044)
expect(spline.compute(-0.7)).toEqual(-0.2222)
expect(spline.compute(-1.6)).toBeCloseTo(0.044, DELTA)
expect(spline.compute(-0.7)).toBeCloseTo(-0.2222, DELTA)
expect(spline.compute(-0.5)).toBeCloseTo(-0.21653879, DELTA)
expect(spline.compute(-0.2)).toEqual(-0.12)
expect(spline.compute(-0.2)).toBeCloseTo(-0.12, DELTA)
})

it('derivatives', () => {
Expand All @@ -25,7 +25,7 @@ describe('Spline', () => {
.addPoint(0.6, 0.4, 0.0)

expect(spline.compute(-0.1)).toBeCloseTo(-0.0022000019, DELTA)
expect(spline.compute(0)).toEqual(0.0178)
expect(spline.compute(0)).toBeCloseTo(0.0178, DELTA)
expect(spline.compute(0.31)).toBeCloseTo(0.24358201, DELTA)
expect(spline.compute(0.4)).toBeCloseTo(0.69171876, DELTA)
})
Expand Down
14 changes: 8 additions & 6 deletions test/worldgen/DensityFunction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { DensityFunction as DF, NoiseGeneratorSettings, NoiseRouter, WorldgenReg
import { RandomState } from '../../src/worldgen/RandomState.js'

describe('DensityFunction', () => {
const DELTA = 1e-7

const ContextA = DF.context(1, 2, 3)
const ContextB = DF.context(2, 3, 4)
const ContextC = DF.context(12, -30, 1)
Expand Down Expand Up @@ -151,12 +153,12 @@ describe('DensityFunction', () => {
.addPoint(5, 0.2)
.addPoint(20, 0.7)
const fn2 = wrap(new DF.Spline(spline))
expect(fn2.compute(DF.context(0, 0, 0))).toEqual(1)
expect(fn2.compute(DF.context(0, 3.2, 0))).toEqual(0.4363904)
expect(fn2.compute(DF.context(0, 5, 0))).toEqual(0.2)
expect(fn2.compute(DF.context(0, 11, 0))).toEqual(0.376)
expect(fn2.compute(DF.context(0, 20, 0))).toEqual(0.7)
expect(fn2.compute(DF.context(0, 25, 0))).toEqual(0.7)
expect(fn2.compute(DF.context(0, 0, 0))).toBeCloseTo(1, DELTA)
expect(fn2.compute(DF.context(0, 3.2, 0))).toBeCloseTo(0.4363904, DELTA)
expect(fn2.compute(DF.context(0, 5, 0))).toBeCloseTo(0.2, DELTA)
expect(fn2.compute(DF.context(0, 11, 0))).toBeCloseTo(0.376, DELTA)
expect(fn2.compute(DF.context(0, 20, 0))).toBeCloseTo(0.7, DELTA)
expect(fn2.compute(DF.context(0, 25, 0))).toBeCloseTo(0.7, DELTA)
})

it('YClampedGradient', () => {
Expand Down

0 comments on commit ca34032

Please sign in to comment.