2015-06-15 08:07:16 +02:00
|
|
|
require_relative "helper"
|
2015-05-03 19:16:06 +02:00
|
|
|
|
2017-09-27 14:35:55 +02:00
|
|
|
class ObjectRxFile < MiniTest::Test
|
2015-05-15 19:59:33 +02:00
|
|
|
include Checker
|
|
|
|
|
2015-05-03 19:16:06 +02:00
|
|
|
def test_simple_object
|
2015-05-15 20:03:11 +02:00
|
|
|
@out = ObjectWithAttributes.new
|
2015-05-15 19:59:33 +02:00
|
|
|
check "#{OBJECT_STRING}"
|
2015-05-03 19:16:06 +02:00
|
|
|
end
|
|
|
|
def test_object_extra_array
|
|
|
|
object = ObjectWithAttributes.new
|
|
|
|
object.extra = [:sym , 123]
|
2015-05-15 20:03:11 +02:00
|
|
|
@out = object
|
2015-06-17 20:16:39 +02:00
|
|
|
check "ObjectWithAttributes(:name => 'some name', :number => 1234, :extra => [:sym, 123])"
|
2015-05-03 19:16:06 +02:00
|
|
|
end
|
|
|
|
def test_array_object
|
2015-05-15 20:03:11 +02:00
|
|
|
@out = [true, 1234 , ObjectWithAttributes.new]
|
2015-06-16 17:12:15 +02:00
|
|
|
check "- true\n- 1234\n- #{OBJECT_STRING}"
|
2015-05-03 19:16:06 +02:00
|
|
|
end
|
|
|
|
def test_array_array_object
|
2015-05-15 20:03:11 +02:00
|
|
|
@out = [true, 1 , [true , 12 , ObjectWithAttributes.new]]
|
2015-06-16 17:12:15 +02:00
|
|
|
check "- true\n- 1\n- - true\n - 12\n - #{OBJECT_STRING}"
|
2015-05-03 19:16:06 +02:00
|
|
|
end
|
|
|
|
def test_hash_object
|
2015-06-16 17:12:15 +02:00
|
|
|
@out = { :one => 1 , :two => ObjectWithAttributes.new }
|
|
|
|
check "- :one => 1\n- :two => #{OBJECT_STRING}"
|
2015-05-03 19:16:06 +02:00
|
|
|
end
|
|
|
|
def test_hash_array
|
2015-06-16 17:12:15 +02:00
|
|
|
@out = { :one => [1 , ObjectWithAttributes.new] , :two => true }
|
|
|
|
check "- :one => - 1\n - #{OBJECT_STRING}\n- :two => true"
|
2015-05-03 19:16:06 +02:00
|
|
|
end
|
|
|
|
def test_object_recursive
|
|
|
|
object = ObjectWithAttributes.new
|
|
|
|
object.extra = object
|
2015-05-15 20:03:11 +02:00
|
|
|
@out = object
|
2015-06-16 17:12:15 +02:00
|
|
|
check "&1 ObjectWithAttributes(:name => 'some name', :number => 1234, :extra => ->1)"
|
2015-05-03 19:16:06 +02:00
|
|
|
end
|
|
|
|
def test_object_inline
|
|
|
|
object = ObjectWithAttributes.new
|
|
|
|
object.extra = Object.new
|
2015-05-15 20:03:11 +02:00
|
|
|
@out = object
|
2015-05-15 19:59:33 +02:00
|
|
|
check "ObjectWithAttributes(:name => 'some name', :number => 1234, :extra => Object())"
|
2015-05-03 19:16:06 +02:00
|
|
|
end
|
2015-06-15 07:26:56 +02:00
|
|
|
def test_volotile
|
|
|
|
@out = ObjectWithAttributes.new
|
|
|
|
@out.volotile = 42
|
2015-06-16 17:12:15 +02:00
|
|
|
check "#{OBJECT_STRING}"
|
2015-06-15 07:26:56 +02:00
|
|
|
end
|
2015-05-03 19:16:06 +02:00
|
|
|
def test_class
|
2015-05-15 20:03:11 +02:00
|
|
|
@out = ObjectWithAttributes
|
2015-05-03 19:16:06 +02:00
|
|
|
check "ObjectWithAttributes"
|
|
|
|
end
|
|
|
|
def test_class_ref
|
|
|
|
object = ObjectWithAttributes.new
|
|
|
|
object.extra = ObjectWithAttributes
|
|
|
|
ar = [object , ObjectWithAttributes]
|
2015-05-15 20:03:11 +02:00
|
|
|
@out = ar
|
2015-06-16 17:51:30 +02:00
|
|
|
check "- ObjectWithAttributes(:name => 'some name', :number => 1234, :extra => ObjectWithAttributes)\n- ObjectWithAttributes"
|
2015-05-03 19:16:06 +02:00
|
|
|
end
|
2015-05-15 19:59:33 +02:00
|
|
|
end
|