Sha256: 466236b9889dc8e11bc650af433b283d6d02560c37d76665e38d1eac9905df8f

Contents?: true

Size: 778 Bytes

Versions: 12

Compression:

Stored size: 778 Bytes

Contents

module WLang
  describe Scope, '.chain' do

    it 'returns the NullScope on empty chain' do
      Scope.chain([]).should eq(Scope.null)
    end

    it 'returns a single scope on singleton' do
      s = Scope.chain([{:who => "World"}])
      s.should be_a(Scope::ObjectScope)
      s.parent.should be_nil
    end

    it 'uses the last scope as most specific' do
      s = Scope.chain([{:who => "World"}, lambda{}])
      s.should be_a(Scope::ProcScope)
      s.parent.should be_a(Scope::ObjectScope)
      s.parent.parent.should be_nil
    end

    it 'strips nils' do
      s = Scope.chain([nil, {:who => "World"}, nil, lambda{}, nil])
      s.should be_a(Scope::ProcScope)
      s.parent.should be_a(Scope::ObjectScope)
      s.parent.parent.should be_nil
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
wlang-3.0.1 spec/unit/scope/test_chain.rb
wlang-3.0.0 spec/unit/scope/test_chain.rb
wlang-2.3.1 spec/unit/scope/test_chain.rb
wlang-2.3.0 spec/unit/scope/test_chain.rb
wlang-2.2.4 spec/unit/scope/test_chain.rb
wlang-2.2.3 spec/unit/scope/test_chain.rb
wlang-2.2.2 spec/unit/scope/test_chain.rb
wlang-2.2.1 spec/unit/scope/test_chain.rb
wlang-2.2.0 spec/unit/scope/test_chain.rb
wlang-2.1.2 spec/unit/scope/test_chain.rb
wlang-2.1.1 spec/unit/scope/test_chain.rb
wlang-2.1.0 spec/unit/scope/test_chain.rb