[前][次][番号順一覧][スレッド一覧]

ruby-changes:12849

From: mame <ko1@a...>
Date: Wed, 19 Aug 2009 02:55:47 +0900 (JST)
Subject: [ruby-changes:12849] Ruby:r24581 (trunk): * test/ruby/test_settracefunc.rb (test_return, test_return2): add two

mame	2009-08-19 02:55:26 +0900 (Wed, 19 Aug 2009)

  New Revision: 24581

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24581

  Log:
    * test/ruby/test_settracefunc.rb (test_return, test_return2): add two
      tests for [ruby-dev:38701] and [ruby-core:24463].

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_settracefunc.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24580)
+++ ChangeLog	(revision 24581)
@@ -1,3 +1,8 @@
+Wed Aug 19 02:54:01 2009  Yusuke Endoh  <mame@t...>
+
+	* test/ruby/test_settracefunc.rb (test_return, test_return2): add two
+	  tests for [ruby-dev:38701] and [ruby-core:24463].
+
 Wed Aug 19 01:08:34 2009  Yusuke Endoh  <mame@t...>
 
 	* compile.c (NODE_RETURN): fire return event at explicit return.
Index: test/ruby/test_settracefunc.rb
===================================================================
--- test/ruby/test_settracefunc.rb	(revision 24580)
+++ test/ruby/test_settracefunc.rb	(revision 24581)
@@ -129,6 +129,89 @@
     assert_equal([], events)
   end
 
+  def test_return # [ruby-dev:38701]
+    events = []
+    eval <<-EOF.gsub(/^.*?: /, "")
+     1: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass|
+     2:   events << [event, lineno, mid, klass]
+     3: })
+     4: def foo(a)
+     5:   return if a
+     6:   return
+     7: end
+     8: foo(true)
+     9: foo(false)
+    10: set_trace_func(nil)
+    EOF
+    assert_equal(["c-return", 3, :set_trace_func, Kernel],
+                 events.shift)
+    assert_equal(["line", 4, __method__, self.class],
+                 events.shift)
+    assert_equal(["c-call", 4, :method_added, Module],
+                 events.shift)
+    assert_equal(["c-return", 4, :method_added, Module],
+                 events.shift)
+    assert_equal(["line", 8, __method__, self.class],
+                 events.shift)
+    assert_equal(["call", 4, :foo, self.class],
+                 events.shift)
+    assert_equal(["line", 5, :foo, self.class],
+                 events.shift)
+    assert_equal(["return", 5, :foo, self.class],
+                 events.shift)
+    assert_equal(["line", 9, :test_return, self.class],
+                 events.shift)
+    assert_equal(["call", 4, :foo, self.class],
+                 events.shift)
+    assert_equal(["line", 5, :foo, self.class],
+                 events.shift)
+    assert_equal(["return", 7, :foo, self.class],
+                 events.shift)
+    assert_equal(["line", 10, :test_return, self.class],
+                 events.shift)
+    assert_equal(["c-call", 10, :set_trace_func, Kernel],
+                 events.shift)
+    assert_equal([], events)
+  end
+
+  def test_return2 # [ruby-core:24463]
+    events = []
+    eval <<-EOF.gsub(/^.*?: /, "")
+     1: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass|
+     2:   events << [event, lineno, mid, klass]
+     3: })
+     4: def foo
+     5:   a = 5
+     6:   return a
+     7: end
+     8: foo
+     9: set_trace_func(nil)
+    EOF
+    assert_equal(["c-return", 3, :set_trace_func, Kernel],
+                 events.shift)
+    assert_equal(["line", 4, __method__, self.class],
+                 events.shift)
+    assert_equal(["c-call", 4, :method_added, Module],
+                 events.shift)
+    assert_equal(["c-return", 4, :method_added, Module],
+                 events.shift)
+    assert_equal(["line", 8, __method__, self.class],
+                 events.shift)
+    assert_equal(["call", 4, :foo, self.class],
+                 events.shift)
+    assert_equal(["line", 5, :foo, self.class],
+                 events.shift)
+    assert_equal(["line", 6, :foo, self.class],
+                 events.shift)
+    assert_equal(["return", 7, :foo, self.class],
+                 events.shift)
+    assert_equal(["line", 9, :test_return2, self.class],
+                 events.shift)
+    assert_equal(["c-call", 9, :set_trace_func, Kernel],
+                 events.shift)
+    assert_equal([], events)
+  end
+
   def test_raise
     events = []
     eval <<-EOF.gsub(/^.*?: /, "")

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]