...

Text file src/cuelang.org/go/cue/testdata/comprehensions/issue436.txtar

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

     1-- in.cue --
     2#a: {
     3	val:    string
     4	result: string
     5}
     6
     7a: #a & {
     8	val:    *"default" | string
     9	result: *"not-matched" | string
    10	if (val == "match") {
    11		result: "matched"
    12	}
    13}
    14
    15match: a & {
    16	val: "match"
    17}
    18
    19not: a & {
    20	val: "other"
    21}
    22-- out/eval/stats --
    23Leaks:  0
    24Freed:  25
    25Reused: 20
    26Allocs: 5
    27Retain: 0
    28
    29Unifications: 13
    30Conjuncts:    44
    31Disjuncts:    25
    32-- out/eval --
    33(struct){
    34  #a: (#struct){
    35    val: (string){ string }
    36    result: (string){ string }
    37  }
    38  a: (#struct){
    39    val: (string){ |(*(string){ "default" }, (string){ string }) }
    40    result: (string){ |(*(string){ "not-matched" }, (string){ string }) }
    41  }
    42  match: (#struct){
    43    val: (string){ "match" }
    44    result: (string){ "matched" }
    45  }
    46  not: (#struct){
    47    val: (string){ "other" }
    48    result: (string){ |(*(string){ "not-matched" }, (string){ string }) }
    49  }
    50}
    51-- out/compile --
    52--- in.cue
    53{
    54  #a: {
    55    val: string
    56    result: string
    57  }
    58  a: (〈0;#a〉 & {
    59    val: (*"default"|string)
    60    result: (*"not-matched"|string)
    61    if (〈0;val〉 == "match") {
    62      result: "matched"
    63    }
    64  })
    65  match: (〈0;a〉 & {
    66    val: "match"
    67  })
    68  not: (〈0;a〉 & {
    69    val: "other"
    70  })
    71}

View as plain text