Skip to content

Commit

Permalink
Clean up trait swizzling in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zoddicus committed Oct 23, 2023
1 parent 13b3ec7 commit b1c58bf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/unittests/floating_point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ import { UnitTest } from './unit_test.js';

export const g = makeTestGroup(UnitTest);

/**
* For ULP purposes, abstract float behaves like f32, so need to swizzle it in
* for expectations.
*/
const kFPTraitForULP = {
abstract: 'f32',
f32: 'f32',
f16: 'f16',
} as const;

/** Bounds indicating an expectation of unbounded error */
const kUnboundedBounds: IntervalBounds = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY];

Expand Down Expand Up @@ -2082,8 +2092,7 @@ g.test('ulpInterval')
.combine('trait', ['abstract', 'f32', 'f16'] as const)
.beginSubcases()
.expandWithParams<ULPCase>(p => {
// For ULP purposes, abstract float behaves like f32, so swizzling it in.
const trait = p.trait === 'abstract' ? 'f32' : p.trait;
const trait = kFPTraitForULP[p.trait];
const constants = FP[trait].constants();
const ULPValue = kULPErrorValue[trait];
const plusOneULP = kPlusOneULPFunctions[trait];
Expand Down

0 comments on commit b1c58bf

Please sign in to comment.