@@ -424,8 +424,8 @@ def Visit(key, value):
424424 outer .Visit (Visit )
425425
426426 self .assertListEqual (visit_keys , [
427- 'inner.a [0][0]' , 'inner.a [0][1][0]' , 'inner.a [0][1][1]' ,
428- 'inner.a [0][1][2][x]'
427+ 'inner[ \' a \' ] [0][0]' , 'inner[ \' a \' ] [0][1][0]' , 'inner[ \' a \' ] [0][1][1]' ,
428+ 'inner[ \' a \' ] [0][1][2][x]'
429429 ])
430430
431431 def testToText (self ):
@@ -446,6 +446,10 @@ def testToText(self):
446446 outer .Define ('plain_dict' , {'a' : 10 }, '' )
447447 outer .Define ('complex_dict' , {'a' : 10 , 'b' : inner }, '' )
448448 outer .Define ('complex_dict_escape' , {'a' : 'abc"\' \n def' }, '' )
449+ outer .Define ('complex_dict_with_params' , {
450+ 'a' : inner ,
451+ 'b' : inner .Copy ()
452+ }, '' )
449453 outer .Define ('some_class' , complex (0 , 1 ), '' )
450454 outer .Define ('optional_bool' , None , '' )
451455 outer .Define ('enum' , TestEnum .B , '' )
@@ -460,7 +464,12 @@ def testToText(self):
460464 '\n ' + outer .ToText (), r"""
461465class : type/__main__/TestClass1
462466complex_dict : {'a': 10, 'b': {'bar': 2.71, 'baz': 'hello'}}
463- complex_dict_escape : {'a': 'abc"\'\ndef'}
467+ complex_dict_escape : {'a': 'abc"\'
468+ def'}
469+ complex_dict_with_params['a'].bar : 2.71
470+ complex_dict_with_params['a'].baz : 'hello'
471+ complex_dict_with_params['b'].bar : 2.71
472+ complex_dict_with_params['b'].baz : 'hello'
464473dataclass : {'a': [42], 'b': 'float32'}
465474dtype : float32
466475dtype2 : int32
@@ -488,6 +497,10 @@ class : type/__main__/TestClass1
488497 dtype2 : float32
489498 inner.baz : 'world'
490499 # foo : 123
500+ complex_dict_with_params['a'].bar : 2.71
501+ complex_dict_with_params['a'].baz : 'world'
502+ complex_dict_with_params['b'].bar : 2.71
503+ complex_dict_with_params['b'].baz : 'hello'
491504 optional_bool : true
492505 list_of_params[0].bar : 2.72
493506 seqlen : [1, 2.0, '3', [4]]
@@ -507,7 +520,12 @@ class : type/__main__/TestClass2
507520 '\n ' + outer .ToText (), r"""
508521class : type/__main__/TestClass2
509522complex_dict : {'a': 10, 'b': {'bar': 2.71, 'baz': 'world'}}
510- complex_dict_escape : {'a': 'abc"\'\ndef'}
523+ complex_dict_escape : {'a': 'abc"\'
524+ def'}
525+ complex_dict_with_params['a'].bar : 2.71
526+ complex_dict_with_params['a'].baz : 'world'
527+ complex_dict_with_params['b'].bar : 2.71
528+ complex_dict_with_params['b'].baz : 'hello'
511529dataclass : {'a': 27, 'b': 'int32'}
512530dtype : float32
513531dtype2 : float32
0 commit comments