Sha256: 242f208c51dcff860777181be1ac721a0d91c11822d06836681394637230349a

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

require 'spec_helper'
module Finitio
  describe Syntax, "builtin_type" do

    subject{
      Syntax.parse(source, root: "builtin_type")
    }

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

      context 'when an unqualified class name' do
        let(:source){ ".Integer" }

        it 'compiles to a BuiltinType' do
          compiled.should be_a(BuiltinType)
          compiled.ruby_type.should be(Integer)
        end
      end

      context 'when a qualified class name' do
        let(:source){ ".Finitio::Type" }

        it 'compiles to a BuiltinType' do
          compiled.should be_a(BuiltinType)
          compiled.ruby_type.should be(::Finitio::Type)
        end
      end
    end

    describe "AST" do
      let(:source){ ".Finitio::Type" }

      let(:ast){
        subject.to_ast
      }

      it{ ast.should eq([:builtin_type, "Finitio::Type"]) }
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finitio-0.4.1 spec/unit/syntax/nodes/test_builtin_type.rb
finitio-0.4.0 spec/unit/syntax/nodes/test_builtin_type.rb