2020-08-14 23:36:18 -04:00
|
|
|
# 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
|
2020-08-18 01:36:39 -04:00
|
|
|
assert_match(/test_backtrace/, backtrace[0])
|
2020-08-14 23:36:18 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_backtrace_locations
|
|
|
|
backtrace = Fiber.current.backtrace_locations
|
|
|
|
assert_kind_of Array, backtrace
|
2020-08-18 01:36:39 -04:00
|
|
|
assert_match(/test_backtrace_locations/, backtrace[1].label)
|
2020-08-14 23:36:18 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_local_backtrace
|
|
|
|
backtrace = Fiber.current.backtrace(2)
|
|
|
|
assert_equal backtrace, caller
|
|
|
|
end
|
|
|
|
end
|