diff options
| author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-05-29 01:59:53 +0000 |
|---|---|---|
| committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-05-29 01:59:53 +0000 |
| commit | c55e7d2abc2f94c2ebf6cf119d826ea7a3fe9048 (patch) | |
| tree | 47fc8916b5816c5f32544f09d30295381a2bc3a2 /test/ruby/test_continuation.rb | |
| parent | 1fe0a3655fc1715540fda45e2e92679b02e925d0 (diff) | |
| download | ruby-c55e7d2abc2f94c2ebf6cf119d826ea7a3fe9048.tar.gz ruby-c55e7d2abc2f94c2ebf6cf119d826ea7a3fe9048.tar.xz ruby-c55e7d2abc2f94c2ebf6cf119d826ea7a3fe9048.zip | |
* cont.c: fix bug around Continuation and Fiber.
* test/ruby/test_continuation.rb: add tests for Continuation.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_continuation.rb')
| -rw-r--r-- | test/ruby/test_continuation.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/ruby/test_continuation.rb b/test/ruby/test_continuation.rb new file mode 100644 index 000000000..d5c9c32e4 --- /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 + |
