Skip to content

Commit

Permalink
Update error message from 'floating point' to 'decimal'.
Browse files Browse the repository at this point in the history
  • Loading branch information
elle-j committed Jun 12, 2024
1 parent d67b258 commit f9e1b99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions integration-tests/tests/src/tests/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ describe("Counter", () => {
this.realm.write(() => {
counter.increment(1.1);
});
}).to.throw("Expected 'by' to be an integer, got a floating point number");
}).to.throw("Expected 'by' to be an integer, got a decimal number");
expect(counter.value).equals(10);

expect(() => {
Expand Down Expand Up @@ -525,7 +525,7 @@ describe("Counter", () => {
this.realm.write(() => {
counter.decrement(1.1);
});
}).to.throw("Expected 'by' to be an integer, got a floating point number");
}).to.throw("Expected 'by' to be an integer, got a decimal number");
expect(counter.value).equals(10);

expect(() => {
Expand Down Expand Up @@ -573,7 +573,7 @@ describe("Counter", () => {
this.realm.write(() => {
counter.set(1.1);
});
}).to.throw("Expected 'value' to be an integer, got a floating point number");
}).to.throw("Expected 'value' to be an integer, got a decimal number");
expect(counter.value).equals(10);

expect(() => {
Expand Down
7 changes: 3 additions & 4 deletions packages/realm/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ export class TypeAssertionError extends AssertionError {
} else if (typeof value === "function") {
return `a function or class named ${value.name}`;
} else if (typeof value === "number") {
let type = "a number";
if (Number.isNaN(value)) {
type = "NaN";
return "NaN";
} else if (!Number.isInteger(value)) {
type = "a floating point number";
return "a decimal number";
}
return type;
return "a number";
} else {
return "a " + typeof value;
}
Expand Down

0 comments on commit f9e1b99

Please sign in to comment.