Sha256: ae95bc59cb514596f32b23ac5842bb069cf40b24cece1aee035be550b14400fe
Contents?: true
Size: 1.24 KB
Versions: 9
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true require_relative '../spec_helper' # Use the RSpec framework require 'stringio' # Load the class under test require_relative '../../lib/loxxy/back_end/engine' module Loxxy module BackEnd describe Engine do let(:sample_options) do { ostream: StringIO.new } end subject { Engine.new(sample_options) } context 'Initialization:' do it 'should accept a option Hash at initialization' do expect { Engine.new(sample_options) }.not_to raise_error end it 'should know its config options' do expect(subject.config).to eq(sample_options) end it 'should have an empty stack' do expect(subject.stack).to be_empty end end context 'Listening to visitor events:' do let(:greeting) { Datatype::LXString.new('Hello, world') } let(:sample_pos) { double('fake-position') } let(:lit_expr) { Ast::LoxLiteralExpr.new(sample_pos, greeting) } it "should react to 'before_literal_expr' event" do expect { subject.before_literal_expr(lit_expr) }.not_to raise_error expect(subject.stack.pop).to eq(greeting) end end end # describe end # module end # module
Version data entries
9 entries across 9 versions & 1 rubygems