Skip to content

Commit

Permalink
Minor fix to throw error when it should be thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
javagl committed Aug 23, 2024
1 parent 49d9b29 commit 9ecdc36
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions specs/metadata/metadata/ArrayValuesSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,4 +632,23 @@ describe("metadata/ArrayValues", function () {
const actual = ArrayValues.anyDeepGreaterThan(a, b);
expect(actual).toEqual(expected);
});

//==========================================================================
// Error cases for deepMin/deepMax

it("throws error for non-numeric types in deepMin", function () {
expect(function () {
const a = [5, 2];
const b = [3, "NOT_A_NUMBER"];
ArrayValues.deepMin(a, b);
}).toThrowError();
});

it("throws error for non-numeric types in deepMax", function () {
expect(function () {
const a = [5, 2];
const b = [3, "NOT_A_NUMBER"];
ArrayValues.deepMax(a, b);
}).toThrowError();
});
});
4 changes: 2 additions & 2 deletions src/metadata/metadata/ArrayValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ArrayValues {
// Implementation note:
// The methods here are supposed to be called in a context
// where no (compile-time) type information is available.
// Thes are offered to operate on "any" types, but usually
// These are offered to operate on "any" types, but usually
// delegate to "...Internal" methods with more specific
// type signatures. This does not imply any compile-time
// checks, but these specific signatures might be exposed
Expand All @@ -63,7 +63,7 @@ export class ArrayValues {
if (typeof value === "bigint") {
return true;
}
return true;
return false;
}

/**
Expand Down

0 comments on commit 9ecdc36

Please sign in to comment.