File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -44,13 +44,11 @@ module Mutex_m
44
44
Ractor . make_shareable ( VERSION ) if defined? ( Ractor )
45
45
46
46
def Mutex_m . define_aliases ( cl ) # :nodoc:
47
- cl . module_eval %q{
48
- alias locked? mu_locked?
49
- alias lock mu_lock
50
- alias unlock mu_unlock
51
- alias try_lock mu_try_lock
52
- alias synchronize mu_synchronize
53
- }
47
+ cl . alias_method ( :locked? , :mu_locked? )
48
+ cl . alias_method ( :lock , :mu_lock )
49
+ cl . alias_method ( :unlock , :mu_unlock )
50
+ cl . alias_method ( :try_lock , :mu_try_lock )
51
+ cl . alias_method ( :synchronize , :mu_synchronize )
54
52
end
55
53
56
54
def Mutex_m . append_features ( cl ) # :nodoc:
Original file line number Diff line number Diff line change @@ -55,4 +55,25 @@ def initialize
55
55
def test_initialize_no_args
56
56
assert NoArgInitializeChild . new
57
57
end
58
+
59
+ def test_alias_extended_object
60
+ object = Object . new
61
+ object . extend ( Mutex_m )
62
+
63
+ assert object . respond_to? ( :locked? )
64
+ assert object . respond_to? ( :lock )
65
+ assert object . respond_to? ( :unlock )
66
+ assert object . respond_to? ( :try_lock )
67
+ assert object . respond_to? ( :synchronize )
68
+ end
69
+
70
+ def test_alias_included_class
71
+ object = NoArgInitializeChild . new
72
+
73
+ assert object . respond_to? ( :locked? )
74
+ assert object . respond_to? ( :lock )
75
+ assert object . respond_to? ( :unlock )
76
+ assert object . respond_to? ( :try_lock )
77
+ assert object . respond_to? ( :synchronize )
78
+ end
58
79
end
You can’t perform that action at this time.
0 commit comments