diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index e8655ce6cda..b984c6fce6e 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -254,9 +254,9 @@ fn check_variants_T( let L = vec::len(things); if L < 100u { - under(math::min(L, 20u)) {|i| + under(uint::min(L, 20u)) {|i| log(error, "Replacing... #" + uint::str(i)); - under(math::min(L, 30u)) {|j| + under(uint::min(L, 30u)) {|j| log(error, "With... " + stringifier(@things[j])); let crate2 = @replacer(crate, i, things[j], cx.mode); // It would be best to test the *crate* for stability, but testing the diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 4edea85dd53..0b3729fac31 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -34,7 +34,7 @@ export either, option, result, iter; export libc, os, ctypes, sys, unsafe, logging; export comm, task, future; export extfmt; -export math, bessel; +export bessel; export tuple; export to_str; @@ -84,7 +84,6 @@ mod os; mod path; mod ctypes; -mod math; mod cmath; mod sys; mod unsafe; diff --git a/src/libcore/math.rs b/src/libcore/math.rs deleted file mode 100644 index 9e14091a532..00000000000 --- a/src/libcore/math.rs +++ /dev/null @@ -1,307 +0,0 @@ -#[doc = " -Generic functions that have been defined for all numeric types - -(may very well go away again soon) -"]; - -#[doc = "Returns the minimum of two values"] -pure fn min(x: T, y: T) -> T { if x < y { x } else { y} } - -#[doc = "Returns the maximum of two values"] -pure fn max(x: T, y: T) -> T { if x < y { y } else { x } } - -#[test] -fn test_max_min() { - assert max(0, 1) == 1; - assert min(0, 1) == 0; - assert max(0, -1) == 0; - assert min(0, -1) == -1; - assert max(0.0, 1.0) == 1.0; - assert min(0.0, 1.0) == 0.0; -} - -// FIXME use macros to execute the tests below for all float types - -/* -#[test] -fn test_trig() { - assert sin(0.0) == 0.0; - assert sin(-0.0) == 0.0; - - assert float::isNaN(sin(float::infinity)); - assert float::isNaN(sin(float::neg_infinity)); - - assert cos(0.0) == 1.0; - assert cos(-0.0) == 1.0; - assert float::isNaN(cos(float::infinity)); - assert float::isNaN(cos(float::neg_infinity)); - - assert tan(0.0) == 0.0; - assert tan(-0.0) == 0.0;; - assert float::isNaN(tan(float::infinity)); - assert float::isNaN(tan(float::neg_infinity)); -} - -#[test] -fn test_inv_trig() { - assert asin(0.0) == 0.0; - assert asin(-0.0) == -0.0; - assert float::isNaN(asin(1.1)); - assert float::isNaN(asin(-1.1)); - - assert acos(1.0) == 0.0; - assert float::isNaN(acos(1.1)); - assert float::isNaN(acos(-1.1)); - - assert atan(0.0) == 0.0; - assert atan(-0.0) == 0.0; - assert atan(float::infinity) == consts::frac_pi_2; - assert atan(float::neg_infinity) == - consts::frac_pi_2; - - assert atan2(0.0, -0.0) == consts::pi; - assert atan2(-0.0, -0.0) == -consts::pi; - - assert atan2(0.0, 0.0) == 0.0; - assert atan2(-0.0, 0.0) == -0.0; - - assert atan2(0.0, -1.0) == consts::pi; - assert atan2(-0.0, -1.0) == -consts::pi; - - assert atan2(0.0, 1.0) == 0.0; - assert atan2(-0.0, 1.0) == -0.0; - - assert atan2(1.0, 0.0) == consts::frac_pi_2; - assert atan2(1.0, -0.0) == consts::frac_pi_2; -} - -// FIXME (1222): The commented-out tests give different results on windows -#[test] -fn test_pow() { - assert pow(2.0, 4.0) == 16.0; - - assert pow(0.0, -3.0) == float::infinity; - assert pow(-0.0, -3.0) == float::neg_infinity; - - assert pow(0.0, -4.0) == float::infinity; - assert pow(-0.0, -4.0) == float::infinity; - - assert pow(0.0, 3.0) == 0.0; - assert pow(-0.0, 3.0) == -0.0; - assert pow(0.0, 4.0) == 0.0; - assert pow(-0.0, 4.0) == 0.0; - - assert pow(-1.0, float::infinity) == 1.0; - //assert pow(-1.0, float::neg_infinity) == 1.0; - - assert pow(1.0, 4.0) == 1.0; - assert pow(1.0, 0.0) == 1.0; - assert pow(1.0, -0.0) == 1.0; - //assert pow(1.0, float::NaN) == 1.0; - assert pow(1.0, float::infinity) == 1.0; - //assert pow(1.0, float::neg_infinity) == 1.0; - assert pow(1.0, -3.0) == 1.0; - assert pow(1.0, -4.0) == 1.0; - - assert pow(4.0, 0.0) == 1.0; - assert pow(0.0, 0.0) == 1.0; - assert pow(-0.0, 0.0) == 1.0; - //assert pow(float::NaN, 0.0) == 1.0; - assert pow(float::infinity, 0.0) == 1.0; - assert pow(float::neg_infinity, 0.0) == 1.0; - assert pow(-3.0, 0.0) == 1.0; - assert pow(-4.0, 0.0) == 1.0; - - assert pow(4.0, -0.0) == 1.0; - assert pow(0.0, -0.0) == 1.0; - assert pow(-0.0, -0.0) == 1.0; - //assert pow(float::NaN, -0.0) == 1.0; - assert pow(float::infinity, -0.0) == 1.0; - assert pow(float::neg_infinity, -0.0) == 1.0; - assert pow(-3.0, -0.0) == 1.0; - assert pow(-4.0, -0.0) == 1.0; - - assert float::isNaN(pow(-1.0, -1.5)); - assert float::isNaN(pow(-1.0, 1.5)); - - assert float::isNaN(pow(-1.2, -1.5)); - assert float::isNaN(pow(-1.2, 1.5)); - - assert pow(0.5, float::neg_infinity) == float::infinity; - assert pow(-0.5, float::neg_infinity) == float::infinity; - - assert pow(1.5, float::neg_infinity) == 0.0; - assert pow(-1.5, float::neg_infinity) == 0.0; - - assert pow(0.5, float::infinity) == 0.0; - assert pow(-0.5, float::infinity) == 0.0; - - assert pow(-1.5, float::infinity) == float::infinity; - assert pow(1.5, float::infinity) == float::infinity; - - assert pow(float::neg_infinity, -3.0) == -0.0; - assert pow(float::neg_infinity, -4.0) == 0.0; - - assert pow(float::neg_infinity, 3.0) == float::neg_infinity; - assert pow(float::neg_infinity, 4.0) == float::infinity; - - assert pow(float::infinity, -16.0) == 0.0; - assert pow(float::infinity, 16.0) == float::infinity; -} - -// FIXME (1222): The commented-out tests give different results on windows -#[test] -fn test_exp_and_mod() { - assert exp(0.0) == 1.0; - assert exp(-0.0) == 1.0; - assert exp(float::neg_infinity) == 0.0; - assert exp(float::infinity) == float::infinity; - - let d1: c_int = 1 as c_int; - assert frexp(0.0, d1) == 0.0; - assert frexp(-0.0, d1) == 0.0; - //assert frexp(float::infinity, d1) == float::infinity; - //assert frexp(float::neg_infinity, d1) == float::neg_infinity; - assert float::isNaN(frexp(float::NaN, d1)); - - let d2: float = 1.0; - assert modf(float::infinity, d2) == 0.0; - assert d2 == float::infinity; - assert modf(float::neg_infinity, d2) == -0.0; - assert d2 == float::neg_infinity; - assert float::isNaN(modf(float::NaN, d2)); - assert float::isNaN(d2); -} - -#[test] -fn test_round_and_abs() { - assert abs(0.0) == 0.0; - assert abs(-0.0) == 0.0; - assert abs(float::infinity) == float::infinity; - assert abs(float::neg_infinity) == float::infinity; - - assert abs(-2.5) == 2.5; - assert abs(2.5) == 2.5; - - assert ceil(0.0) == 0.0; - assert ceil(-0.0) == -0.0; - assert ceil(float::infinity) == float::infinity; - assert ceil(float::neg_infinity) == float::neg_infinity; - - assert ceil(1.9) == 2.0; - assert ceil(-1.9) == -1.0; - - assert floor(0.0) == 0.0; - assert floor(-0.0) == -0.0; - assert floor(float::infinity) == float::infinity; - assert floor(float::neg_infinity) == float::neg_infinity; - - assert floor(1.9) == 1.0; - assert floor(-1.9) == -2.0; - - assert trunc(0.0) == 0.0; - assert trunc(-0.0) == -0.0; - assert trunc(float::infinity) == float::infinity; - assert trunc(float::neg_infinity) == float::neg_infinity; - - assert trunc(1.5) == 1.0; - assert trunc(1.2) == 1.0; - assert trunc(1.0) == 1.0; - assert trunc(1.9) == 1.0; - assert trunc(-1.5) == -1.0; - assert trunc(-1.2) == -1.0; - assert trunc(-1.0) == -1.0; - assert trunc(-1.9) == -1.0; - - assert round(0.0) == 0.0; - assert round(-0.0) == -0.0; - assert round(float::infinity) == float::infinity; - assert round(float::neg_infinity) == float::neg_infinity; - - assert rint(0.0) == 0.0; - assert rint(-0.0) == -0.0; - assert rint(float::infinity) == float::infinity; - assert rint(float::neg_infinity) == float::neg_infinity; -} - -#[test] -fn test_hyp_trig() { - assert sinh(0.0) == 0.0; - assert sinh(-0.0) == 0.0; - assert sinh(float::infinity) == float::infinity; - assert sinh(float::neg_infinity) == float::neg_infinity; - - assert cosh(0.0) == 1.0; - assert cosh(-0.0) == 1.0; - assert cosh(float::infinity) == float::infinity; - assert cosh(float::neg_infinity) == float::infinity; - - assert tanh(0.0) == 0.0; - assert tanh(-0.0) == 0.0; - assert tanh(float::infinity) == 1.0; - assert tanh(float::neg_infinity) == -1.0; -} - -#[test] -fn test_sqrt() { - assert sqrt(9.0) == 3.0; - assert sqrt(4.0) == 2.0; - assert sqrt(1.0) == 1.0; - assert sqrt(0.0) == 0.0; -} - - -#[test] -fn test_angle() { - fn angle(vec: (float, float)) -> float { - alt vec { - (0f, y) if y < 0f { 1.5 * consts::pi } - (0f, y) { 0.5 * consts::pi } - (x, y) { float::atan(y / x) } - } - } - assert angle((1f, 0f)) == 0f; - assert angle((1f, 1f)) == 0.25 * consts::pi; - assert angle((0f, 1f)) == 0.5 * consts::pi; -} - - -#[test] -fn test_log_functions() { - assert ln(1.0) == 0.0; - assert log2(1.0) == 0.0; - assert log10(1.0) == 0.0; - - // FIXME remove round-up due to valgrind weirdness - assert ceil(ln(consts::e)) == 1.0; /* ln(e) == 0.999.. under valgrind */ - assert log2(2.0) == 1.0; - assert log10(10.0) == 1.0; - - // FIXME remove round-up due to valgrind weirdness - assert ceil(ln(consts::e*consts::e*consts::e*consts::e)) == 4.0; - assert log2(256.0) == 8.0; - assert log10(1000.0) == 3.0; - - assert ln(0.0) == float::neg_infinity; - assert log2(0.0) == float::neg_infinity; - assert log10(0.0) == float::neg_infinity; - - assert ln(-0.0) == float::neg_infinity; - assert log2(-0.0) == float::neg_infinity; - assert log10(-0.0) == float::neg_infinity; - - assert float::isNaN(ln(-1.0)); - assert float::isNaN(log2(-1.0)); - assert float::isNaN(log10(-1.0)); - - assert ln(float::infinity) == float::infinity; - assert log2(float::infinity) == float::infinity; - assert log10(float::infinity) == float::infinity; - - assert ln1p(0.0) == 0.0; - assert ln1p(-0.0) == 0.0; - assert ln1p(-1.0) == float::neg_infinity; - assert float::isNaN(ln1p(-2.0f)); - assert ln1p(float::infinity) == float::infinity; -} - -*/ diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index cb37ad361df..2b3829dd910 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -912,7 +912,7 @@ mod u8 { pure fn cmp(&&a: [u8], &&b: [u8]) -> int unsafe { let a_len = len(a); let b_len = len(b); - let n = math::min(a_len, b_len) as ctypes::size_t; + let n = uint::min(a_len, b_len) as ctypes::size_t; let r = libc::memcmp(unsafe::to_ptr(a) as *libc::c_void, unsafe::to_ptr(b) as *libc::c_void, n) as int; diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 1166241f010..b9656df7e2f 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -1006,7 +1006,7 @@ mod node { right : right, char_len: char_len(left) + char_len(right), byte_len: byte_len(left) + byte_len(right), - height: math::max(height(left), height(right)) + 1u + height: uint::max(height(left), height(right)) + 1u }) } diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index eef999a9571..cfe3e63c4e2 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -129,7 +129,7 @@ fn get_relative_to(abs1: fs::path, abs2: fs::path) -> fs::path { assert len1 > 0u; assert len2 > 0u; - let max_common_path = math::min(len1, len2) - 1u; + let max_common_path = uint::min(len1, len2) - 1u; let start_idx = 0u; while start_idx < max_common_path && split1[start_idx] == split2[start_idx] { diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index dc6053ad73d..ea8de5b8b77 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -1568,7 +1568,7 @@ mod unify { _ { cx.tcx.sess.bug("someone forgot to document an invariant \ in union"); } }; - ufind::grow(vb.sets, math::max(set_a, set_b) + 1u); + ufind::grow(vb.sets, uint::max(set_a, set_b) + 1u); let root_a = ufind::find(vb.sets, set_a); let root_b = ufind::find(vb.sets, set_b); diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index cd45deb9423..12bf9d6b960 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -1,4 +1,3 @@ -import math::{max, min}; import std::map::hashmap; import syntax::ast; import ast::{ty, pat}; diff --git a/src/rustdoc/unindent_pass.rs b/src/rustdoc/unindent_pass.rs index 1ec765b13b8..48d7b595f5f 100644 --- a/src/rustdoc/unindent_pass.rs +++ b/src/rustdoc/unindent_pass.rs @@ -57,7 +57,7 @@ fn unindent(s: str) -> str { false } }; - math::min(min_indent, spaces) + uint::min(min_indent, spaces) } };