1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-04-28 23:20:11 +02:00
parent 994833085a
commit 79671ec57e
135 changed files with 4415 additions and 4885 deletions

View file

@ -26,7 +26,6 @@ describe "ARGF.gets" do
end
end
with_feature :encoding do
before :each do
@external = Encoding.default_external
@internal = Encoding.default_internal
@ -46,6 +45,5 @@ describe "ARGF.gets" do
@argf.gets.encoding.should == Encoding::US_ASCII
end
end
end
end

View file

@ -62,7 +62,6 @@ describe "ARGF.read" do
end
end
with_feature :encoding do
before :each do
@external = Encoding.default_external
@ -84,4 +83,3 @@ describe "ARGF.read" do
end
end
end
end

View file

@ -11,12 +11,10 @@ describe :dir_glob, shared: true do
DirSpecs.delete_mock_dirs
end
with_feature :encoding do
it "raises an Encoding::CompatibilityError if the argument encoding is not compatible with US-ASCII" do
pattern = "file*".force_encoding Encoding::UTF_16BE
lambda { Dir.send(@method, pattern) }.should raise_error(Encoding::CompatibilityError)
end
end
it "calls #to_path to convert a pattern" do
obj = mock('file_one.ext')

View file

@ -18,7 +18,6 @@ describe :dir_path, shared: true do
dir.send(@method).should == DirSpecs.mock_dir
end
with_feature :encoding do
it "returns a String with the same encoding as the argument to .open" do
path = DirSpecs.mock_dir.force_encoding Encoding::IBM866
dir = Dir.open path
@ -29,4 +28,3 @@ describe :dir_path, shared: true do
end
end
end
end

View file

@ -1,9 +1,7 @@
describe :dir_pwd, shared: true do
with_feature :encoding do
before :each do
@fs_encoding = Encoding.find('filesystem')
end
end
it "returns the current working directory" do
pwd = Dir.send(@method)
@ -36,7 +34,6 @@ describe :dir_pwd, shared: true do
end
end
with_feature :encoding do
it "returns a String with the filesystem encoding" do
enc = Dir.send(@method).encoding
if @fs_encoding == Encoding::US_ASCII
@ -46,4 +43,3 @@ describe :dir_pwd, shared: true do
end
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding.aliases" do
it "returns a Hash" do
Encoding.aliases.should be_an_instance_of(Hash)
@ -42,4 +41,3 @@ with_feature :encoding do
end
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding#ascii_compatible?" do
it "returns true if self represents an ASCII-compatible encoding" do
Encoding::UTF_8.ascii_compatible?.should be_true
@ -10,4 +9,3 @@ with_feature :encoding do
Encoding::UTF_16LE.ascii_compatible?.should be_false
end
end
end

View file

@ -2,7 +2,6 @@
require_relative '../../spec_helper'
with_feature :encoding do
# TODO: add IO
describe "Encoding.compatible? String, String" do
@ -378,4 +377,3 @@ with_feature :encoding do
Encoding.compatible?(:sym, Object.new).should be_nil
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter.asciicompat_encoding" do
it "accepts an encoding name as a String argument" do
lambda { Encoding::Converter.asciicompat_encoding('UTF-8') }.
@ -36,4 +35,3 @@ with_feature :encoding do
Encoding.default_internal = internal
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter::INVALID_MASK" do
it "exists" do
Encoding::Converter.should have_constant(:INVALID_MASK)
@ -130,4 +129,3 @@ with_feature :encoding do
Encoding::Converter::XML_ATTR_QUOTE_DECORATOR.should be_an_instance_of(Fixnum)
end
end
end

View file

@ -1,7 +1,6 @@
# -*- encoding: binary -*-
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter#convert" do
it "returns a String" do
ec = Encoding::Converter.new('ascii', 'utf-8')
@ -44,4 +43,3 @@ with_feature :encoding do
lambda { ec.convert("\u{65}") }.should raise_error(ArgumentError)
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter#convpath" do
it "returns an Array with a single element if there is a direct converter" do
cp = Encoding::Converter.new('ASCII', 'UTF-8').convpath
@ -23,4 +22,3 @@ with_feature :encoding do
ec.convpath.last.should_not == "crlf_newline"
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter#destination_encoding" do
it "returns the destination encoding as an Encoding object" do
ec = Encoding::Converter.new('ASCII','Big5')
@ -10,4 +9,3 @@ with_feature :encoding do
ec.destination_encoding.should == Encoding::EUC_JP
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter#finish" do
before :each do
@ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
@ -35,4 +34,3 @@ with_feature :encoding do
@ec.finish.should == ""
end
end
end

View file

@ -1,7 +1,6 @@
# -*- encoding: binary -*-
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter#last_error" do
it "returns nil when the no conversion has been attempted" do
ec = Encoding::Converter.new('ascii','utf-8')
@ -90,4 +89,3 @@ with_feature :encoding do
ec.last_error.message.should include "from ISO-8859-1 to UTF-8 to Big5"
end
end
end

View file

@ -1,7 +1,6 @@
# -*- encoding: ascii-8bit -*-
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter.new" do
it "accepts a String for the source encoding" do
conv = Encoding::Converter.new("us-ascii", "utf-8")
@ -118,4 +117,3 @@ with_feature :encoding do
end
end
end
end

View file

@ -1,7 +1,6 @@
# -*- encoding: binary -*-
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter#primitive_convert" do
before :each do
@ec = Encoding::Converter.new("utf-8", "iso-8859-1")
@ -210,4 +209,3 @@ with_feature :encoding do
dest.should == "abcd"
end
end
end

View file

