Sha256: 603c9735acafef568310f924808a1db3c3f945f4e13826fc9e80bf155e3c4a7c

Contents?: true

Size: 825 Bytes

Versions: 4

Compression:

Stored size: 825 Bytes

Contents

covers 'facets/binding/caller'

tests Binding do

  a = 1
  b = 2
  x = "hello"
  
  bind = binding
  line = __LINE__  # the line number must be updated if it moves
  file = __FILE__  # why does it equal basename only?

  unit :__LINE__ do
    bind.__LINE__.assert == line - 1
  end

  unit :__FILE__ do
    bind.__FILE__.assert == file
  end

  unit :__DIR__ do
    bind.__DIR__.assert == File.dirname(file)
  end

  unit :callstack do
    bind.callstack.assert.is_a?(Array)
  end

  unit :call_stack do
    bind.call_stack.assert.is_a?(Array)
  end

  unit :caller do
    Exception.refute.raised? do
      bind.caller
    end
  end

  unit :__callee__ do
    alternate.__callee__.assert == :alternate
  end

  unit :__method__ do
    alternate.__method__.assert == :alternate
  end

  def alternate
    binding
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facets-2.9.1 test/core/binding/test_caller.rb
facets-2.9.0 test/core/binding/test_caller.rb
facets-2.9.0.pre.2 test/core/binding/test_caller.rb
facets-2.9.0.pre.1 test/core/binding/test_caller.rb