2011-07-08 04:16:46 -05:00
|
|
|
use std;
|
|
|
|
import std::ivec;
|
|
|
|
|
2011-08-04 18:20:53 -05:00
|
|
|
fn ivec_equal[T](v: &[T], u: &[T], element_equality_test: fn(&T, &T) -> bool )
|
2011-07-27 07:19:39 -05:00
|
|
|
-> bool {
|
|
|
|
let Lv = ivec::len(v);
|
|
|
|
if Lv != ivec::len(u) { ret false; }
|
|
|
|
let i = 0u;
|
|
|
|
while i < Lv {
|
|
|
|
if !element_equality_test(v.(i), u.(i)) { ret false; }
|
2011-07-08 04:16:46 -05:00
|
|
|
i += 1u;
|
|
|
|
}
|
|
|
|
ret true;
|
|
|
|
}
|
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn builtin_equal[T](a: &T, b: &T) -> bool { ret a == b; }
|
2011-07-08 04:16:46 -05:00
|
|
|
|
|
|
|
fn main() {
|
2011-07-27 07:19:39 -05:00
|
|
|
assert (builtin_equal(5, 5));
|
|
|
|
assert (!builtin_equal(5, 4));
|
|
|
|
assert (!ivec_equal(~[5, 5], ~[5], builtin_equal));
|
|
|
|
assert (!ivec_equal(~[5, 5], ~[5, 4], builtin_equal));
|
|
|
|
assert (!ivec_equal(~[5, 5], ~[4, 5], builtin_equal));
|
|
|
|
assert (ivec_equal(~[5, 5], ~[5, 5], builtin_equal));
|
2011-07-08 04:16:46 -05:00
|
|
|
|
|
|
|
log_err "Pass";
|
2011-08-04 18:20:53 -05:00
|
|
|
}
|