Sha256: 1e7cf2692d9c50fd0b9176c31a2bc6122d717b5c53c9fa703efe437fc53b9984

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require 'tataru'

describe Tataru::Instructions::CallInstruction do
  it 'call an existing label' do
    mem = Tataru::Memory.new
    instr = Tataru::Instructions::CallInstruction.new('function')

    mem.hash[:labels] = { 'function' => 10 }
    instr.memory = mem
    instr.run

    expect(mem.program_counter).to eq 9
  end

  it 'sets error if no such label' do
    mem = Tataru::Memory.new
    mem.hash[:labels] = { }
    instr = Tataru::Instructions::CallInstruction.new('function')

    instr.memory = mem
    instr.run

    expect(mem.program_counter).to eq 0
    expect(mem.error).to eq 'Label not found'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tataru-0.2.0 spec/instructions/call_instruction_spec.rb