=begin
File implements Filetests as class methods but maybe we should
have instance methods for some.
There's two points in my example, I expect file.size
1) to work, that is to work like File.size(file)
2) not to report size of the physical file but
the size of 'logical' file. I shouldn't be forced to
flush the buffers to disk before I can query the real size.
=end
def print_unpredictable_many_bytes( file )
0..rand(1024*10).times { file.print "%c" % rand(256) }
end
filename = "foo"
file = open( filename, "w+" )
print_unpredictable_many_bytes( file )
# fill to nearest kb
# this is what I expect to work
# file.print "\00" * (1023 - (file.size-1) % 1024)
# and this really works (as documented)
file.flush
file.print "\00" * (1023 - ((File.size(file)-1) % 1024))
file.close