Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

/* Any copyright is dedicated to the Public Domain.
"use strict";
const {
toFixed,
} = require("resource://devtools/shared/inspector/font-utils.js");
add_task(async () => {
info("Check whether toFixed rounds properly");
/** @type {[[number, number], number][]} */
const tests = [
[[1.009, 3], 1.009],
[[0.9999, 3], 1],
[[0.29, 2], 0.29],
[[1.91, 1], 1.9],
];
for (const [[input, decimals], expected] of tests) {
equal(
toFixed(input, decimals),
expected,
"toFixed doesn't return expected value"
);
}
});