2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(dead_code)]
|
2018-08-31 08:02:01 -05:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
|
2021-02-08 16:15:45 -06:00
|
|
|
// aux-build:xc.rs
|
2013-06-12 16:22:17 -05:00
|
|
|
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2021-02-08 16:15:45 -06:00
|
|
|
extern crate xc as aux;
|
2013-07-11 17:08:43 -05:00
|
|
|
use aux::{A, TestEquality, Something};
|
|
|
|
use aux::B;
|
2013-06-12 16:22:17 -05:00
|
|
|
|
|
|
|
fn f<T: aux::A>(i: T) {
|
|
|
|
assert_eq!(i.g(), 10);
|
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn welp<T>(i: isize, _x: &T) -> isize {
|
2013-07-11 17:08:43 -05:00
|
|
|
i.g()
|
|
|
|
}
|
|
|
|
|
2013-07-02 16:39:25 -05:00
|
|
|
mod stuff {
|
2015-03-25 19:06:52 -05:00
|
|
|
pub struct thing { pub x: isize }
|
2013-07-02 16:39:25 -05:00
|
|
|
}
|
2013-06-12 16:22:17 -05:00
|
|
|
|
2013-07-02 16:39:25 -05:00
|
|
|
impl A for stuff::thing {
|
2015-03-25 19:06:52 -05:00
|
|
|
fn f(&self) -> isize { 10 }
|
2013-06-12 16:22:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn g<T, U, V: B<T>>(i: V, j: T, k: U) -> (T, U) {
|
|
|
|
i.thing(j, k)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn eq<T: TestEquality>(lhs: &T, rhs: &T) -> bool {
|
|
|
|
lhs.test_eq(rhs)
|
|
|
|
}
|
|
|
|
fn neq<T: TestEquality>(lhs: &T, rhs: &T) -> bool {
|
|
|
|
lhs.test_neq(rhs)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-02 16:39:25 -05:00
|
|
|
impl TestEquality for stuff::thing {
|
|
|
|
fn test_eq(&self, rhs: &stuff::thing) -> bool {
|
2013-06-12 16:22:17 -05:00
|
|
|
//self.x.test_eq(&rhs.x)
|
|
|
|
eq(&self.x, &rhs.x)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-05 20:56:44 -05:00
|
|
|
pub fn main() {
|
2013-06-12 16:22:17 -05:00
|
|
|
// Some tests of random things
|
2015-01-25 15:05:03 -06:00
|
|
|
f(0);
|
2013-06-12 16:22:17 -05:00
|
|
|
|
2015-01-25 15:05:03 -06:00
|
|
|
assert_eq!(A::lurr(&0, &1), 21);
|
2013-07-11 17:08:43 -05:00
|
|
|
|
2013-07-02 16:39:25 -05:00
|
|
|
let a = stuff::thing { x: 0 };
|
|
|
|
let b = stuff::thing { x: 1 };
|
|
|
|
let c = Something { x: 1 };
|
2013-06-12 16:22:17 -05:00
|
|
|
|
2015-01-25 15:05:03 -06:00
|
|
|
assert_eq!(0.g(), 10);
|
2013-06-12 16:22:17 -05:00
|
|
|
assert_eq!(a.g(), 10);
|
2013-07-11 17:08:43 -05:00
|
|
|
assert_eq!(a.h(), 11);
|
|
|
|
assert_eq!(c.h(), 11);
|
2013-06-12 16:22:17 -05:00
|
|
|
|
2015-01-25 15:05:03 -06:00
|
|
|
assert_eq!(0.thing(3.14f64, 1), (3.14f64, 1));
|
|
|
|
assert_eq!(B::staticthing(&0, 3.14f64, 1), (3.14f64, 1));
|
2015-03-25 19:06:52 -05:00
|
|
|
assert_eq!(B::<f64>::staticthing::<isize>(&0, 3.14, 1), (3.14, 1));
|
2013-06-12 16:22:17 -05:00
|
|
|
|
2015-01-25 15:05:03 -06:00
|
|
|
assert_eq!(g(0, 3.14f64, 1), (3.14f64, 1));
|
|
|
|
assert_eq!(g(false, 3.14f64, 1), (3.14, 1));
|
2013-06-12 16:22:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
// Trying out a real one
|
2015-01-25 15:05:03 -06:00
|
|
|
assert!(12.test_neq(&10));
|
|
|
|
assert!(!10.test_neq(&10));
|
2013-06-12 16:22:17 -05:00
|
|
|
assert!(a.test_neq(&b));
|
|
|
|
assert!(!a.test_neq(&a));
|
|
|
|
|
2015-01-25 15:05:03 -06:00
|
|
|
assert!(neq(&12, &10));
|
|
|
|
assert!(!neq(&10, &10));
|
2013-06-12 16:22:17 -05:00
|
|
|
assert!(neq(&a, &b));
|
|
|
|
assert!(!neq(&a, &a));
|
|
|
|
}
|