Skip to content

Commit

Permalink
Fix formatting of non-standard vals
Browse files Browse the repository at this point in the history
  • Loading branch information
frostburn committed May 4, 2024
1 parent 1140790 commit 58c3060
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/monzo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2480,11 +2480,13 @@ export class TimeMonzo {
}
if (pe.length && basis.length) {
let index = 0;
while (!pe[0].n) {
while (pe.length && !pe[0].n) {
pe.shift();
index++;
}
basis.push({numerator: PRIMES[index], denominator: null});
if (pe.length) {
basis.push({numerator: PRIMES[index], denominator: null});
}
if (pe.length > 1) {
// Two dots looks better IMO...
basis.push('');
Expand Down
5 changes: 5 additions & 0 deletions src/parser/__tests__/expression.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2335,4 +2335,9 @@ describe('Poor grammar / Fun with "<"', () => {
expect(sqrt2.domain).toBe('linear');
expect(sqrt2.valueOf()).toBeCloseTo(Math.SQRT2);
});

it('has string representation for the geometric inverse of the Hertz', () => {
const whatIsThis = evaluate('str(%logarithmic(1z))');
expect(whatIsThis).toBe('withEquave(<1]@Hz, 1 Hz)');
});
});

0 comments on commit 58c3060

Please sign in to comment.