Skip to content

Commit

Permalink
chore: move plain number tests from node-tests to unit-tests, rem…
Browse files Browse the repository at this point in the history
…ove redundant tests (see #3011)
  • Loading branch information
josdejong committed Sep 20, 2023
1 parent 0127001 commit 0e9c737
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 57 deletions.
3 changes: 1 addition & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ Evan Miller <[email protected]>
Timur <[email protected]>
Ari Markowitz <[email protected]>
Jay Wang <[email protected]>
David Contreras <[email protected]
Jaeu Jeong <[email protected]>
cyavictor88 <[email protected]>
David Contreras <[email protected]>
Expand All @@ -230,9 +229,9 @@ Michael Greminger <[email protected]>
Kiku <[email protected]>
MaybePixem <[email protected]>
Aly Khaled <[email protected]>
Praise Nnamonu <[email protected]>
BuildTools <[email protected]>
Anik Patel <[email protected]>
Vrushaket Chaudhari <[email protected]>
Praise Nnamonu <[email protected]>

# Generated by tools/update-authors.js
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# History

# unpublished changes since 11.11.0

- Fix #2989: use one-based indices in `print` in the parser (#3009).
Thanks @dvd101x.
- Fix #2936: `mod` sometimes giving wrong results due to internal round-off
errors (#3011). Thanks @praisennamonu1.


# 2023-09-05, 11.11.0

- Implement function `corr` to calculate the correlation between two matrices
Expand Down
55 changes: 0 additions & 55 deletions test/node-tests/plain/number/arithmetic.test.js

This file was deleted.

27 changes: 27 additions & 0 deletions test/unit-tests/plain/number/arithmetic.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import assert from 'assert'
import approx from '../../../../tools/approx.js'
import { modNumber } from '../../../../src/plain/number/arithmetic.js'

describe('mod', function () {
it('should calculate the modulus of two numbers', function () {
assert.strictEqual(modNumber(1, 1), 0)
assert.strictEqual(modNumber(0, 1), 0)
assert.strictEqual(modNumber(1, 0), 1)
assert.strictEqual(modNumber(0, 0), 0)
assert.strictEqual(modNumber(7, 0), 7)

approx.equal(modNumber(7, 2), 1)
approx.equal(modNumber(9, 3), 0)
approx.equal(modNumber(10, 4), 2)
approx.equal(modNumber(-10, 4), 2)
approx.equal(modNumber(8.2, 3), 2.2)
approx.equal(modNumber(4, 1.5), 1)
approx.equal(modNumber(0, 3), 0)
approx.equal(modNumber(-10, 4), 2)
approx.equal(modNumber(-5, 3), 1)
})

it('should calculate mod for negative divisor', function () {
assert.strictEqual(modNumber(10, -4), -2)
})
})

0 comments on commit 0e9c737

Please sign in to comment.