Sha256: e5c82de37c4e09eea87f12b66beb58a0a60021b84dac7dfaffd1d1a8a873e56e

Contents?: true

Size: 1.25 KB

Versions: 19

Compression:

Stored size: 1.25 KB

Contents

require 'support/parser_helpers'

describe Opal::Parser do
  describe '-@' do
    context 'with an integer' do
      it "parses unary op. with the right precedence" do
        parsed("-1.hello").should == [:call, [:int, -1], :hello, [:arglist]]
      end

      it "parses unary op. as a method call" do
        parsed("-1").should == [:int, -1]
      end

    end

    context 'with a float' do
      it "parses unary op. with the right precedence" do
        parsed("-1.23.hello").should == [:call, [:float, -1.23], :hello, [:arglist]]
      end

      it "parses unary op. as a method call" do
        parsed("-1.23").should == [:float, -1.23]
      end
    end
  end

  describe '+@' do
    context 'with an integer' do
      it "parses unary op. with the right precedence" do
        parsed("+1.hello").should == [:call, [:int, 1], :hello, [:arglist]]
      end

      it "parses unary op. as a method call" do
        parsed("-1").should == [:int, -1]
      end
    end

    context 'with a float' do
      it "parses unary op. with the right precedence" do
        parsed("+1.23.hello").should == [:call, [:float, 1.23], :hello, [:arglist]]
      end

      it "parses unary op. as a method call" do
        parsed("-1.23").should == [:float, -1.23]
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
opal-0.9.0.beta2 spec/lib/parser/unary_spec.rb
opal-0.9.0.beta1 spec/lib/parser/unary_spec.rb
opal-0.8.1 spec/lib/parser/unary_spec.rb
opal-0.8.1.rc1 spec/lib/parser/unary_spec.rb
opal-wedge-0.9.0.dev spec/lib/parser/unary_spec.rb
opal-0.8.0 spec/lib/parser/unary_spec.rb
opal-0.8.0.rc3 spec/lib/parser/unary_spec.rb
opal-0.8.0.rc2 spec/lib/parser/unary_spec.rb
opal-0.8.0.rc1 spec/lib/parser/unary_spec.rb
opal-0.8.0.beta1 spec/lib/parser/unary_spec.rb
opal-0.7.2 spec/lib/parser/unary_spec.rb
opal-0.7.1 spec/lib/parser/unary_spec.rb
opal-0.7.0 spec/lib/parser/unary_spec.rb
opal-0.7.0.rc1 spec/lib/parser/unary_spec.rb
opal-0.7.0.beta3 spec/lib/parser/unary_spec.rb
opal-0.7.0.beta2 spec/lib/parser/unary_spec.rb
opal-cj-0.7.0.beta2 spec/lib/parser/unary_spec.rb
opal-cj-0.7.0.beta1 spec/lib/parser/unary_spec.rb
opal-0.7.0.beta1 spec/lib/parser/unary_spec.rb