Sha256: 1054f92ce0640bed9f87087ec097fe39e5a69db95c0fffd0d391ccfaec08b59f

Contents?: true

Size: 612 Bytes

Versions: 6

Compression:

Stored size: 612 Bytes

Contents

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

describe "The unless keyword" do
  it "returns s(:if) with reversed true and false bodies" do
    opal_parse("unless 10; 20; end").should == [:if, [:lit, 10], nil, [:lit, 20]]
    opal_parse("unless 10; 20; 30; end").should == [:if, [:lit, 10], nil, [:block, [:lit, 20], [:lit, 30]]]
    opal_parse("unless 10; 20; else; 30; end").should == [:if, [:lit, 10], [:lit, 30], [:lit, 20]]
  end

  it "returns s(:if) with reversed true and false bodies for prefix unless" do
    opal_parse("20 unless 10").should == [:if, [:lit, 10], nil, [:lit, 20]]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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