GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — toBeOdd fails on negative odd numbers (false pass with .not) · Issue #191 · stackbuilders/assertive-ts

toBeOdd fails on negative odd numbers (false pass with .not) #191

New issue
Copy link
New issue
Copy link
Open
#209
Open
toBeOdd fails on negative odd numbers (false pass with .not)#191
#209
Copy link
Assignees
KeylaMunnoz
Labels
bugSomething isn't working

Description

@fefi95
fefi95
opened on Oct 15, 2026
Issue body actions

Priority: P1

Context

JS % keeps the sign of the left operand, so -13 % 2 === -1. The check % 2 === 1 in packages/core/src/lib/NumberAssertion.ts:237 therefore treats every negative odd number as not odd:

  • expect(-13).toBeOdd() throws, even though it's the method's own JSDoc example (:220).
  • expect(-13).not.toBeOdd() passes. That's a false pass: users' tests go green on wrong code.

The tests only use positive values, which is why 98% coverage never caught this. Reproduced against the built dist.

Do

  • Use assertWhen: Math.abs(this.actual % 2) === 1.
  • Check how toBeEven handles -0, NaN, Infinity and non-integers (1.5). Decide the behaviour and document it.
  • Add tests for negative numbers and non-integers to packages/core/test/lib/NumberAssertion.test.ts (the .toBeOdd block is at line 162).
  • Commit as fix(core): toBeOdd fails on negative odd numbers.

Done when

The new tests fail on main and pass on the branch.

Source: code audit of stackbuilders/assertive-ts at e81a614 (2026-10-13) plus open Vanta/Dependabot findings.

Activity

  1. fefi95
    added
    bugSomething isn't working
    on Oct 15, 2026
  2. KeylaMunnoz
    self-assigned this
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @KeylaMunnoz
    KeylaMunnoz

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.