summaryrefslogtreecommitdiff
path: root/spec/ruby/language
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-08-28 20:26:02 +0200
committerBenoit Daloze <eregontp@gmail.com>2020-08-28 20:26:02 +0200
commitb49307c701911a713cbdb48367833d3661a4880a (patch)
tree75674a3f22bee0b347b3efbbcc160bc7a637b8e3 /spec/ruby/language
parent3dd63108b0e7551aba76eba85a459b58ec971ccb (diff)
Update to ruby/spec@335eb9b
Diffstat (limited to 'spec/ruby/language')
-rw-r--r--spec/ruby/language/BEGIN_spec.rb5
-rw-r--r--spec/ruby/language/regexp_spec.rb6
2 files changed, 11 insertions, 0 deletions
diff --git a/spec/ruby/language/BEGIN_spec.rb b/spec/ruby/language/BEGIN_spec.rb
index 58cc2bebfb..5aef5a1d7c 100644
--- a/spec/ruby/language/BEGIN_spec.rb
+++ b/spec/ruby/language/BEGIN_spec.rb
@@ -18,6 +18,11 @@ describe "The BEGIN keyword" do
-> { eval "1.times { BEGIN { 1 } }" }.should raise_error(SyntaxError)
end
+ it "uses top-level for self" do
+ eval("BEGIN { ScratchPad << self.to_s }", TOPLEVEL_BINDING)
+ ScratchPad.recorded.should == ['main']
+ end
+
it "runs first in a given code unit" do
eval "ScratchPad << 'foo'; BEGIN { ScratchPad << 'bar' }"
diff --git a/spec/ruby/language/regexp_spec.rb b/spec/ruby/language/regexp_spec.rb
index ac3f773c49..059428ec69 100644
--- a/spec/ruby/language/regexp_spec.rb
+++ b/spec/ruby/language/regexp_spec.rb
@@ -115,6 +115,12 @@ describe "Literal Regexps" do
/foo.(?<=\d)/.match("fooA foo1").to_a.should == ["foo1"]
end
+ # https://bugs.ruby-lang.org/issues/13671
+ it "raises a RegexpError for lookbehind with specific characters" do
+ r = Regexp.new("(?<!dss)", Regexp::IGNORECASE)
+ -> { r =~ "✨" }.should raise_error(RegexpError)
+ end
+
it "supports (?<! ) (negative lookbehind)" do
/foo.(?<!\d)/.match("foo1 fooA").to_a.should == ["fooA"]
end