More tests for <-.
This commit is contained in:
parent
fd1029e6dd
commit
78b0d33c35
5 changed files with 41 additions and 7 deletions
|
@ -1,4 +0,0 @@
|
||||||
fn main() {
|
|
||||||
auto x;
|
|
||||||
x <- 5;
|
|
||||||
}
|
|
|
@ -1,6 +1,3 @@
|
||||||
use std;
|
|
||||||
import std::uint;
|
|
||||||
|
|
||||||
fn test(bool x, @tup(int, int, int) foo) -> int {
|
fn test(bool x, @tup(int, int, int) foo) -> int {
|
||||||
auto bar = foo;
|
auto bar = foo;
|
||||||
let @tup(int,int,int) y;
|
let @tup(int,int,int) y;
|
||||||
|
|
5
src/test/run-pass/move-2.rs
Normal file
5
src/test/run-pass/move-2.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
fn main() {
|
||||||
|
auto x = @tup(1,2,3);
|
||||||
|
auto y <- x;
|
||||||
|
assert (y._1 == 2);
|
||||||
|
}
|
21
src/test/run-pass/move-3.rs
Normal file
21
src/test/run-pass/move-3.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);
|
||||||
|
for each (uint i in uint::range(0u, 10000u)) {
|
||||||
|
assert (test(true, x) == 2);
|
||||||
|
}
|
||||||
|
assert (test(false, x) == 5);
|
||||||
|
}
|
15
src/test/run-pass/move-4.rs
Normal file
15
src/test/run-pass/move-4.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
use std;
|
||||||
|
import std::uint;
|
||||||
|
|
||||||
|
fn test(@tup(int, int, int) foo) -> @tup(int, int, int) {
|
||||||
|
auto bar <- foo;
|
||||||
|
auto baz <- bar;
|
||||||
|
auto quux <- baz;
|
||||||
|
ret quux;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
auto x = @tup(1,2,3);
|
||||||
|
auto y = test(x);
|
||||||
|
assert (y._2 == 3);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue