Skip to content

test(conversions): cover ouncesToKilograms failure behavior (R50-T038) - #76

Open
nishadaniket174 wants to merge 1 commit into
S-AI-Projects:masterfrom
nishadaniket174:student/e26b07f0789/R50-T038
Open

nishadaniket174 wants to merge 1 commit into
S-AI-Projects:masterfrom
nishadaniket174:student/e26b07f0789/R50-T038

Conversation

@nishadaniket174

@nishadaniket174 nishadaniket174 commented Nov 16, 2026 •

Copy link
Copy Markdown

Summary

This PR adds focused failure-path and recovery tests for ouncesToKilograms in Conversions/OuncesToKilograms.js.

The function uses direct arithmetic and returns NaN for missing or non-numeric inputs rather than throwing an exception. The tests document and verify this behavior while ensuring valid conversions continue to work.

Changes Made

  • Improved the function's JSDoc to describe its inputs, return value, and failure behavior.
  • Documented the function's total-function contract and its NaN result for missing or non-numeric inputs.
  • Expanded the test suite with explicit fixtures and independently calculated expected values:
    • Smallest valid input: 0 ounces → 0 kilograms.
    • Ordinary input: 60 ounces → 1.700988 kilograms.
    • Failure/absent-result inputs: NaN, undefined, and a non-numeric string → NaN.
  • Added checks to verify caller-owned state is not mutated.
  • Verified that a valid conversion still succeeds immediately after a failure-path call.
  • Added task-specific verification evidence in work/R50-T038/.
  • Added work/R50-T038/check.py to run focused checks, verify deliberate mutation detection, and execute the repository test suite.

Testing and Verification

The following checks passed:

  • Focused tests: npx vitest run Conversions/test/OuncesToKilogram.test.js (5 tests passed).
  • Deliberate mutation check: confirmed that changing the conversion factor causes the tests to fail.
  • Full repository test suite: npm test (347 test files and 12,023 tests passed).
  • Code style: npm run check-style passed.

Run the complete task-specific verification with:

python3 work/R50-T038/check.py

Related Issue

Closes #38

Task: R50-T038
Target file: Conversions/OuncesToKilograms.js
Function: ouncesToKilograms

All task-specific evidence is kept under work/R50-T038/.

@nishadaniket174
nishadaniket174 force-pushed the student/e26b07f0789/R50-T038 branch from 92c1804 to fcfb662 Compare November 21, 2026 14:27
@nishadaniket174 nishadaniket174 changed the title Student/e26b07f0789/r50 t038 test(conversions): cover ouncesToKilograms failure behavior (R50-T038) Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ANIKET KUMAR NISHAD — R50-T038: Cover the failure behavior of ouncesToKilograms (OuncesToKilograms.js) [Conversions/OuncesToKilograms.js]

1 participant