From ede21dfb56ea29e45e47f99d5e06834c9efeb29e Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 6 Feb 2014 17:23:54 -0800 Subject: [PATCH] math: fix docs for next-power-of-2 and some tests. --- core/math/math-docs.factor | 2 +- core/math/math-tests.factor | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index b673a02b70..138d557c0f 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -407,7 +407,7 @@ HELP: number HELP: next-power-of-2 { $values { "m" "a non-negative integer" } { "n" "an integer" } } -{ $description "Outputs the smallest power of 2 greater than " { $snippet "m" } ". The output value is always at least 2." } ; +{ $description "Outputs the smallest power of 2 greater than or equal to " { $snippet "m" } ". The output value is always at least 2." } ; HELP: power-of-2? { $values { "n" integer } { "?" "a boolean" } } diff --git a/core/math/math-tests.factor b/core/math/math-tests.factor index 1a729fcef4..fb25886e70 100644 --- a/core/math/math-tests.factor +++ b/core/math/math-tests.factor @@ -86,3 +86,10 @@ IN: math.tests { -0x3fffffffffffffff } [ 0x3ffffffffffffffe >bignum bitnot ] unit-test { -0x4000000000000000 } [ 0x3fffffffffffffff >bignum bitnot ] unit-test { -0x4000000000000001 } [ 0x4000000000000000 >bignum bitnot ] unit-test + +{ 2 } [ 0 next-power-of-2 ] unit-test +{ 2 } [ 1 next-power-of-2 ] unit-test +{ 2 } [ 2 next-power-of-2 ] unit-test +{ 4 } [ 3 next-power-of-2 ] unit-test +{ 4 } [ 4 next-power-of-2 ] unit-test +{ 8 } [ 5 next-power-of-2 ] unit-test