Skip to content

Commit

Permalink
Add vec.rs each2_mut testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
recrack committed May 13, 2013
1 parent 943b9d5 commit 1d1c502
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/test/run-pass/vec-each2_mut.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// -*- rust -*-
fn main(){
let mut t1 = ~[];
t1.push('a');

let mut t2 = ~[];
t2.push('b');

for vec::each2_mut(t1, t2) | i1, i2 | {
assert!(*i1 == 'a');
assert!(*i2 == 'b');
}

for vec::each2(t1, t2) | i1, i2 | {
io::println(fmt!("after t1: %?, t2: %?", i1, i2));
}

for vec::each2_mut(t1, t2) | i1, i2 | {
*i1 = 'b';
*i2 = 'a';
assert!(*i1 == 'b');
assert!(*i2 == 'a');
}

for vec::each2(t1, t2) | i1, i2 | {
io::println(fmt!("before t1: %?, t2: %?", i1, i2));
}
}

0 comments on commit 1d1c502

Please sign in to comment.