[前][次][番号順一覧][スレッド一覧]

ruby-changes:54247

From: eregon <ko1@a...>
Date: Thu, 20 Dec 2018 13:57:19 +0900 (JST)
Subject: [ruby-changes:54247] eregon:r65388 (trunk): Update to ruby/spec@8b743a3

eregon	2018-10-27 19:48:40 +0900 (Sat, 27 Oct 2018)

  New Revision: 65388

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65388

  Log:
    Update to ruby/spec@8b743a3

  Added files:
    trunk/spec/ruby/core/array/pack/shared/taint.rb
    trunk/spec/ruby/core/io/pread_spec.rb
    trunk/spec/ruby/core/io/pwrite_spec.rb
    trunk/spec/ruby/core/proc/fixtures/proc_aref.rb
    trunk/spec/ruby/core/proc/fixtures/proc_aref_frozen.rb
    trunk/spec/ruby/core/random/shared/bytes.rb
    trunk/spec/ruby/core/string/each_grapheme_cluster_spec.rb
    trunk/spec/ruby/core/string/grapheme_clusters_spec.rb
    trunk/spec/ruby/core/string/shared/grapheme_clusters.rb
    trunk/spec/ruby/core/string/unpack/shared/taint.rb
    trunk/spec/ruby/library/datetime/add_spec.rb
    trunk/spec/ruby/library/datetime/subtract_spec.rb
    trunk/spec/ruby/security/cve_2018_16396_spec.rb
  Modified files:
    trunk/spec/ruby/.travis.yml
    trunk/spec/ruby/core/array/eql_spec.rb
    trunk/spec/ruby/core/array/fixtures/classes.rb
    trunk/spec/ruby/core/array/pack/a_spec.rb
    trunk/spec/ruby/core/array/pack/b_spec.rb
    trunk/spec/ruby/core/array/pack/h_spec.rb
    trunk/spec/ruby/core/array/pack/m_spec.rb
    trunk/spec/ruby/core/array/pack/p_spec.rb
    trunk/spec/ruby/core/array/pack/shared/string.rb
    trunk/spec/ruby/core/array/pack/u_spec.rb
    trunk/spec/ruby/core/array/pack/z_spec.rb
    trunk/spec/ruby/core/enumerable/all_spec.rb
    trunk/spec/ruby/core/enumerable/none_spec.rb
    trunk/spec/ruby/core/enumerable/one_spec.rb
    trunk/spec/ruby/core/hash/slice_spec.rb
    trunk/spec/ruby/core/io/write_spec.rb
    trunk/spec/ruby/core/kernel/Complex_spec.rb
    trunk/spec/ruby/core/kernel/fixtures/classes.rb
    trunk/spec/ruby/core/kernel/shared/kind_of.rb
    trunk/spec/ruby/core/proc/element_reference_spec.rb
    trunk/spec/ruby/core/proc/shared/to_s.rb
    trunk/spec/ruby/core/random/bytes_spec.rb
    trunk/spec/ruby/core/range/eql_spec.rb
    trunk/spec/ruby/core/range/equal_value_spec.rb
    trunk/spec/ruby/core/string/chars_spec.rb
    trunk/spec/ruby/core/string/codepoints_spec.rb
    trunk/spec/ruby/core/string/fixtures/classes.rb
    trunk/spec/ruby/core/string/lines_spec.rb
    trunk/spec/ruby/core/string/modulo_spec.rb
    trunk/spec/ruby/core/string/slice_spec.rb
    trunk/spec/ruby/core/string/split_spec.rb
    trunk/spec/ruby/core/string/unpack/a_spec.rb
    trunk/spec/ruby/core/string/unpack/b_spec.rb
    trunk/spec/ruby/core/string/unpack/h_spec.rb
    trunk/spec/ruby/core/string/unpack/m_spec.rb
    trunk/spec/ruby/core/string/unpack/p_spec.rb
    trunk/spec/ruby/core/string/unpack/u_spec.rb
    trunk/spec/ruby/core/string/unpack/z_spec.rb
    trunk/spec/ruby/core/struct/eql_spec.rb
    trunk/spec/ruby/core/thread/backtrace/location/path_spec.rb
    trunk/spec/ruby/core/time/new_spec.rb
    trunk/spec/ruby/language/regexp/back-references_spec.rb
    trunk/spec/ruby/language/regexp_spec.rb
    trunk/spec/ruby/library/bigdecimal/divmod_spec.rb
    trunk/spec/ruby/library/bigdecimal/to_s_spec.rb
    trunk/spec/ruby/library/socket/unixsocket/open_spec.rb
    trunk/spec/ruby/library/stringio/getbyte_spec.rb
    trunk/spec/ruby/library/stringio/getc_spec.rb
    trunk/spec/ruby/library/stringio/getch_spec.rb
    trunk/spec/ruby/library/stringio/readbyte_spec.rb
    trunk/spec/ruby/library/stringio/readchar_spec.rb
    trunk/spec/ruby/library/zlib/crc32_spec.rb
    trunk/spec/ruby/optional/capi/encoding_spec.rb
    trunk/spec/ruby/optional/capi/object_spec.rb
    trunk/spec/ruby/shared/basicobject/send.rb
    trunk/spec/ruby/shared/kernel/raise.rb
