summaryrefslogtreecommitdiff
path: root/spec/ruby/language
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-02-11 11:56:34 -0800
committerJeremy Evans <code@jeremyevans.net>2020-02-11 12:44:23 -0800
commit7a288df7b85d3565f369b305f225c2cd5baa5905 (patch)
tree994eea5130e4d2e78773b4ee383b63ff46d43740 /spec/ruby/language
parentea32715e004dc8f56dc599883d3183d7b2635f81 (diff)
Make yield in singleton class definitions in methods a SyntaxError
This behavior was deprecated in 2.7 and scheduled to be removed in 3.0. Calling yield in a class definition outside a method is now a SyntaxError instead of a LocalJumpError, as well.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2901
Diffstat (limited to 'spec/ruby/language')
-rw-r--r--spec/ruby/language/class_spec.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/spec/ruby/language/class_spec.rb b/spec/ruby/language/class_spec.rb
index 88b7a6a74f..2b9a4afef7 100644
--- a/spec/ruby/language/class_spec.rb
+++ b/spec/ruby/language/class_spec.rb
@@ -285,7 +285,7 @@ describe "A class definition extending an object (sclass)" do
}.should raise_error(TypeError)
end
- ruby_version_is ""..."3.0" do
+ ruby_version_is ""..."2.8" do
it "allows accessing the block of the original scope" do
suppress_warning do
ClassSpecs.sclass_with_block { 123 }.should == 123
@@ -293,6 +293,14 @@ describe "A class definition extending an object (sclass)" do
end
end
+ ruby_version_is "2.8" do
+ it "does not allow accessing the block of the original scope" do
+ -> {
+ ClassSpecs.sclass_with_block { 123 }
+ }.should raise_error(SyntaxError)
+ end
+ end
+
it "can use return to cause the enclosing method to return" do
ClassSpecs.sclass_with_return.should == :inner
end