]> git.lizzy.rs Git - rust.git/commitdiff
Tweak test name and make it more specific
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 10 Feb 2014 11:24:32 +0000 (06:24 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 11 Feb 2014 16:38:42 +0000 (11:38 -0500)
src/test/run-pass/cleanup-rvalue-during-if-and-while.rs [new file with mode: 0644]
src/test/run-pass/temporary-lifetime-for-conditions.rs [deleted file]

diff --git a/src/test/run-pass/cleanup-rvalue-during-if-and-while.rs b/src/test/run-pass/cleanup-rvalue-during-if-and-while.rs
new file mode 100644 (file)
index 0000000..1ae9070
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright 2014 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.
+
+
+// This test verifies that temporaries created for `while`'s and `if`
+// conditions are dropped after the condition is evaluated.
+
+struct Temporary;
+
+static mut DROPPED: int = 0;
+
+impl Drop for Temporary {
+    fn drop(&mut self) {
+        unsafe { DROPPED += 1; }
+    }
+}
+
+impl Temporary {
+    fn do_stuff(&self) -> bool {true}
+}
+
+fn borrow() -> ~Temporary { ~Temporary }
+
+
+pub fn main() {
+    let mut i = 0;
+
+    // This loop's condition
+    // should call `Temporary`'s
+    // `drop` 6 times.
+    while borrow().do_stuff() {
+        i += 1;
+        unsafe { assert_eq!(DROPPED, i) }
+        if i > 5 {
+            break;
+        }
+    }
+
+    // This if condition should
+    // call it 1 time
+    if borrow().do_stuff() {
+        unsafe { assert_eq!(DROPPED, i + 1) }
+    }
+}
diff --git a/src/test/run-pass/temporary-lifetime-for-conditions.rs b/src/test/run-pass/temporary-lifetime-for-conditions.rs
deleted file mode 100644 (file)
index 0716ea5..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2014 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.
-
-
-// This test verifies that temporaries created for `while`'s
-// and `if` conditions are correctly cleaned up.
-
-struct Temporary;
-
-static mut DROPPED: int = 0;
-
-impl Drop for Temporary {
-    fn drop(&mut self) {
-        unsafe { DROPPED += 1; }
-    }
-}
-
-impl Temporary {
-    fn do_stuff(&self) -> bool {true}
-}
-
-fn borrow() -> ~Temporary { ~Temporary }
-
-
-pub fn main() {
-    let mut i = 0;
-
-    // This loop's condition
-    // should call `Temporary`'s
-    // `drop` 6 times.
-    while borrow().do_stuff() {
-        i += 1;
-        if i > 5 {
-            break;
-        }
-    }
-
-    // This if condition should
-    // call it 1 time
-    if borrow().do_stuff() {
-        unsafe { assert_eq!(DROPPED, 7) }
-    }
-}