mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -05:00
fix(std/testing): formatting bigint (#4626)
This commit is contained in:
parent
faa0f520cf
commit
788a6abfd3
2 changed files with 15 additions and 0 deletions
|
@ -115,6 +115,10 @@ function printSymbol(val: symbol): string {
|
||||||
return symbolToString.call(val).replace(SYMBOL_REGEXP, "Symbol($1)");
|
return symbolToString.call(val).replace(SYMBOL_REGEXP, "Symbol($1)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function printBigInt(val: bigint): string {
|
||||||
|
return val.toString() + "n";
|
||||||
|
}
|
||||||
|
|
||||||
function printError(val: Error): string {
|
function printError(val: Error): string {
|
||||||
return "[" + errorToString.call(val) + "]";
|
return "[" + errorToString.call(val) + "]";
|
||||||
}
|
}
|
||||||
|
@ -155,6 +159,9 @@ function printBasicValue(
|
||||||
if (typeOf === "symbol") {
|
if (typeOf === "symbol") {
|
||||||
return printSymbol(val);
|
return printSymbol(val);
|
||||||
}
|
}
|
||||||
|
if (typeOf === "bigint") {
|
||||||
|
return printBigInt(val);
|
||||||
|
}
|
||||||
|
|
||||||
const toStringed = toString.call(val);
|
const toStringed = toString.call(val);
|
||||||
|
|
||||||
|
|
|
@ -580,6 +580,14 @@ test({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test({
|
||||||
|
name: "prints a bigint",
|
||||||
|
fn(): void {
|
||||||
|
const val = 12345n;
|
||||||
|
assertEquals(format(val), "12345n");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
test({
|
test({
|
||||||
name: "prints undefined",
|
name: "prints undefined",
|
||||||
fn(): void {
|
fn(): void {
|
||||||
|
|
Loading…
Reference in a new issue