...

Text file src/cuelang.org/go/cue/testdata/definitions/issue342.txtar

Documentation: cuelang.org/go/cue/testdata/definitions

     1-- in.cue --
     2X: {
     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
    29Z: X.test_3_XXX.ref
    30-- out/eval/stats --
    31Leaks:  0
    32Freed:  24
    33Reused: 17
    34Allocs: 7
    35Retain: 2
    36
    37Unifications: 18
    38Conjuncts:    33
    39Disjuncts:    24
    40-- out/eval --
    41(struct){
    42  X: (struct){
    43    #Simple: (#struct){
    44      ref: (string){ string }
    45    }
    46    #Complex: (#struct){ |((#struct){
    47        ref: (string){ string }
    48      }, (#struct){
    49        local: (string){ string }
    50      }) }
    51    var: (string){ "XXX" }
    52    test_1: (#struct){ |((#struct){
    53        ref: (string){ string }
    54      }, (#struct){
    55        local: (string){ string }
    56      }) }
    57    test_3_XXX: (#struct){
    58      ref: (string){ "FOO" }
    59    }
    60    test_2_XXX: (#struct){
    61      ref: (string){ string }
    62    }
    63  }
    64  Z: (string){ "FOO" }
    65}
    66-- out/compile --
    67--- in.cue
    68{
    69  X: {
    70    #Simple: {
    71      ref: string
    72    }
    73    #Complex: {
    74      ({
    75        ref: string
    76      }|{
    77        local: string
    78      })
    79    }
    80    var: "XXX"
    81    test_1: 〈0;#Complex〉
    82    "test_2_\(〈0;var〉)": 〈0;#Simple〉
    83    "test_3_\(〈0;var〉)": 〈0;#Complex〉
    84    test_3_XXX: {
    85      ref: "FOO"
    86    }
    87  }
    88  Z: 〈0;X〉.test_3_XXX.ref
    89}

View as plain text