aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/objspace/objspace.c5
-rw-r--r--test/objspace/test_objspace.rb4
3 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3d3cabd155..c4290f4481 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Mar 5 10:40:22 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/objspace/objspace.c (count_nodes): count also newly added nodes,
+ and fix key for unknown node. patch by tmm1 (Aman Gupta) in
+ [ruby-core:53130] [Bug #8014]
+
Tue Mar 5 10:20:16 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enumerator.c (enumerator_with_index_i): allow Bignum as offset, to
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index b8f524cb6f..5857327f21 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -469,6 +469,7 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_OP_ASGN2);
COUNT_NODE(NODE_OP_ASGN_AND);
COUNT_NODE(NODE_OP_ASGN_OR);
+ COUNT_NODE(NODE_OP_CDECL);
COUNT_NODE(NODE_CALL);
COUNT_NODE(NODE_FCALL);
COUNT_NODE(NODE_VCALL);
@@ -502,6 +503,7 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_ARGS);
COUNT_NODE(NODE_ARGS_AUX);
COUNT_NODE(NODE_OPT_ARG);
+ COUNT_NODE(NODE_KW_ARG);
COUNT_NODE(NODE_POSTARG);
COUNT_NODE(NODE_ARGSCAT);
COUNT_NODE(NODE_ARGSPUSH);
@@ -519,6 +521,7 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_SCLASS);
COUNT_NODE(NODE_COLON2);
COUNT_NODE(NODE_COLON3);
+ COUNT_NODE(NODE_CREF);
COUNT_NODE(NODE_DOT2);
COUNT_NODE(NODE_DOT3);
COUNT_NODE(NODE_FLIP2);
@@ -539,7 +542,7 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_PRELUDE);
COUNT_NODE(NODE_LAMBDA);
#undef COUNT_NODE
- default: node = INT2FIX(nodes[i]);
+ default: node = INT2FIX(i);
}
rb_hash_aset(hash, node, SIZET2NUM(nodes[i]));
}
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index 136f7e8318..2f8503fcee 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -58,7 +58,9 @@ class TestObjSpace < Test::Unit::TestCase
assert_equal(false, res.empty?)
arg = {}
ObjectSpace.count_nodes(arg)
- assert_equal(false, arg.empty?)
+ assert_not_empty(arg)
+ bug8014 = '[ruby-core:53130] [Bug #8014]'
+ assert_empty(arg.select {|k, v| !(Symbol === k && Integer === v)}, bug8014)
end
def test_count_tdata_objects