@ -1,7 +1,6 @@
# -*- encoding: binary -*-
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter#primitive_errinfo" do
it "returns [:source_buffer_empty,nil,nil,nil,nil] when no conversion has been attempted" do
ec = Encoding::Converter.new('ascii','utf-8')
@ -67,4 +66,3 @@ with_feature :encoding do
ec.primitive_errinfo.should == [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""]
end
end
end

View file

@ -1,7 +1,6 @@
# -*- encoding: binary -*-
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter#putback" do
before :each do
@ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
@ -46,4 +45,3 @@ with_feature :encoding do
ec.putback.should == ""
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter#replacement" do
it "returns '?' in US-ASCII when the destination encoding is not UTF-8" do
ec = Encoding::Converter.new("utf-8", "us-ascii")
@ -71,4 +70,3 @@ with_feature :encoding do
dest.should == "!!123"
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter.search_convpath" do
it "returns an Array with a single element if there is a direct converter" do
cp = Encoding::Converter.search_convpath('ASCII', 'UTF-8')
@ -31,4 +30,3 @@ with_feature :encoding do
end.should raise_error(Encoding::ConverterNotFoundError)
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::Converter#source_encoding" do
it "returns the source encoding as an Encoding object" do
ec = Encoding::Converter.new('ASCII','Big5')
@ -10,4 +9,3 @@ with_feature :encoding do
ec.source_encoding.should == Encoding::SHIFT_JIS
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding.default_external" do
before :each do
@original_encoding = Encoding.default_external
@ -62,4 +61,3 @@ with_feature :encoding do
lambda { Encoding.default_external = nil }.should raise_error(ArgumentError)
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding.default_internal" do
before :each do
@original_encoding = Encoding.default_internal
@ -73,4 +72,3 @@ with_feature :encoding do
Encoding.default_internal.should be_nil
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding#dummy?" do
it "returns false for proper encodings" do
Encoding::UTF_8.dummy?.should be_false
@ -13,4 +12,3 @@ with_feature :encoding do
Encoding::UTF_7.dummy?.should be_true
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding.find" do
before :all do
@encodings = Encoding.aliases.to_a.flatten.uniq
@ -81,4 +80,3 @@ with_feature :encoding do
it "needs to be reviewed for spec completeness"
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding#inspect" do
it "returns a String" do
Encoding::UTF_8.inspect.should be_an_instance_of(String)
@ -18,4 +17,3 @@ with_feature :encoding do
end
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::InvalidByteSequenceError#destination_encoding_name" do
before :each do
@exception, = EncodingSpecs::InvalidByteSequenceError.exception
@ -17,4 +16,3 @@ with_feature :encoding do
@exception2.destination_encoding_name.should == "UTF-8"
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::InvalidByteSequenceError#destination_encoding" do
before :each do
@exception, = EncodingSpecs::InvalidByteSequenceError.exception
@ -17,4 +16,3 @@ with_feature :encoding do
@exception2.destination_encoding.should == Encoding::UTF_8
end
end
end

View file

@ -1,7 +1,6 @@
# -*- encoding: binary -*-
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::InvalidByteSequenceError#error_bytes" do
before :each do
@exception, @errinfo = EncodingSpecs::InvalidByteSequenceError.exception
@ -29,4 +28,3 @@ with_feature :encoding do
@exception2.error_bytes.encoding.should == Encoding::ASCII_8BIT
end
end
end

View file

@ -1,7 +1,6 @@
# -*- encoding: binary -*-
require_relative '../../../spec_helper'
with_feature :encoding do
describe "Encoding::InvalidByteSequenceError#incomplete_input?" do
it "returns nil by default" do
@ -28,4 +27,3 @@ with_feature :encoding do
end
end
end
end

View file

@ -1,7 +1,6 @@
# -*- encoding: binary -*-
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::InvalidByteSequenceError#readagain_bytes" do
before :each do
@exception, @errinfo = EncodingSpecs::InvalidByteSequenceError.exception
@ -29,4 +28,3 @@ with_feature :encoding do
@exception2.readagain_bytes.encoding.should == Encoding::ASCII_8BIT
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::UndefinedConversionError#source_encoding_name" do
before :each do
@exception, = EncodingSpecs::UndefinedConversionError.exception
@ -27,4 +26,3 @@ with_feature :encoding do
@exception2.source_encoding_name.should == 'UTF-8'
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::InvalidByteSequenceError#source_encoding" do
before :each do
@exception, = EncodingSpecs::InvalidByteSequenceError.exception
@ -32,4 +31,3 @@ with_feature :encoding do
@exception2.source_encoding.should == Encoding::EUC_JP
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding.list" do
it "returns an Array" do
Encoding.list.should be_an_instance_of(Array)
@ -40,4 +39,3 @@ with_feature :encoding do
# TODO: Find example that illustrates this
it "updates the list when #find is used to load a new encoding"
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding.locale_charmap" do
it "returns a String" do
Encoding.locale_charmap.should be_an_instance_of(String)
@ -44,4 +43,3 @@ with_feature :encoding do
end
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding.name_list" do
it "returns an Array" do
Encoding.name_list.should be_an_instance_of(Array)
@ -22,4 +21,3 @@ with_feature :encoding do
end
end
end
end

View file

@ -1,7 +1,5 @@
require_relative 'shared/name'
with_feature :encoding do
describe "Encoding#name" do
it_behaves_like :encoding_name, :name
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding#names" do
it "returns an Array" do
Encoding.name_list.each do |name|
@ -34,4 +33,3 @@ with_feature :encoding do
end
end
end
end

View file

