about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@gmail>2013-08-23 18:45:02 +0200
committerMichael Woerister <michaelwoerister@gmail>2013-09-04 18:38:46 +0200
commitb81ea86530dfd9dff69815b099ba10be274830ea (patch)
tree157b642e9a6d196adf91f9bc3358d514193e6c8e /src/test
parent67555d9bd40a36d93e193fe2d178713481ad445e (diff)
downloadrust-b81ea86530dfd9dff69815b099ba10be274830ea.tar.gz
rust-b81ea86530dfd9dff69815b099ba10be274830ea.zip
debuginfo: Support for variables captured in closures and closure type descriptions.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/debug-info/var-captured-in-managed-closure.rs58
-rw-r--r--src/test/debug-info/var-captured-in-sendable-closure.rs56
-rw-r--r--src/test/debug-info/var-captured-in-stack-closure.rs61
3 files changed, 175 insertions, 0 deletions
diff --git a/src/test/debug-info/var-captured-in-managed-closure.rs b/src/test/debug-info/var-captured-in-managed-closure.rs
new file mode 100644
index 00000000000..37f5fef471b
--- /dev/null
+++ b/src/test/debug-info/var-captured-in-managed-closure.rs
@@ -0,0 +1,58 @@
+// Copyright 2013 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.
+
+// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
+
+// compile-flags:-Z extra-debug-info
+// debugger:break zzz
+// debugger:run
+// debugger:finish
+
+// debugger:print constant
+// check:$1 = 1
+// debugger:print a_struct
+// check:$2 = {a = -2, b = 3.5, c = 4}
+// debugger:print *owned
+// check:$3 = 5
+// debugger:print managed->val
+// check:$4 = 6
+
+#[allow(unused_variable)];
+
+struct Struct {
+    a: int,
+    b: float,
+    c: uint
+}
+
+fn main() {
+    let constant = 1;
+
+    let a_struct = Struct {
+        a: -2,
+        b: 3.5,
+        c: 4
+    };
+
+    let owned = ~5;
+    let managed = @6;
+
+    let closure: @fn() = || {
+        zzz();
+        do_something(&constant, &a_struct.a, owned, managed);
+    };
+
+    closure();
+}
+
+fn do_something(_: &int, _:&int, _:&int, _:&int) {
+}
+
+fn zzz() {()}
diff --git a/src/test/debug-info/var-captured-in-sendable-closure.rs b/src/test/debug-info/var-captured-in-sendable-closure.rs
new file mode 100644
index 00000000000..c4568bd592f
--- /dev/null
+++ b/src/test/debug-info/var-captured-in-sendable-closure.rs
@@ -0,0 +1,56 @@
+// Copyright 2013 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.
+
+// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
+
+// compile-flags:-Z extra-debug-info
+// debugger:break zzz
+// debugger:run
+// debugger:finish
+
+// debugger:print constant
+// check:$1 = 1
+// debugger:print a_struct
+// check:$2 = {a = -2, b = 3.5, c = 4}
+// debugger:print *owned
+// check:$3 = 5
+
+#[allow(unused_variable)];
+
+struct Struct {
+    a: int,
+    b: float,
+    c: uint
+}
+
+fn main() {
+    let constant = 1;
+
+    let a_struct = Struct {
+        a: -2,
+        b: 3.5,
+        c: 4
+    };
+
+    let owned = ~5;
+
+    let closure: ~fn() = || {
+        zzz();
+        do_something(&constant, &a_struct.a, owned);
+    };
+
+    closure();
+}
+
+fn do_something(_: &int, _:&int, _:&int) {
+
+}
+
+fn zzz() {()}
diff --git a/src/test/debug-info/var-captured-in-stack-closure.rs b/src/test/debug-info/var-captured-in-stack-closure.rs
new file mode 100644
index 00000000000..6694d5111a8
--- /dev/null
+++ b/src/test/debug-info/var-captured-in-stack-closure.rs
@@ -0,0 +1,61 @@
+// Copyright 2013 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.
+
+// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
+
+// compile-flags:-Z extra-debug-info
+// debugger:break zzz
+// debugger:run
+// debugger:finish
+
+// debugger:print variable
+// check:$1 = 1
+// debugger:print constant
+// check:$2 = 2
+// debugger:print a_struct
+// check:$3 = {a = -3, b = 4.5, c = 5}
+// debugger:print *struct_ref
+// check:$4 = {a = -3, b = 4.5, c = 5}
+// debugger:print *owned
+// check:$5 = 6
+// debugger:print managed->val
+// check:$6 = 7
+
+#[allow(unused_variable)];
+
+struct Struct {
+    a: int,
+    b: float,
+    c: uint
+}
+
+fn main() {
+    let mut variable = 1;
+    let constant = 2;
+
+    let a_struct = Struct {
+        a: -3,
+        b: 4.5,
+        c: 5
+    };
+
+    let struct_ref = &a_struct;
+    let owned = ~6;
+    let managed = @7;
+
+    let closure = || {
+        zzz();
+        variable = constant + a_struct.a + struct_ref.a + *owned + *managed;
+    };
+
+    closure();
+}
+
+fn zzz() {()}