libcore: Fix core test
This commit is contained in:
parent
0c6e470a25
commit
180202fa4d
3 changed files with 30 additions and 20 deletions
|
|
@ -16,14 +16,17 @@ trait Eq {
|
|||
pure fn eq(&&other: self) -> bool;
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool {
|
||||
v1.lt(*v2)
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
pure fn le<T: Ord Eq>(v1: &T, v2: &T) -> bool {
|
||||
v1.lt(*v2) || v1.eq(*v2)
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
pure fn eq<T: Eq>(v1: &T, v2: &T) -> bool {
|
||||
v1.eq(*v2)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import T = inst::T;
|
||||
import cmp::{Eq, Ord};
|
||||
import num::from_int;
|
||||
|
||||
export min_value, max_value;
|
||||
|
|
@ -63,19 +62,23 @@ pure fn abs(i: T) -> T {
|
|||
if is_negative(i) { -i } else { i }
|
||||
}
|
||||
|
||||
impl T: Ord {
|
||||
pure fn lt(&&other: T) -> bool {
|
||||
return self < other;
|
||||
#[cfg(notest)]
|
||||
mod impls {
|
||||
import cmp::{Eq, Ord};
|
||||
|
||||
impl T: Ord {
|
||||
pure fn lt(&&other: T) -> bool {
|
||||
return self < other;
|
||||
}
|
||||
}
|
||||
|
||||
impl T: Eq {
|
||||
pure fn eq(&&other: T) -> bool {
|
||||
return self == other;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl T: Eq {
|
||||
pure fn eq(&&other: T) -> bool {
|
||||
return self == other;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl T: num::Num {
|
||||
pure fn add(&&other: T) -> T { return self + other; }
|
||||
pure fn sub(&&other: T) -> T { return self - other; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import T = inst::T;
|
||||
import cmp::{Eq, Ord};
|
||||
|
||||
export min_value, max_value;
|
||||
export min, max;
|
||||
|
|
@ -56,15 +55,20 @@ pure fn compl(i: T) -> T {
|
|||
max_value ^ i
|
||||
}
|
||||
|
||||
impl T: Ord {
|
||||
pure fn lt(&&other: T) -> bool {
|
||||
return self < other;
|
||||
}
|
||||
}
|
||||
#[cfg(notest)]
|
||||
mod impls {
|
||||
import cmp::{Eq, Ord};
|
||||
|
||||
impl T: Eq {
|
||||
pure fn eq(&&other: T) -> bool {
|
||||
return self == other;
|
||||
impl T: Ord {
|
||||
pure fn lt(&&other: T) -> bool {
|
||||
return self < other;
|
||||
}
|
||||
}
|
||||
|
||||
impl T: Eq {
|
||||
pure fn eq(&&other: T) -> bool {
|
||||
return self == other;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue