github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/tools/trim/testdata/defaults.txtar (about)

     1  -- in.cue --
     2  domToSub: {
     3  	foo: [string]: a: *1 | int
     4  	foo: b: a:        1
     5  }
     6  
     7  // Issue #759
     8  subToDom: {
     9  	#maybeString: {ip?: string}
    10  	something: ip: *"default" | string
    11  	something: #maybeString
    12  }
    13  
    14  // references to definitions of a disjunction should be resolved and counted
    15  // as dominator nodes.
    16  resolveDefaults: {
    17  	#monitor: {
    18  		kind: "a"
    19  	} | {
    20  		kind: "b"
    21  	}
    22  
    23  	monitor: #monitor
    24  
    25  	monitor: kind: "a"
    26  }
    27  
    28  issue781: {
    29  	#monitor_check: {
    30  		check_name:      string
    31  		check_interval?: string
    32  	}
    33  
    34  	#monitor_check: {
    35  		check_type: "nginx_config"
    36  	} | {
    37  		check_type: "docker_running"
    38  		vars: {
    39  			container_name: string
    40  		}
    41  	}
    42  
    43  	monitor: {
    44  		checks: [...#monitor_check]
    45  	}
    46  
    47  	monitor: {
    48  		checks: [{
    49  			check_type: "nginx_config"
    50  			check_name: "nginx_config"
    51  		}]
    52  	}
    53  }
    54  
    55  // Issue #801
    56  // Here the concrete value selects the default from a dominator, after which
    57  // the dominator becomes an exact match. The exact match should not allow it
    58  // to be erased, as the exact match is only there because subordinate value
    59  // was first used to select the default.
    60  dontEraseDefaultSelection: {
    61  	rule: _#Rule & {
    62  		verbs: [ "c"]
    63  	}
    64  	_#Rule: {
    65  		verbs: *["a", "b"] | ["c"]
    66  	}
    67  }
    68  -- out/trim --
    69  == in.cue
    70  domToSub: {
    71  	foo: [string]: a: *1 | int
    72  	foo: b: {}
    73  }
    74  
    75  // Issue #759
    76  subToDom: {
    77  	#maybeString: {ip?: string}
    78  	something: ip: *"default" | string
    79  	something: #maybeString
    80  }
    81  
    82  // references to definitions of a disjunction should be resolved and counted
    83  // as dominator nodes.
    84  resolveDefaults: {
    85  	#monitor: {
    86  		kind: "a"
    87  	} | {
    88  		kind: "b"
    89  	}
    90  
    91  	monitor: #monitor
    92  
    93  	monitor: kind: "a"
    94  }
    95  
    96  issue781: {
    97  	#monitor_check: {
    98  		check_name:      string
    99  		check_interval?: string
   100  	}
   101  
   102  	#monitor_check: {
   103  		check_type: "nginx_config"
   104  	} | {
   105  		check_type: "docker_running"
   106  		vars: {
   107  			container_name: string
   108  		}
   109  	}
   110  
   111  	monitor: {
   112  		checks: [...#monitor_check]
   113  	}
   114  
   115  	monitor: {
   116  		checks: [{
   117  			check_type: "nginx_config"
   118  			check_name: "nginx_config"
   119  		}]
   120  	}
   121  }
   122  
   123  // Issue #801
   124  // Here the concrete value selects the default from a dominator, after which
   125  // the dominator becomes an exact match. The exact match should not allow it
   126  // to be erased, as the exact match is only there because subordinate value
   127  // was first used to select the default.
   128  dontEraseDefaultSelection: {
   129  	rule: _#Rule & {
   130  		verbs: [ "c"]
   131  	}
   132  	_#Rule: {
   133  		verbs: *["a", "b"] | ["c"]
   134  	}
   135  }