Skip to content

Commit

Permalink
improve timestamp comparison idioms
Browse files Browse the repository at this point in the history
  • Loading branch information
warner committed May 2, 2023
1 parent 61b0fde commit d6989a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions packages/solo/test/test-home.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ test.serial('home.localTimerService makeNotifier', async t => {

// Tests gets an actual localTimerService, which returns actual times. We
// can't verify the actual time, so we compare to make sure it's increasing.
t.truthy(TimeMath.absValue(update2.value) > TimeMath.absValue(update1.value));
t.truthy(TimeMath.compareAbs(update2.value, update1.value) > 0);
});

function makeHandler() {
Expand Down Expand Up @@ -178,9 +178,7 @@ test.serial('home.localTimerService makeRepeater', async t => {
await E(notifier).getUpdateSince();

t.truthy(handler.getCalls() >= 1);
t.truthy(
TimeMath.absValue(handler.getArgs()[0]) > TimeMath.absValue(timestamp),
);
t.truthy(TimeMath.compareAbs(handler.getArgs()[0], timestamp) > 0);
});

// =========================================
Expand Down
4 changes: 2 additions & 2 deletions packages/zoe/test/unitTests/test-manualTimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test('manualTimer makeNotifier', async t => {
const update2 = await p2;
// @ts-expect-error updateCount could be undefined
t.truthy(BigInt(update2.updateCount) > BigInt(update1.updateCount));
t.truthy(TimeMath.absValue(update2.value) > TimeMath.absValue(update1.value));
t.truthy(TimeMath.compareAbs(update2.value, update1.value) > 0);
});

const makeHandler = () => {
Expand Down Expand Up @@ -58,7 +58,7 @@ test('manualTimer makeRepeater', async t => {
await manualTimer.tick();

t.is(1n, handler.getCalls());
t.is(TimeMath.compareAbs(handler.getArgs()[0], timestamp), 1);
t.truthy(TimeMath.compareAbs(handler.getArgs()[0], timestamp) > 0);
});

const stallLots = async () => {
Expand Down

0 comments on commit d6989a4

Please sign in to comment.