Module: Tst
- Defined in:
- lib/coderunner/test.rb
Defined Under Namespace
Constant Summary collapse
- KIND_OF =
MakeProcs - used for making tests
MakeProc.new{|*klasses| TestProc.new{|obj, name=""| check(name, obj, klasses.inject(""){|str, klass| str << " or self.kind_of? #{klass.to_s}"}.sub(/^ or /, '') , true, TypeError)}}
- VALUE =
MakeProc.new{|*values| TestProc.new{|obj, name=""| check(name, obj, "self", values, ArgumentError)}}
- FLOAT =
Some predefined tests
KIND_OF.with_result(Float, Integer)
- FLOAT_STRICT =
KIND_OF.with_result(Float)
- INT =
INTEGER = KIND_OF.with_result(Integer)
- STRING =
KIND_OF.with_result(String)
- FORTRAN_BOOL =
VALUE.with_result(*String::FORTRAN_BOOLS)
Class Method Summary collapse
Class Method Details
.check(name, obj, test_string, expected_results, error_class) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/coderunner/test.rb', line 2 def self.check(name, obj, test_string, expected_results, error_class) value = obj.instance_eval test_string unless (expected_results.class == Array ? expected_results.include?(value) : value == expected_results) = "\n==============================\n" += "= Test Failed =\n" += "==============================\n\n" += "Object Description: #{name}\n" += "Object Value: #{obj.inspect}\n" += "Test: #{test_string.inspect}\n" += "Expected Result: #{expected_results}\n" += "Actual Result: #{value.inspect}" += "\n\n===============================" raise error_class.new() end end |