aboutsummaryrefslogtreecommitdiff
path: root/core/math.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-30 15:05:41 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-30 15:06:03 -0700
commitab4ebdf1751158391100efb0002f40b1d7f6314c (patch)
treebe675ed7b35164a24bdae5e8f1d3dd73af98490f /core/math.nom
parent7c488dd266466f80e55a3f02050f4e4a019d64b5 (diff)
Changed autoformatting rules to ensure tests get clumped together with
the thing below them.
Diffstat (limited to 'core/math.nom')
-rw-r--r--core/math.nom7
1 files changed, 2 insertions, 5 deletions
diff --git a/core/math.nom b/core/math.nom
index 5337d8c..3fad8f0 100644
--- a/core/math.nom
+++ b/core/math.nom
@@ -14,7 +14,6 @@ test:
math constants failed
%nan = (NaN)
assume (%nan != %nan) or barf "NaN failed"
-
compile [infinity, inf] to (Lua value "math.huge")
compile [not a number, NaN, nan] to (Lua value "(0/0)")
compile [pi, Pi, PI] to (Lua value "math.pi")
@@ -25,8 +24,8 @@ compile [e] to (Lua value "math.exp(1)")
# Functions:
test:
assume (("5" as a number) == 5)
-
compile [% as a number, % as number] to (Lua value "tonumber(\(% as lua expr))")
+
test:
assume (..)
all of [..]
@@ -34,7 +33,6 @@ test:
arc tangent 5, arc tangent 5 / 10, hyperbolic sine 5, hyperbolic cosine 5
hyperbolic tangent 5, e^ 5, ln 5, log base 2 of 5, floor 5, ceiling 5, round 5
..or barf "math functions failed"
-
compile [absolute value %, | % |, abs %] to (..)
Lua value "math.abs(\(% as lua expr))"
@@ -63,10 +61,10 @@ compile [log % base %base, log base %base of %] to (..)
compile [floor %] to (Lua value "math.floor(\(% as lua expr))")
compile [ceiling %, ceil %] to (Lua value "math.ceil(\(% as lua expr))")
compile [round %, % rounded] to (Lua value "math.floor(\(% as lua expr) + .5)")
+
test:
assume ((463 to the nearest 100) == 500) or barf "rounding failed"
assume ((2.6 to the nearest 0.25) == 2.5) or barf "rounding failed"
-
action [%n to the nearest %rounder] (..)
=lua "(\%rounder)*math.floor((\%n / \%rounder) + .5)"
@@ -107,7 +105,6 @@ compile [max of %items, biggest of %items, largest of %items, highest of %items]
test:
assume ((min of [3, -4, 1, 2] by % = (% * %)) == 1)
assume ((max of [3, -4, 1, 2] by % = (% * %)) == -4)
-
parse [min of %items by %item = %value_expr] as (..)
result of:
set {%best:nil, %best_key:nil}