Validate that 0 and -0 coerce to "0"

This commit is contained in:
Josh Gross
2023-03-16 12:30:15 -04:00
parent 9c8c407478
commit 65d89c6775
2 changed files with 14 additions and 1 deletions
+13
View File
@@ -0,0 +1,13 @@
import {NumberData} from "./number";
describe("number", () => {
it("coerces to string", () => {
expect(new NumberData(-0).coerceString()).toEqual("0");
expect(new NumberData(0).coerceString()).toEqual("0");
expect(new NumberData(1).coerceString()).toEqual("1");
expect(new NumberData(1.2).coerceString()).toEqual("1.2");
// Round to 15 digits precision
expect(new NumberData(1.2345678901234567).coerceString()).toEqual("1.234567890123457");
});
});
+1 -1
View File
@@ -8,7 +8,7 @@ export class NumberData implements ExpressionDataInterface {
public primitive = true;
coerceString(): string {
if (Object.is(this.value, -0)) {
if (this.value === 0) {
return "0";
}