From 1d1c502dd4727401865258fe60b4f858947c40a0 Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Fri, 10 May 2013 15:51:34 +0900 Subject: [PATCH] Add vec.rs each2_mut testsuite --- src/test/run-pass/vec-each2_mut.rs | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/test/run-pass/vec-each2_mut.rs diff --git a/src/test/run-pass/vec-each2_mut.rs b/src/test/run-pass/vec-each2_mut.rs new file mode 100644 index 00000000000..3c6b7da9f14 --- /dev/null +++ b/src/test/run-pass/vec-each2_mut.rs @@ -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 or the MIT license +// , 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)); + } +}