From d64609463fb755d94922e0d205283416542d9ea2 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 29 May 2007 01:59:53 +0000 Subject: * cont.c: fix bug around Continuation and Fiber. * test/ruby/test_continuation.rb: add tests for Continuation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_continuation.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/ruby/test_continuation.rb (limited to 'test/ruby/test_continuation.rb') diff --git a/test/ruby/test_continuation.rb b/test/ruby/test_continuation.rb new file mode 100644 index 0000000000..d5c9c32e4b --- /dev/null +++ b/test/ruby/test_continuation.rb @@ -0,0 +1,31 @@ +require 'test/unit' + +class TestContinuation < Test::Unit::TestCase + def test_create + assert_equal(:ok, callcc{:ok}) + assert_equal(:ok, callcc{|c| c.call :ok}) + end + + def test_call + assert_equal(:ok, callcc{|c| c.call :ok}) + + ary = [] + ary << callcc{|c| + @cont = c + :a + } + @cont.call :b if ary.length < 3 + assert_equal([:a, :b, :b], ary) + end + + def test_error + cont = callcc{|c| c} + assert_raise(RuntimeError){ + Thread.new{cont.call}.join + } + assert_raise(LocalJumpError){ + callcc + } + end +end + -- cgit v1.2.3