2011-04-05 23:42:33 -04:00
|
|
|
// -*- rust -*-
|
|
|
|
|
|
|
|
type compare[T] = fn(@T t1, @T t2) -> bool;
|
|
|
|
|
|
|
|
fn test_generic[T](@T expected, @T not_expected, &compare[T] eq) {
|
|
|
|
let @T actual = if (true) { expected } else { not_expected };
|
2011-05-02 17:47:24 -07:00
|
|
|
assert (eq(expected, actual));
|
2011-04-05 23:42:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_box() {
|
|
|
|
fn compare_box(@bool b1, @bool b2) -> bool {
|
|
|
|
ret *b1 == *b2;
|
|
|
|
}
|
|
|
|
auto eq = bind compare_box(_, _);
|
|
|
|
test_generic[bool](@true, @false, eq);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
test_box();
|
|
|
|
}
|