Sha256: a0a2ef75f3c113cbbe110a16bca77db387f3901f9e0bda0b79fcb454504f508c

Contents?: true

Size: 1.1 KB

Versions: 39

Compression:

Stored size: 1.1 KB

Contents

require 'support/parser_helpers'

describe "The class keyword" do
  it "returns an empty s(:block) when given an empty body" do
    parsed('class A; end').should == [:class, [:const, :A], nil, [:block]]
  end

  it "does not place single expressions into a s(:block)" do
    parsed('class A; 1; end').should == [:class, [:const, :A], nil, [:int, 1]]
  end

  it "adds multiple body expressions into a s(:block)" do
    parsed('class A; 1; 2; end').should == [:class, [:const, :A], nil, [:block, [:int, 1], [:int, 2]]]
  end

  it "uses nil as a placeholder when no superclass is given" do
    parsed('class A; end')[2].should == nil
  end

  it "reflects the given superclass" do
    parsed('class A < B; end')[2].should == [:const, :B]
  end

  it "should accept just a constant for the class name" do
    parsed('class A; end')[1].should == [:const, :A]
  end

  it "should accept a prefix constant for the class name" do
    parsed('class ::A; end')[1].should == [:colon3, :A]
  end

  it "should accept a nested constant for the class name" do
    parsed('class A::B; end')[1].should == [:colon2, [:const, :A], :B]
  end
end

Version data entries

39 entries across 39 versions & 3 rubygems

Version Path
opal-0.10.6 spec/lib/parser/class_spec.rb
opal-0.10.6.beta spec/lib/parser/class_spec.rb
opal-0.10.5 spec/lib/parser/class_spec.rb
opal-0.10.4 spec/lib/parser/class_spec.rb
opal-0.10.3 spec/lib/parser/class_spec.rb
opal-0.10.2 spec/lib/parser/class_spec.rb
opal-0.10.1 spec/lib/parser/class_spec.rb
opal-0.10.0 spec/lib/parser/class_spec.rb
opal-0.10.0.rc2 spec/lib/parser/class_spec.rb
opal-0.9.4 spec/lib/parser/class_spec.rb
opal-0.9.3 spec/lib/parser/class_spec.rb
opal-0.10.0.rc1 spec/lib/parser/class_spec.rb
opal-0.10.0.beta5 spec/lib/parser/class_spec.rb
opal-0.10.0.beta4 spec/lib/parser/class_spec.rb
opal-0.10.0.beta3 spec/lib/parser/class_spec.rb
opal-0.10.0.beta2 spec/lib/parser/class_spec.rb
opal-0.10.0.beta1 spec/lib/parser/class_spec.rb
opal-0.9.2 spec/lib/parser/class_spec.rb
opal-0.9.0 spec/lib/parser/class_spec.rb
opal-0.9.0.rc1 spec/lib/parser/class_spec.rb