Sha256: 03466e386136717de8ffb97c38dc41f6374b005196d1f571f3844a251dae58f2

Contents?: true

Size: 951 Bytes

Versions: 1

Compression:

Stored size: 951 Bytes

Contents

require 'test/unit'
require 'carat/detach.rb'


# fixture

class Logger
  def log(str)
      puts "From #{Process.pid}: #{str.to_s}"
  end
end

class Person
  attr_accessor :log
  def say(msg)
    puts "Detached #{Process.pid}"
    @log.log("hello, i said #{msg}")
  end
  def wait
    sleep 10
    "hi"
  end
end


class TC_Detach < Test::Unit::TestCase

  puts "Parent is #{Process.pid}"
  
  log = Logger.new
  p = Person.new
  p = p.detach(:allref => true)
  puts "p is a #{p.class}"
  p.log = log
  p.say("I won!")
  
  s = p.wait
  
  puts "s is a #{s.class}"
  
  puts "While i'm here, the other process should be doing it's thing."
  puts "It's waiting for 10 seconds, so if i wait for 5, it should only be another 5 after i ask for the method that it returns"
  sleep 5
  
  puts "Lets try something..."
  while not s.ready?
      puts "Is the method ready? (#{s.ready?})"
      sleep 2
  end
  p s.to_s
  
  puts "Stats:"
  p s.stats

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carats-0.3.0 lib/carat-dev/detach/tc_detach.rb