Fixed the tests up, replaced OpenStruct with Data, which requires ruby 3.2+
This commit is contained in:
1 parent
5aec94a036
commit
97fc625280
4 files changed
+15
-16
No files matched your search
+8
-11
@@ -15,7 +15,9 @@ module N65
|
|||||||
class INESHeaderAlreadySet < StandardError; end
|
class INESHeaderAlreadySet < StandardError; end
|
||||||
class FileNotFound < StandardError; end
|
class FileNotFound < StandardError; end
|
||||||
|
|
||||||
# Assemble from an asm file to a nes ROM
|
State = Data.define(:program_counter, :segment, :bank, :scope)
|
||||||
|
|
||||||
|
# Assemble from an asm file to a NES ROM
|
||||||
# TODO: This really needs a logger instead of all these unless quiet conditions
|
# TODO: This really needs a logger instead of all these unless quiet conditions
|
||||||
def self.from_file(infile, options)
|
def self.from_file(infile, options)
|
||||||
raise(FileNotFound, infile) unless File.exist?(infile)
|
raise(FileNotFound, infile) unless File.exist?(infile)
|
||||||
@@ -92,18 +94,13 @@ module N65
|
|||||||
def get_current_state
|
def get_current_state
|
||||||
saved_program_counter, saved_segment, saved_bank = @program_counter, @current_segment, @current_bank
|
saved_program_counter, saved_segment, saved_bank = @program_counter, @current_segment, @current_bank
|
||||||
saved_scope = symbol_table.scope_stack.dup
|
saved_scope = symbol_table.scope_stack.dup
|
||||||
OpenStruct.new(
|
State.new(saved_program_counter, saved_segment, saved_bank, saved_scope)
|
||||||
program_counter: saved_program_counter,
|
|
||||||
segment: saved_segment,
|
|
||||||
bank: saved_bank,
|
|
||||||
scope: saved_scope
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set the current state from an OpenStruct
|
# Set the current state
|
||||||
def set_current_state(struct)
|
def set_current_state(state)
|
||||||
@program_counter, @current_segment, @current_bank = struct.program_counter, struct.segment, struct.bank
|
@program_counter, @current_segment, @current_bank = state.program_counter, state.segment, state.bank
|
||||||
symbol_table.scope_stack = struct.scope.dup
|
symbol_table.scope_stack = state.scope.dup
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is the main assemble method, it parses one line into an object
|
# This is the main assemble method, it parses one line into an object
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module N65
|
module N65
|
||||||
VERSION ||= '0.5.3'
|
VERSION ||= '1.0.0'
|
||||||
end
|
end
|
||||||
+1
-1
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|||||||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
||||||
spec.require_paths = ['lib']
|
spec.require_paths = ['lib']
|
||||||
|
|
||||||
spec.required_ruby_version = '>= 2.4.0'
|
spec.required_ruby_version = '>= 3.2.0'
|
||||||
|
|
||||||
spec.add_development_dependency 'bundler'
|
spec.add_development_dependency 'bundler'
|
||||||
spec.add_development_dependency 'rake'
|
spec.add_development_dependency 'rake'
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ RSpec.describe(N65::Assembler) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
let(:source) do
|
let(:source) do
|
||||||
File.read(File.join(examples, filename))
|
File.read(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:assembler) do
|
let(:assembler) do
|
||||||
@@ -18,7 +18,9 @@ RSpec.describe(N65::Assembler) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
let(:binary) do
|
let(:binary) do
|
||||||
assembler.assemble_string(source).emit_binary_rom
|
Dir.chdir(examples) do
|
||||||
|
assembler.assemble_string(source).emit_binary_rom
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:sha256) do
|
let(:sha256) do
|
||||||
@@ -70,7 +72,7 @@ RSpec.describe(N65::Assembler) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when assembling mario2.asm', skip: '.incbin include path should be relative to source file' do
|
context 'when assembling mario2.asm' do
|
||||||
let(:filename) { 'mario2.asm' }
|
let(:filename) { 'mario2.asm' }
|
||||||
let(:expected) { '0974b799eac7ffb8835fcbd518a5cdeeec734d5d9476cd11cb6b75491c6ef488' }
|
let(:expected) { '0974b799eac7ffb8835fcbd518a5cdeeec734d5d9476cd11cb6b75491c6ef488' }
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user