From 0a218a97ad31f06eb7f59ccdd428fd46c4b93982 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 15 Aug 2020 15:36:18 +1200 Subject: Expose ec -> backtrace (internal) and use it to implement fiber backtrace. See for more details. --- test/fiber/test_backtrace.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/fiber/test_backtrace.rb (limited to 'test/fiber/test_backtrace.rb') diff --git a/test/fiber/test_backtrace.rb b/test/fiber/test_backtrace.rb new file mode 100644 index 0000000000..2d637c09c8 --- /dev/null +++ b/test/fiber/test_backtrace.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +require 'test/unit' +require 'fiber' + +class TestFiberBacktrace < Test::Unit::TestCase + def test_backtrace + backtrace = Fiber.current.backtrace + assert_kind_of Array, backtrace + assert_match /test_backtrace/, backtrace[0] + end + + def test_backtrace_locations + backtrace = Fiber.current.backtrace_locations + assert_kind_of Array, backtrace + assert_match /test_backtrace_locations/, backtrace[1].label + end + + def test_local_backtrace + backtrace = Fiber.current.backtrace(2) + assert_equal backtrace, caller + end +end -- cgit v1.2.3