Add some simple tests for move.
This commit is contained in:
parent
c232964301
commit
68b4688875
2 changed files with 25 additions and 0 deletions
4
src/test/compile-fail/move-not-variable.rs
Normal file
4
src/test/compile-fail/move-not-variable.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
auto x;
|
||||
x <- 5;
|
||||
}
|
21
src/test/run-pass/move-1.rs
Normal file
21
src/test/run-pass/move-1.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
use std;
|
||||
import std::uint;
|
||||
|
||||
fn test(bool x, @tup(int, int, int) foo) -> int {
|
||||
auto bar = foo;
|
||||
let @tup(int,int,int) y;
|
||||
if (x) {
|
||||
y <- bar;
|
||||
} else {
|
||||
y = @tup(4,5,6);
|
||||
}
|
||||
ret y._1;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
auto x = @tup(1,2,3);
|
||||
assert (test(true, x) == 2);
|
||||
assert (test(true, x) == 2);
|
||||
assert (test(true, x) == 2);
|
||||
assert (test(false, x) == 5);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue