Sha256: b6b72e12415dd794acbe20e2fe514e22b0873828f663d1a1c6ce40641da50732

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'
module Qrb
  describe Syntax, "heading" do

    subject{
      Syntax.parse(input, root: "heading")
    }

    describe "compilation result" do
      let(:compiled){
        subject.compile(type_factory)
      }

      context 'empty heading' do
        let(:input){ '  ' }

        it 'compiles to a Heading' do
          compiled.should be_a(Heading)
          compiled.to_name.should eq('')
        end
      end

      context 'a: .Integer' do
        let(:input){ 'a: .Integer' }

        it 'compiles to a Heading' do
          compiled.should be_a(Heading)
          compiled.to_name.should eq('a: Integer')
        end
      end

      context 'a: .Integer, b: .Float' do
        let(:input){ 'a: .Integer, b: .Float' }

        it 'compiles to a Heading' do
          compiled.should be_a(Heading)
          compiled.to_name.should eq('a: Integer, b: Float')
        end
      end
    end

    describe "AST" do
      let(:input){ 'a: .Integer, b: .Float' }

      let(:ast){
        subject.to_ast
      }

      it{
        ast.should eq([
          :heading,
          [ :attribute, "a", [:builtin_type, "Integer" ]],
          [ :attribute, "b", [:builtin_type, "Float" ]]
        ])
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qrb-0.3.0 spec/unit/syntax/nodes/test_heading.rb