From 3e6337b88b5255aba07b8f44de72cd5885f59465 Mon Sep 17 00:00:00 2001 From: eregon Date: Sat, 27 Oct 2018 10:48:40 +0000 Subject: Update to ruby/spec@8b743a3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/language/regexp/back-references_spec.rb | 4 ++++ spec/ruby/language/regexp_spec.rb | 27 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'spec/ruby/language') diff --git a/spec/ruby/language/regexp/back-references_spec.rb b/spec/ruby/language/regexp/back-references_spec.rb index fb1e1eb594..81015ac21e 100644 --- a/spec/ruby/language/regexp/back-references_spec.rb +++ b/spec/ruby/language/regexp/back-references_spec.rb @@ -46,4 +46,8 @@ describe "Regexps with back-references" do it "resets nested \ backreference before match of outer subexpression" do /(a\1?){2}/.match("aaaa").to_a.should == ["aa", "a"] end + + it "can match an optional quote, followed by content, followed by a matching quote, as the whole string" do + /^("|)(.*)\1$/.match('x').to_a.should == ["x", "", "x"] + end end diff --git a/spec/ruby/language/regexp_spec.rb b/spec/ruby/language/regexp_spec.rb index 19f4871e6e..6da29ee7a2 100644 --- a/spec/ruby/language/regexp_spec.rb +++ b/spec/ruby/language/regexp_spec.rb @@ -167,4 +167,31 @@ describe "Literal Regexps" do pattern.to_s.should == ref end end + + ruby_version_is '2.4' do + it "support handling unicode 9.0 characters with POSIX bracket expressions" do + char_lowercase = "\u{104D8}" # OSAGE SMALL LETTER A + /[[:lower:]]/.match(char_lowercase).to_s.should == char_lowercase + char_uppercase = "\u{104B0}" # OSAGE CAPITAL LETTER A + /[[:upper:]]/.match(char_uppercase).to_s.should == char_uppercase + end + end + + ruby_version_is ""..."2.4" do + it "does not support handling unicode 9.0 characters with POSIX bracket expressions" do + char_lowercase = "\u{104D8}" # OSAGE SMALL LETTER A + /[[:lower:]]/.match(char_lowercase).should == nil + + char_uppercase = "\u{104B0}" # OSAGE CAPITAL LETTER A + /[[:upper:]]/.match(char_lowercase).should == nil + end + + it "supports handling unicode 8.0 characters with POSIX bracket expressions" do + char_lowercase = "\u{A7B5}" # LATIN SMALL LETTER BETA + /[[:lower:]]/.match(char_lowercase).to_s.should == char_lowercase + + char_uppercase = "\u{A7B4}" # LATIN CAPITAL LETTER BETA + /[[:upper:]]/.match(char_uppercase).to_s.should == char_uppercase + end + end end -- cgit v1.2.3