diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-14 17:31:51 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-14 17:31:51 +0900 |
commit | 10688de25ddc071ffbe46f9ffa83d01f6812b0d2 (patch) | |
tree | de9530eed93e9cc35f0faffe867f75c9769dbba0 /test | |
parent | 881f8c942d450e28db1bc85928068a22ce37a656 (diff) | |
parent | eb5facc1549cf044bf474b52a6a78dc55ea5fa0a (diff) | |
download | plum-10688de25ddc071ffbe46f9ffa83d01f6812b0d2.tar.gz |
Merge branch 'master' of github.com:rhenium/plum
Diffstat (limited to 'test')
-rw-r--r-- | test/plum/hpack/test_context.rb | 4 | ||||
-rw-r--r-- | test/plum/test_event_emitter.rb | 31 |
2 files changed, 33 insertions, 2 deletions
diff --git a/test/plum/hpack/test_context.rb b/test/plum/hpack/test_context.rb index 86654ec..3b662ec 100644 --- a/test/plum/hpack/test_context.rb +++ b/test/plum/hpack/test_context.rb @@ -54,10 +54,10 @@ class HPACKContextTest < Minitest::Test private def new_context(limit = 1 << 31) - @c ||= Class.new { + klass = Class.new { include Plum::HPACK::Context public *Plum::HPACK::Context.private_instance_methods } - @c.new(limit) + klass.new(limit) end end diff --git a/test/plum/test_event_emitter.rb b/test/plum/test_event_emitter.rb new file mode 100644 index 0000000..01d6001 --- /dev/null +++ b/test/plum/test_event_emitter.rb @@ -0,0 +1,31 @@ +require "test_helper" + +using BinaryString +class EventEmitterTest < Minitest::Test + def test_simple + ret = nil + emitter = new_emitter + emitter.on(:event) {|arg| ret = arg } + emitter.callback(:event, 123) + assert_equal(123, ret) + end + + def test_multiple + ret1 = nil; ret2 = nil + emitter = new_emitter + emitter.on(:event) {|arg| ret1 = arg } + emitter.on(:event) {|arg| ret2 = arg } + emitter.callback(:event, 123) + assert_equal(123, ret1) + assert_equal(123, ret2) + end + + private + def new_emitter + klass = Class.new { + include EventEmitter + public *EventEmitter.private_instance_methods + } + klass.new + end +end |