@ -1,7 +1,6 @@
# -*- encoding: binary -*-
require_relative '../../spec_helper'
with_feature :encoding do
describe "Encoding#replicate" do
before :all do
@i = 0
@ -45,4 +44,3 @@ with_feature :encoding do
e.dummy?.should be_true
end
end
end

View file

@ -1,7 +1,5 @@
require_relative 'shared/name'
with_feature :encoding do
describe "Encoding#to_s" do
it_behaves_like :encoding_name, :to_s
end
end

View file

@ -1,6 +1,5 @@
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::UndefinedConversionError#destination_encoding_name" do
before :each do
@exception = EncodingSpecs::UndefinedConversionError.exception
@ -14,4 +13,3 @@ with_feature :encoding do
@exception.destination_encoding_name.should == "US-ASCII"
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::UndefinedConversionError#destination_encoding" do
before :each do
@exception = EncodingSpecs::UndefinedConversionError.exception
@ -14,4 +13,3 @@ with_feature :encoding do
@exception.destination_encoding.should == Encoding::US_ASCII
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::UndefinedConversionError#error_char" do
before :each do
@exception = EncodingSpecs::UndefinedConversionError.exception
@ -26,4 +25,3 @@ with_feature :encoding do
@exception2.error_char.encoding.should == @exception2.source_encoding
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::UndefinedConversionError#source_encoding_name" do
before :each do
@exception = EncodingSpecs::UndefinedConversionError.exception
@ -27,4 +26,3 @@ with_feature :encoding do
@exception2.source_encoding_name.should == 'UTF-8'
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../fixtures/classes'
with_feature :encoding do
describe "Encoding::UndefinedConversionError#source_encoding" do
before :each do
@exception = EncodingSpecs::UndefinedConversionError.exception
@ -28,4 +27,3 @@ with_feature :encoding do
@exception2.source_encoding.should == Encoding::UTF_8
end
end
end

View file

@ -27,7 +27,6 @@ describe "ENV.[]" do
end
end
with_feature :encoding do
describe "ENV.[]" do
before :each do
@variable = "env_element_reference_encoding_specs"
@ -63,4 +62,3 @@ with_feature :encoding do
ENV[@variable].encoding.should equal(Encoding::IBM437)
end
end
end

View file

@ -25,7 +25,6 @@ describe :env_each, shared: true do
end
it_should_behave_like :enumeratorized_with_origin_size
with_feature :encoding do
describe "with encoding" do
before :each do
@external = Encoding.default_external
@ -62,4 +61,3 @@ describe :env_each, shared: true do
end
end
end
end

View file

@ -24,7 +24,6 @@ describe "ENV.shift" do
end
end
with_feature :encoding do
describe "ENV.shift" do
before :each do
@orig = ENV.to_hash
@ -56,4 +55,3 @@ with_feature :encoding do
pair.last.encoding.should equal(Encoding::IBM437)
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :fiber do
describe "Fiber.new" do
it "creates a fiber from the given block" do
fiber = Fiber.new {}
@ -38,4 +37,3 @@ with_feature :fiber do
o.f.should == 2
end
end
end

View file

@ -1,7 +1,6 @@
require_relative '../../spec_helper'
require_relative '../../shared/fiber/resume'
with_feature :fiber do
describe "Fiber#resume" do
it_behaves_like :fiber_resume, :resume
end
@ -18,18 +17,14 @@ with_feature :fiber do
fiber2.resume.should == :fiber2
end
with_feature :fork do
# Redmine #595
it "executes the ensure clause" do
rd, wr = IO.pipe
pid = Kernel::fork do
rd.close
code = <<-RUBY
f = Fiber.new do
begin
Fiber.yield
ensure
wr.write "executed"
puts "ensure executed"
end
end
@ -46,14 +41,8 @@ with_feature :fiber do
f.resume
exit 0
end
RUBY
wr.close
Process.waitpid pid
rd.read.should == "executed"
rd.close
end
end
ruby_exe(code).should == "ensure executed\n"
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :fiber do
describe "Fiber.yield" do
it "passes control to the Fiber's caller" do
step = 0
@ -48,4 +47,3 @@ with_feature :fiber do
lambda{ Fiber.yield }.should raise_error(FiberError)
end
end
end

View file

@ -153,7 +153,6 @@ describe "File.basename" do
end
end
with_feature :encoding do
it "returns the extension for a multibyte filename" do
File.basename('/path/Офис.m4a').should == "Офис.m4a"
@ -165,6 +164,5 @@ describe "File.basename" do
basename.encoding.should == Encoding::Windows_1250
end
end
end

View file

@ -19,7 +19,6 @@ describe "File.expand_path" do
end
end
with_feature :encoding do
before :each do
@external = Encoding.default_external
end
@ -27,7 +26,6 @@ describe "File.expand_path" do
after :each do
Encoding.default_external = @external
end
end
it "converts a pathname to an absolute pathname" do
File.expand_path('').should == @base
@ -136,7 +134,6 @@ describe "File.expand_path" do
end
end
with_feature :encoding do
it "returns a String in the same encoding as the argument" do
Encoding.default_external = Encoding::SHIFT_JIS
@ -165,7 +162,6 @@ describe "File.expand_path" do
lambda { File.expand_path("./a") }.should raise_error(Encoding::CompatibilityError)
end
end
end
it "does not modify the string argument" do
str = "./a/b/../c"

View file

@ -44,11 +44,9 @@ describe "File.extname" do
lambda { File.extname("foo.bar", "foo.baz") }.should raise_error(ArgumentError)
end
with_feature :encoding do
it "returns the extension for a multibyte filename" do
File.extname('Имя.m4a').should == ".m4a"
end
end
end

