ruby-changes:60744
From: Nobuyoshi <ko1@a...>
Date: Sat, 11 Apr 2020 15:13:27 +0900 (JST)
Subject: [ruby-changes:60744] e56e089b1f (master): Assertions for basic use of `encoding:` option
https://git.ruby-lang.org/ruby.git/commit/?id=e56e089b1f From e56e089b1f92dbc55d3239b6843dd0786be9000e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 11 Apr 2020 12:06:59 +0900 Subject: Assertions for basic use of `encoding:` option diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index 3e33eef..13b9c1d 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -320,6 +320,9 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir.rb#L320 assert_entries(Dir.open(@root) {|dir| dir.entries}) assert_entries(Dir.entries(@root)) assert_raise(ArgumentError) {Dir.entries(@root+"\0")} + [Encoding::UTF_8, Encoding::ASCII_8BIT].each do |enc| + assert_equal(enc, Dir.entries(@root, encoding: enc).first.encoding) + end end def test_foreach @@ -332,12 +335,19 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir.rb#L335 Dir.mkdir(newdir) File.write(newdir+"/a", "") assert_equal(%w[. .. a], e.to_a.sort) + [Encoding::UTF_8, Encoding::ASCII_8BIT].each do |enc| + e = Dir.foreach(newdir, encoding: enc) + assert_equal(enc, e.to_a.first.encoding) + end end def test_children assert_entries(Dir.open(@root) {|dir| dir.children}, true) assert_entries(Dir.children(@root), true) assert_raise(ArgumentError) {Dir.children(@root+"\0")} + [Encoding::UTF_8, Encoding::ASCII_8BIT].each do |enc| + assert_equal(enc, Dir.children(@root, encoding: enc).first.encoding) + end end def test_each_child @@ -350,6 +360,10 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir.rb#L360 Dir.mkdir(newdir) File.write(newdir+"/a", "") assert_equal(%w[a], e.to_a) + [Encoding::UTF_8, Encoding::ASCII_8BIT].each do |enc| + e = Dir.each_child(newdir, encoding: enc) + assert_equal(enc, e.to_a.first.encoding) + end end def test_dir_enc -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/