@@ -388,62 +388,62 @@ mod tests {
388388 fn test_generics_layering_depth ( ) {
389389 let db = setup_db ( ) ;
390390
391- let list_of_int =
392- KnownClass :: List . to_specialized_instance ( & db, [ KnownClass :: Int . to_instance ( & db) ] ) ;
391+ let int = || KnownClass :: Int . to_instance ( & db) ;
392+ let list = |element| KnownClass :: List . to_specialized_instance ( & db, [ element] ) ;
393+ let dict = |key, value| KnownClass :: Dict . to_specialized_instance ( & db, [ key, value] ) ;
394+ let set = |element| KnownClass :: Set . to_specialized_instance ( & db, [ element] ) ;
395+ let str = || KnownClass :: Str . to_instance ( & db) ;
396+ let bytes = || KnownClass :: Bytes . to_instance ( & db) ;
397+
398+ let list_of_int = list ( int ( ) ) ;
393399 assert_eq ! ( specialization_depth( & db, list_of_int) , 1 ) ;
394400
395- let list_of_list_of_int = KnownClass :: List . to_specialized_instance ( & db , [ list_of_int] ) ;
401+ let list_of_list_of_int = list ( list_of_int) ;
396402 assert_eq ! ( specialization_depth( & db, list_of_list_of_int) , 2 ) ;
397403
398- let list_of_list_of_list_of_int =
399- KnownClass :: List . to_specialized_instance ( & db, [ list_of_list_of_int] ) ;
404+ let list_of_list_of_list_of_int = list ( list_of_list_of_int) ;
400405 assert_eq ! ( specialization_depth( & db, list_of_list_of_list_of_int) , 3 ) ;
401406
402- let set_of_dict_of_str_and_list_of_int = KnownClass :: Set . to_specialized_instance (
403- & db,
404- [ KnownClass :: Dict
405- . to_specialized_instance ( & db, [ KnownClass :: Str . to_instance ( & db) , list_of_int] ) ] ,
406- ) ;
407+ assert_eq ! ( specialization_depth( & db, set( dict( str ( ) , list_of_int) ) ) , 3 ) ;
408+
407409 assert_eq ! (
408- specialization_depth( & db, set_of_dict_of_str_and_list_of_int) ,
410+ specialization_depth(
411+ & db,
412+ UnionType :: from_elements( & db, [ list_of_list_of_list_of_int, list_of_list_of_int] )
413+ ) ,
409414 3
410415 ) ;
411416
412- let union_type_1 =
413- UnionType :: from_elements ( & db , [ list_of_list_of_list_of_int , list_of_list_of_int ] ) ;
414- assert_eq ! ( specialization_depth ( & db, union_type_1 ) , 3 ) ;
415-
416- let union_type_2 =
417- UnionType :: from_elements ( & db , [ list_of_list_of_int , list_of_list_of_list_of_int ] ) ;
418- assert_eq ! ( specialization_depth ( & db , union_type_2 ) , 3 ) ;
417+ assert_eq ! (
418+ specialization_depth (
419+ & db,
420+ UnionType :: from_elements ( & db , [ list_of_list_of_int , list_of_list_of_list_of_int ] )
421+ ) ,
422+ 3
423+ ) ;
419424
420- let tuple_of_tuple_of_int = Type :: heterogeneous_tuple (
421- & db,
422- [ Type :: heterogeneous_tuple (
425+ assert_eq ! (
426+ specialization_depth(
423427 & db,
424- [ KnownClass :: Int . to_instance ( & db) ] ,
425- ) ] ,
428+ Type :: heterogeneous_tuple( & db, [ Type :: heterogeneous_tuple( & db, [ int( ) ] ) ] )
429+ ) ,
430+ 2
426431 ) ;
427- assert_eq ! ( specialization_depth( & db, tuple_of_tuple_of_int) , 2 ) ;
428432
429- let tuple_of_list_of_int_and_str = KnownClass :: Tuple
430- . to_specialized_instance ( & db, [ list_of_int, KnownClass :: Str . to_instance ( & db) ] ) ;
431- assert_eq ! ( specialization_depth( & db, tuple_of_list_of_int_and_str) , 1 ) ;
433+ assert_eq ! (
434+ specialization_depth( & db, Type :: heterogeneous_tuple( & db, [ list_of_int, str ( ) ] ) ) ,
435+ 2
436+ ) ;
432437
433- let list_of_union_of_lists = KnownClass :: List . to_specialized_instance (
434- & db,
435- [ UnionType :: from_elements (
438+ assert_eq ! (
439+ specialization_depth(
436440 & db,
437- [
438- KnownClass :: List
439- . to_specialized_instance ( & db, [ KnownClass :: Int . to_instance ( & db) ] ) ,
440- KnownClass :: List
441- . to_specialized_instance ( & db, [ KnownClass :: Str . to_instance ( & db) ] ) ,
442- KnownClass :: List
443- . to_specialized_instance ( & db, [ KnownClass :: Bytes . to_instance ( & db) ] ) ,
444- ] ,
445- ) ] ,
441+ list( UnionType :: from_elements(
442+ & db,
443+ [ list( int( ) ) , list( str ( ) ) , list( bytes( ) ) ]
444+ ) )
445+ ) ,
446+ 2
446447 ) ;
447- assert_eq ! ( specialization_depth( & db, list_of_union_of_lists) , 2 ) ;
448448 }
449449}
0 commit comments