View file

@ -165,23 +165,6 @@ describe "File.open" do
File.exist?(@file).should == true
end
without_feature :mjit do # [ruby-core:90895] MJIT worker may leave fd open in a forked child. TODO: consider acquiring GVL from MJIT worker.
it "opens a file with a file descriptor d and a block" do
@fh = File.open(@file)
@fh.should be_kind_of(File)
lambda {
File.open(@fh.fileno) do |fh|
@fd = fh.fileno
@fh.close
end
}.should raise_error(Errno::EBADF)
lambda { File.open(@fd) }.should raise_error(Errno::EBADF)
File.exist?(@file).should == true
end
end
it "opens a file that no exists when use File::WRONLY mode" do
lambda { File.open(@nonexistent, File::WRONLY) }.should raise_error(Errno::ENOENT)
end
@ -673,7 +656,7 @@ describe "File.open when passed a file descriptor" do
before do
@content = "File#open when passed a file descriptor"
@name = tmp("file_open_with_fd.txt")
@fd = new_fd @name, fmode("w:utf-8")
@fd = new_fd @name, "w:utf-8"
@file = nil
end

View file

@ -44,13 +44,11 @@ describe :file_path, shared: true do
end
end
with_feature :encoding do
it "preserves the encoding of the path" do
path = @path.force_encoding("euc-jp")
@file = File.new path
@file.send(@method).encoding.should == Encoding.find("euc-jp")
end
end
ruby_version_is "2.5" do
platform_is :linux do

View file

@ -289,7 +289,6 @@ describe "Float#to_s" do
end
end
with_feature :encoding do
describe "Float#to_s" do
before :each do
@internal = Encoding.default_internal
@ -309,4 +308,3 @@ with_feature :encoding do
5.47.to_s.encoding.should equal(Encoding::US_ASCII)
end
end
end

View file

@ -29,7 +29,6 @@ describe "Integer#to_s" do
end
end
with_feature :encoding do
before :each do
@internal = Encoding.default_internal
end
@ -48,7 +47,6 @@ describe "Integer#to_s" do
1.to_s.encoding.should equal(Encoding::US_ASCII)
end
end
end
context "bignum" do
describe "when given a base" do
@ -76,7 +74,6 @@ describe "Integer#to_s" do
end
end
with_feature :encoding do
before :each do
@internal = Encoding.default_internal
end
@ -96,4 +93,3 @@ describe "Integer#to_s" do
end
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe :io_external_encoding_write, shared: true do
describe "when Encoding.default_internal is nil" do
before :each do
@ -215,4 +214,3 @@ with_feature :encoding do
it_behaves_like :io_external_encoding_write, nil, "a+"
end
end
end

View file

@ -118,10 +118,10 @@ module IOSpecs
# Creates an IO instance for an existing fixture file. The
# file should obviously not be deleted.
def self.io_fixture(name, options_or_mode="r:utf-8")
def self.io_fixture(name, mode = "r:utf-8")
path = fixture __FILE__, name
name = path if File.exist? path
new_io name, options_or_mode
new_io(name, mode)
end
# Returns a closed instance of IO that was opened to reference

View file

@ -24,7 +24,7 @@ describe "IO.foreach" do
ScratchPad.recorded.should == ["hello\n", "line2\n"]
end
with_feature :fork do
platform_is_not :windows do
it "gets data from a fork when passed -" do
parent_pid = $$

View file

@ -156,11 +156,11 @@ describe "IO#gets" do
end
it "raises an IOError if the stream is opened for append only" do
lambda { File.open(@name, fmode("a:utf-8")) { |f| f.gets } }.should raise_error(IOError)
lambda { File.open(@name, "a:utf-8") { |f| f.gets } }.should raise_error(IOError)
end
it "raises an IOError if the stream is opened for writing only" do
lambda { File.open(@name, fmode("w:utf-8")) { |f| f.gets } }.should raise_error(IOError)
lambda { File.open(@name, "w:utf-8") { |f| f.gets } }.should raise_error(IOError)
end
end
@ -168,7 +168,7 @@ describe "IO#gets" do
before :each do
@name = tmp("io_gets")
touch(@name) { |f| f.write "one\n\ntwo\n\nthree\nfour\n" }
@io = new_io @name, fmode("r:utf-8")
@io = new_io @name, "r:utf-8"
end
after :each do
@ -232,7 +232,7 @@ describe "IO#gets" do
# create data "朝日" + "\xE3\x81" * 100 to avoid utf-8 conflicts
data = "朝日" + ([227,129].pack('C*') * 100).force_encoding('utf-8')
touch(@name) { |f| f.write data }
@io = new_io @name, fmode("r:utf-8")
@io = new_io @name, "r:utf-8"
end
after :each do

View file

@ -13,15 +13,10 @@ describe "IO#initialize" do
rm_r @name
end
# File descriptor numbers are not predictable in multi-threaded code;
# MJIT will be opening/closing files the background
without_feature :mjit do
it "reassociates the IO instance with the new descriptor when passed a Fixnum" do
fd = new_fd @name, "r:utf-8"
@io.send :initialize, fd, 'r'
@io.fileno.should == fd
# initialize has closed the old descriptor
lambda { IO.for_fd(@fd).close }.should raise_error(Errno::EBADF)
end
it "calls #to_int to coerce the object passed as an fd" do
@ -30,9 +25,6 @@ describe "IO#initialize" do
obj.should_receive(:to_int).and_return(fd)
@io.send :initialize, obj, 'r'
@io.fileno.should == fd
# initialize has closed the old descriptor
lambda { IO.for_fd(@fd).close }.should raise_error(Errno::EBADF)
end
end
it "raises a TypeError when passed an IO" do

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe :io_internal_encoding, shared: true do
describe "when Encoding.default_internal is not set" do
before :each do
@ -137,4 +136,3 @@ with_feature :encoding do
it_behaves_like :io_internal_encoding, nil, "a+"
end
end
end

