Sha256: 68beaf195ae54a923e72ff6b4cddcdf988dfebfd1cbf5879a691b867ab9ddef4

Contents?: true

Size: 1.09 KB

Versions: 13

Compression:

Stored size: 1.09 KB

Contents

#!/usr/local/bin/ruby
if $0 == __FILE__
  Dir.chdir File.dirname(__FILE__)+'/../'
  $:.unshift File.expand_path('../lib/')
end

require 'rio'
require 'tc/testcase'

class TC_copylines < Test::RIO::TestCase
  @@once = false
  STR = 'peter piper picked a peck of pickled peppers'
  WORDS = STR.split(/\s+/)
  LINE = WORDS.map { |w| w+"\n" }.join('')
  def self.once
    @@once = true
    src = rio('src').print!(LINE)
  end
  def setup
    super
    self.class.once unless @@once
  end
  def test_basic
    out = rio(?")
    rio('src').chomp.lines(/^[^p]/) > out
    assert(out.closed?, "copy closed")

    assert_equal('aof',out.contents)
    
    out < rio('src').lines(/^[^p]/)
    assert_equal("a\nof\n",out.contents)
    
    aout = Array.new
    rio('src').chomp.lines(1,4..6) > aout
    assert_equal(%w{piper peck of pickled},aout)
    
    out < rio('src').chomp.lines(0..1)
    assert_equal("peterpiper",out.contents)
    
    rio('src').chomp.lines(0..1) > aout
    assert_equal(%w{peter piper},aout)

    rio('src').chomp.lines(0..1) >> aout
    assert_equal(%w{peter piper peter piper},aout)
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
rio-0.6.0 test/tc/copylines.rb
wishdev-rio-0.4.3.1 test/tc/copylines.rb
rio-0.5.1 test/tc/copylines.rb
rio-0.3.2 test/tc/copylines.rb
rio-0.3.3 test/tc/copylines.rb
rio-0.3.8 test/tc/copylines.rb
rio-0.3.7 test/tc/copylines.rb
rio-0.3.9 test/tc/copylines.rb
rio-0.3.6 test/tc/copylines.rb
rio-0.3.4 test/tc/copylines.rb
rio-0.4.0 test/tc/copylines.rb
rio-0.4.1 test/tc/copylines.rb
rio-0.4.2 test/tc/copylines.rb