2014-10-29 18:53:13 +01:00
|
|
|
# coding: utf-8
|
|
|
|
|
2014-10-30 03:34:00 +01:00
|
|
|
require_relative '../lib/fOOrth'
|
2014-10-29 18:53:13 +01:00
|
|
|
require_relative 'support/foorth_testing'
|
2014-11-04 06:26:00 +01:00
|
|
|
require 'minitest/autorun'
|
2014-10-29 18:53:13 +01:00
|
|
|
|
|
|
|
#Test the standard fOOrth library.
|
2014-11-04 06:26:00 +01:00
|
|
|
class ObjectLibraryTester < MiniTest::Unit::TestCase
|
2014-10-29 18:53:13 +01:00
|
|
|
|
|
|
|
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_object_class_is_available
|
2014-11-13 18:06:25 +01:00
|
|
|
foorth_equal("Object", [Object])
|
2014-10-29 18:53:13 +01:00
|
|
|
end
|
|
|
|
|
2014-10-30 02:39:29 +01:00
|
|
|
def test_getting_a_things_name
|
|
|
|
foorth_equal("Object .name", ['Object'])
|
|
|
|
foorth_equal("Class .name", ['Class'])
|
|
|
|
|
|
|
|
foorth_equal("Object .new .name", ['Object instance'])
|
|
|
|
foorth_equal("45 .name", ['Fixnum instance'])
|
|
|
|
foorth_equal('"Foobar" .name', ['String instance'])
|
|
|
|
end
|
2014-10-29 18:53:13 +01:00
|
|
|
|
2014-12-03 20:10:20 +01:00
|
|
|
def test_getting_an_object_as_a_string
|
|
|
|
foorth_equal("4 .to_s", ['4'])
|
|
|
|
foorth_equal("Object .to_s", ['Object'])
|
|
|
|
foorth_equal("VirtualMachine .to_s", ['VirtualMachine'])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2014-10-29 18:53:13 +01:00
|
|
|
end
|