diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-07-01 21:05:55 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-07-02 07:59:54 +0900 |
commit | c68781e9181cb43af1bac29b3c974887205c3bf3 (patch) | |
tree | 34019fe4147362f117fdc0b23d2b3533a956ccb5 /tool/test/testunit/test_assertion.rb | |
parent | c3c0e3f5c9444c197779cb242de46dfffda79dec (diff) |
Split test files for test-framework that are test-unit and minitest to tool direcotry.
Diffstat (limited to 'tool/test/testunit/test_assertion.rb')
-rw-r--r-- | tool/test/testunit/test_assertion.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tool/test/testunit/test_assertion.rb b/tool/test/testunit/test_assertion.rb new file mode 100644 index 0000000000..0c7c4882b8 --- /dev/null +++ b/tool/test/testunit/test_assertion.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: false +require 'test/unit' +class TestAssertion < Test::Unit::TestCase + def test_wrong_assertion + error, line = assert_raise(ArgumentError) {assert(true, true)}, __LINE__ + assert_match(/assertion message must be String or Proc, but TrueClass was given/, error.message) + assert_match(/\A#{Regexp.quote(__FILE__)}:#{line}:/, error.backtrace[0]) + end + + def test_timeout_separately + assert_raise(Timeout::Error) do + assert_separately([], <<~"end;", timeout: 0.1) + sleep + end; + end + end + + def return_in_assert_raise + assert_raise(RuntimeError) do + return + end + end + + def test_assert_raise + assert_raise(MiniTest::Assertion) do + return_in_assert_raise + end + end +end |