Index: spec/ruby/core/array/pack/u_spec.rb
===================================================================
--- spec/ruby/core/array/pack/u_spec.rb	(revision 65387)
+++ spec/ruby/core/array/pack/u_spec.rb	(revision 65388)
@@ -3,6 +3,7 @@ require_relative '../../../spec_helper' https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/pack/u_spec.rb#L3
 require_relative '../fixtures/classes'
 require_relative 'shared/basic'
 require_relative 'shared/unicode'
+require_relative 'shared/taint'
 
 describe "Array#pack with format 'U'" do
   it_behaves_like :array_pack_basic, 'U'
@@ -15,6 +16,7 @@ describe "Array#pack with format 'u'" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/pack/u_spec.rb#L16
   it_behaves_like :array_pack_basic, 'u'
   it_behaves_like :array_pack_basic_non_float, 'u'
   it_behaves_like :array_pack_arguments, 'u'
+  it_behaves_like :array_pack_taint, 'u'
 
   it "encodes an empty string as an empty string" do
     [""].pack("u").should == ""
Index: spec/ruby/core/array/pack/b_spec.rb
===================================================================
--- spec/ruby/core/array/pack/b_spec.rb	(revision 65387)
+++ spec/ruby/core/array/pack/b_spec.rb	(revision 65388)
@@ -3,12 +3,14 @@ require_relative '../../../spec_helper' https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/pack/b_spec.rb#L3
 require_relative '../fixtures/classes'
 require_relative 'shared/basic'
 require_relative 'shared/encodings'
+require_relative 'shared/taint'
 
 describe "Array#pack with format 'B'" do
   it_behaves_like :array_pack_basic, 'B'
   it_behaves_like :array_pack_basic_non_float, 'B'
   it_behaves_like :array_pack_arguments, 'B'
   it_behaves_like :array_pack_hex, 'B'
+  it_behaves_like :array_pack_taint, 'B'
 
   it "calls #to_str to convert an Object to a String" do
     obj = mock("pack H string")
@@ -59,6 +61,7 @@ describe "Array#pack with format 'b'" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/pack/b_spec.rb#L61
   it_behaves_like :array_pack_basic_non_float, 'b'
   it_behaves_like :array_pack_arguments, 'b'
   it_behaves_like :array_pack_hex, 'b'
+  it_behaves_like :array_pack_taint, 'b'
 
   it "calls #to_str to convert an Object to a String" do
     obj = mock("pack H string")
Index: spec/ruby/core/enumerable/none_spec.rb
===================================================================
--- spec/ruby/core/enumerable/none_spec.rb	(revision 65387)
+++ spec/ruby/core/enumerable/none_spec.rb	(revision 65388)
@@ -51,7 +51,6 @@ describe "Enumerable#none?" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/enumerable/none_spec.rb#L51
     end
 
     it "gathers whole arrays as elements when each yields multiple" do
