Skip to content

Commit 78b0d33

Browse files
msullivangraydon
authored andcommitted
More tests for <-.
1 parent fd1029e commit 78b0d33

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

src/test/compile-fail/move-not-variable.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/test/run-pass/move-1.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use std;
2-
import std::uint;
3-
41
fn test(bool x, @tup(int, int, int) foo) -> int {
52
auto bar = foo;
63
let @tup(int,int,int) y;

src/test/run-pass/move-2.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
auto x = @tup(1,2,3);
3+
auto y <- x;
4+
assert (y._1 == 2);
5+
}

src/test/run-pass/move-3.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use std;
2+
import std::uint;
3+
4+
fn test(bool x, @tup(int, int, int) foo) -> int {
5+
auto bar = foo;
6+
let @tup(int,int,int) y;
7+
if (x) {
8+
y <- bar;
9+
} else {
10+
y = @tup(4,5,6);
11+
}
12+
ret y._1;
13+
}
14+
15+
fn main() {
16+
auto x = @tup(1,2,3);
17+
for each (uint i in uint::range(0u, 10000u)) {
18+
assert (test(true, x) == 2);
19+
}
20+
assert (test(false, x) == 5);
21+
}

src/test/run-pass/move-4.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use std;
2+
import std::uint;
3+
4+
fn test(@tup(int, int, int) foo) -> @tup(int, int, int) {
5+
auto bar <- foo;
6+
auto baz <- bar;
7+
auto quux <- baz;
8+
ret quux;
9+
}
10+
11+
fn main() {
12+
auto x = @tup(1,2,3);
13+
auto y = test(x);
14+
assert (y._2 == 3);
15+
}

0 commit comments

Comments
 (0)