Sha256: 46da1107b8318589b92cbe45c3a540da944ff373050070313602dd6368971cbf

Contents?: true

Size: 664 Bytes

Versions: 6

Compression:

Stored size: 664 Bytes

Contents

require File.expand_path('../../spec_helper', __FILE__)

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

6 entries across 6 versions & 1 rubygems

Version Path
opal-0.3.20 spec/grammar/return_spec.rb
opal-0.3.19 spec/grammar/return_spec.rb
opal-0.3.18 spec/grammar/return_spec.rb
opal-0.3.17 test/grammar/return_spec.rb
opal-0.3.16 spec/grammar/return_spec.rb
opal-0.3.15 spec/grammar/return_spec.rb