View file

@ -136,7 +136,7 @@ describe "IO.popen" do
end
end
with_feature :fork do
platform_is_not :windows do
it "starts returns a forked process if the command is -" do
io = IO.popen("-")
@ -153,7 +153,6 @@ describe "IO.popen" do
end
end
with_feature :encoding do
it "has the given external encoding" do
@io = IO.popen(ruby_cmd('exit'), external_encoding: Encoding::EUC_JP)
@io.external_encoding.should == Encoding::EUC_JP
@ -169,7 +168,6 @@ describe "IO.popen" do
internal_encoding: Encoding::EUC_JP)
@io.internal_encoding.should be_nil
end
end
context "with a leading ENV Hash" do
it "accepts a single String command" do

View file

@ -114,7 +114,6 @@ describe "IO#puts" do
lambda { IOSpecs.closed_io.puts("stuff") }.should raise_error(IOError)
end
with_feature :encoding do
it "writes crlf when IO is opened with newline: :crlf" do
File.open(@name, 'wt', newline: :crlf) do |file|
file.puts
@ -138,4 +137,3 @@ describe "IO#puts" do
end
end
end
end

View file

@ -95,7 +95,6 @@ describe "IO.read" do
lambda { IO.read @fname, -1, -1 }.should raise_error(Errno::EINVAL)
end
with_feature :encoding do
it "uses the external encoding specified via the :external_encoding option" do
str = IO.read(@fname, external_encoding: Encoding::ISO_8859_1)
str.encoding.should == Encoding::ISO_8859_1
@ -106,7 +105,6 @@ describe "IO.read" do
str.encoding.should == Encoding::ISO_8859_1
end
end
end
describe "IO.read from a pipe" do
it "runs the rest as a subprocess and returns the standard output" do
@ -117,7 +115,7 @@ describe "IO.read from a pipe" do
IO.read(cmd).should == "hello\n"
end
with_feature :fork do
platform_is_not :windows do
it "opens a pipe to a fork if the rest is -" do
str = IO.read("|-")
if str # parent
@ -456,7 +454,6 @@ describe "IO.read with BOM" do
end
end
with_feature :encoding do
describe :io_read_internal_encoding, shared: true do
it "returns a transcoded String" do
@io.read.should == "ありがとう\n"
@ -587,7 +584,6 @@ with_feature :encoding do
end
end
end
end
describe "IO#read with large data" do
before :each do

View file

@ -112,7 +112,7 @@ describe "IO#readlines" do
lines.should == ["hello\n", "line2\n"]
end
with_feature :fork do
platform_is_not :windows do
it "gets data from a fork when passed -" do
lines = IO.readlines("|-")
@ -139,13 +139,13 @@ describe "IO#readlines" do
it "raises an IOError if the stream is opened for append only" do
lambda do
File.open(@name, fmode("a:utf-8")) { |f| f.readlines }
File.open(@name, "a:utf-8") { |f| f.readlines }
end.should raise_error(IOError)
end
it "raises an IOError if the stream is opened for write only" do
lambda do
File.open(@name, fmode("w:utf-8")) { |f| f.readlines }
File.open(@name, "w:utf-8") { |f| f.readlines }
end.should raise_error(IOError)
end
end

View file

@ -145,23 +145,6 @@ describe "IO#reopen with a String" do
File.read(@other_name).should == "new data"
end
# File descriptor numbers are not predictable in multi-threaded code;
# MJIT will be opening/closing files the background
without_feature :mjit do
it "closes the file descriptor obtained by opening the new file" do
@io = new_io @name, "w"
@other_io = File.open @other_name, "w"
max = @other_io.fileno
@other_io.close
@io.reopen @other_name
@other_io = File.open @other_name, "w"
@other_io.fileno.should == max
end
end
it "always resets the close-on-exec flag to true on non-STDIO objects" do
@io = new_io @name, "w"

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe :io_set_encoding_write, shared: true do
it "sets the encodings to nil" do
@io = new_io @name, "#{@object}:ibm437:ibm866"
@ -190,4 +189,3 @@ with_feature :encoding do
@io.internal_encoding.should == Encoding::UTF_16BE
end
end
end

View file

@ -85,7 +85,11 @@ describe :io_write, shared: true do
@r.read.should == "foo"
end
without_feature :mjit do # [ruby-core:90895] MJIT worker may leave fd open in a forked child. TODO: consider acquiring GVL from MJIT worker.
# [ruby-core:90895] MJIT worker may leave fd open in a forked child.
# For instance, MJIT creates a worker before @r.close with fork(), @r.close happens,
# and the MJIT worker keeps the pipe open until the worker execve().
# TODO: consider acquiring GVL from MJIT worker.
guard_not -> { defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? } do
it "raises Errno::EPIPE if the read end is closed and does not die from SIGPIPE" do
@r.close
-> { @w.send(@method, "foo") }.should raise_error(Errno::EPIPE, /Broken pipe/)

View file

@ -28,7 +28,6 @@ describe "IO#write on a file" do
@file.write('').should == 0
end
with_feature :encoding do
before :each do
@external = Encoding.default_external
@internal = Encoding.default_internal
@ -74,7 +73,6 @@ describe "IO#write on a file" do
File.binread(@filename).should == res.force_encoding(Encoding::ASCII_8BIT)
end
end
end
describe "IO.write" do
it_behaves_like :io_binwrite, :write

