* lib/scanf.rb (Scanf::FormatSpecifier#letter, #width): use matched

substring directly.

* ext/nkf/lib/kconv.rb (Kconv.conv): get rid of nil.to_a.

* test/ruby/test_assignment.rb, test/ruby/test_iterator.rb: followed
  change of sample/test.rb.

* test/net/http/test_http.rb: removed superfluous splatting stars.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-10-08 10:45:52 +00:00
Родитель 8fb6f790fe
Коммит ec12edb11c
6 изменённых файлов: 18 добавлений и 69 удалений

Просмотреть файл

@ -1,3 +1,15 @@
Sat Oct 8 19:45:16 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/scanf.rb (Scanf::FormatSpecifier#letter, #width): use matched
substring directly.
* ext/nkf/lib/kconv.rb (Kconv.conv): get rid of nil.to_a.
* test/ruby/test_assignment.rb, test/ruby/test_iterator.rb: followed
change of sample/test.rb.
* test/net/http/test_http.rb: removed superfluous splatting stars.
Sat Oct 8 19:32:56 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_io_init_copy): clear PREP flag for copied IO.

Просмотреть файл

@ -113,7 +113,7 @@ module Kconv
to = symbol_to_option(option[0])
from = symbol_to_option(option[1]).to_s.sub(/(-[jesw])/o){$1.upcase}
opt = option[2..-1].to_a.flatten.map{|x|symbol_to_option(x)}.compact.join(' ')
opt = option[2..-1] and opt = opt.flatten.map{|x|symbol_to_option(x)}.compact.join(' ')
nkf_opt = '-x -m0 %s %s %s' % [to, from, opt]
result = ::NKF::nkf( nkf_opt, str)

Просмотреть файл

@ -467,11 +467,11 @@ module Scanf
end
def letter
/%\*?\d*([a-z\[])/.match(@spec_string).to_a[1]
@spec_string[/%\*?\d*([a-z\[])/, 1]
end
def width
w = /%\*?(\d+)/.match(@spec_string).to_a[1]
w = @spec_string[/%\*?(\d+)/, 1]
w && w.to_i
end

Просмотреть файл

@ -31,7 +31,7 @@ module TestNetHTTP_version_1_1_methods
end
def _test_get__get(http)
res, body = *http.get('/')
res, body = http.get('/')
assert_kind_of Net::HTTPResponse, res
assert_kind_of String, res.body
assert_kind_of String, body
@ -61,7 +61,7 @@ module TestNetHTTP_version_1_1_methods
def _test_get__chunked(http)
buf = ''
res, body = *http.get('/') {|s| buf << s }
res, body = http.get('/') {|s| buf << s }
assert_kind_of Net::HTTPResponse, res
# assert_kind_of String, res.body
# assert_kind_of String, body
@ -86,7 +86,7 @@ module TestNetHTTP_version_1_1_methods
end
def test_get__implicit_start
res, body = *new().get('/')
res, body = new().get('/')
assert_kind_of Net::HTTPResponse, res
assert_kind_of String, body
assert_kind_of String, res.body

Просмотреть файл

@ -29,8 +29,6 @@ class TestAssignment < Test::Unit::TestCase
a = [*[1]]; assert_equal([1], a)
a = [*[1,2]]; assert_equal([1,2], a)
a = *nil; assert_nil(a)
a = *1; assert_equal(1, a)
a = *[]; assert_nil(a)
a = *[1]; assert_equal(1, a)
a = *[nil]; assert_nil(a)
@ -51,8 +49,6 @@ class TestAssignment < Test::Unit::TestCase
*a = [*[1]]; assert_equal([[1]], a)
*a = [*[1,2]]; assert_equal([[1,2]], a)
*a = *nil; assert_equal([nil], a)
*a = *1; assert_equal([1], a)
*a = *[]; assert_equal([], a)
*a = *[1]; assert_equal([1], a)
*a = *[nil]; assert_equal([nil], a)
@ -73,8 +69,6 @@ class TestAssignment < Test::Unit::TestCase
a,b,*c = [*[1]]; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = [*[1,2]]; assert_equal([1,2,[]], [a,b,c])
a,b,*c = *nil; assert_equal([nil,nil,[]], [a,b,c])
a,b,*c = *1; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = *[]; assert_equal([nil,nil,[]], [a,b,c])
a,b,*c = *[1]; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = *[nil]; assert_equal([nil,nil,[]], [a,b,c])
@ -96,8 +90,6 @@ class TestAssignment < Test::Unit::TestCase
def f; yield([*[1]]); end; f {|a| assert_equal([1], a)}; undef f
def f; yield([*[1,2]]); end; f {|a| assert_equal([1,2], a)}; undef f
def f; yield(*nil); end; f {|a| assert_nil(a)}; undef f
def f; yield(*1); end; f {|a| assert_equal(1, a)}; undef f
def f; yield(*[1]); end; f {|a| assert_equal(1, a)}; undef f
def f; yield(*[nil]); end; f {|a| assert_nil(a)}; undef f
def f; yield(*[[]]); end; f {|a| assert_equal([], a)}; undef f
@ -115,8 +107,6 @@ class TestAssignment < Test::Unit::TestCase
def f; yield([*[1]]); end; f {|*a| assert_equal([[1]], a)}; undef f
def f; yield([*[1,2]]); end; f {|*a| assert_equal([[1,2]], a)}; undef f
def f; yield(*nil); end; f {|*a| assert_equal([nil], a)}; undef f
def f; yield(*1); end; f {|*a| assert_equal([1], a)}; undef f
def f; yield(*[]); end; f {|*a| assert_equal([], a)}; undef f
def f; yield(*[1]); end; f {|*a| assert_equal([1], a)}; undef f
def f; yield(*[nil]); end; f {|*a| assert_equal([nil], a)}; undef f
@ -136,8 +126,6 @@ class TestAssignment < Test::Unit::TestCase
def f; yield([*[1]]); end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}; undef f
def f; yield([*[1,2]]); end; f {|a,b,*c| assert_equal([1,2,[]], [a,b,c])}; undef f
def f; yield(*nil); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
def f; yield(*1); end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}; undef f
def f; yield(*[]); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
def f; yield(*[1]); end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}; undef f
def f; yield(*[nil]); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
@ -159,8 +147,6 @@ class TestAssignment < Test::Unit::TestCase
def r; return [*[1]]; end; a = r(); assert_equal([1], a); undef r
def r; return [*[1,2]]; end; a = r(); assert_equal([1,2], a); undef r
def r; return *nil; end; a = r(); assert_nil(a); undef r
def r; return *1; end; a = r(); assert_equal(1, a); undef r
def r; return *[]; end; a = r(); assert_nil(a); undef r
def r; return *[1]; end; a = r(); assert_equal(1, a); undef r
def r; return *[nil]; end; a = r(); assert_nil(a); undef r
@ -169,14 +155,7 @@ class TestAssignment < Test::Unit::TestCase
def r; return *[*[1]]; end; a = r(); assert_equal(1, a); undef r
def r; return *[*[1,2]]; end; a = r(); assert_equal([1,2], a); undef r
def r; return *nil; end; a = *r(); assert_nil(a); undef r
def r; return *1; end; a = *r(); assert_equal(1, a); undef r
def r; return *[]; end; a = *r(); assert_nil(a); undef r
def r; return *[1]; end; a = *r(); assert_equal(1, a); undef r
def r; return *[nil]; end; a = *r(); assert_nil(a); undef r
def r; return *[[]]; end; a = *r(); assert_nil(a); undef r
def r; return *[*[]]; end; a = *r(); assert_nil(a); undef r
def r; return *[*[1]]; end; a = *r(); assert_equal(1, a); undef r
def r; return *[*[1,2]]; end; a = *r(); assert_equal([1,2], a); undef r
def r; return; end; *a = r(); assert_equal([nil], a); undef r
@ -191,8 +170,6 @@ class TestAssignment < Test::Unit::TestCase
def r; return [*[1]]; end; *a = r(); assert_equal([[1]], a); undef r
def r; return [*[1,2]]; end; *a = r(); assert_equal([[1,2]], a); undef r
def r; return *nil; end; *a = r(); assert_equal([nil], a); undef r
def r; return *1; end; *a = r(); assert_equal([1], a); undef r
def r; return *[]; end; *a = r(); assert_equal([nil], a); undef r
def r; return *[1]; end; *a = r(); assert_equal([1], a); undef r
def r; return *[nil]; end; *a = r(); assert_equal([nil], a); undef r
@ -202,15 +179,8 @@ class TestAssignment < Test::Unit::TestCase
def r; return *[*[1]]; end; *a = r(); assert_equal([1], a); undef r
def r; return *[*[1,2]]; end; *a = r(); assert_equal([[1,2]], a); undef r
def r; return *nil; end; *a = *r(); assert_equal([nil], a); undef r
def r; return *1; end; *a = *r(); assert_equal([1], a); undef r
def r; return *[]; end; *a = *r(); assert_equal([nil], a); undef r
def r; return *[1]; end; *a = *r(); assert_equal([1], a); undef r
def r; return *[nil]; end; *a = *r(); assert_equal([nil], a); undef r
def r; return *[[]]; end; *a = *r(); assert_equal([], a); undef r
def r; return *[1,2]; end; *a = *r(); assert_equal([1,2], a); undef r
def r; return *[*[]]; end; *a = *r(); assert_equal([nil], a); undef r
def r; return *[*[1]]; end; *a = *r(); assert_equal([1], a); undef r
def r; return *[*[1,2]]; end; *a = *r(); assert_equal([1,2], a); undef r
def r; return; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
@ -225,8 +195,6 @@ class TestAssignment < Test::Unit::TestCase
def r; return [*[1]]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
def r; return [*[1,2]]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c]); undef r
def r; return *nil; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
def r; return *1; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
def r; return *[]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
def r; return *[1]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
def r; return *[nil]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
@ -292,8 +260,6 @@ class TestAssignment < Test::Unit::TestCase
a = loop do break [*[1]]; end; assert_equal([1], a)
a = loop do break [*[1,2]]; end; assert_equal([1,2], a)
a = loop do break *nil; end; assert_nil(a)
a = loop do break *1; end; assert_equal(1, a)
a = loop do break *[]; end; assert_nil(a)
a = loop do break *[1]; end; assert_equal(1, a)
a = loop do break *[nil]; end; assert_nil(a)
@ -314,8 +280,6 @@ class TestAssignment < Test::Unit::TestCase
*a = loop do break [*[1]]; end; assert_equal([[1]], a)
*a = loop do break [*[1,2]]; end; assert_equal([[1,2]], a)
*a = loop do break *nil; end; assert_equal([nil], a)
*a = loop do break *1; end; assert_equal([1], a)
*a = loop do break *[]; end; assert_equal([nil], a)
*a = loop do break *[1]; end; assert_equal([1], a)
*a = loop do break *[nil]; end; assert_equal([nil], a)
@ -325,15 +289,8 @@ class TestAssignment < Test::Unit::TestCase
*a = loop do break *[*[1]]; end; assert_equal([1], a)
*a = loop do break *[*[1,2]]; end; assert_equal([[1,2]], a)
*a = *loop do break *nil; end; assert_equal([nil], a)
*a = *loop do break *1; end; assert_equal([1], a)
*a = *loop do break *[]; end; assert_equal([nil], a)
*a = *loop do break *[1]; end; assert_equal([1], a)
*a = *loop do break *[nil]; end; assert_equal([nil], a)
*a = *loop do break *[[]]; end; assert_equal([], a)
*a = *loop do break *[1,2]; end; assert_equal([1,2], a)
*a = *loop do break *[*[]]; end; assert_equal([nil], a)
*a = *loop do break *[*[1]]; end; assert_equal([1], a)
*a = *loop do break *[*[1,2]]; end; assert_equal([1,2], a)
a,b,*c = loop do break; end; assert_equal([nil,nil,[]], [a,b,c])
@ -348,8 +305,6 @@ class TestAssignment < Test::Unit::TestCase
a,b,*c = loop do break [*[1]]; end; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = loop do break [*[1,2]]; end; assert_equal([1,2,[]], [a,b,c])
a,b,*c = loop do break *nil; end; assert_equal([nil,nil,[]], [a,b,c])
a,b,*c = loop do break *1; end; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = loop do break *[]; end; assert_equal([nil,nil,[]], [a,b,c])
a,b,*c = loop do break *[1]; end; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = loop do break *[nil]; end; assert_equal([nil,nil,[]], [a,b,c])
@ -373,8 +328,6 @@ class TestAssignment < Test::Unit::TestCase
r([1]){next [*[1]]}
r([1,2]){next [*[1,2]]}
r(nil){next *nil}
r(1){next *1}
r(nil){next *[]}
r(1){next *[1]}
r(nil){next *[nil]}
@ -399,15 +352,8 @@ class TestAssignment < Test::Unit::TestCase
undef r
def r(val); *a = *yield(); assert_equal(val, a); end
r([nil]){next *nil}
r([1]){next *1}
r([nil]){next *[]}
r([1]){next *[1]}
r([nil]){next *[nil]}
r([]){next *[[]]}
r([1,2]){next *[1,2]}
r([nil]){next *[*[]]}
r([1]){next *[*[1]]}
r([1,2]){next *[*[1,2]]}
undef r
@ -426,15 +372,8 @@ class TestAssignment < Test::Unit::TestCase
undef r
def r(val); a,b,*c = *yield(); assert_equal(val, [a,b,c]); end
r([nil,nil,[]]){next *nil}
r([1,nil,[]]){next *1}
r([nil,nil,[]]){next *[]}
r([1,nil,[]]){next *[1]}
r([nil,nil,[]]){next *[nil]}
r([nil,nil,[]]){next *[[]]}
r([1,2,[]]){next *[1,2]}
r([nil,nil,[]]){next *[*[]]}
r([1,nil,[]]){next *[*[1]]}
r([1,2,[]]){next *[*[1,2]]}
undef r
end

Просмотреть файл

@ -149,11 +149,9 @@ class TestIterator < Test::Unit::TestCase
IterTest.new([0]).each0 {|x| assert_equal(0, x)}
IterTest.new([1]).each1 {|x| assert_equal(1, x)}
IterTest.new([2]).each2 {|x| assert_equal([2], x)}
IterTest.new([3]).each3 {|x| assert_equal(3, x)}
IterTest.new([4]).each4 {|x| assert_equal(4, x)}
IterTest.new([5]).each5 {|x| assert_equal(5, x)}
IterTest.new([6]).each6 {|x| assert_equal([6], x)}
IterTest.new([7]).each7 {|x| assert_equal(7, x)}
IterTest.new([8]).each8 {|x| assert_equal(8, x)}
IterTest.new([[0]]).each0 {|x| assert_equal([0], x)}