-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0d8f69
commit d9637b3
Showing
10 changed files
with
751 additions
and
918 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { Decimal128 } from "../src/decimal128.mjs"; | ||
import { expectDecimal128 } from "./util.js"; | ||
|
||
|
||
describe("truncate", () => { | ||
test("basic example", () => { | ||
expect(Decimal128.truncate("123.45678")).toStrictEqual("123"); | ||
}); | ||
test("truncate negative", () => { | ||
expect(Decimal128.truncate("-42.99")).toStrictEqual("-42"); | ||
}); | ||
test("between zero and one", () => { | ||
expect(Decimal128.truncate("0.00765")).toStrictEqual("0"); | ||
}); | ||
let data = { | ||
"123.45678": "123", | ||
"-42.99": "-42", | ||
"0.00765": "0" | ||
}; | ||
for (let [key, value] of Object.entries(data)) { | ||
test(key, () => { | ||
expectDecimal128(new Decimal128(key).truncate(), value) | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Decimal128 } from "../src/decimal128.mjs"; | ||
|
||
export function expectDecimal128(a, b) | ||
{ | ||
let lhs = a instanceof Decimal128 ? a.toString() : a; | ||
let rhs = b instanceof Decimal128 ? b.toString() : b; | ||
expect(lhs).toStrictEqual(rhs); | ||
} |