Sha256: a324256b7157ff17729abef270df4167ae61f20816bc77a2f2b7bc0ad8fcce30

Contents?: true

Size: 956 Bytes

Versions: 23

Compression:

Stored size: 956 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
    }
  end

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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
opal-0.3.41 spec/language/symbol_spec.rb
opal-0.3.40 spec/language/symbol_spec.rb
opal-0.3.39 spec/language/symbol_spec.rb
opal-0.3.38 spec/language/symbol_spec.rb
opal-0.3.37 spec/language/symbol_spec.rb
opal-0.3.36 spec/language/symbol_spec.rb
opal-0.3.35 spec/language/symbol_spec.rb
opal-0.3.34 spec/language/symbol_spec.rb
opal-0.3.33 spec/language/symbol_spec.rb
opal-0.3.32 spec/language/symbol_spec.rb
opal-0.3.31 spec/language/symbol_spec.rb
opal-0.3.30 spec/language/symbol_spec.rb
opal-0.3.29 spec/language/symbol_spec.rb
opal-0.3.28 spec/language/symbol_spec.rb
opal-0.3.27 spec/language/symbol_spec.rb
opal-0.3.26 spec/language/symbol_spec.rb
opal-0.3.25 spec/language/symbol_spec.rb
opal-0.3.22 spec/language/symbol_spec.rb
opal-0.3.21 test/language/symbol_spec.rb
opal-0.3.20 test/language/symbol_spec.rb