]> git.lizzy.rs Git - rust.git/commitdiff
Fix run-pass tests
authorJorge Aparicio <japaricious@gmail.com>
Mon, 1 Dec 2014 22:33:22 +0000 (17:33 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Sun, 14 Dec 2014 01:15:39 +0000 (20:15 -0500)
src/test/auxiliary/trait_inheritance_overloading_xc.rs
src/test/run-pass/bool.rs
src/test/run-pass/deriving-zero.rs
src/test/run-pass/issue-3743.rs
src/test/run-pass/numeric-method-autoexport.rs
src/test/run-pass/operator-multidispatch.rs
src/test/run-pass/operator-overloading.rs
src/test/run-pass/overloaded-calls-param-vtables.rs
src/test/run-pass/simd-generics.rs
src/test/run-pass/trait-inheritance-overloading-xc-exe.rs
src/test/run-pass/trait-inheritance-overloading.rs

index 95bdecd77605f03e1eb5976d819595f8ec813f44..61854aba2790de84b2fddf282aafc89bf35c84ab 100644 (file)
 
 use std::cmp::PartialEq;
 
-pub trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + PartialEq {
+pub trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + PartialEq + Clone {
 }
 
-#[deriving(Show)]
+#[deriving(Clone, Show)]
 pub struct MyInt {
     pub val: int
 }
 
 impl Add<MyInt, MyInt> for MyInt {
-    fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
+    fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) }
 }
 
 impl Sub<MyInt, MyInt> for MyInt {
-    fn sub(&self, other: &MyInt) -> MyInt { mi(self.val - other.val) }
+    fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) }
 }
 
 impl Mul<MyInt, MyInt> for MyInt {
-    fn mul(&self, other: &MyInt) -> MyInt { mi(self.val * other.val) }
+    fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) }
 }
 
 impl PartialEq for MyInt {
index 91075633ab8d844c5ac9ea84725018ac779d362b..238d0ecdca7f8cc6b01b6081f45297df9b0071c4 100644 (file)
@@ -16,30 +16,30 @@ fn main() {
     assert_eq!(false != true, true);
     assert_eq!(false.ne(&false), false);
 
-    assert_eq!(false.bitand(&false), false);
-    assert_eq!(true.bitand(&false), false);
-    assert_eq!(false.bitand(&true), false);
-    assert_eq!(true.bitand(&true), true);
+    assert_eq!(false.bitand(false), false);
+    assert_eq!(true.bitand(false), false);
+    assert_eq!(false.bitand(true), false);
+    assert_eq!(true.bitand(true), true);
 
     assert_eq!(false & false, false);
     assert_eq!(true & false, false);
     assert_eq!(false & true, false);
     assert_eq!(true & true, true);
 
-    assert_eq!(false.bitor(&false), false);
-    assert_eq!(true.bitor(&false), true);
-    assert_eq!(false.bitor(&true), true);
-    assert_eq!(true.bitor(&true), true);
+    assert_eq!(false.bitor(false), false);
+    assert_eq!(true.bitor(false), true);
+    assert_eq!(false.bitor(true), true);
+    assert_eq!(true.bitor(true), true);
 
     assert_eq!(false | false, false);
     assert_eq!(true | false, true);
     assert_eq!(false | true, true);
     assert_eq!(true | true, true);
 
-    assert_eq!(false.bitxor(&false), false);
-    assert_eq!(true.bitxor(&false), true);
-    assert_eq!(false.bitxor(&true), true);
-    assert_eq!(true.bitxor(&true), false);
+    assert_eq!(false.bitxor(false), false);
+    assert_eq!(true.bitxor(false), true);
+    assert_eq!(false.bitxor(true), true);
+    assert_eq!(true.bitxor(true), false);
 
     assert_eq!(false ^ false, false);
     assert_eq!(true ^ false, true);
index 690d82a4ed25aba4e532e440f4ccc9ce48a7789f..88f3e5775b78b8f09b10ac4786c7442f50566827 100644 (file)
 struct Vector2<T>(T, T);
 
 impl<T: Add<T, T>> Add<Vector2<T>, Vector2<T>> for Vector2<T> {
-    fn add(&self, other: &Vector2<T>) -> Vector2<T> {
+    fn add(self, other: Vector2<T>) -> Vector2<T> {
         match (self, other) {
-            (&Vector2(ref x0, ref y0), &Vector2(ref x1, ref y1)) => {
-                Vector2(*x0 + *x1, *y0 + *y1)
+            (Vector2(x0, y0), Vector2(x1, y1)) => {
+                Vector2(x0 + x1, y0 + y1)
             }
         }
     }
@@ -30,7 +30,7 @@ struct Vector3<T> {
 }
 
 impl<T: Add<T, T>> Add<Vector3<T>, Vector3<T>> for Vector3<T> {
-    fn add(&self, other: &Vector3<T>) -> Vector3<T> {
+    fn add(self, other: Vector3<T>) -> Vector3<T> {
         Vector3 {
             x: self.x + other.x,
             y: self.y + other.y,
@@ -47,7 +47,7 @@ struct Matrix3x2<T> {
 }
 
 impl<T: Add<T, T>> Add<Matrix3x2<T>, Matrix3x2<T>> for Matrix3x2<T> {
-    fn add(&self, other: &Matrix3x2<T>) -> Matrix3x2<T> {
+    fn add(self, other: Matrix3x2<T>) -> Matrix3x2<T> {
         Matrix3x2 {
             x: self.x + other.x,
             y: self.y + other.y,
index ada3e37c092a7a92d28bb4c43126ad21099c66b8..80d3d29bc004d1b6d7a824a42efd7975f7c2139e 100644 (file)
@@ -28,7 +28,7 @@ fn vmul(self, other: f64) -> Vec2 {
 
 // Vec2's implementation of Mul "from the other side" using the above trait
 impl<Res, Rhs: RhsOfVec2Mul<Res>> Mul<Rhs,Res> for Vec2 {
-    fn mul(&self, rhs: &Rhs) -> Res { rhs.mul_vec2_by(self) }
+    fn mul(self, rhs: Rhs) -> Res { rhs.mul_vec2_by(&self) }
 }
 
 // Implementation of 'f64 as right-hand-side of Vec2::Mul'
index 585ade71fc6037278aef2a9d93733a5b2ec38a0b..f8184d248ff0166bcd38f56180097ae7fff15e23 100644 (file)
 pub fn main() {
 // ints
     // num
-    assert_eq!(15i.add(&6), 21);
-    assert_eq!(15i8.add(&6i8), 21i8);
-    assert_eq!(15i16.add(&6i16), 21i16);
-    assert_eq!(15i32.add(&6i32), 21i32);
-    assert_eq!(15i64.add(&6i64), 21i64);
+    assert_eq!(15i.add(6), 21);
+    assert_eq!(15i8.add(6i8), 21i8);
+    assert_eq!(15i16.add(6i16), 21i16);
+    assert_eq!(15i32.add(6i32), 21i32);
+    assert_eq!(15i64.add(6i64), 21i64);
 
 // uints
     // num
-    assert_eq!(15u.add(&6u), 21u);
-    assert_eq!(15u8.add(&6u8), 21u8);
-    assert_eq!(15u16.add(&6u16), 21u16);
-    assert_eq!(15u32.add(&6u32), 21u32);
-    assert_eq!(15u64.add(&6u64), 21u64);
+    assert_eq!(15u.add(6u), 21u);
+    assert_eq!(15u8.add(6u8), 21u8);
+    assert_eq!(15u16.add(6u16), 21u16);
+    assert_eq!(15u32.add(6u32), 21u32);
+    assert_eq!(15u64.add(6u64), 21u64);
 
 // floats
     // num
index fc79e4f0edb368035c5bd6693480836dae27e3cf..cb3397c00bc57a1196d3859e4065ce9666218dd6 100644 (file)
@@ -20,13 +20,13 @@ struct Point {
 }
 
 impl ops::Add<Point,Point> for Point {
-    fn add(&self, other: &Point) -> Point {
-        Point {x: self.x + (*other).x, y: self.y + (*other).y}
+    fn add(self, other: Point) -> Point {
+        Point {x: self.x + other.x, y: self.y + other.y}
     }
 }
 
 impl ops::Add<int,Point> for Point {
-    fn add(&self, &other: &int) -> Point {
+    fn add(self, other: int) -> Point {
         Point {x: self.x + other,
                y: self.y + other}
     }
index a896d2b06f7bddbf3de1e66e130252892db001d8..0f3da6836cb34e9f5a3d2f5b15ed5a40e27f4a58 100644 (file)
 use std::cmp;
 use std::ops;
 
-#[deriving(Show)]
+#[deriving(Copy, Show)]
 struct Point {
     x: int,
     y: int
 }
 
 impl ops::Add<Point,Point> for Point {
-    fn add(&self, other: &Point) -> Point {
-        Point {x: self.x + (*other).x, y: self.y + (*other).y}
+    fn add(self, other: Point) -> Point {
+        Point {x: self.x + other.x, y: self.y + other.y}
     }
 }
 
 impl ops::Sub<Point,Point> for Point {
-    fn sub(&self, other: &Point) -> Point {
-        Point {x: self.x - (*other).x, y: self.y - (*other).y}
+    fn sub(self, other: Point) -> Point {
+        Point {x: self.x - other.x, y: self.y - other.y}
     }
 }
 
index d0dbee39ae095cece48af0590070b040fbb15e91..2e8ec3916bd89f5c5ace9e8513c9d9bf6e007e99 100644 (file)
@@ -18,7 +18,7 @@
 
 impl<'a, A: Add<int, int>> Fn<(A,), int> for G {
     extern "rust-call" fn call(&self, (arg,): (A,)) -> int {
-        arg.add(&1)
+        arg.add(1)
     }
 }
 
index 31c29b615fc0938474c3bf836338f6f659ce1ad8..42f93a97142d239138dcec06978bec3884a6ffe9 100644 (file)
@@ -22,8 +22,8 @@ fn add<T: ops::Add<T, T>>(lhs: T, rhs: T) -> T {
 }
 
 impl ops::Add<f32x4, f32x4> for f32x4 {
-    fn add(&self, rhs: &f32x4) -> f32x4 {
-        *self + *rhs
+    fn add(self, rhs: f32x4) -> f32x4 {
+        self + rhs
     }
 }
 
index 7760395bf1c959338a3740147dac82799f14ddb4..2a087e5e425ad23d976baf8a98ab48f131ddde20 100644 (file)
@@ -14,7 +14,7 @@
 use trait_inheritance_overloading_xc::{MyNum, MyInt};
 
 fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
-    return (x + y, x - y, x * y);
+    return (x.clone() + y.clone(), x.clone() - y.clone(), x * y);
 }
 
 fn mi(v: int) -> MyInt { MyInt { val: v } }
index b13ea7ae0baef4602b0de80b4bc989142b4c1f9e..5f8e945cce8604d696c86ca9f2d37aecb1290e9d 100644 (file)
 
 use std::cmp::PartialEq;
 
-trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + PartialEq { }
+trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + PartialEq + Clone { }
 
-#[deriving(Show)]
+#[deriving(Clone, Show)]
 struct MyInt { val: int }
 
 impl Add<MyInt, MyInt> for MyInt {
-    fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
+    fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) }
 }
 
 impl Sub<MyInt, MyInt> for MyInt {
-    fn sub(&self, other: &MyInt) -> MyInt { mi(self.val - other.val) }
+    fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) }
 }
 
 impl Mul<MyInt, MyInt> for MyInt {
-    fn mul(&self, other: &MyInt) -> MyInt { mi(self.val * other.val) }
+    fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) }
 }
 
 impl PartialEq for MyInt {
@@ -35,7 +35,7 @@ fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
 impl MyNum for MyInt {}
 
 fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
-    return (x + y, x - y, x * y);
+    return (x.clone() + y.clone(), x.clone() - y.clone(), x * y);
 }
 
 fn mi(v: int) -> MyInt { MyInt { val: v } }