View file

@ -40,7 +40,6 @@ describe "Kernel#chomp" do
it_behaves_like :kernel_chomp_private, :chomp
end
with_feature :encoding do
describe :kernel_chomp_encoded, shared: true do
before :each do
@external = Encoding.default_external
@ -64,4 +63,3 @@ with_feature :encoding do
describe "Kernel#chomp" do
it_behaves_like :kernel_chomp_encoded, "chomp_f"
end
end

View file

@ -28,7 +28,6 @@ describe "Kernel#chop" do
it_behaves_like :kernel_chop, "chop"
end
with_feature :encoding do
describe :kernel_chop_encoded, shared: true do
before :each do
@external = Encoding.default_external
@ -52,4 +51,3 @@ with_feature :encoding do
describe "Kernel#chop" do
it_behaves_like :kernel_chop_encoded, "chop_f"
end
end

View file

@ -204,7 +204,6 @@ describe "Marshal.dump" do
Marshal.dump(str.force_encoding("binary")).should == "\x04\bI\"\x00\x06:\t@foo\"\bbar"
end
with_feature :encoding do
it "dumps a US-ASCII String" do
str = "abc".force_encoding("us-ascii")
Marshal.dump(str).should == "\x04\bI\"\babc\x06:\x06EF"
@ -225,7 +224,6 @@ describe "Marshal.dump" do
Marshal.dump(["".encode("us-ascii"), "".encode("utf-8")]).should == "\x04\b[\aI\"\x00\x06:\x06EFI\"\x00\x06;\x00T"
end
end
end
describe "with a Regexp" do
it "dumps a Regexp" do
@ -541,7 +539,6 @@ describe "Marshal.dump" do
lambda { Marshal.dump("test", obj) }.should raise_error(TypeError)
end
with_feature :encoding do
it "calls binmode when it's defined" do
obj = mock('test')
@ -550,7 +547,6 @@ describe "Marshal.dump" do
Marshal.dump("test", obj)
end
end
end

View file

@ -422,7 +422,6 @@ describe :marshal_load, shared: true do
str.should be_an_instance_of(UserCustomConstructorString)
end
with_feature :encoding do
it "loads a US-ASCII String" do
str = "abc".force_encoding("us-ascii")
data = "\x04\bI\"\babc\x06:\x06EF"
@ -455,7 +454,6 @@ describe :marshal_load, shared: true do
result.should == str
end
end
end
describe "for a Struct" do
it "loads a extended_struct having fields with same objects" do

View file

@ -22,7 +22,6 @@ describe "MatchData#post_match" do
$'.untrusted?.should be_true
end
with_feature :encoding do
it "sets the encoding to the encoding of the source String" do
str = "abc".force_encoding Encoding::EUC_JP
str.match(/b/).post_match.encoding.should equal(Encoding::EUC_JP)
@ -33,4 +32,3 @@ describe "MatchData#post_match" do
str.match(/c/).post_match.encoding.should equal(Encoding::ISO_8859_1)
end
end
end

View file

