Begin overhaul of dyadic ops. New coerce protocols.

This commit is contained in:
Peter Camilleri 2015-01-10 14:16:44 -05:00
parent b569f07cba
commit fa41b0130e
2 changed files with 35 additions and 0 deletions

View file

@ -38,6 +38,19 @@ class Object
raise XfOOrth::ForceAbort, msg
end
#Argument coercion methods. These are stubs.
#Coerce the argument to match my type. Stub
def foorth_coerce(_arg)
error "Cannot coerce to a #{self.foorth_name}"
end
#Coerce the argument to match my type with min/max support. Stub
def foorth_mnmx_coerce(_arg)
error "Cannot min/max coerce to a #{self.foorth_name}"
end
#New math methods. The mnmx_ prefix is short for min_max_.
#These methods handle the default case for non-numeric data.

View file

@ -0,0 +1,22 @@
# coding: utf-8
require_relative '../../lib/fOOrth/monkey_patch'
require 'minitest/autorun'
require 'minitest_visible'
#Test the monkey patches applied to the coerce protocol.
class CoerceProtocolTester < MiniTest::Unit::TestCase
#Track mini-test progress.
MinitestVisible.track self, __FILE__
#Test that it embeds
def test_obect_stubs
obj = Object.new
assert_raises(XfOOrth::XfOOrthError) { obj.foorth_coerce(42) }
assert_raises(XfOOrth::XfOOrthError) { obj.foorth_mnmx_coerce(42) }
end
end