public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  tromey/operator-new-delete: update README.archer
@ 2013-03-13 19:34 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2013-03-13 19:34 UTC (permalink / raw)
  To: archer-commits

The branch, tromey/operator-new-delete has been updated
       via  46e210c07d4ffe7e7885032ac005bec2545c36f0 (commit)
       via  af09cb52a2d6771475b1bc116ecacccb50b115c7 (commit)
      from  fa32dc9d2276dd1602b2c296f768ffb533232ab3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 46e210c07d4ffe7e7885032ac005bec2545c36f0
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Mar 13 13:33:38 2013 -0600

    update README.archer

commit af09cb52a2d6771475b1bc116ecacccb50b115c7
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Mar 13 13:33:07 2013 -0600

    add test to count number of destructor invocations

-----------------------------------------------------------------------

Summary of changes:
 README.archer                |    3 ---
 gdb/testsuite/gdb.cp/new.cc  |    9 +++++++++
 gdb/testsuite/gdb.cp/new.exp |   36 +++++++++++++++++++-----------------
 3 files changed, 28 insertions(+), 20 deletions(-)

First 500 lines of diff:
diff --git a/README.archer b/README.archer
index 6dfb9a9..32cd4c7 100644
--- a/README.archer
+++ b/README.archer
@@ -18,6 +18,3 @@ It is incomplete:
 * syntax for calling a destructor explicitly
   do we need to handle this specially?
   cannot be used with an implicit "this", must always be qualified
-* needs a test for the number of times a destructor is called for
-  arrays (don't need this for constructor since we can just print the
-  array and see)
diff --git a/gdb/testsuite/gdb.cp/new.cc b/gdb/testsuite/gdb.cp/new.cc
index 9b78e25..99fa5f5 100644
--- a/gdb/testsuite/gdb.cp/new.cc
+++ b/gdb/testsuite/gdb.cp/new.cc
@@ -21,6 +21,9 @@ enum what_operator
 
 int whatop = WHATOP_INVALID;
 
+// Number of times a destructor is invoked.
+int dcount;
+
 void *operator new (std::size_t size)
 {
   whatop = WHATOP_GLOBAL;
@@ -50,6 +53,7 @@ struct Simple
   int x;
   Simple() : x (7) { }
   Simple (int y) : x (y) { }
+  ~Simple() { ++dcount; }
 };
 
 struct Derived : public Simple
@@ -133,6 +137,7 @@ struct Base
 
   virtual ~Base()
   {
+    ++dcount;
   }
 };
 
@@ -146,6 +151,7 @@ struct DerivedFromBase : public Base
 
   ~DerivedFromBase()
   {
+    ++dcount;
   }
 };
 
@@ -157,6 +163,7 @@ struct VDerived : public virtual Base
 
   ~VDerived()
   {
+    ++dcount;
   }
 };
 
@@ -168,6 +175,7 @@ struct VDerived2 : public VDerived, public virtual Base
 
   ~VDerived2()
   {
+    ++dcount;
   }
 };
 
@@ -179,6 +187,7 @@ int keep_stuff ()
   delete new Base;
   delete new VDerived;
   delete new VDerived2;
+  delete new Simple;
 }
 
 int main ()
diff --git a/gdb/testsuite/gdb.cp/new.exp b/gdb/testsuite/gdb.cp/new.exp
index d292b94..54e1b4d 100644
--- a/gdb/testsuite/gdb.cp/new.exp
+++ b/gdb/testsuite/gdb.cp/new.exp
@@ -32,22 +32,22 @@ if ![runto_main] then {
 gdb_breakpoint [gdb_get_line_number "Stop here"]
 gdb_continue_to_breakpoint Stop
 
-set op_count 0
-
-proc check_op {name value} {
-    global op_count
-
-    gdb_test "print whatop == ($value)" " = true" "check settings - $name"
-
-    # For debugging.
-    # gdb_test "print (enum what_operator) whatop" " = .*" \
-    # 	"debug print whatop #$op_count"
-
-    # Mildly lame that this ends up in the test results.
-    gdb_test_no_output "set variable whatop = WHATOP_INVALID" \
-	"reset whatop #$op_count"
-
-    incr op_count
+proc check_op {name value {dcount ""}} {
+    with_test_prefix $name {
+	gdb_test "print whatop == ($value)" " = true" "check settings"
+
+	if {$dcount != ""} {
+	    gdb_test "print dcount" " = $dcount" "check destructor count"
+	}
+
+	# For debugging.
+	# gdb_test "print (enum what_operator) whatop" " = .*" \
+	#     "debug print whatop"
+
+	# Mildly lame that these end up in the test results.
+	gdb_test_no_output "set variable whatop = WHATOP_INVALID" "reset whatop"
+	gdb_test_no_output "set variable dcount = 0" "reset dcount"
+    }
 }
 
 gdb_test "print \$an_int = new int" " = .int .. $hex"
@@ -138,7 +138,9 @@ gdb_test "print delete \$simple" " = void"
 check_op "delete Simple" {WHATOP_GLOBAL | WHATOP_DELETE}
 
 gdb_test "print delete\[\] \$simple_array" " = void"
-check_op "delete Simple array" {WHATOP_GLOBAL | WHATOP_DELETE | WHATOP_ARRAY}
+check_op "delete Simple array" \
+    {WHATOP_GLOBAL | WHATOP_DELETE | WHATOP_ARRAY} \
+    7
 
 gdb_test "print delete \$derived" " = void"
 check_op "delete Derived" {WHATOP_GLOBAL | WHATOP_DELETE}


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-03-13 19:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-13 19:34 [SCM] tromey/operator-new-delete: update README.archer tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).