starfleet-ui
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#6 · main · 2 min 01 s
0Étoiles
0Forks
0Issues
| 1 | import { expect, test } from 'bun:test'; |
| 2 | import { damp } from './motion'; |
| 3 | |
| 4 | test('damp is frame-rate independent', () => { |
| 5 | // two 1/120 s steps cover the same ground as one 1/60 s step |
| 6 | const k60 = damp(8, 1 / 60); |
| 7 | const k120 = damp(8, 1 / 120); |
| 8 | expect(1 - (1 - k120) ** 2).toBeCloseTo(k60, 10); |
| 9 | }); |
| 10 | |
| 11 | test('damp stays in [0, 1)', () => { |
| 12 | expect(damp(8, 0)).toBe(0); |
| 13 | expect(damp(8, 0.5)).toBeLessThan(1); |
| 14 | expect(damp(8, 0.5)).toBeGreaterThan(0.98); |
| 15 | }); |