about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@gmail>2013-07-02 18:10:24 +0200
committerMichael Woerister <michaelwoerister@gmail>2013-07-19 07:55:24 +0200
commitf389bd8f2a72020c25e37b81757643abd481bc11 (patch)
tree670ed90cdb00198a61b731b6e5a721985bf20511 /src/test
parent739f3eece9c341f4f1e70b8a0417853ed2a09cbc (diff)
debuginfo: Support for tuple-style enums (WIP)
Diffstat (limited to 'src/test')
-rw-r--r--src/test/debug-info/c-style-enum.rs12
-rw-r--r--src/test/debug-info/nil-enum.rs38
-rw-r--r--src/test/debug-info/tuple-style-enum.rs33
3 files changed, 81 insertions, 2 deletions
diff --git a/src/test/debug-info/c-style-enum.rs b/src/test/debug-info/c-style-enum.rs
index 408e9810266..3071cb2d326 100644
--- a/src/test/debug-info/c-style-enum.rs
+++ b/src/test/debug-info/c-style-enum.rs
@@ -31,19 +31,25 @@
 // debugger:print manual_one_million
 // check:$6 = OneMillion
 
+// debugger:print single_variant
+// check:$7 = TheOnlyVariant
 
-enum AutoDiscriminator {
+enum AutoDiscriminant {
     One,
     Two,
     Three
 }
 
-enum ManualDiscriminator {
+enum ManualDiscriminant {
     OneHundred = 100,
     OneThousand = 1000,
     OneMillion = 1000000
 }
 
+enum SingleVariant {
+    TheOnlyVariant
+}
+
 fn main() {
 
     let auto_one = One;
@@ -54,6 +60,8 @@ fn main() {
     let manual_one_thousand = OneThousand;
     let manual_one_million = OneMillion;
 
+    let single_variant = TheOnlyVariant;
+
     zzz();
 }
 
diff --git a/src/test/debug-info/nil-enum.rs b/src/test/debug-info/nil-enum.rs
new file mode 100644
index 00000000000..09f41ee9f42
--- /dev/null
+++ b/src/test/debug-info/nil-enum.rs
@@ -0,0 +1,38 @@
+// 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.
+
+// compile-flags:-Z extra-debug-info
+// debugger:break zzz
+// debugger:run
+// debugger:finish
+
+// debugger:print first
+// check:$1 = {<No data fields>}
+
+// debugger:print second
+// check:$2 = {<No data fields>}
+
+enum ANilEnum {}
+enum AnotherNilEnum {}
+
+// I (mw) am not sure this test case makes much sense...
+// Also, it relies on some implementation details:
+// 1. That empty enums as well as '()' are represented as empty structs
+// 2. That gdb prints the string "{<No data fields>}" for empty structs (which may change some time)
+fn main() {
+    unsafe {
+        let first : ANilEnum = std::cast::transmute(());
+        let second : AnotherNilEnum = std::cast::transmute(());
+
+        zzz();
+    }
+}
+
+fn zzz() {()}
\ No newline at end of file
diff --git a/src/test/debug-info/tuple-style-enum.rs b/src/test/debug-info/tuple-style-enum.rs
new file mode 100644
index 00000000000..00144aa1bb5
--- /dev/null
+++ b/src/test/debug-info/tuple-style-enum.rs
@@ -0,0 +1,33 @@
+// 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.
+
+// compile-flags:-Z extra-debug-info
+// debugger:set print union on
+// debugger:break zzz
+// debugger:run
+// debugger:finish
+
+// debugger:print case2
+// check:$1 = {Case1, 0, 1}
+
+enum Test {
+    Case1(i32, i64),
+    Case2(bool, i16, i32)
+}
+
+fn main() {
+
+    let case1 = Case1(110, 220);
+    let case2 = Case2(false, 2, 3);
+
+    zzz();
+}
+
+fn zzz() {()}
\ No newline at end of file