Sha256: 2cded191157e03efdbfd8d94c68e11afe8774e8dec5a9e48c8c69f3cc3fe321a

Contents?: true

Size: 1.69 KB

Versions: 52

Compression:

Stored size: 1.69 KB

Contents

require File.expand_path('../../spec_helper', __FILE__)

module LangModuleSpec
  module Sub1; end
end

module LangModuleSpecInObject
  module LangModuleTop
  end
end

# Must be here, we have to include it into Object because thats
# the case.
include LangModuleSpecInObject

module LangModuleSpec::Sub2; end

describe "module" do
  it "has the right name" do
    LangModuleSpec::Sub1.name.should == "LangModuleSpec::Sub1"
    LangModuleSpec::Sub2.name.should == "LangModuleSpec::Sub2"
  end

  it "gets a name when assigned to a constant" do
    LangModuleSpec::Anon = Module.new
    LangModuleSpec::Anon.name.should == "LangModuleSpec::Anon"
  end

  it "raises a TypeError if the constant is a class" do
    class LangModuleSpec::C1; end

    lambda {
      module LangModuleSpec::C1; end
    }.should raise_error(TypeError)
  end

  it "raises a TypeError if the constant is not a module" do
    module LangModuleSpec
      C2 = 2
    end

    lambda {
      module LangModuleSpec::C2; end
    }.should raise_error(TypeError)
  end

  it "allows for reopening a module subclass" do
    class ModuleSubClass < Module; end
    LangModuleSpec::C3 = ModuleSubClass.new

    module LangModuleSpec::C3
      C4 = 4
    end

    LangModuleSpec::C3::C4.should == 4
  end

  it "reopens a module included into Object" do
    module LangModuleTop
    end

    LangModuleTop.should == LangModuleSpecInObject::LangModuleTop
  end
end

describe "An anonymous module" do
  ruby_version_is "" ... "1.9" do
    it "returns an empty string for its name" do
      m = Module.new
      m.name.should == ""
    end
  end

  ruby_version_is "1.9" do
    it "returns nil for its name" do
      m = Module.new
      m.name.should == nil
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/language/module_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/language/module_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/language/module_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-3.3.5 spec/framework_spec/app/spec/language/module_spec.rb
rhodes-3.4.2 spec/framework_spec/app/spec/language/module_spec.rb