From 44aa05dba0561e0e1dc2ca53a90316141bac45cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20B=C3=BCnger?= Date: Wed, 3 Oct 2018 15:27:56 +0200 Subject: [PATCH 1/5] Include some basic tests for Regexp to test POSIX bracket expressions for unicode 8.0 / 9.0 --- language/regexp_spec.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/language/regexp_spec.rb b/language/regexp_spec.rb index 19f4871e6e..0593d0238a 100644 --- a/language/regexp_spec.rb +++ b/language/regexp_spec.rb @@ -167,4 +167,31 @@ 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).to_s.should == nil + + char_uppercase = "\u{104B0}" # OSAGE CAPITAL LETTER A + /[[:upper:]]/.match(char_lowercase).to_s.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 CAPTIAL LETTER BETA + /[[:upper:]]/.match(char_uppercase).to_s.should == char_uppercase + end + end end From 92e86048a50d0f600a028d4be644160ae13f91b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20B=C3=BCnger?= Date: Wed, 3 Oct 2018 15:48:42 +0200 Subject: [PATCH 2/5] Fix typo --- language/regexp_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/regexp_spec.rb b/language/regexp_spec.rb index 0593d0238a..7125e702ee 100644 --- a/language/regexp_spec.rb +++ b/language/regexp_spec.rb @@ -190,7 +190,7 @@ char_lowercase = "\u{A7B5}" # LATIN SMALL LETTER BETA /[[:lower:]]/.match(char_lowercase).to_s.should == char_lowercase - char_uppercase = "\u{A7B4}" # LATIN CAPTIAL LETTER BETA + char_uppercase = "\u{A7B4}" # LATIN CAPITAL LETTER BETA /[[:upper:]]/.match(char_uppercase).to_s.should == char_uppercase end end From c17fa9ab474ead646b66db1530ba570f2a03bc7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20B=C3=BCnger?= Date: Wed, 3 Oct 2018 15:51:26 +0200 Subject: [PATCH 3/5] Fix test by checking against empty? instead of nil value --- language/regexp_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language/regexp_spec.rb b/language/regexp_spec.rb index 7125e702ee..9ea71a0e4b 100644 --- a/language/regexp_spec.rb +++ b/language/regexp_spec.rb @@ -180,10 +180,10 @@ 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).to_s.should == nil + /[[:lower:]]/.match(char_lowercase).to_s.should.empty? char_uppercase = "\u{104B0}" # OSAGE CAPITAL LETTER A - /[[:upper:]]/.match(char_lowercase).to_s.should == nil + /[[:upper:]]/.match(char_lowercase).to_s.should.empty? end it "supports handling unicode 8.0 characters with POSIX bracket expressions" do From 4d321fe2564bc758f6c40837044eed64676468a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20B=C3=BCnger?= Date: Wed, 3 Oct 2018 16:08:06 +0200 Subject: [PATCH 4/5] Fix tests --- language/regexp_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language/regexp_spec.rb b/language/regexp_spec.rb index 9ea71a0e4b..4350ca7c3a 100644 --- a/language/regexp_spec.rb +++ b/language/regexp_spec.rb @@ -180,10 +180,10 @@ 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).to_s.should.empty? + /[[:lower:]]/.match(char_lowercase).to_s.should == "" char_uppercase = "\u{104B0}" # OSAGE CAPITAL LETTER A - /[[:upper:]]/.match(char_lowercase).to_s.should.empty? + /[[:upper:]]/.match(char_lowercase).to_s.should == "" end it "supports handling unicode 8.0 characters with POSIX bracket expressions" do From dfcf098e1003773fac743841a046a32374cabecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20B=C3=BCnger?= Date: Wed, 3 Oct 2018 17:33:28 +0200 Subject: [PATCH 5/5] remove obsolete to_s method --- language/regexp_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language/regexp_spec.rb b/language/regexp_spec.rb index 4350ca7c3a..6da29ee7a2 100644 --- a/language/regexp_spec.rb +++ b/language/regexp_spec.rb @@ -180,10 +180,10 @@ 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).to_s.should == "" + /[[:lower:]]/.match(char_lowercase).should == nil char_uppercase = "\u{104B0}" # OSAGE CAPITAL LETTER A - /[[:upper:]]/.match(char_lowercase).to_s.should == "" + /[[:upper:]]/.match(char_lowercase).should == nil end it "supports handling unicode 8.0 characters with POSIX bracket expressions" do