github.com/solo-io/cue@v0.4.7/cue/testdata/definitions/issue342.txtar (about)

     1  -- in.cue --
     2  X: {
     3  	#Simple: {
     4  		ref: string
     5  	}
     6  
     7  	#Complex: {
     8  		{
     9  			ref: string
    10  		} | {
    11  			local: string
    12  		}
    13  	}
    14  
    15  	var: "XXX"
    16  
    17  	// Validate(concrete) after Fill() on Complex.ref from a "static" key will succeed
    18  	"test_1": #Complex
    19  
    20  	// Validate(concrete) after Fill() on "#Simple.ref" from a "dynamic" key will succeed
    21  	"test_2_\(var)": #Simple
    22  	
    23  	// Validate(concrete) after Fill() on Complex.ref from a "dynamic" key will fail
    24  	"test_3_\(var)": #Complex
    25  
    26  	test_3_XXX: ref: "FOO"
    27  }
    28  
    29  Z: X.test_3_XXX.ref
    30  -- out/eval --
    31  (struct){
    32    X: (struct){
    33      #Simple: (#struct){
    34        ref: (string){ string }
    35      }
    36      #Complex: (#struct){ |((#struct){
    37          ref: (string){ string }
    38        }, (#struct){
    39          local: (string){ string }
    40        }) }
    41      var: (string){ "XXX" }
    42      test_1: (#struct){ |((#struct){
    43          ref: (string){ string }
    44        }, (#struct){
    45          local: (string){ string }
    46        }) }
    47      test_3_XXX: (#struct){
    48        ref: (string){ "FOO" }
    49      }
    50      test_2_XXX: (#struct){
    51        ref: (string){ string }
    52      }
    53    }
    54    Z: (string){ "FOO" }
    55  }
    56  -- out/compile --
    57  --- in.cue
    58  {
    59    X: {
    60      #Simple: {
    61        ref: string
    62      }
    63      #Complex: {
    64        ({
    65          ref: string
    66        }|{
    67          local: string
    68        })
    69      }
    70      var: "XXX"
    71      test_1: 〈0;#Complex〉
    72      "test_2_\(〈0;var〉)": 〈0;#Simple〉
    73      "test_3_\(〈0;var〉)": 〈0;#Complex〉
    74      test_3_XXX: {
    75        ref: "FOO"
    76      }
    77    }
    78    Z: 〈0;X〉.test_3_XXX.ref
    79  }