Sha256: 889e4fe0f3babac36dc4db63205d61b7c029834618849bb5a8a04c32dc57268f

Contents?: true

Size: 630 Bytes

Versions: 26

Compression:

Stored size: 630 Bytes

Contents

require 'spec_helper'

describe "The return keyword" do
  it "should return s(:return) when given no arguments" do
    opal_parse("return").should == [:return]
  end

  it "returns s(:return) with the direct argument when given one argument" do
    opal_parse("return 1").should == [:return, [:lit, 1]]
    opal_parse("return *2").should == [:return, [:splat, [:lit, 2]]]
  end

  it "returns s(:return) with an s(:array) when args size > 1" do
    opal_parse("return 1, 2").should == [:return, [:array, [:lit, 1], [:lit, 2]]]
    opal_parse("return 1, *2").should == [:return, [:array, [:lit, 1], [:splat, [:lit, 2]]]]
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

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