| 1 |
# frozen_string_literal: true |
| 2 |
require 'test/unit' |
| 3 |
|
| 4 |
class Test_Load_stringify_symbols < Test::Unit::TestCase |
| 5 |
def test_load_stringify_symbol_required_extensions |
| 6 |
require '-test-/load/stringify_symbols' |
| 7 |
require '-test-/load/stringify_target' |
| 8 |
r1 = StringifySymbols.stringify_symbol("-test-/load/stringify_target", "stt_any_method") |
| 9 |
assert_not_nil r1 |
| 10 |
r2 = StringifySymbols.stringify_symbol("-test-/load/stringify_target.so", "stt_any_method") |
| 11 |
assert_equal r1, r2, "resolved symbols should be equal even with or without .so suffix" |
| 12 |
end |
| 13 |
|
| 14 |
def test_load_stringify_symbol_statically_linked |
| 15 |
require '-test-/load/stringify_symbols' |
| 16 |
# "complex.so" is actually not a statically linked extension. |
| 17 |
# But it is registered in $LOADED_FEATURES, so it can be a target of this test. |
| 18 |
r1 = StringifySymbols.stringify_symbol("complex", "rb_complex_minus") |
| 19 |
assert_not_nil r1 |
| 20 |
r2 = StringifySymbols.stringify_symbol("complex.so", "rb_complex_minus") |
| 21 |
assert_equal r1, r2 |
| 22 |
end |
| 23 |
|
| 24 |
def test_load_stringify_symbol_missing_target |
| 25 |
require '-test-/load/stringify_symbols' |
| 26 |
r1 = assert_nothing_raised { |
| 27 |
StringifySymbols.stringify_symbol("something_missing", "unknown_method") |
| 28 |
} |
| 29 |
assert_nil r1 |
| 30 |
r2 = assert_nothing_raised { |
| 31 |
StringifySymbols.stringify_symbol("complex.so", "unknown_method") |
| 32 |
} |
| 33 |
assert_nil r2 |
| 34 |
end |
| 35 |
end |