More tests for <-.

This commit is contained in:
Michael Sullivan 2011-05-31 16:11:30 -07:00 committed by Graydon Hoare
parent fd1029e6dd
commit 78b0d33c35
5 changed files with 41 additions and 7 deletions

View File

@ -1,4 +0,0 @@
fn main() {
auto x;
x <- 5;
}

View File

@ -1,6 +1,3 @@
use std;
import std::uint;
fn test(bool x, @tup(int, int, int) foo) -> int {
auto bar = foo;
let @tup(int,int,int) y;

View File

@ -0,0 +1,5 @@
fn main() {
auto x = @tup(1,2,3);
auto y <- x;
assert (y._1 == 2);
}

View 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);
}

View 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);
}