Sha256: 28d68c3bd9a0508a9de2f0a3d00bf03f9d1362061c01a905cb450c4cd9c5b0d6

Contents?: true

Size: 977 Bytes

Versions: 19

Compression:

Stored size: 977 Bytes

Contents

describe "A Symbol literal" do
  it "is a ':' followed by any number of valid characters" do
    a = :foo
    a.should be_kind_of(Symbol)
    # FIXME: this doesnt work as Symbols are Strings
    #a.inspect.should == ':foo'
  end

  it "is a ':' followed by any valid variable, method, or constant name" do
    # Add more of these?
    [ :Foo,
      :foo,
      :@foo,
      :@@foo,
      :$foo,
      :_,
      :~,
      :-,
      :FOO,
      :_Foo,
      :&,
      :_9
    ].each { |s| s.should be_kind_of(Symbol) }
  end

  it "is a ':' followed by a single- or double-quoted string that may contain otherwise invalid characters" do
    [ [:'foo bar',      ':"foo bar"'],
      [:'++',           ':"++"'],
      [:'9',            ':"9"'],
      [:"foo #{1 + 1}", ':"foo 2"']
    ].each {
      # FIXME: Symbols are Strings, so #inspect wont work
      1.should == 1
    }
  end

  it "may contain '::' in the string" do
    :'Some::Class'.should be_kind_of(Symbol)
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
opal-0.6.3 spec/opal/core/language/symbol_spec.rb
opal-cj-0.7.0.beta2 spec/opal/core/language/symbol_spec.rb
opal-cj-0.7.0.beta1 spec/opal/core/language/symbol_spec.rb
opal-0.7.0.beta1 spec/opal/core/language/symbol_spec.rb
opal-0.6.2 spec/opal/core/language/symbol_spec.rb
opal-0.6.1 spec/opal/core/language/symbol_spec.rb
opal-0.6.0 spec/opal/core/language/symbol_spec.rb
opal-0.5.5 spec/opal/core/language/symbol_spec.rb
opal-0.5.4 spec/corelib/language/symbol_spec.rb
opal-0.5.2 spec/corelib/language/symbol_spec.rb
opal-0.5.0 spec/corelib/language/symbol_spec.rb
opal-0.4.4 spec/rubyspec/language/symbol_spec.rb
opal-0.4.3 spec/rubyspec/language/symbol_spec.rb
opal-0.4.2 spec/rubyspec/language/symbol_spec.rb
opal-0.4.1 spec/rubyspec/language/symbol_spec.rb
opal-0.4.0 spec/rubyspec/language/symbol_spec.rb
opal-0.3.44 spec/rubyspec/language/symbol_spec.rb
opal-0.3.43 spec/rubyspec/language/symbol_spec.rb
opal-0.3.42 spec/language/symbol_spec.rb