Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 2/2][PR gdb/20239] Add tests for printing of NonZero-optimized enums in Rust
@ 2016-06-21  9:42 Manish Goregaokar
  2016-06-22 19:11 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Manish Goregaokar @ 2016-06-21  9:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Continuing discussion from
https://sourceware.org/bugzilla/show_bug.cgi?id=20239, I'm not sure if
it's worth it to have a test that inspects the entire output, since
the internals of the String type may change in the future. Did you
mean something else?


gdb/testsuite/ChangeLog:
2016-06-21  Manish Goregaokar  <manish@mozilla.com>

    PR gdb/20239
    * gdb.rust/simple.rs: Add more tests for printing NonZero enums.
    * gdb.rust/simple.exp: Add test expectations for new NonZero tests.
---
 gdb/testsuite/gdb.rust/simple.exp | 11 +++++++++++
 gdb/testsuite/gdb.rust/simple.rs  | 17 +++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/gdb/testsuite/gdb.rust/simple.exp
b/gdb/testsuite/gdb.rust/simple.exp
index a4a2190..88f1c89 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -169,6 +169,17 @@ gdb_test "print ..5" " = .*::ops::RangeTo.* \\{end: 5\\}"
 gdb_test "print 5.." " = .*::ops::RangeFrom.* \\{start: 5\\}"
 gdb_test "print .." " = .*::ops::RangeFull"

+gdb_test "print str_some" \
+    " = core::option::Option<collections::string::String>::Some\\(collections::string::String
.*"
+gdb_test "print str_none" " =
core::option::Option<collections::string::String>::None"
+gdb_test "print int_some" " = core::option::Option::Some\\(1\\)"
+gdb_test "print int_none" " = core::option::Option::None"
+gdb_test "print box_some" " = core::option::Option<Box<u8>>::Some\\(.*\\)"
+gdb_test "print box_none" " = core::option::Option<Box<u8>>::None"
+gdb_test "print custom_some" \
+    " = simple::NonZeroOptimized::Value\\(collections::string::String .*"
+gdb_test "print custom_none" " = simple::NonZeroOptimized::Empty"
+
 proc test_one_slice {svar length base range} {
     global hex

diff --git a/gdb/testsuite/gdb.rust/simple.rs b/gdb/testsuite/gdb.rust/simple.rs
index 6d6395a..32da580 100644
--- a/gdb/testsuite/gdb.rust/simple.rs
+++ b/gdb/testsuite/gdb.rust/simple.rs
@@ -38,6 +38,12 @@ enum MoreComplicated {
     Four{this: bool, is: u8, a: char, struct_: u64, variant: u32},
 }

+// tests the nonzero optimization, but fields are reversed
+enum NonZeroOptimized {
+    Empty,
+    Value(String),
+}
+
 fn diff2(x: i32, y: i32) -> i32 {
     x - y
 }
@@ -92,6 +98,17 @@ fn main () {
     let to1 = &w[..3];
     let to2 = &slice[..1];

+    // tests for enum optimizations
+
+    let str_some = Some("hi".to_string());
+    let str_none = None::<String>;
+    let box_some = Some(Box::new(1u8));
+    let box_none = None::<Box<u8>>;
+    let int_some = Some(1u8);
+    let int_none = None::<u8>;
+    let custom_some = NonZeroOptimized::Value("hi".into());
+    let custom_none = NonZeroOptimized::Empty;
+
     println!("{}, {}", x.0, x.1);        // set breakpoint here
     println!("{}", diff2(92, 45));
 }
-- 
2.8.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2][PR gdb/20239] Add tests for printing of NonZero-optimized enums in Rust
  2016-06-21  9:42 [PATCH 2/2][PR gdb/20239] Add tests for printing of NonZero-optimized enums in Rust Manish Goregaokar
@ 2016-06-22 19:11 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2016-06-22 19:11 UTC (permalink / raw)
  To: Manish Goregaokar; +Cc: gdb-patches, Tom Tromey

>>>>> "Manish" == Manish Goregaokar <manish@mozilla.com> writes:

Manish> Continuing discussion from
Manish> https://sourceware.org/bugzilla/show_bug.cgi?id=20239, I'm not sure if
Manish> it's worth it to have a test that inspects the entire output, since
Manish> the internals of the String type may change in the future. Did you
Manish> mean something else?

Actually it just wasn't clear to me if the test case in question was "as
complicated" as the code inspiring the original report.  But it probably
doesn't matter.

Manish> gdb/testsuite/ChangeLog:
Manish> 2016-06-21  Manish Goregaokar  <manish@mozilla.com>

Manish>     PR gdb/20239
Manish>     * gdb.rust/simple.rs: Add more tests for printing NonZero enums.
Manish>     * gdb.rust/simple.exp: Add test expectations for new NonZero tests.

Thank you.  This patch is ok.

Tom


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-22 19:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-21  9:42 [PATCH 2/2][PR gdb/20239] Add tests for printing of NonZero-optimized enums in Rust Manish Goregaokar
2016-06-22 19:11 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox