@@ -83,6 +83,7 @@ def yard_to_parlour_default(type)
8383
8484 context 'with literals' do
8585 it 'converts literals to their types' do
86+ expect ( yard_to_parlour_default ( 'nil' ) ) . to eq Types ::Raw . new ( 'NilClass' )
8687 expect ( yard_to_parlour_default ( [ ':up' , ':down' ] ) ) . to eq Types ::Raw . new ( 'Symbol' )
8788 expect ( yard_to_parlour_default ( [ 'String' , ':up' , ':down' ] ) ) . to eq \
8889 Types ::Union . new ( [ 'String' , 'Symbol' ] )
@@ -138,6 +139,11 @@ def self.path
138139 Types ::Array . new ( Types ::Union . new ( [ 'String' , 'Integer' ] ) )
139140 end
140141
142+ it 'handles nil is one of multiple arguments in a one-argument type parameter' do
143+ expect ( yard_to_parlour_default ( 'Array<String, nil>' ) ) . to eq \
144+ Types ::Array . new ( Types ::Nilable . new ( 'String' ) )
145+ end
146+
141147 it 'handles whitespace' do
142148 expect ( yard_to_parlour_default ( 'Array < String >' ) ) . to eq Types ::Array . new ( 'String' )
143149 end
@@ -154,6 +160,7 @@ def self.path
154160 it 'handles correctly-formed two-argument type parameters with hash rockets' do
155161 expect ( yard_to_parlour_default ( 'Hash<String=>Symbol>' ) ) . to eq Types ::Hash . new ( 'String' , 'Symbol' )
156162 expect ( yard_to_parlour_default ( 'Hash{String=>Symbol}' ) ) . to eq Types ::Hash . new ( 'String' , 'Symbol' )
163+ expect ( yard_to_parlour_default ( 'Hash{String=>String}' ) ) . to eq Types ::Hash . new ( 'String' , 'String' )
157164 expect ( yard_to_parlour_default ( 'Hash{String => Symbol}' ) ) . to eq Types ::Hash . new ( 'String' , 'Symbol' )
158165 expect ( yard_to_parlour_default ( 'Hash{String, Integer => Symbol, Float}' ) ) . to eq \
159166 Types ::Hash . new (
0 commit comments