aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/language/regexp
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-28 15:15:48 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-28 15:15:48 +0000
commit8c5b60eb22d6d661e87992a65d54e3a5bc0aeed4 (patch)
tree7905b284cb5b3d62c17ad8a939e339621a498a2c /spec/ruby/language/regexp
parent6530b14cee76e2512424d225e64d3c61dd1f6511 (diff)
downloadruby-8c5b60eb22d6d661e87992a65d54e3a5bc0aeed4.tar.gz
Update to ruby/spec@a6b8805
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/language/regexp')
-rw-r--r--spec/ruby/language/regexp/character_classes_spec.rb23
-rw-r--r--spec/ruby/language/regexp/modifiers_spec.rb7
2 files changed, 30 insertions, 0 deletions
diff --git a/spec/ruby/language/regexp/character_classes_spec.rb b/spec/ruby/language/regexp/character_classes_spec.rb
index 74568a0beb..ce66d8e65f 100644
--- a/spec/ruby/language/regexp/character_classes_spec.rb
+++ b/spec/ruby/language/regexp/character_classes_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)
@@ -607,4 +608,26 @@ describe "Regexp with character classes" do
it "matches unicode Hangul properties" do
"루비(Ruby)".match(/\p{Hangul}+/u).to_a.should == ["루비"]
end
+
+ ruby_version_is "2.4" do
+ it "supports \\X (unicode 9.0 with UTR #51 workarounds)" do
+ # simple emoji without any fancy modifier or ZWJ
+ /\X/.match("\u{1F98A}").to_a.should == ["🦊"]
+
+ # skin tone modifier
+ /\X/.match("\u{1F918}\u{1F3FD}").to_a.should == ["🀘🏽"]
+
+ # emoji joined with ZWJ
+ /\X/.match("\u{1F3F3}\u{FE0F}\u{200D}\u{1F308}").to_a.should == ["πŸ³οΈβ€πŸŒˆ"]
+ /\X/.match("\u{1F469}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466}").to_a.should == ["πŸ‘©β€πŸ‘©β€πŸ‘§β€πŸ‘¦"]
+
+ # without the ZWJ
+ /\X+/.match("\u{1F3F3}\u{FE0F}\u{1F308}").to_a.should == ["🏳️🌈"]
+ /\X+/.match("\u{1F469}\u{1F469}\u{1F467}\u{1F466}").to_a.should == ["πŸ‘©πŸ‘©πŸ‘§πŸ‘¦"]
+
+ # both of the ZWJ combined
+ /\X+/.match("\u{1F3F3}\u{FE0F}\u{200D}\u{1F308}\u{1F469}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466}")
+ .to_a.should == ["πŸ³οΈβ€πŸŒˆπŸ‘©β€πŸ‘©β€πŸ‘§β€πŸ‘¦"]
+ end
+ end
end
diff --git a/spec/ruby/language/regexp/modifiers_spec.rb b/spec/ruby/language/regexp/modifiers_spec.rb
index 03dec26f3f..a7052a941c 100644
--- a/spec/ruby/language/regexp/modifiers_spec.rb
+++ b/spec/ruby/language/regexp/modifiers_spec.rb
@@ -39,6 +39,13 @@ describe "Regexps with modifers" do
lambda { eval('/foo/a') }.should raise_error(SyntaxError)
end
+ ruby_version_is "2.4" do
+ it "supports (?~) (absent operator)" do
+ Regexp.new("(?~foo)").match("hello").to_a.should == ["hello"]
+ "foo".scan(Regexp.new("(?~foo)")).should == ["fo","o",""]
+ end
+ end
+
it "supports (?imx-imx) (inline modifiers)" do
/(?i)foo/.match("FOO").to_a.should == ["FOO"]
/foo(?i)/.match("FOO").should be_nil