-      # This spec doesn't spec what it says it does
       multi = EnumerableSpecs::YieldsMultiWithFalse.new
       multi.none?.should be_false
     end
Index: spec/ruby/core/random/bytes_spec.rb
===================================================================
--- spec/ruby/core/random/bytes_spec.rb	(revision 65387)
+++ spec/ruby/core/random/bytes_spec.rb	(revision 65388)
@@ -1,18 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/random/bytes_spec.rb#L1
 # -*- encoding: binary -*-
 require_relative '../../spec_helper'
+require_relative 'shared/bytes'
 
 describe "Random#bytes" do
-  it "returns a String" do
-    Random.new.bytes(1).should be_an_instance_of(String)
-  end
-
-  it "returns a String of the length given as argument" do
-    Random.new.bytes(15).length.should == 15
-  end
-
-  it "returns an ASCII-8BIT String" do
-    Random.new.bytes(15).encoding.should == Encoding::ASCII_8BIT
-  end
+  it_behaves_like :random_bytes, :bytes, Random.new
 
   it "returns the same output for a given seed" do
     Random.new(33).bytes(2).should == Random.new(33).bytes(2)
@@ -32,8 +23,10 @@ describe "Random#bytes" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/random/bytes_spec.rb#L23
     rnd.bytes(1000) # skip some
     rnd.bytes(2).should == "\x17\x12"
   end
+end
 
-  it "returns a random binary String" do
-    Random.new.bytes(12).should_not == Random.new.bytes(12)
+ruby_version_is "2.6" do
+  describe "Random.bytes" do
+    it_behaves_like :random_bytes, :bytes, Random
   end
 end
Index: spec/ruby/core/range/eql_spec.rb
===================================================================
--- spec/ruby/core/range/eql_spec.rb	(revision 65387)
+++ spec/ruby/core/range/eql_spec.rb	(revision 65388)
@@ -5,6 +5,6 @@ describe "Range#eql?" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/range/eql_spec.rb#L5
   it_behaves_like :range_eql, :eql?
 
   it "returns false if the endpoints are not eql?" do
-    (0..1).send(@method, 0..1.0).should == false
+    (0..1).should_not eql(0..1.0)
   end
 end
Index: spec/ruby/library/zlib/crc32_spec.rb
===================================================================
--- spec/ruby/library/zlib/crc32_spec.rb	(revision 65387)
+++ spec/ruby/library/zlib/crc32_spec.rb	(revision 65388)
@@ -24,6 +24,8 @@ describe "Zlib.crc32" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/zlib/crc32_spec.rb#L24
     Zlib.crc32(test_string, 1).should == 1809313411
     Zlib.crc32(test_string, 2**8).should == 1722745982
     Zlib.crc32(test_string, 2**16).should == 1932511220
+    Zlib.crc32("p", ~305419896).should == 4046865307
+    Zlib.crc32("p", -305419897).should == 4046865307
     lambda { Zlib.crc32(test_string, 2**128) }.should raise_error(RangeError)
   end
 
Index: spec/ruby/library/socket/unixsocket/open_spec.rb
===================================================================
--- spec/ruby/library/socket/unixsocket/open_spec.rb	(revision 65387)
+++ spec/ruby/library/socket/unixsocket/open_spec.rb	(revision 65388)
@@ -19,7 +19,7 @@ describe "UNIXSocket.open" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/socket/unixsocket/open_spec.rb#L19
     end
 
     it "opens a unix socket on the specified file and yields it to the block" do
-      UNIXSocket.send(@method, @path) do |client|
+      UNIXSocket.open(@path) do |client|
         client.addr[0].should == "AF_UNIX"
         client.closed?.should == false
       end
