From 395335aa23bdd4b7c9117c8d845575ba24baa9b1 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Tue, 10 Jul 2018 09:51:15 -0400 Subject: [PATCH 1/3] convert round calls to math.Round --- program/function_definition.go | 1 + tests/math.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/program/function_definition.go b/program/function_definition.go index 848bf2775..eed041fe5 100644 --- a/program/function_definition.go +++ b/program/function_definition.go @@ -126,6 +126,7 @@ var builtInFunctionDefinitions = map[string][]string{ "double log(double) -> math.Log", "double log10(double) -> math.Log10", "double pow(double, double) -> math.Pow", + "double round(double) -> math.Round", "double sin(double) -> math.Sin", "double sinh(double) -> math.Sinh", "double sqrt(double) -> math.Sqrt", diff --git a/tests/math.c b/tests/math.c index 4f7675501..0fef7eb15 100644 --- a/tests/math.c +++ b/tests/math.c @@ -400,6 +400,17 @@ int main() is_nan(pow(-INFINITY, NAN)); is_nan(pow(NAN, NAN)); + diag("round") + is_nan(round(NAN)); + is_eq(round(INFINITY), INFINITY); + is_eq(round(-INFINITY), -INFINITY); + is_eq(round(0), 0); + is_eq(round(1), 1); + is_eq(round(0.5), 1); + is_eq(round(0.4), 0); + is_eq(round(1.23e300), 1.23e300); + is_eq(round(M_PI), 3); + diag("sin"); is_eq(sin(0), 0); is_eq(sin(1), 0.84147098480789650488); From b6db69868b3f6520ae02ed8abb19cb6d4f10eaf1 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Wed, 11 Jul 2018 10:23:03 -0400 Subject: [PATCH 2/3] update tests --- tests/math.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/math.c b/tests/math.c index 0fef7eb15..7847aecf6 100644 --- a/tests/math.c +++ b/tests/math.c @@ -400,16 +400,20 @@ int main() is_nan(pow(-INFINITY, NAN)); is_nan(pow(NAN, NAN)); - diag("round") - is_nan(round(NAN)); - is_eq(round(INFINITY), INFINITY); - is_eq(round(-INFINITY), -INFINITY); + diag("round"); is_eq(round(0), 0); is_eq(round(1), 1); + is_eq(round(-1), -1); is_eq(round(0.5), 1); + is_eq(round(-0.5), -1); is_eq(round(0.4), 0); + is_negzero(round(-0.4)); is_eq(round(1.23e300), 1.23e300); + is_eq(round(-1.23e300), -1.23e300); is_eq(round(M_PI), 3); + is_inf(round(INFINITY), 1); + is_inf(round(-INFINITY), -1); + is_nan(round(NAN)); diag("sin"); is_eq(sin(0), 0); From 252b34a0b1f78039d4604ebde2c72dae1aa00164 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Thu, 12 Jul 2018 12:55:55 -0400 Subject: [PATCH 3/3] update number of expected tests --- tests/math.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/math.c b/tests/math.c index 7847aecf6..bbda2d36c 100644 --- a/tests/math.c +++ b/tests/math.c @@ -11,7 +11,7 @@ unsigned long long ullmax = 18446744073709551615ull; int main() { - plan(359); + plan(372); // Note: There are some tests that must be disabled because they return // different values under different compilers. See the comment surrounding the