Skip to content

Commit

Permalink
add on_init/on_exit exception tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcorino committed Oct 29, 2023
1 parent d9907fa commit 20c76ff
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_app_exit_exception.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.

require 'test/unit'
require 'wx'

class TestApp < Test::Unit::TestCase

class TestFrame < Wx::Frame
def initialize
super(nil, -1, '')
evt_paint { on_paint }
end

def on_paint
paint {}
close
end
end

class TestApp < Wx::App
def on_init
TestFrame.new.show
end

def on_exit
raise RuntimeError, 'on_exit exception'
end
end

def test_self_closing_frame
assert_raise_kind_of(RuntimeError) { TestApp.run }
end

end
20 changes: 20 additions & 0 deletions tests/test_app_init_exception.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.

require 'test/unit'
require 'wx'

class AppInitExitExceptions < Test::Unit::TestCase

class TestApp < Wx::App
def on_init
raise RuntimeError, 'on_init exception'
end
end

def test_on_init_exception
assert_raise_kind_of(RuntimeError) { TestApp.run }
end

end

0 comments on commit 20c76ff

Please sign in to comment.