Index: spec/ruby/library/datetime/add_spec.rb
===================================================================
--- spec/ruby/library/datetime/add_spec.rb	(nonexistent)
+++ spec/ruby/library/datetime/add_spec.rb	(revision 65388)
@@ -0,0 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/datetime/add_spec.rb#L1
+require_relative '../../spec_helper'
+require 'date'
+
+describe "DateTime#+" do
+  it "is able to add sub-millisecond precision values" do
+    datetime = DateTime.new(2017)
+    (datetime + 0.00001).to_time.usec.should == 864000
+  end
+end
Index: spec/ruby/library/datetime/subtract_spec.rb
===================================================================
--- spec/ruby/library/datetime/subtract_spec.rb	(nonexistent)
+++ spec/ruby/library/datetime/subtract_spec.rb	(revision 65388)
@@ -0,0 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/datetime/subtract_spec.rb#L1
+require_relative '../../spec_helper'
+require 'date'
+
+describe "DateTime#-" do
+  it "is able to subtract sub-millisecond precision values" do
+    date = DateTime.new(2017)
+    ((date + 0.00001) - date).should == Rational(1, 100000)
+  end
+end
Index: spec/ruby/library/stringio/readbyte_spec.rb
===================================================================
--- spec/ruby/library/stringio/readbyte_spec.rb	(revision 65387)
+++ spec/ruby/library/stringio/readbyte_spec.rb	(revision 65388)
@@ -8,10 +8,10 @@ describe "StringIO#readbyte" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/stringio/readbyte_spec.rb#L8
   it "reads the next 8-bit byte from self's current position" do
     io = StringIO.new("example")
 
-    io.send(@method).should == 101
+    io.readbyte.should == 101
 
     io.pos = 4
-    io.send(@method).should == 112
+    io.readbyte.should == 112
   end
 end
 
Index: spec/ruby/library/stringio/getbyte_spec.rb
===================================================================
--- spec/ruby/library/stringio/getbyte_spec.rb	(revision 65387)
+++ spec/ruby/library/stringio/getbyte_spec.rb	(revision 65388)
@@ -8,9 +8,9 @@ describe "StringIO#getbyte" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/stringio/getbyte_spec.rb#L8
   it "returns the 8-bit byte at the current position" do
     io = StringIO.new("example")
 
-    io.send(@method).should == 101
-    io.send(@method).should == 120
-    io.send(@method).should ==  97
+    io.getbyte.should == 101
+    io.getbyte.should == 120
+    io.getbyte.should ==  97
   end
 end
 
Index: spec/ruby/library/stringio/getc_spec.rb
===================================================================
--- spec/ruby/library/stringio/getc_spec.rb	(revision 65387)
+++ spec/ruby/library/stringio/getc_spec.rb	(revision 65388)
@@ -8,9 +8,9 @@ describe "StringIO#getc" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/stringio/getc_spec.rb#L8
   it "returns the character at the current position" do
     io = StringIO.new("example")
 
-    io.send(@method).should == ?e
-    io.send(@method).should == ?x
-    io.send(@method).should == ?a
+    io.getc.should == ?e
+    io.getc.should == ?x
+    io.getc.should == ?a
   end
 end
 
Index: spec/ruby/library/stringio/readchar_spec.rb
===================================================================
--- spec/ruby/library/stringio/readchar_spec.rb	(revision 65387)
+++ spec/ruby/library/stringio/readchar_spec.rb	(revision 65388)
@@ -8,10 +8,10 @@ describe "StringIO#readchar" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/stringio/readchar_spec.rb#L8
   it "reads the next 8-bit byte from self's current position" do
     io = StringIO.new("example")
 
-    io.send(@method).should == ?e
+    io.readchar.should == ?e
 
     io.pos = 4
-    io.send(@method).should == ?p
+    io.readchar.should == ?p
   end
 end
 
Index: spec/ruby/library/stringio/getch_spec.rb
===================================================================
--- spec/ruby/library/stringio/getch_spec.rb	(revision 65387)
+++ spec/ruby/library/stringio/getch_spec.rb	(revision 65388)
@@ -12,32 +12,32 @@ describe "StringIO#getch" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/stringio/getch_spec.rb#L12
   it "returns the character at the current position" do
     io = StringIO.new("example")
 
-    io.send(@method).should == ?e
-    io.send(@method).should == ?x
-    io.send(@method).should == ?a
+    io.getch.should == ?e
+    io.getch.should == ?x
+    io.getch.should == ?a
   end
 
   with_feature :encoding do
     it "increments #pos by the byte size of the character in multibyte strings" do
       io = StringIO.new("f旦坦bar")
 
