2018-03-04 15:09:32 +00:00
|
|
|
require_relative '../../spec_helper'
|
|
|
|
require_relative 'fixtures/classes'
|
|
|
|
require_relative 'shared/codepoints'
|
2017-05-07 12:04:49 +00:00
|
|
|
|
2020-12-04 16:32:14 +01:00
|
|
|
ruby_version_is ''...'3.0' do
|
2017-05-07 12:04:49 +00:00
|
|
|
|
2020-07-27 11:15:50 +09:00
|
|
|
# See redmine #1667
|
|
|
|
describe "IO#codepoints" do
|
2020-12-27 17:35:32 +01:00
|
|
|
before :each do
|
|
|
|
@verbose, $VERBOSE = $VERBOSE, nil
|
|
|
|
end
|
|
|
|
|
|
|
|
after :each do
|
|
|
|
$VERBOSE = @verbose
|
|
|
|
end
|
|
|
|
|
2020-07-27 11:15:50 +09:00
|
|
|
it_behaves_like :io_codepoints, :codepoints
|
2017-05-07 12:04:49 +00:00
|
|
|
end
|
|
|
|
|
2020-07-27 11:15:50 +09:00
|
|
|
describe "IO#codepoints" do
|
|
|
|
before :each do
|
|
|
|
@io = IOSpecs.io_fixture "lines.txt"
|
2020-12-27 17:35:32 +01:00
|
|
|
@verbose, $VERBOSE = $VERBOSE, nil
|
2020-07-27 11:15:50 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
after :each do
|
2020-12-27 17:35:32 +01:00
|
|
|
$VERBOSE = @verbose
|
2020-07-27 11:15:50 +09:00
|
|
|
@io.close unless @io.closed?
|
|
|
|
end
|
2017-05-07 12:04:49 +00:00
|
|
|
|
2020-07-27 11:15:50 +09:00
|
|
|
it "calls the given block" do
|
|
|
|
r = []
|
|
|
|
@io.codepoints { |c| r << c }
|
|
|
|
r[24].should == 232
|
|
|
|
r.last.should == 10
|
|
|
|
end
|
2017-05-07 12:04:49 +00:00
|
|
|
end
|
|
|
|
end
|