Number fields drop trailing zeros: formatNumber still rounds to at most 3 decimals and then removes zeros at the end, so 100.000 reads 100 and 0.500 reads 0.5, everywhere (inspector, graph and shader nodes, duration and fps in the animation and tile tabs); a field's own decimals is now an upper limit, stored values are unchanged, -0 still shows as 0, and the graph's separate integer rule is gone (#172)
game-maker / gate (push) Successful in 1m55s
game-maker / suite (push) Successful in 6m50s

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5 committed 2026-09-19 14:29:00 +02:00
1 parent 47eea2f6e4
commit 4f546c0e08
6 files changed
+36 -17

No files matched your search

+24 -7
View File
@@ -31,11 +31,25 @@ describe('centreY', () => {
});
describe('formatNumber', () => {
it('shows three decimals by default', () => {
it('shows at most three decimals by default and drops trailing zeros', () => {
expect(NUMBER_DECIMALS).toBe(3);
expect(formatNumber(100)).toBe('100.000');
expect(formatNumber(0.5)).toBe('0.500');
expect(formatNumber(-12)).toBe('-12.000');
expect(formatNumber(100)).toBe('100');
expect(formatNumber(0.5)).toBe('0.5');
expect(formatNumber(-12)).toBe('-12');
expect(formatNumber(9.0909)).toBe('9.091');
expect(formatNumber(2.1)).toBe('2.1');
});
it('keeps the zeros of a whole number', () => {
expect(formatNumber(100, 0)).toBe('100');
expect(formatNumber(1000)).toBe('1000');
expect(formatNumber(-50, 2)).toBe('-50');
});
it('drops the whole fraction once rounding leaves only zeros', () => {
expect(formatNumber(2.0004)).toBe('2');
expect(formatNumber(1.9996)).toBe('2');
expect(formatNumber(0.10004)).toBe('0.1');
});
it('never hides a fractional value behind a whole number', () => {
@@ -50,13 +64,16 @@ describe('formatNumber', () => {
});
it('drops the minus sign from a value that displays as zero', () => {
expect(formatNumber(-0)).toBe('0.000');
expect(formatNumber(-0.0001)).toBe('0.000');
expect(formatNumber(-0)).toBe('0');
expect(formatNumber(-0.0001)).toBe('0');
expect(formatNumber(-0.04, 1)).toBe('0');
});
it('honours an explicit precision', () => {
it('honours an explicit precision as an upper bound', () => {
expect(formatNumber(1.25, 1)).toBe('1.3');
expect(formatNumber(1.25, 0)).toBe('1');
expect(formatNumber(1.5, 2)).toBe('1.5');
expect(formatNumber(12, 2)).toBe('12');
});
it('shows a field of integral values without a decimal point at all', () => {