-      io.send(@method); io.pos.should == 1 # "f" has byte size 1
-      io.send(@method); io.pos.should == 3 # "旦" has byte size 2
-      io.send(@method); io.pos.should == 5 # "坦" has byte size 2
-      io.send(@method); io.pos.should == 6 # "b" has byte size 1
+      io.getch; io.pos.should == 1 # "f" has byte size 1
+      io.getch; io.pos.should == 3 # "旦" has byte size 2
+      io.getch; io.pos.should == 5 # "坦" has byte size 2
+      io.getch; io.pos.should == 6 # "b" has byte size 1
     end
   end
 
   it "returns nil at the end of the string" do
     # empty string case
     io = StringIO.new("")
-    io.send(@method).should == nil
-    io.send(@method).should == nil
+    io.getch.should == nil
+    io.getch.should == nil
 
     # non-empty string case
     io = StringIO.new("a")
-    io.send(@method) # skip one
-    io.send(@method).should == nil
+    io.getch # skip one
+    io.getch.should == nil
   end
 
   describe "StringIO#getch when self is not readable" do
Index: spec/ruby/library/bigdecimal/to_s_spec.rb
===================================================================
--- spec/ruby/library/bigdecimal/to_s_spec.rb	(revision 65387)
+++ spec/ruby/library/bigdecimal/to_s_spec.rb	(revision 65388)
@@ -15,8 +15,16 @@ describe "BigDecimal#to_s" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/bigdecimal/to_s_spec.rb#L15
     @bigneg.to_s.kind_of?(String).should == true
   end
 
-  it "the default format looks like 0.xxxxEnn" do
-    @bigdec.to_s.should =~ /^0\.[0-9]*E[0-9]*$/i
+  ruby_version_is ''...'2.4' do
+    it "the default format looks like 0.xxxxEnn" do
+      @bigdec.to_s.should =~ /^0\.[0-9]*E[0-9]*$/
+    end
+  end
+
+  ruby_version_is '2.4' do
+    it "the default format looks like 0.xxxxenn" do
+      @bigdec.to_s.should =~ /^0\.[0-9]*e[0-9]*$/
+    end
   end
 
   it "takes an optional argument" do
@@ -63,10 +71,12 @@ describe "BigDecimal#to_s" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/bigdecimal/to_s_spec.rb#L71
   end
 
   it "can use conventional floating point notation" do
-    @bigdec.to_s("F").should == @bigdec_str
-    @bigneg.to_s("F").should == @bigneg_str
-    str2 = "+123.45678901 23456789"
-    BigDecimal('123.45678901234567890').to_s('+8F').should == str2
+    %w[f F].each do |format_char|
+      @bigdec.to_s(format_char).should == @bigdec_str
+      @bigneg.to_s(format_char).should == @bigneg_str
+      str2 = "+123.45678901 23456789"
+      BigDecimal('123.45678901234567890').to_s("+8#{format_char}").should == str2
+    end
   end
 
 end
Index: spec/ruby/library/bigdecimal/divmod_spec.rb
===================================================================
--- spec/ruby/library/bigdecimal/divmod_spec.rb	(revision 65387)
+++ spec/ruby/library/bigdecimal/divmod_spec.rb	(revision 65388)
@@ -38,9 +38,9 @@ describe "BigDecimal#mod_part_of_divmod" https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/bigdecimal/divmod_spec.rb#L38
   it "raises ZeroDivisionError if other is zero" do
     bd5667 = BigDecimal("5667.19")
 
-    lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError)
-    lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError)
-    lambda { @zero.send(@method, @zero) }.should raise_error(ZeroDivisionError)
+    lambda { bd5667.mod_part_of_divmod(0) }.should raise_error(ZeroDivisionError)
+    lambda { bd5667.mod_part_of_divmod(BigDecimal("0")) }.should raise_error(ZeroDivisionError)
+    lambda { @zero.mod_part_of_divmod(@zero) }.should raise_error(ZeroDivisionError)
   end
 end
 
