Willi Ballenthin 0fd6190b46
fix: From Base operation produces wrong results for fractional inputs (#2285)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-20 08:48:49 +01:00

67 lines
1.3 KiB
JavaScript

/**
* From Base operation tests.
*
* @author Willi Ballenthin
* @copyright Crown Copyright 2026
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "From Base: binary integer",
input: "1010",
expectedOutput: "10",
recipeConfig: [
{
op: "From Base",
args: [2],
},
],
},
{
name: "From Base: binary fraction",
input: "10.1",
expectedOutput: "2.5",
recipeConfig: [
{
op: "From Base",
args: [2],
},
],
},
{
name: "From Base: hex fraction",
input: "a.8",
expectedOutput: "10.5",
recipeConfig: [
{
op: "From Base",
args: [16],
},
],
},
{
name: "From Base: octal integer",
input: "77",
expectedOutput: "63",
recipeConfig: [
{
op: "From Base",
args: [8],
},
],
},
{
name: "From Base: octal fraction",
input: "7.4",
expectedOutput: "7.5",
recipeConfig: [
{
op: "From Base",
args: [8],
},
],
},
]);