Change soft-fail to use the config, rather than env
[rbx.git] / spec / frozen / 1.8 / core / io / pos_spec.rb
blob381cdac99b6c57249360198ea70dc8f2798e5d51
1 require File.dirname(__FILE__) + '/../../spec_helper'
2 require File.dirname(__FILE__) + '/fixtures/classes'
3 require File.dirname(__FILE__) + '/shared/pos'
5 describe "IO#pos" do
6   it_behaves_like(:io_pos, :pos)
7 end
9 describe "IO#pos=" do
11   before :each do
12     @fname = 'test.txt'
13     File.open @fname, 'w' do |f| f.write "123" end
14   end
16   after :each do
17     File.unlink @fname
18   end
20   it "sets the offset" do
21     File.open @fname do |f|
22       val1 = f.read 1
23       f.pos = 0
24       f.read(1).should == val1
25     end
26   end
28   it "can handle any numerical argument without breaking" do
29     File.open @fname do |io|
30       io.pos = 1.2
31       io.pos.should == 1
33       io.pos = 2**32
34       io.pos.should == 2**32
36       io.pos = 1.23423423432e12
37       io.pos.should == Integer(1.23423423432e12)
39       io.pos = Float::EPSILON
40       io.pos.should == 0
42       lambda { io.pos = 2**128 }.should raise_error(RangeError)
43     end
44   end
45   
46   it "raises IOError on closed stream" do
47     lambda { IOSpecs.closed_file.pos = 0 }.should raise_error(IOError)
48   end
50 end