Core refactor for VM.

This commit is contained in:
Peter Camilleri 2014-10-29 15:43:12 -04:00
parent 3019e61062
commit c9bf89dd6c
6 changed files with 52 additions and 3 deletions

View file

@ -22,7 +22,7 @@ class ClassLibraryTester < MiniTest::Unit::TestCase
super(*all)
end
def test_that_the_object_class_is_available
def test_that_the_class_class_is_available
foorth_equal("Class", [XfOOrth.class_class])
end

View file

@ -0,0 +1,33 @@
# coding: utf-8
require_relative '../lib/foorth'
require_relative 'support/foorth_testing'
require 'minitest/autorun'
#Test the standard fOOrth library.
class VMLibraryTester < MiniTest::Unit::TestCase
include XfOOrthTestExtensions
#Special initialize to track rake progress.
def initialize(*all)
$do_this_only_one_time = "" unless defined? $do_this_only_one_time
if $do_this_only_one_time != __FILE__
puts
puts "Running test file: #{File.split(__FILE__)[1]}"
$do_this_only_one_time = __FILE__
end
super(*all)
end
def test_that_the_VM_class_and_instance_are_available
foorth_equal("VirtualMachine", [XfOOrth::VirtualMachine])
vm = XfOOrth.virtual_machine
foorth_equal("vm", [vm])
end
end

View file

@ -72,8 +72,6 @@ module XfOOrth
#Everything after this point should be re-factored elsewhere!
@object_class.create_shared_method('VirtualMachine', MacroWordSpec,
["vm.push(VirtualMachine); "])
#==========================================================================
# Define some core methods.

View file

@ -2,6 +2,7 @@
require_relative 'library/object_library'
require_relative 'library/class_library'
require_relative 'library/vm_library'
require_relative 'library/compile_library'
require_relative 'library/standard_library'
require_relative 'library/ctrl_struct_library'

View file

@ -0,0 +1,15 @@
# coding: utf-8
#* library/class_library.rb - The fOOrth Class class library.
module XfOOrth
#Create a macro to get at the Virtual Machine class.
@object_class.create_shared_method('VirtualMachine', MacroWordSpec,
["vm.push(VirtualMachine); "])
#Create a macro to get at the current virtual machine instance.
VirtualMachine.create_shared_method('vm', MacroWordSpec,
["vm.push(vm); "])
end

View file

@ -31,6 +31,7 @@ RDoc::Task.new do |rdoc|
"lib/fOOrth/library.rb",
"lib/fOOrth/library/object_library.rb",
"lib/fOOrth/library/class_library.rb",
"lib/fOOrth/library/vm_library.rb",
"lib/fOOrth/library/compile_library.rb",
"lib/fOOrth/library/standard_library.rb",
"lib/fOOrth/library/ctrl_struct_library.rb",
@ -101,6 +102,7 @@ Rake::TestTask.new(:integration) do |t|
#List out all the test files.
t.test_files = ["integration/object_library_tests.rb",
"integration/class_library_tests.rb",
"integration/vm_library_tests.rb",
"integration/standard_library_tests.rb",
"integration/ctrl_struct_library_tests.rb",
"integration/compile_library_tests.rb",