2012-12-10 17:32:48 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2011-04-05 23:42:33 -04:00
|
|
|
|
2011-06-15 11:19:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
// -*- rust -*-
|
2013-03-01 15:55:31 -08:00
|
|
|
type compare<T> = @fn(@T, @T) -> bool;
|
2011-04-05 23:42:33 -04:00
|
|
|
|
2011-09-12 11:27:30 +02:00
|
|
|
fn test_generic<T>(expected: @T, not_expected: @T, eq: compare<T>) {
|
2011-07-27 14:19:39 +02:00
|
|
|
let actual: @T = if true { expected } else { not_expected };
|
2011-06-15 11:19:50 -07:00
|
|
|
assert (eq(expected, actual));
|
2011-04-05 23:42:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_box() {
|
2012-08-01 17:30:05 -07:00
|
|
|
fn compare_box(b1: @bool, b2: @bool) -> bool { return *b1 == *b2; }
|
2012-06-19 19:34:01 -07:00
|
|
|
test_generic::<bool>(@true, @false, compare_box);
|
2011-04-05 23:42:33 -04:00
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() { test_box(); }
|