summaryrefslogtreecommitdiff
path: root/test/drb/ut_drb.rb
diff options
context:
space:
mode:
authorseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-20 15:24:00 +0000
committerseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-20 15:24:00 +0000
commitbc867112ecb2ce355caf98c3627d50a7d0b60f3d (patch)
tree9c8658426165ebaf3e815ac6aa21356956944da7 /test/drb/ut_drb.rb
parentd6153337f60acb466d48ac4b563aed8c847e8ecf (diff)
import drb/runit/*.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/drb/ut_drb.rb')
-rw-r--r--test/drb/ut_drb.rb137
1 files changed, 137 insertions, 0 deletions
diff --git a/test/drb/ut_drb.rb b/test/drb/ut_drb.rb
new file mode 100644
index 0000000000..7a6409a783
--- /dev/null
+++ b/test/drb/ut_drb.rb
@@ -0,0 +1,137 @@
+require 'drb/drb'
+require 'drb/extserv'
+require 'timeout'
+
+class XArray < Array
+ def initialize(ary)
+ ary.each do |x|
+ self.push(x)
+ end
+ end
+end
+
+class XArray2 < XArray
+ include DRbUndumped
+end
+
+class Unknown2
+ def initialize
+ @foo = 'unknown2'
+ end
+end
+
+class DRbEx
+ include DRbUndumped
+
+ class FooBar
+ def initialize
+ @foo = 'bar'
+ end
+ end
+
+ class UError < RuntimeError; end
+
+ def initialize
+ @hello = 'hello'
+ end
+ attr_reader :hello
+
+ def sample(a, b, c)
+ a.to_i + b.to_i + c.to_i
+ end
+
+ def sum(*a)
+ s = 0
+ a.each do |e|
+ s += e.to_i
+ end
+ s
+ end
+
+ def do_timeout(n)
+ timeout(1) do
+ n.sleep(2)
+ end
+ end
+
+ def unknown_module
+ FooBar.new
+ end
+
+ def unknown_class
+ Unknown2.new
+ end
+
+ def unknown_error
+ raise UError
+ end
+
+ def test_yield
+ yield
+ yield([])
+ yield(*[])
+ end
+
+ def echo_yield(*arg)
+ yield(*arg)
+ nil
+ end
+
+ def echo_yield_0
+ yield
+ nil
+ end
+
+ def echo_yield_1(one)
+ yield(one)
+ nil
+ end
+
+ def echo_yield_2(one, two)
+ yield(one, two)
+ nil
+ end
+
+ def xarray_each
+ xary = [XArray.new([0])]
+ xary.each do |x|
+ yield(x)
+ end
+ nil
+ end
+
+ def xarray2_hash
+ unless @xary2_hash
+ @xary2_hash = { "a" => XArray2.new([0]), "b" => XArray2.new([1]) }
+ end
+ DRbObject.new(@xary2_hash)
+ end
+
+ def [](key)
+ key.to_s
+ end
+
+ def to_a
+ [self]
+ end
+
+ private
+ def call_private_method
+ true
+ end
+end
+
+if __FILE__ == $0
+ def ARGV.shift
+ it = super()
+ raise "usage: #{$0} <manager-uri> <name>" unless it
+ it
+ end
+
+ DRb::DRbServer.default_argc_limit(8)
+ DRb::DRbServer.default_load_limit(2048)
+ DRb.start_service(nil, DRbEx.new)
+ es = DRb::ExtServ.new(ARGV.shift, ARGV.shift)
+ DRb.thread.join
+end
+