summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-05-11 16:32:00 -0700
committerJeremy Evans <code@jeremyevans.net>2019-05-30 18:34:45 -0700
commit1cd93f1cdfbe6f7e71b05b3f8e707f21d70e94ba (patch)
treea1741805f80749f90f35d21f0f646148b41dd610 /test
parent856593cc4972562d2ab0a59a61f38fe3a4a863ab (diff)
Allow DelegateClass() to module_eval given block
Methods that return classes often module_eval the given block (e.g. Class.new and Struct.new). This allows DelegateClass to work similarly. This makes it easier to use DelegateClass directly without subclassing, so as not to create an unnecessary subclass. Implements [Feature #15842]
Diffstat (limited to 'test')
-rw-r--r--test/test_delegate.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/test_delegate.rb b/test/test_delegate.rb
index ffc4d9527e..8ed3342afa 100644
--- a/test/test_delegate.rb
+++ b/test/test_delegate.rb
@@ -22,6 +22,13 @@ class TestDelegateClass < Test::Unit::TestCase
assert_equal(:m, obj.m, "[ruby-dev:33116]")
end
+ def test_delegate_class_block
+ klass = DelegateClass(Array) do
+ alias foo first
+ end
+ assert_equal(1, klass.new([1]).foo)
+ end
+
def test_systemcallerror_eq
e = SystemCallError.new(0)
assert((SimpleDelegator.new(e) == e) == (e == SimpleDelegator.new(e)), "[ruby-dev:34808]")