Sha256: 58420c1421c45019876f19157e6348796507cc1ccdd4aa04f1eb899611e35dbb

Contents?: true

Size: 1.57 KB

Versions: 12

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

require 'ostruct'
require_relative '../../spec_helper'

require_relative '../../../lib/rley/syntax/terminal'
require_relative '../../../lib/rley/lexical/token_range'
require_relative '../../../lib/rley/lexical/token'

# Load the class under test
require_relative '../../../lib/rley/sppf/token_node'

module Rley # Open this namespace to avoid module qualifier prefixes
  module SPPF # Open this namespace to avoid module qualifier prefixes
    describe TokenNode do
      let(:sample_symbol) { Syntax::Terminal.new('Noun') }
      let(:sample_position) { Lexical::Position.new(3, 4) }
      let(:sample_token) do
        Lexical::Token.new('language', sample_symbol, sample_position)
      end
      let(:sample_rank) { 3 }

      subject { TokenNode.new(sample_token, sample_rank) }

      context 'Initialization:' do
        it 'should know its token' do
          expect(subject.token).to eq(sample_token)
        end

        it 'should know its token range' do
          expect(subject.origin).to eq(sample_rank)
          expect(subject.range.low).to eq(sample_rank)
          expect(subject.range.high).to eq(sample_rank + 1)
        end
      end # context

      context 'Provided services:' do
        it 'should know its string representation' do
          expect(subject.to_string(0)).to eq('Noun[3, 4]')
          expect(subject.inspect).to eq('Noun[3, 4]')
        end

        it 'should return a key value of itself' do
          expect(subject.key).to eq('Noun[3, 4]')
        end
      end # context
    end # describe
  end # module
end # module

# End of file

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rley-0.8.13 spec/rley/sppf/token_node_spec.rb
rley-0.8.11 spec/rley/sppf/token_node_spec.rb
rley-0.8.10 spec/rley/sppf/token_node_spec.rb
rley-0.8.09 spec/rley/sppf/token_node_spec.rb
rley-0.8.08 spec/rley/sppf/token_node_spec.rb
rley-0.8.06 spec/rley/sppf/token_node_spec.rb
rley-0.8.05 spec/rley/sppf/token_node_spec.rb
rley-0.8.03 spec/rley/sppf/token_node_spec.rb
rley-0.8.02 spec/rley/sppf/token_node_spec.rb
rley-0.8.01 spec/rley/sppf/token_node_spec.rb
rley-0.8.00 spec/rley/sppf/token_node_spec.rb
rley-0.7.08 spec/rley/sppf/token_node_spec.rb