Index: spec/ruby/shared/basicobject/send.rb
===================================================================
--- spec/ruby/shared/basicobject/send.rb	(revision 65387)
+++ spec/ruby/shared/basicobject/send.rb	(revision 65388)
@@ -29,6 +29,13 @@ describe :basicobject_send, shared: true https://github.com/ruby/ruby/blob/trunk/spec/ruby/shared/basicobject/send.rb#L29
     SendSpecs::Foo.send(@method, :bar).should == 'done'
   end
 
+  it "raises a TypeError if the method name is not a string or symbol" do
+    -> { SendSpecs.send(@method, nil) }.should raise_error(TypeError, /not a symbol nor a string/)
+    -> { SendSpecs.send(@method, 42) }.should raise_error(TypeError, /not a symbol nor a string/)
+    -> { SendSpecs.send(@method, 3.14) }.should raise_error(TypeError, /not a symbol nor a string/)
+    -> { SendSpecs.send(@method, true) }.should raise_error(TypeError, /not a symbol nor a string/)
+  end
+
   it "raises a NameError if the corresponding method can't be found" do
     class SendSpecs::Foo
       def bar
Index: spec/ruby/shared/kernel/raise.rb
===================================================================
--- spec/ruby/shared/kernel/raise.rb	(revision 65387)
+++ spec/ruby/shared/kernel/raise.rb	(revision 65388)
@@ -41,7 +41,7 @@ describe :kernel_raise, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/shared/kernel/raise.rb#L41
     lambda { @object.raise(nil) }.should raise_error(TypeError)
   end
 
-  it "re-raises the rescued exception" do
+  it "re-raises the previously rescued exception if no exception is specified" do
     lambda do
       begin
         raise Exception, "outer"
@@ -60,6 +60,22 @@ describe :kernel_raise, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/shared/kernel/raise.rb#L60
     ScratchPad.recorded.should be_nil
   end
 
+  it "re-raises a previously rescued exception without overwriting the backtrace" do
+    begin
+      raise 'raised'
+    rescue => raised
+      begin
+        raise_again_line = __LINE__; raise raised
+      rescue => raised_again
+        # This spec is written using #backtrace and matching the line number
+        # from the string, as backtrace_locations is a more advanced
+        # method that is not always supported by implementations.
+
+        raised_again.backtrace.first.should_not include(":#{raise_again_line}:")
+      end
+    end
+  end
+
   it "allows Exception, message, and backtrace parameters" do
     lambda do
       @object.raise(ArgumentError, "message", caller)
Index: spec/ruby/security/cve_2018_16396_spec.rb
===================================================================
--- spec/ruby/security/cve_2018_16396_spec.rb	(nonexistent)
+++ spec/ruby/security/cve_2018_16396_spec.rb	(revision 65388)
@@ -0,0 +1,21 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/security/cve_2018_16396_spec.rb#L1
+require_relative '../spec_helper'
+
+describe "Array#pack" do
+
+  it "resists CVE-2018-16396 by tainting output based on input" do
+    "aAZBbHhuMmPp".each_char do |f|
+      ["123456".taint].pack(f).tainted?.should be_true
+    end
+  end
+
+end
+
+describe "String#unpack" do
+
+  it "resists CVE-2018-16396 by tainting output based on input" do
+    "aAZBbHhuMm".each_char do |f|
+      "123456".taint.unpack(f).first.tainted?.should be_true
+    end
+  end
+
+end
Index: spec/ruby/language/regexp/back-references_spec.rb
===================================================================
--- spec/ruby/language/regexp/back-references_spec.rb	(revision 65387)
+++ spec/ruby/language/regexp/back-references_spec.rb	(revision 65388)
@@ -46,4 +46,8 @@ describe "Regexps with back-references" https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/regexp/back-references_spec.rb#L46
   it "resets nested \<n> 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
Index: spec/ruby/language/regexp_spec.rb
===================================================================
--- spec/ruby/language/regexp_spec.rb	(revision 65387)
+++ spec/ruby/language/regexp_spec.rb	(revision 65388)
@@ -167,4 +167,31 @@ describe "Literal Regexps" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/regexp_spec.rb#L167
       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
+     (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]