Convert most working tests to ivecs
I tried to pay attention to what was actually being tested so, e.g. when I test was just using a vec as a boxed thing, I converted to boxed ints, etc. Haven't converted the macro tests yet. Not sure what to do there.
This commit is contained in:
parent
594c7fb0c6
commit
ee7d03f7d7
56 changed files with 124 additions and 121 deletions
|
@ -12,9 +12,9 @@ fn main() {
|
|||
// during 'make check' under valgrind
|
||||
// 5000000
|
||||
// 50000000
|
||||
let inputs: vec[int] = [50000, 500000];
|
||||
let inputs: [int] = ~[50000, 500000];
|
||||
|
||||
let bodies: vec[Body::props] = NBodySystem::MakeNBodySystem();
|
||||
let bodies: [Body::props] = NBodySystem::MakeNBodySystem();
|
||||
|
||||
|
||||
for n: int in inputs {
|
||||
|
@ -31,10 +31,10 @@ fn main() {
|
|||
|
||||
mod NBodySystem {
|
||||
|
||||
fn MakeNBodySystem() -> vec[Body::props] {
|
||||
fn MakeNBodySystem() -> [Body::props] {
|
||||
// these each return a Body::props
|
||||
let bodies: vec[Body::props] =
|
||||
[Body::sun(), Body::jupiter(), Body::saturn(), Body::uranus(),
|
||||
let bodies: [Body::props] =
|
||||
~[Body::sun(), Body::jupiter(), Body::saturn(), Body::uranus(),
|
||||
Body::neptune()];
|
||||
|
||||
let px: float = 0.0;
|
||||
|
@ -56,7 +56,7 @@ mod NBodySystem {
|
|||
ret bodies;
|
||||
}
|
||||
|
||||
fn advance(bodies: vec[Body::props], dt: float) {
|
||||
fn advance(bodies: &[Body::props], dt: float) {
|
||||
|
||||
let i: int = 0;
|
||||
while i < 5 {
|
||||
|
@ -95,7 +95,7 @@ mod NBodySystem {
|
|||
b.z += dt * b.vz;
|
||||
}
|
||||
|
||||
fn energy(bodies: vec[Body::props]) -> float {
|
||||
fn energy(bodies: &[Body::props]) -> float {
|
||||
let dx: float;
|
||||
let dy: float;
|
||||
let dz: float;
|
||||
|
|
|
@ -69,9 +69,9 @@ fn stress_task(id: int) {
|
|||
}
|
||||
|
||||
fn stress(num_tasks: int) {
|
||||
let tasks = [];
|
||||
let tasks = ~[];
|
||||
for each i: int in range(0, num_tasks) {
|
||||
tasks += [spawn stress_task(i)];
|
||||
tasks += ~[spawn stress_task(i)];
|
||||
}
|
||||
for each i: int in range(0, num_tasks) { task::join(tasks.(i)); }
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
// error-pattern:expected str but found vec
|
||||
fn main() { fail []; }
|
||||
// error-pattern:expected str but found [int]
|
||||
fn main() { fail ~[0]; }
|
|
@ -1,6 +1,6 @@
|
|||
// -*- rust -*-
|
||||
// error-pattern: illegal recursive type
|
||||
|
||||
type x = vec[x];
|
||||
type x = [x];
|
||||
|
||||
fn main() { let b: x = []; }
|
||||
fn main() { let b: x = ~[]; }
|
|
@ -1,5 +1,5 @@
|
|||
// error-pattern:Attempt to use a type argument out of scope
|
||||
fn hd[U](v: &vec[U]) -> U {
|
||||
fn hd1(w: &vec[U]) -> U { ret w.(0); }
|
||||
fn hd[U](v: &[U]) -> U {
|
||||
fn hd1(w: &[U]) -> U { ret w.(0); }
|
||||
ret hd1(v);
|
||||
}
|
|
@ -6,7 +6,7 @@ import std::option::some;
|
|||
|
||||
// error-pattern: mismatched types
|
||||
|
||||
tag bar { t1((), option::t[vec[int]]); t2; }
|
||||
tag bar { t1((), option::t[[int]]); t2; }
|
||||
|
||||
fn foo(t: bar) -> int { alt t { t1(_, some(x)) { ret x * 3; } _ { fail; } } }
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import std::option::some;
|
|||
|
||||
// error-pattern: mismatched types
|
||||
|
||||
tag bar { t1((), option::t[vec[int]]); t2; }
|
||||
tag bar { t1((), option::t[[int]]); t2; }
|
||||
|
||||
fn foo(t: bar) { alt t { t1(_, some[int](x)) { log x; } _ { fail; } } }
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
// -*- rust -*-
|
||||
// error-pattern:src/test/compile-fail/shadow.rs
|
||||
fn foo(c: vec[int]) {
|
||||
fn foo(c: [int]) {
|
||||
let a: int = 5;
|
||||
let b: vec[int] = [];
|
||||
let b: [int] = ~[];
|
||||
|
||||
|
||||
alt none[int] {
|
||||
some[int](_) { for i: int in c { log a; let a = 17; b += [a]; } }
|
||||
some[int](_) { for i: int in c { log a; let a = 17; b += ~[a]; } }
|
||||
}
|
||||
}
|
||||
|
||||
tag t[T] { none; some(T); }
|
||||
|
||||
fn main() { foo([]); }
|
||||
fn main() { foo(~[]); }
|
|
@ -1,6 +1,6 @@
|
|||
// error-pattern:invalidate alias x
|
||||
|
||||
fn main() {
|
||||
let v: vec[mutable int] = [mutable 1, 2, 3];
|
||||
let v: [mutable int] = ~[mutable 1, 2, 3];
|
||||
for x: int in v { v.(0) = 10; log x; }
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
// error-pattern:attempted field access on type vec[int]
|
||||
// error-pattern:attempted field access on type [int]
|
||||
// issue #367
|
||||
|
||||
fn f() {
|
||||
let v = [1];
|
||||
let v = ~[1];
|
||||
log v.some_field_name; //type error
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// error-pattern: Unsatisfied precondition constraint
|
||||
|
||||
fn test() { let w: vec[int]; w.(5) = 0; }
|
||||
fn test() { let w: [int]; w.(5) = 0; }
|
||||
|
||||
fn main() { test(); }
|
|
@ -1,2 +1,2 @@
|
|||
// error-pattern:assignment to immutable vec content
|
||||
fn main() { let v: vec[int] = [1, 2, 3]; v.(1) = 4; }
|
||||
fn main() { let v: [int] = ~[1, 2, 3]; v.(1) = 4; }
|
|
@ -3,7 +3,7 @@
|
|||
// error-pattern:bounds check
|
||||
// no-valgrind
|
||||
fn main() {
|
||||
let v: vec[int] = [10];
|
||||
let v: [int] = ~[10];
|
||||
let x: int = 0;
|
||||
assert (v.(x) == 10);
|
||||
// Bounds-check failure.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// error-pattern:bounds check
|
||||
// no-valgrind
|
||||
fn main() {
|
||||
let v: vec[int] = [10, 20];
|
||||
let v: [int] = ~[10, 20];
|
||||
let x: int = 0;
|
||||
assert (v.(x) == 10);
|
||||
// Bounds-check failure.
|
||||
|
|
|
@ -7,12 +7,12 @@ import std::option::some;
|
|||
|
||||
fn foo[T](y: &option::t[T]) {
|
||||
let x: int;
|
||||
let rs: vec[int] = [];
|
||||
let rs: [int] = ~[];
|
||||
/* tests that x doesn't get put in the precondition for the
|
||||
entire if expression */
|
||||
|
||||
if true {
|
||||
} else { alt y { none[T]. { x = 17; } _ { x = 42; } } rs += [x]; }
|
||||
} else { alt y { none[T]. { x = 17; } _ { x = 42; } } rs += ~[x]; }
|
||||
ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
|
||||
use std;
|
||||
import std::ivec;
|
||||
|
||||
fn main(args: vec[str]) {
|
||||
let vs: vec[str] = ["hi", "there", "this", "is", "a", "vec"];
|
||||
let vvs: vec[vec[str]] = [args, vs];
|
||||
for vs: vec[str] in vvs { for s: str in vs { log s; } }
|
||||
let vs: [str] = ~["hi", "there", "this", "is", "a", "vec"];
|
||||
let vvs: [[str]] = ~[ivec::from_vec(args), vs];
|
||||
for vs: [str] in vvs { for s: str in vs { log s; } }
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
fn main() {
|
||||
fn echo[T](c: int, x: vec[T]) { }
|
||||
fn echo[T](c: int, x: &[T]) { }
|
||||
|
||||
let y: fn(vec[int]) = bind echo(42, _);
|
||||
let y: fn(&[int]) = bind echo(42, _);
|
||||
|
||||
y([1]);
|
||||
y(~[1]);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
fn iter_vec[T](v: &vec[T], f: &block(&T) ) { for x: T in v { f(x); } }
|
||||
fn iter_vec[T](v: &[T], f: &block(&T) ) { for x: T in v { f(x); } }
|
||||
|
||||
fn main() {
|
||||
let v = [1, 2, 3, 4, 5, 6, 7];
|
||||
let v = ~[1, 2, 3, 4, 5, 6, 7];
|
||||
let odds = 0;
|
||||
iter_vec(v,
|
||||
block (i: &int) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
fn iter_vec[T](v: &vec[T], f: &block(&T) ) { for x: T in v { f(x); } }
|
||||
fn iter_vec[T](v: &[T], f: &block(&T) ) { for x: T in v { f(x); } }
|
||||
|
||||
fn main() {
|
||||
let v = [1, 2, 3, 4, 5];
|
||||
let v = ~[1, 2, 3, 4, 5];
|
||||
let sum = 0;
|
||||
iter_vec(v,
|
||||
block (i: &int) {
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
// -*- rust -*-
|
||||
|
||||
fn some_vec(x: int) -> vec[int] { ret []; }
|
||||
fn some_box(x: int) -> @int { ret @x; }
|
||||
|
||||
fn is_odd(n: int) -> bool { ret true; }
|
||||
|
||||
fn length_is_even(vs: vec[int]) -> bool { ret true; }
|
||||
fn length_is_even(vs: @int) -> bool { ret true; }
|
||||
|
||||
fn foo(acc: int, n: int) {
|
||||
if is_odd(n) && length_is_even(some_vec(1)) { log_err "bloop"; }
|
||||
if is_odd(n) && length_is_even(some_box(1)) { log_err "bloop"; }
|
||||
}
|
||||
|
||||
fn main() { foo(67, 5); }
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
// -*- rust -*-
|
||||
|
||||
fn some_vec(x: int) -> vec[int] { ret []; }
|
||||
fn some_box(x: int) -> @int { ret @x; }
|
||||
|
||||
fn is_odd(n: int) -> bool { ret true; }
|
||||
|
||||
fn length_is_even(vs: vec[int]) -> bool { ret true; }
|
||||
fn length_is_even(vs: @int) -> bool { ret true; }
|
||||
|
||||
fn foo(acc: int, n: int) {
|
||||
if is_odd(n) || length_is_even(some_vec(1)) { log_err "bloop"; }
|
||||
if is_odd(n) || length_is_even(some_box(1)) { log_err "bloop"; }
|
||||
}
|
||||
|
||||
fn main() { foo(67, 5); }
|
|
@ -6,7 +6,7 @@ fn main() {
|
|||
assert (i == 10);
|
||||
do { i += 1; if i == 20 { break; } } while i < 30
|
||||
assert (i == 20);
|
||||
for x: int in [1, 2, 3, 4, 5, 6] {
|
||||
for x: int in ~[1, 2, 3, 4, 5, 6] {
|
||||
if x == 3 { break; }
|
||||
assert (x <= 3);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ fn main() {
|
|||
while i < 10 { i += 1; if i % 2 == 0 { cont; } assert (i % 2 != 0); }
|
||||
i = 0;
|
||||
do { i += 1; if i % 2 == 0 { cont; } assert (i % 2 != 0); } while i < 10
|
||||
for x: int in [1, 2, 3, 4, 5, 6] {
|
||||
for x: int in ~[1, 2, 3, 4, 5, 6] {
|
||||
if x % 2 == 0 { cont; }
|
||||
assert (x % 2 != 0);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
|
||||
|
||||
fn main() { let v: vec[mutable int] = [mutable ]; }
|
||||
fn main() { let v: [mutable int] = ~[mutable ]; }
|
|
@ -4,7 +4,7 @@ fn test_simple() {
|
|||
}
|
||||
|
||||
fn test_box() {
|
||||
let r = alt true { true { [10] } false { fail } };
|
||||
let r = alt true { true { ~[10] } false { fail } };
|
||||
assert (r.(0) == 10);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ fn test_generic[T](expected: &T, eq: &compare[T]) {
|
|||
}
|
||||
|
||||
fn test_vec() {
|
||||
fn compare_vec(v1: &vec[int], v2: &vec[int]) -> bool { ret v1 == v2; }
|
||||
let eq = bind compare_vec(_, _);
|
||||
test_generic[vec[int]]([1, 2, 3], eq);
|
||||
fn compare_box(v1: &@int, v2: &@int) -> bool { ret v1 == v2; }
|
||||
let eq = bind compare_box(_, _);
|
||||
test_generic[@int](@1, eq);
|
||||
}
|
||||
|
||||
fn main() { test_vec(); }
|
|
@ -10,9 +10,9 @@ fn test_generic[T](expected: &T, eq: &compare[T]) {
|
|||
}
|
||||
|
||||
fn test_vec() {
|
||||
fn compare_vec(v1: &vec[int], v2: &vec[int]) -> bool { ret v1 == v2; }
|
||||
fn compare_vec(v1: &@int, v2: &@int) -> bool { ret v1 == v2; }
|
||||
let eq = bind compare_vec(_, _);
|
||||
test_generic[vec[int]]([1, 2], eq);
|
||||
test_generic[@int](@1, eq);
|
||||
}
|
||||
|
||||
fn main() { test_vec(); }
|
|
@ -1,2 +1,2 @@
|
|||
// Regression test for issue #388
|
||||
fn main() { let x = { { [10] } }; }
|
||||
fn main() { let x = { { @10 } }; }
|
|
@ -1,7 +1,7 @@
|
|||
// Make sure we drop the refs of the temporaries needed to return the
|
||||
// values from the else if branch
|
||||
fn main() {
|
||||
let y: vec[uint] = [10u];
|
||||
let y: @uint = @10u;
|
||||
let x = if false { y } else if (true) { y } else { y };
|
||||
assert (y.(0) == 10u);
|
||||
assert (y == 10u);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// Regression test for issue #388
|
||||
fn main() {
|
||||
let x = if false { [0u] } else if (true) { [10u] } else { [0u] };
|
||||
let x = if false { @0u } else if (true) { @10u } else { @0u };
|
||||
}
|
|
@ -4,7 +4,7 @@ fn test_int() {
|
|||
}
|
||||
|
||||
fn test_vec() {
|
||||
fn f() -> vec[int] { [10, 11] }
|
||||
fn f() -> [int] { ~[10, 11] }
|
||||
assert (f().(1) == 11);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ fn test_generic[T](expected: &T, not_expected: &T, eq: &compare[T]) {
|
|||
}
|
||||
|
||||
fn test_vec() {
|
||||
fn compare_vec(v1: &vec[int], v2: &vec[int]) -> bool { ret v1 == v2; }
|
||||
let eq = bind compare_vec(_, _);
|
||||
test_generic[vec[int]]([1, 2], [2, 3], eq);
|
||||
fn compare_box(v1: &@int, v2: &@int) -> bool { ret v1 == v2; }
|
||||
let eq = bind compare_box(_, _);
|
||||
test_generic[@int](@1, @2, eq);
|
||||
}
|
||||
|
||||
fn main() { test_vec(); }
|
|
@ -1 +1 @@
|
|||
fn main() { let x: vec[int] = []; for i: int in x { fail "moop"; } }
|
||||
fn main() { let x: [int] = ~[]; for i: int in x { fail "moop"; } }
|
|
@ -10,7 +10,7 @@ iter range(start: int, stop: int) -> int {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let a: vec[mutable int] = [mutable -1, -1, -1, -1, -1, -1, -1, -1];
|
||||
let a: [mutable int] = ~[mutable -1, -1, -1, -1, -1, -1, -1, -1];
|
||||
let p: int = 0;
|
||||
for each i: int in two() {
|
||||
for each j: int in range(0, 2) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
iter two() -> int { put 0; put 1; }
|
||||
|
||||
fn main() {
|
||||
let a: vec[mutable int] = [mutable -1, -1, -1, -1];
|
||||
let a: [mutable int] = ~[mutable -1, -1, -1, -1];
|
||||
let p: int = 0;
|
||||
for each i: int in two() {
|
||||
for each j: int in two() { a.(p) = 10 * i + j; p += 1; }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
// This is a testcase for issue #94.
|
||||
fn main() {
|
||||
let v: vec[int] = [0, 1, 2, 3, 4, 5];
|
||||
let v: [int] = ~[0, 1, 2, 3, 4, 5];
|
||||
let s: str = "abcdef";
|
||||
assert (v.(3u) == 3);
|
||||
assert (v.(3u8) == 3);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
|
||||
fn main() {
|
||||
let x = [1, 2, 3];
|
||||
let x = ~[1, 2, 3];
|
||||
let y = 0;
|
||||
for i: int in x { log i; y += i; }
|
||||
log y;
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
|
||||
// -*- rust -*-
|
||||
fn len(v: vec[mutable? int]) -> uint {
|
||||
fn len(v: [mutable? int]) -> uint {
|
||||
let i = 0u;
|
||||
for x: int in v { i += 1u; }
|
||||
ret i;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let v0 = [1, 2, 3, 4, 5];
|
||||
let v0 = ~[1, 2, 3, 4, 5];
|
||||
log len(v0);
|
||||
let v1 = [mutable 1, 2, 3, 4, 5];
|
||||
let v1 = ~[mutable 1, 2, 3, 4, 5];
|
||||
log len(v1);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
fn main() {
|
||||
// This just tests whether the vec leaks its members.
|
||||
let pvec: vec[mutable @{a: int, b: int}] =
|
||||
[mutable @{a: 1, b: 2}, @{a: 3, b: 4}, @{a: 5, b: 6}];
|
||||
let pvec: [mutable @{a: int, b: int}] =
|
||||
~[mutable @{a: 1, b: 2}, @{a: 3, b: 4}, @{a: 5, b: 6}];
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
tag myvec[X] = vec[X];
|
||||
tag myvec[X] = [X];
|
||||
|
||||
fn myvec_deref[X](mv: &myvec[X]) -> vec[X] { ret *mv; }
|
||||
fn myvec_deref[X](mv: &myvec[X]) -> [X] { ret *mv; }
|
||||
|
||||
fn myvec_elt[X](mv: &myvec[X]) -> X { ret mv.(0); }
|
||||
|
||||
fn main() {
|
||||
let mv = myvec([1, 2, 3]);
|
||||
let mv = myvec(~[1, 2, 3]);
|
||||
assert (myvec_deref(mv).(1) == 2);
|
||||
assert (myvec_elt(mv) == 1);
|
||||
assert (mv.(2) == 3);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
|
||||
fn main() {
|
||||
obj buf(data: vec[u8]) {
|
||||
obj buf(data: [u8]) {
|
||||
fn get(i: int) -> u8 { ret data.(i); }
|
||||
}
|
||||
let b = buf([1 as u8, 2 as u8, 3 as u8]);
|
||||
let b = buf(~[1 as u8, 2 as u8, 3 as u8]);
|
||||
log b.get(1);
|
||||
assert (b.get(1) == 2 as u8);
|
||||
}
|
|
@ -4,13 +4,13 @@ fn main() {
|
|||
assert ("hello" < "hellr");
|
||||
assert ("hello " > "hello");
|
||||
assert ("hello" != "there");
|
||||
assert ([1, 2, 3, 4] > [1, 2, 3]);
|
||||
assert ([1, 2, 3] < [1, 2, 3, 4]);
|
||||
assert ([1, 2, 4, 4] > [1, 2, 3, 4]);
|
||||
assert ([1, 2, 3, 4] < [1, 2, 4, 4]);
|
||||
assert ([1, 2, 3] <= [1, 2, 3]);
|
||||
assert ([1, 2, 3] <= [1, 2, 3, 3]);
|
||||
assert ([1, 2, 3, 4] > [1, 2, 3]);
|
||||
assert ([1, 2, 3] == [1, 2, 3]);
|
||||
assert ([1, 2, 3] != [1, 1, 3]);
|
||||
assert (~[1, 2, 3, 4] > ~[1, 2, 3]);
|
||||
assert (~[1, 2, 3] < ~[1, 2, 3, 4]);
|
||||
assert (~[1, 2, 4, 4] > ~[1, 2, 3, 4]);
|
||||
assert (~[1, 2, 3, 4] < ~[1, 2, 4, 4]);
|
||||
assert (~[1, 2, 3] <= ~[1, 2, 3]);
|
||||
assert (~[1, 2, 3] <= ~[1, 2, 3, 3]);
|
||||
assert (~[1, 2, 3, 4] > ~[1, 2, 3]);
|
||||
assert (~[1, 2, 3] == ~[1, 2, 3]);
|
||||
assert (~[1, 2, 3] != ~[1, 1, 3]);
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
// -*- rust -*-
|
||||
tag clam[T] { a(T, int); b; }
|
||||
|
||||
fn uhoh[T](v: vec[clam[T]]) {
|
||||
fn uhoh[T](v: &[clam[T]]) {
|
||||
alt v.(1) {
|
||||
a[T](t, u) { log "incorrect"; log u; fail; }
|
||||
b[T]. { log "correct"; }
|
||||
|
@ -12,6 +12,6 @@ fn uhoh[T](v: vec[clam[T]]) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let v: vec[clam[int]] = [b[int], b[int], a[int](42, 17)];
|
||||
let v: [clam[int]] = ~[b[int], b[int], a[int](42, 17)];
|
||||
uhoh[int](v);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
fn swap[@T](v: &vec[mutable T], i: int, j: int) { v.(i) <-> v.(j); }
|
||||
fn swap[@T](v: &[mutable T], i: int, j: int) { v.(i) <-> v.(j); }
|
||||
|
||||
fn main() {
|
||||
let a: vec[mutable int] = [mutable 0, 1, 2, 3, 4, 5, 6];
|
||||
let a: [mutable int] = ~[mutable 0, 1, 2, 3, 4, 5, 6];
|
||||
swap(a, 2, 4);
|
||||
assert (a.(2) == 4);
|
||||
assert (a.(4) == 2);
|
||||
|
|
|
@ -15,8 +15,8 @@ fn test00() {
|
|||
let number_of_tasks: int = 8;
|
||||
|
||||
let i: int = 0;
|
||||
let tasks: vec[task] = [];
|
||||
while i < number_of_tasks { i = i + 1; tasks += [spawn start(i)]; }
|
||||
let tasks: [task] = ~[];
|
||||
while i < number_of_tasks { i = i + 1; tasks += ~[spawn start(i)]; }
|
||||
|
||||
for t: task in tasks { task::join(t); }
|
||||
|
||||
|
|
|
@ -24,9 +24,10 @@ fn test00() {
|
|||
let i: int = 0;
|
||||
|
||||
// Create and spawn tasks...
|
||||
let tasks: vec[task] = [];
|
||||
let tasks: [task] = ~[];
|
||||
while i < number_of_tasks {
|
||||
tasks += [spawn test00_start(ch.unsafe_ptr(), i, number_of_messages)];
|
||||
tasks +=
|
||||
~[spawn test00_start(ch.unsafe_ptr(), i, number_of_messages)];
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@ fn test00() {
|
|||
|
||||
let i: int = 0;
|
||||
|
||||
let tasks: vec[task] = [];
|
||||
let tasks: [task] = ~[];
|
||||
while i < number_of_tasks {
|
||||
i = i + 1;
|
||||
tasks += [spawn test00_start(ch, i, number_of_messages)];
|
||||
tasks += ~[spawn test00_start(ch, i, number_of_messages)];
|
||||
}
|
||||
|
||||
let sum: int = 0;
|
||||
|
@ -132,8 +132,9 @@ fn test06() {
|
|||
|
||||
let i: int = 0;
|
||||
|
||||
let tasks: vec[task] = [];
|
||||
while i < number_of_tasks { i = i + 1; tasks += [spawn test06_start(i)]; }
|
||||
let tasks: [task] = ~[];
|
||||
while i < number_of_tasks {
|
||||
i = i + 1; tasks += ~[spawn test06_start(i)]; }
|
||||
|
||||
|
||||
for t: task in tasks { task::join(t); }
|
||||
|
|
|
@ -5,8 +5,8 @@ iter range(lo: uint, hi: uint) -> uint {
|
|||
while lo_ < hi { put lo_; lo_ += 1u; }
|
||||
}
|
||||
|
||||
fn create_index[T](index: vec[{a: T, b: uint}], hash_fn: fn(&T) -> uint ) {
|
||||
for each i: uint in range(0u, 256u) { let bucket: vec[T] = []; }
|
||||
fn create_index[T](index: &[{a: T, b: uint}], hash_fn: fn(&T) -> uint ) {
|
||||
for each i: uint in range(0u, 256u) { let bucket: [T] = ~[]; }
|
||||
}
|
||||
|
||||
fn main() { }
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
// -*- rust -*-
|
||||
fn main() {
|
||||
let a: vec[int] = [1, 2, 3, 4, 5];
|
||||
let b: vec[int] = [6, 7, 8, 9, 0];
|
||||
let v: vec[int] = a + b;
|
||||
let a: [int] = ~[1, 2, 3, 4, 5];
|
||||
let b: [int] = ~[6, 7, 8, 9, 0];
|
||||
let v: [int] = a + b;
|
||||
log v.(9);
|
||||
assert (v.(0) == 1);
|
||||
assert (v.(7) == 8);
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
fn main() {
|
||||
// This just tests whether the vec leaks its members.
|
||||
|
||||
let pvec: vec[@{x: int, y: int}] =
|
||||
[@{x: 1, y: 2}, @{x: 3, y: 4}, @{x: 5, y: 6}];
|
||||
let pvec: [@{x: int, y: int}] =
|
||||
~[@{x: 1, y: 2}, @{x: 3, y: 4}, @{x: 5, y: 6}];
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
|
||||
fn main() {
|
||||
let v = [1];
|
||||
v += [2];
|
||||
v += [3];
|
||||
v += [4];
|
||||
v += [5];
|
||||
let v = ~[1];
|
||||
v += ~[2];
|
||||
v += ~[3];
|
||||
v += ~[4];
|
||||
v += ~[5];
|
||||
assert (v.(0) == 1);
|
||||
assert (v.(1) == 2);
|
||||
assert (v.(2) == 3);
|
||||
|
|
|
@ -1 +1 @@
|
|||
fn main() { let a = ~[1, 2, 3, 4, 5]; let b = [a, a]; b += b; }
|
||||
fn main() { let a = ~[1, 2, 3, 4, 5]; let b = ~[a, a]; b += b; }
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
|
||||
fn main() {
|
||||
let later: vec[int];
|
||||
if true { later = [1]; } else { later = [2]; }
|
||||
let later: [int];
|
||||
if true { later = ~[1]; } else { later = ~[2]; }
|
||||
log later.(0);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
|
||||
fn push[T](v: &mutable vec[mutable? T], t: &T) { v += [t]; }
|
||||
fn push[T](v: &mutable [mutable? T], t: &T) { v += ~[t]; }
|
||||
|
||||
fn main() { let v = [1, 2, 3]; push(v, 1); }
|
||||
fn main() { let v = ~[1, 2, 3]; push(v, 1); }
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
// -*- rust -*-
|
||||
fn main() {
|
||||
let v: vec[int] = [10, 20];
|
||||
let v: [int] = ~[10, 20];
|
||||
assert (v.(0) == 10);
|
||||
assert (v.(1) == 20);
|
||||
let x: int = 0;
|
||||
|
|
|
@ -1 +1 @@
|
|||
fn main() { let quux: @vec[uint] = @[]; }
|
||||
fn main() { let quux: @[uint] = @~[]; }
|
|
@ -8,8 +8,8 @@ fn main() {
|
|||
log i;
|
||||
i = i + 1;
|
||||
if i == 95 {
|
||||
let v: vec[int] =
|
||||
[1, 2, 3, 4, 5]; // we check that it is freed by break
|
||||
let v: [int] =
|
||||
~[1, 2, 3, 4, 5]; // we check that it is freed by break
|
||||
|
||||
log "breaking";
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue