Sha256: 8ea5077b24203d623bd9276d8e7a4e7cd75f1fd6f5d48da3d018179138f7c1b0

Contents?: true

Size: 901 Bytes

Versions: 26

Compression:

Stored size: 901 Bytes

Contents

require 'spec_helper'

describe "The module keyword" do
  it "returns a plain s(:scope) when given an empty body" do
    opal_parse('module A; end').should == [:module, :A, [:scope]]
  end

  it "does not place single expressions into a s(:block)" do
    opal_parse('module A; 1; end').should == [:module, :A, [:scope, [:lit, 1]]]
  end

  it "adds multiple body expressions into a s(:block)" do
    opal_parse('module A; 1; 2; end').should == [:module, :A, [:scope, [:block, [:lit, 1], [:lit, 2]]]]
  end

  it "should accept just a constant for the module name" do
    opal_parse('module A; end')[1].should == :A
  end

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

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
opal-0.4.3 spec/parser/module_spec.rb
opal-0.4.2 spec/parser/module_spec.rb
opal-0.4.1 spec/parser/module_spec.rb
opal-0.4.0 spec/parser/module_spec.rb
opal-0.3.44 spec/parser/module_spec.rb
opal-0.3.43 spec/parser/module_spec.rb
opal-0.3.42 spec/grammar/module_spec.rb
opal-0.3.41 spec/grammar/module_spec.rb
opal-0.3.40 spec/grammar/module_spec.rb
opal-0.3.39 spec/grammar/module_spec.rb
opal-0.3.38 spec/grammar/module_spec.rb
opal-0.3.37 spec/grammar/module_spec.rb
opal-0.3.36 spec/grammar/module_spec.rb
opal-0.3.35 spec/grammar/module_spec.rb
opal-0.3.34 spec/grammar/module_spec.rb
opal-0.3.33 spec/grammar/module_spec.rb
opal-0.3.32 spec/grammar/module_spec.rb
opal-0.3.31 spec/grammar/module_spec.rb
opal-0.3.30 spec/grammar/module_spec.rb
opal-0.3.29 spec/grammar/module_spec.rb