@@ -55,8 +55,10 @@ def bo.hash; 42; end # Needed to use this object as a hash key
5555 assert_equal BasicObject , bo_key_hash_type . params [ :K ] . klass
5656 assert_equal BasicObject , bo_value_hash_type . params [ :V ] . klass
5757 assert_equal 'Object' , obj_type . inspect
58- assert_equal 'Array[Elem: Integer | String]' , arr_type . inspect
59- assert_equal 'Hash[K: String, V: Symbol]' , hash_type . inspect
58+ assert_equal 'Array[unresolved]' , arr_type . inspect
59+ assert_equal 'Array[Elem: Integer | String]' , arr_type . tap ( &:params ) . inspect
60+ assert_equal 'Hash[unresolved]' , hash_type . inspect
61+ assert_equal 'Hash[K: String, V: Symbol]' , hash_type . tap ( &:params ) . inspect
6062 assert_equal 'Array.itself' , ReplTypeCompletor ::Types . type_from_object ( Array ) . inspect
6163 assert_equal 'ReplTypeCompletor.itself' , ReplTypeCompletor ::Types . type_from_object ( ReplTypeCompletor ) . inspect
6264 end
@@ -112,7 +114,17 @@ def test_params_lazily_expanded_on_recursive_type
112114 assert_equal expected , elem_type . types . map ( &:klass ) . sort_by ( &:name )
113115 type = elem_type . types . find { _1 . klass == Array }
114116 end
115- assert_equal 'Hash[K: Integer, V: Float]' , type . params [ :Elem ] . types . find { _1 . klass == Hash } . inspect
117+ hash_type = type . params [ :Elem ] . types . find { _1 . klass == Hash }
118+ assert_equal 'Hash[unresolved]' , hash_type . inspect
119+ assert_equal 'Hash[K: Integer, V: Float]' , hash_type . tap ( &:params ) . inspect
120+ end
121+
122+ def test_infinite_nested_type_inspect
123+ a = [ ]
124+ a << a
125+ type = ReplTypeCompletor ::Types . type_from_object a
126+ assert_equal 'Array[unresolved]' , type . inspect
127+ assert_equal 'Array[Elem: Array[unresolved]]' , type . tap ( &:params ) . inspect
116128 end
117129 end
118130end
0 commit comments