Skip to content

Commit

Permalink
fix(std/testing): formatting bigint (#4626)
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed Apr 4, 2020
1 parent faa0f52 commit 788a6ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions std/testing/format.ts
Expand Up @@ -115,6 +115,10 @@ function printSymbol(val: symbol): string {
return symbolToString.call(val).replace(SYMBOL_REGEXP, "Symbol($1)");
}

function printBigInt(val: bigint): string {
return val.toString() + "n";
}

function printError(val: Error): string {
return "[" + errorToString.call(val) + "]";
}
Expand Down Expand Up @@ -155,6 +159,9 @@ function printBasicValue(
if (typeOf === "symbol") {
return printSymbol(val);
}
if (typeOf === "bigint") {
return printBigInt(val);
}

const toStringed = toString.call(val);

Expand Down
8 changes: 8 additions & 0 deletions std/testing/format_test.ts
Expand Up @@ -580,6 +580,14 @@ test({
},
});

test({
name: "prints a bigint",
fn(): void {
const val = 12345n;
assertEquals(format(val), "12345n");
},
});

test({
name: "prints undefined",
fn(): void {
Expand Down

0 comments on commit 788a6ab

Please sign in to comment.