Sha256: 29294357e9dbf752e01c45712372f09d2c941c4e59a83eb91c343a5e133273ea

Contents?: true

Size: 1.07 KB

Versions: 22

Compression:

Stored size: 1.07 KB

Contents

require_relative 'helper'


class TestEvent < Test::Unit::TestCase

  def event()
    Reflex::UpdateEvent.new 0, 0
  end

  def test_initialize()
    assert_raise(Reflex::ReflexError) {Reflex::Event.new}
  end

  def test_dup()
    e1 = event
    e2 = e1.dup
    e1.block
    e3 = e1.dup
    assert_true  e1.blocked?
    assert_false e2.blocked?
    assert_true  e3.blocked?
  end

  def test_block()
    events = -> {
      e1 = event
      e2 = e1.dup
      e3 = e2.dup
      return e1, e2, e3
    }

    e1, e2, e3 = events.call
    assert_equal [false, false, false], [e1.blocked?, e2.blocked?, e3.blocked?]

    e1, e2, e3 = events.call
    e2.block
    assert_equal [true,  true,  false], [e1.blocked?, e2.blocked?, e3.blocked?]

    e1, e2, e3 = events.call
    e2.block false
    assert_equal [false, true,  false], [e1.blocked?, e2.blocked?, e3.blocked?]

    e1, e2, e3 = events.call
    e2.block true
    assert_equal [true,  true,  false], [e1.blocked?, e2.blocked?, e3.blocked?]
  end

  def test_time()
    assert_in_delta Time.now.to_f, event.time, 0.001
  end

end# TestEvent

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
reflexion-0.3.2 test/test_event.rb
reflexion-0.3.1 test/test_event.rb
reflexion-0.3 test/test_event.rb
reflexion-0.2.1 test/test_event.rb
reflexion-0.2 test/test_event.rb
reflexion-0.1.57 test/test_event.rb
reflexion-0.1.56 test/test_event.rb
reflexion-0.1.55 test/test_event.rb
reflexion-0.1.54 test/test_event.rb
reflexion-0.1.53 test/test_event.rb
reflexion-0.1.52 test/test_event.rb
reflexion-0.1.51 test/test_event.rb
reflexion-0.1.50 test/test_event.rb
reflexion-0.1.49 test/test_event.rb
reflexion-0.1.48 test/test_event.rb
reflexion-0.1.47 test/test_event.rb
reflexion-0.1.46 test/test_event.rb
reflexion-0.1.45 test/test_event.rb
reflexion-0.1.44 test/test_event.rb
reflexion-0.1.43 test/test_event.rb