tobogganSe connecter

starfleet-ui

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

15 lignes · 457 octetsBrut · Historique
1import { expect, test } from 'bun:test';
2import { damp } from './motion';
3
4test('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
11test('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});