Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spec raising syntax error when defining yield in singleton class #873

Merged
merged 1 commit into from
Oct 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions language/singleton_class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,21 @@ class << Object.new
-> { eval(code) }.should complain(/warning: `yield' in class syntax will not be supported from Ruby 3.0/)
end
end

ruby_version_is "3.0" do
it 'raises a SyntaxError' do
code = <<~RUBY
def m
class << Object.new
yield
end
end
m { :ok }
RUBY

-> { eval(code) }.should raise_error(SyntaxError, /Invalid yield/)
end
end
end

describe "Defining instance methods on a singleton class" do
Expand Down