Re-add some deleted tuple tests
This commit is contained in:
parent
3f127e397f
commit
1570949ef1
4
src/test/run-pass/box-in-tup.rs
Normal file
4
src/test/run-pass/box-in-tup.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
let i: (@int, int) = (@10, 10);
|
||||
let (a, _) = i;
|
||||
}
|
10
src/test/run-pass/generic-tup.rs
Normal file
10
src/test/run-pass/generic-tup.rs
Normal file
@ -0,0 +1,10 @@
|
||||
fn get_third[T](t: &(T, T, T)) -> T {
|
||||
let (_, _, x) = t;
|
||||
ret x;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
log get_third((1, 2, 3));
|
||||
assert (get_third((1, 2, 3)) == 3);
|
||||
assert (get_third((5u8, 6u8, 7u8)) == 7u8);
|
||||
}
|
33
src/test/run-pass/rec-tup.rs
Normal file
33
src/test/run-pass/rec-tup.rs
Normal file
@ -0,0 +1,33 @@
|
||||
// -*- rust -*-
|
||||
type point = {x: int, y: int};
|
||||
|
||||
type rect = (point, point);
|
||||
|
||||
fn fst(r: &rect) -> point {
|
||||
let (fst, _) = r;
|
||||
ret fst;
|
||||
}
|
||||
fn snd(r: &rect) -> point {
|
||||
let (_, snd) = r;
|
||||
ret snd;
|
||||
}
|
||||
|
||||
fn f(r: rect, x1: int, y1: int, x2: int, y2: int) {
|
||||
assert (fst(r).x == x1);
|
||||
assert (fst(r).y == y1);
|
||||
assert (snd(r).x == x2);
|
||||
assert (snd(r).y == y2);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let r: rect = ({x: 10, y: 20}, {x: 11, y: 22});
|
||||
assert (fst(r).x == 10);
|
||||
assert (fst(r).y == 20);
|
||||
assert (snd(r).x == 11);
|
||||
assert (snd(r).y == 22);
|
||||
let r2 = r;
|
||||
let x: int = fst(r2).x;
|
||||
assert (x == 10);
|
||||
f(r, 10, 20, 11, 22);
|
||||
f(r2, 10, 20, 11, 22);
|
||||
}
|
18
src/test/run-pass/tup.rs
Normal file
18
src/test/run-pass/tup.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// -*- rust -*-
|
||||
type point = (int, int);
|
||||
|
||||
fn f(p: point, x: int, y: int) {
|
||||
let (a, b) = p;
|
||||
assert (a == x);
|
||||
assert (b == y);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let p: point = (10, 20);
|
||||
let (a, b) = p;
|
||||
assert (a == 10);
|
||||
assert (b == 20);
|
||||
let p2: point = p;
|
||||
f(p, 10, 20);
|
||||
f(p2, 10, 20);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user