Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 53636fc

Browse files
committed
Add slide examples
1 parent 7d2c54c commit 53636fc

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

tests/equals.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,9 @@ describe("examples from the General Decimal Arithmetic specification", () => {
340340
});
341341
});
342342
});
343+
344+
describe("examples from a presentation at TC39 plenary", () => {
345+
test("NaN with a payload", () => {
346+
expect(new Decimal128("NaN").equals(new Decimal128("NaN123"))).toStrictEqual(true);
347+
});
348+
});

tests/lessthan.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ describe("lessThan", () => {
5353
new Decimal128("0.037").lessThan(new Decimal128("0.037037037037"))
5454
).toStrictEqual(true);
5555
});
56-
describe("examples from a presentation", () => {
56+
describe("examples from a presenation", () => {
5757
let a = new Decimal128("1.00");
5858
let b = new Decimal128("1.0000");
5959
let c = new Decimal128("1.0001");
6060
let d = new Decimal128("0.9999");
6161
test("use mathematical equality by default", () => {
62-
expect(a.lessThan(b)).toStrictEqual(false);
62+
expect(b.lessThan(a)).toStrictEqual(false);
6363
});
6464
test("take trailing zeroes into account", () => {
65-
expect(a.lessThan(b, { total: true })).toStrictEqual(false);
65+
expect(b.lessThan(a, { total: true })).toStrictEqual(true);
6666
});
6767
test("mathematically distinct", () => {
6868
expect(a.lessThan(c)).toStrictEqual(true);

tests/round.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -459,3 +459,17 @@ describe("floor", function () {
459459
).toStrictEqual("-Infinity");
460460
});
461461
});
462+
463+
describe ("examples for TC39 plenary slides", () => {
464+
let a = new Decimal128("1.456");
465+
test("round to 2 decimal places, rounding mode is ceiling", () => {
466+
expect(a.round(2, "ceil").toString()).toStrictEqual("1.46");
467+
});
468+
test("round to 1 decimal place, rounding mode unspecified", () => {
469+
expect(a.round(1).toString()).toStrictEqual("1.4");
470+
expect(a.round(1, "halfEven").toString()).toStrictEqual("1.4");
471+
});
472+
test("round to 0 decimal places, rounding mode is floor", () => {
473+
expect(a.round(0, "floor").toString()).toStrictEqual("1");
474+
});
475+
});

0 commit comments

Comments
 (0)