Sha256: 77d5e221b7640cde7b009657cb457adaf4e0ed4c6872730576dc5124e69b9fed

Contents?: true

Size: 792 Bytes

Versions: 4

Compression:

Stored size: 792 Bytes

Contents

require 'test_helper'

class DynamicScopeTest < Test::Unit::TestCase
  include Tins::DynamicScope

  def test_dynamic_scoping
    assert_raise(NameError) { foo }
    assert_equal false, dynamic_defined?(:foo)
    dynamic_scope do
      assert_raise(NameError) { foo }
      assert_equal false, dynamic_defined?(:foo)
      self.foo = 1
      assert_equal 1, foo
      assert_equal true, dynamic_defined?(:foo)
      dynamic_scope do
        assert_equal 1, foo
        assert_equal true, dynamic_defined?(:foo)
        self.foo = 2
        assert_equal 2, foo
        dynamic_scope do
          assert_equal 2, foo
        end
        assert_equal 2, foo
      end
      assert_equal 1, foo
    end
    assert_equal false, dynamic_defined?(:foo)
    assert_raise(NameError) { foo }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tins-1.37.0 tests/dynamic_scope_test.rb
tins-1.36.1 tests/dynamic_scope_test.rb
tins-1.36.0 tests/dynamic_scope_test.rb
tins-1.35.0 tests/dynamic_scope_test.rb