@ -22,7 +22,6 @@ describe "MatchData#pre_match" do
$`.untrusted?.should be_true
end
with_feature :encoding do
it "sets the encoding to the encoding of the source String" do
str = "abc".force_encoding Encoding::EUC_JP
str.match(/b/).pre_match.encoding.should equal(Encoding::EUC_JP)
@ -33,4 +32,3 @@ describe "MatchData#pre_match" do
str.match(/a/).pre_match.encoding.should equal(Encoding::ISO_8859_1)
end
end
end

View file

@ -3,8 +3,6 @@ require_relative 'fixtures/classes'
# NOTE: A call to define_finalizer does not guarantee that the
# passed proc or callable will be called at any particular time.
# It is highly questionable whether these aspects of ObjectSpace
# should be spec'd at all.
describe "ObjectSpace.define_finalizer" do
it "raises an ArgumentError if the action does not respond to call" do
lambda {
@ -30,72 +28,41 @@ describe "ObjectSpace.define_finalizer" do
end
# see [ruby-core:24095]
with_feature :fork do
it "calls finalizer on process termination" do
rd, wr = IO.pipe
pid = Process.fork do
rd.close
handler = ObjectSpaceFixtures.scoped(wr)
code = <<-RUBY
def scoped
Proc.new { puts "finalized" }
end
handler = scoped
obj = "Test"
ObjectSpace.define_finalizer(obj, handler)
exit 0
end
RUBY
wr.close
begin
rd.read.should == "finalized"
ensure
rd.close
Process.wait pid
end
ruby_exe(code).should == "finalized\n"
end
it "calls finalizer at exit even if it is self-referencing" do
rd, wr = IO.pipe
pid = Process.fork do
rd.close
code = <<-RUBY
obj = "Test"
handler = Proc.new { wr.write "finalized"; wr.close }
handler = Proc.new { puts "finalized" }
ObjectSpace.define_finalizer(obj, handler)
exit 0
RUBY
ruby_exe(code).should == "finalized\n"
end
wr.close
begin
rd.read.should == "finalized"
ensure
rd.close
Process.wait pid
end
end
# These specs are defined under the fork specs because there is no
# deterministic way to force finalizers to be run, except process exit, so
# we rely on that.
it "allows multiple finalizers with different 'callables' to be defined" do
rd1, wr1 = IO.pipe
rd2, wr2 = IO.pipe
code = <<-RUBY
obj = Object.new
pid = Kernel::fork do
rd1.close
rd2.close
obj = mock("ObjectSpace.define_finalizer multiple")
ObjectSpace.define_finalizer(obj, Proc.new { wr1.write "finalized1"; wr1.close })
ObjectSpace.define_finalizer(obj, Proc.new { wr2.write "finalized2"; wr2.close })
ObjectSpace.define_finalizer(obj, Proc.new { STDOUT.write "finalized1\n" })
ObjectSpace.define_finalizer(obj, Proc.new { STDOUT.write "finalized2\n" })
exit 0
end
RUBY
wr1.close
wr2.close
rd1.read.should == "finalized1"
rd2.read.should == "finalized2"
rd1.close
rd2.close
Process.wait pid
end
ruby_exe(code).lines.sort.should == ["finalized1\n", "finalized2\n"]
end
end

View file

@ -33,25 +33,12 @@ describe "Process.euid=" do
as_superuser do
describe "if run by a superuser" do
with_feature :fork do
it "sets the effective user id for the current process if run by a superuser" do
read, write = IO.pipe
pid = Process.fork do
begin
read.close
code = <<-RUBY
Process.euid = 1
write << Process.euid
write.close
rescue Exception => e
write << e << e.backtrace
end
Process.exit!
end
write.close
euid = read.gets
euid.should == "1"
Process.wait pid
end
puts Process.euid
RUBY
ruby_exe(code).should == "1\n"
end
end
end

View file

@ -1,23 +1,7 @@
require_relative '../../spec_helper'
describe "Process.ppid" do
with_feature :fork do
it "returns the process id of the parent of this process" do
read, write = IO.pipe
child_pid = Process.fork {
read.close
write << "#{Process.ppid}\n"
write.close
exit!
}
write.close
pid = read.gets
read.close
Process.wait(child_pid)
pid.to_i.should == Process.pid
end
ruby_exe("puts Process.ppid").should == "#{Process.pid}\n"
end
end

View file

@ -1,7 +1,8 @@
require_relative '../../spec_helper'
describe "Process.setpgid" do
with_feature :fork do
platform_is_not :windows do
# Must use fork as setpgid(2) gives EACCESS after execve()
it "sets the process group id of the specified process" do
rd, wr = IO.pipe

View file

@ -1,37 +1,16 @@
require_relative '../../spec_helper'
describe "Process.setsid" do
with_feature :fork do
platform_is_not :windows do
it "establishes this process as a new session and process group leader" do
read, write = IO.pipe
read2, write2 = IO.pipe
pid = Process.fork {
begin
read.close
write2.close
pgid = Process.setsid
write << pgid
write.close
read2.gets
rescue Exception => e
write << e << e.backtrace
end
Process.exit!
}
write.close
read2.close
pgid_child = Integer(read.gets)
read.close
platform_is_not :aix, :openbsd do
# AIX does not allow Process.getsid(pid)
# if pid is in a different session.
pgid = Process.getsid(pid)
pgid_child.should == pgid
end
write2.close
Process.wait pid
sid = Process.getsid
pgid_child.should_not == Process.getsid
out = ruby_exe("p Process.getsid; p Process.setsid; p Process.getsid").lines
out[0].should == "#{sid}\n"
out[1].should == out[2]
out[2].should_not == "#{sid}\n"
sid.should == Process.getsid
end
end
end

View file

@ -18,7 +18,6 @@ describe "Process.uid" do
end
describe "Process.uid=" do
platform_is_not :windows do
it "raises TypeError if not passed an Integer" do
lambda { Process.uid = Object.new }.should raise_error(TypeError)
@ -36,49 +35,23 @@ describe "Process.uid=" do
as_superuser do
describe "if run by a superuser" do
with_feature :fork do
it "sets the real user id for the current process" do
read, write = IO.pipe
pid = Process.fork do
begin
read.close
code = <<-RUBY
Process.uid = 1
write << Process.uid
write.close
rescue Exception => e
write << e << e.backtrace
end
Process.exit!
end
write.close
uid = read.gets
uid.should == "1"
Process.wait pid
puts Process.uid
RUBY
ruby_exe(code).should == "1\n"
end
it "sets the real user id if preceded by Process.euid=id" do
read, write = IO.pipe
pid = Process.fork do
begin
read.close
code = <<-RUBY
Process.euid = 1
Process.uid = 1
write << Process.uid
write.close
rescue Exception => e
write << e << e.backtrace
end
Process.exit!
end
write.close
uid = read.gets
uid.should == "1"
Process.wait pid
puts Process.uid
RUBY
ruby_exe(code).should == "1\n"
end
end
end
end
end
it "needs to be reviewed for spec completeness"
end

View file

@ -8,9 +8,7 @@ describe "Process.wait2" do
# but we shouldn't reap them from Ruby-space
begin
Process.wait(-1, Process::WNOHANG)
without_feature :mjit do
$stderr.puts "Leaked process before wait2 specs! Waiting for it"
end
leaked = Process.waitall
$stderr.puts "leaked before wait2 specs: #{leaked}" unless leaked.empty?
# Ruby-space should not see PIDs used by mjit

View file

@ -44,7 +44,6 @@ describe "Regexp#match" do
/(.).(.)/.match("01234", 1).captures.should == ["1", "3"]
end
with_feature :encoding do
it "uses the start as a character offset" do
/(.).(.)/.match("零一二三四", 1).captures.should == ["", ""]
end
@ -54,14 +53,12 @@ describe "Regexp#match" do
lambda { /(.).(.)/.match("Hello, #{x96} world!", 1) }.should raise_error(ArgumentError)
end
end
end
describe "when given a negative position" do
it "matches the input at a given position" do
/(.).(.)/.match("01234", -4).captures.should == ["1", "3"]
end
with_feature :encoding do
it "uses the start as a character offset" do
/(.).(.)/.match("零一二三四", -4).captures.should == ["", ""]
end
@ -71,7 +68,6 @@ describe "Regexp#match" do
lambda { /(.).(.)/.match("Hello, #{x96} world!", -1) }.should raise_error(ArgumentError)
end
end
end
describe "when passed a block" do
it "yields the MatchData" do

View file

@ -2,7 +2,6 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
with_feature :encoding do
describe "String#ascii_only?" do
describe "with ASCII only characters" do
it "returns true if the encoding is UTF-8" do
@ -82,4 +81,3 @@ with_feature :encoding do
"".replace("λ").ascii_only?.should be_false
end
end
end

View file

@ -2,7 +2,6 @@
require_relative '../../spec_helper'
describe "String#b" do
with_feature :encoding do
it "returns an ASCII-8BIT encoded string" do
"Hello".b.should == "Hello".force_encoding(Encoding::ASCII_8BIT)
"こんちには".b.should == "こんちには".force_encoding(Encoding::ASCII_8BIT)
@ -21,4 +20,3 @@ describe "String#b" do
ret.untrusted?.should be_true
end
end
end

View file

@ -36,7 +36,6 @@ describe "String#bytes" do
end
end
with_feature :encoding do
describe "String#bytes" do
before :each do
@utf8 = "東京"
@ -54,4 +53,3 @@ with_feature :encoding do
@utf8.force_encoding('ASCII').bytes.to_a.should == @utf8.bytes.to_a
end
end
end

View file

@ -2,7 +2,6 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
with_feature :encoding do
describe "#String#bytesize" do
it "needs to be reviewed for spec completeness"
@ -34,4 +33,3 @@ with_feature :encoding do
"".force_encoding('UTF-8').bytesize.should == 0
end
end
end

View file

@ -17,7 +17,6 @@ describe "String#byteslice with Range" do
it_behaves_like :string_slice_range, :byteslice
end
with_feature :encoding do
describe "String#byteslice on on non ASCII strings" do
it "returns byteslice of unicode strings" do
"\u3042".byteslice(1).should == "\x81".force_encoding("UTF-8")
@ -26,4 +25,3 @@ with_feature :encoding do
"\u3042".byteslice(-1).should == "\x82".force_encoding("UTF-8")
end
end
end

View file

@ -104,7 +104,6 @@ describe "String#center with length, padding" do
"hello".center(6, 'X'.taint).tainted?.should be_true
end
with_feature :encoding do
describe "with width" do
it "returns a String in the same encoding as the original" do
str = "abc".force_encoding Encoding::IBM437
@ -130,4 +129,3 @@ describe "String#center with length, padding" do
end
end
end
end

View file

@ -330,7 +330,6 @@ describe "String#chomp!" do
end
end
with_feature :encoding do
describe "String#chomp" do
before :each do
@before_separator = $/
@ -388,4 +387,3 @@ with_feature :encoding do
str.chomp!.should == "abc".encode("utf-32be")
end
end
end

View file

@ -27,7 +27,6 @@ describe "String#chop" do
"abc\r\n\r\n".chop.should == "abc\r\n"
end
with_feature :encoding do
it "removes a multi-byte character" do
"あれ".chop.should == ""
end
@ -40,7 +39,6 @@ describe "String#chop" do
str = "abc\r\n".encode "utf-32be"
str.chop.should == "abc".encode("utf-32be")
end
end
it "returns an empty string when applied to an empty string" do
"".chop.should == ""
@ -91,7 +89,6 @@ describe "String#chop!" do
"abc\r\n\r\n".chop!.should == "abc\r\n"
end
with_feature :encoding do
it "removes a multi-byte character" do
"あれ".chop!.should == ""
end
@ -104,7 +101,6 @@ describe "String#chop!" do
str = "abc\r\n".encode "utf-32be"
str.chop!.should == "abc".encode("utf-32be")
end
end
it "returns self if modifications were made" do
str = "hello"

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "String#chr" do
it "returns a copy of self" do
s = 'e'
@ -41,4 +40,3 @@ with_feature :encoding do
"#{three}#{four}".chr.should == three
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
with_feature :encoding do
describe "String#clear" do
before :each do
@s = "Jolene"
@ -36,4 +35,3 @@ with_feature :encoding do
lambda { "".freeze.clear }.should raise_error(frozen_error_class)
end
end
end

View file

@ -3,7 +3,6 @@ require_relative '../../spec_helper'
require_relative 'shared/codepoints'
require_relative 'shared/each_codepoint_without_block'
with_feature :encoding do
describe "String#codepoints" do
it_behaves_like :string_codepoints, :codepoints
@ -17,4 +16,3 @@ with_feature :encoding do
lambda { s.codepoints }.should raise_error(ArgumentError)
end
end
end

View file

@ -174,9 +174,7 @@ describe "String#downcase!" do
lambda { "hello".freeze.downcase! }.should raise_error(frozen_error_class)
end
with_feature :encoding do
it "sets the result String encoding to the source String encoding" do
"ABC".downcase.encoding.should equal(Encoding::UTF_8)
end
end
end

View file

@ -2,9 +2,7 @@ require_relative '../../spec_helper'
require_relative 'shared/codepoints'
require_relative 'shared/each_codepoint_without_block'
with_feature :encoding do
describe "String#each_codepoint" do
it_behaves_like :string_codepoints, :each_codepoint
it_behaves_like :string_each_codepoint_without_block, :each_codepoint
end
end

Some files were not shown because too many files have changed in this diff Show more