Files
Agent-Workbench/docs/model-protocols-f-release-evidence/408-add.test.mjs
T
2026-11-01 00:19:52 +08:00

10 lines
564 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { add } from '../src/add.mjs';
test('positive additions return the actual sum', () => assert.equal(add(2, 3), 5));
test('negative additions preserve the signed result', () => assert.equal(add(-3, 1), -2));
test('fractional additions retain numeric precision', () => assert.ok(Math.abs(add(0.1, 0.2) - 0.3) < 1e-12));
test('nonfinite and nonnumeric inputs are rejected', () => {
for (const pair of [[Infinity, 1], ['2', 3], [NaN, 1]]) assert.throws(() => add(...pair), TypeError);
});