summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-12-23 05:04:38 -0600
committerGitHub <noreply@github.com>2020-12-23 12:04:38 +0100
commitb1c3dab2089bb4327627c2152a1148b299f1a930 (patch)
tree0369cb3b3b003a7ea9b954e3048cd9016a4b6d2a /tests
parent417c2509c42367edc4130a8761fae80d529d8574 (diff)
downloadNim-b1c3dab2089bb4327627c2152a1148b299f1a930.tar.gz
add `euclDiv` and `euclMod` to `math` (#16414)
* add `euclDiv` and `euclMod` to `math`
* use abs
* Update lib/pure/math.nim

Co-authored-by: Clyybber <darkmine956@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/tmath.nim28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/stdlib/tmath.nim b/tests/stdlib/tmath.nim
index 18e42cbdc..43d19f9e0 100644
--- a/tests/stdlib/tmath.nim
+++ b/tests/stdlib/tmath.nim
@@ -270,6 +270,34 @@ block:
       doAssert floorMod(8.0, -3.0) ==~ -1.0
       doAssert floorMod(-8.5, 3.0) ==~ 0.5
 
+    block: # euclDiv/euclMod
+      doAssert euclDiv(8, 3) == 2
+      doAssert euclMod(8, 3) == 2
+
+      doAssert euclDiv(8, -3) == -2
+      doAssert euclMod(8, -3) == 2
+
+      doAssert euclDiv(-8, 3) == -3
+      doAssert euclMod(-8, 3) == 1
+
+      doAssert euclDiv(-8, -3) == 3
+      doAssert euclMod(-8, -3) == 1
+
+      doAssert euclMod(8.0, -3.0) ==~ 2.0
+      doAssert euclMod(-8.5, 3.0) ==~ 0.5
+
+      doAssert euclDiv(9, 3) == 3
+      doAssert euclMod(9, 3) == 0
+
+      doAssert euclDiv(9, -3) == -3
+      doAssert euclMod(9, -3) == 0
+
+      doAssert euclDiv(-9, 3) == -3
+      doAssert euclMod(-9, 3) == 0
+
+      doAssert euclDiv(-9, -3) == 3
+      doAssert euclMod(-9, -3) == 0
+
     block: # log
       doAssert log(4.0, 3.0) ==~ ln(4.0) / ln(3.0)
       doAssert log2(8.0'f64) == 3.0'f64