Sha256: cbb22899d29543da5b3491f1ae69419aaa70d74858b84c2292c13a556865d6cf

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

#!/usr/bin/env ruby
require 'test/unit'
require_relative '../../lib/trace_mod' if '1.9.2' == RUBY_VERSION

# Testing Trace Module
class TestTrace < Test::Unit::TestCase

  def test_set_trace_func
    @events = []
    def foo ; end

    event_set = [:call, :return]
    Trace::set_trace_func(Proc.new {|e, tf| @events << e}, event_set)
    foo
    call_return_mask = Trace::event_masks[0]
    assert_equal(Fixnum, call_return_mask.class)

    Trace::event_masks = [:call]
    foo
    call_mask = Trace::event_masks[0]
    Trace::set_trace_func(nil)

    @events.each do |e| 
      assert_equal(true, event_set.member?(e.to_sym), 
                   "#{e} should be in #{event_set}")
    end
    
    assert_equal(true,
                 ((call_return_mask > call_mask) &&
                  (0 != (call_return_mask & call_mask))))
                 
    @events = []
    Trace::set_trace_func(nil)
    @events.each do |e| 
      assert_equal(true, event_set.member?(e.to_sym), 
                   "#{e} should be in #{event_set}")
    end

    assert_equal(nil, Trace::event_masks[0])
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rb-trace-0.7 test/unit/test-trace_mod.rb
rb-trace-0.6 test/unit/test-trace_mod.rb