cuelang.org/go@v0.10.1/cue/format/testdata/simplify.txtar (about) 1 simplify 2 3 -- simplify.input -- 4 import "time" 5 6 "foo": "bar": "str" 7 8 a: "B": 42 9 10 "a.b": "foo-": "cc_dd": x 11 12 @attr(3) 13 14 a: 15 b: 16 c: 3 17 18 // references to bar are all shadowed and this can be safely turned into 19 // an identifier. 20 "bar": "str" 21 22 // These references would be directly referred to if turned into an identifier. 23 // The quotes should therefore not be removed. 24 "baz1": 3 25 "baz2": 3 26 "baz3": 3 // TODO: could be simplified. 27 28 // These string labels may be turned into an identifier. 29 "qux": 4 30 "quux": 5 31 32 // TODO(legacy): Don't simplify "hidden" fields for now. 33 "_foo": 3 34 35 // Issue #294 36 "\("x")": "x" 37 38 (x): "foo" 39 (x)?: "foo" 40 (x)!: "foo" 41 42 a: { 43 [string]: _ 44 foo: 2 45 } 46 47 "#A": dontSimplify 48 49 x: { 50 @tag0(foo) 51 r1: baz1 52 bar: r2: bar 53 r3: bar 54 E=quux: 3 55 56 @tag1(bar) 57 r4: quux 58 [baz2="str"]: 4 59 r5: baz2 60 [baz3="bar"]: name: baz3 61 "Time": time.Time 62 } 63 64 y: { 65 "a": { 66 "bar": "a-value" 67 [!="bar"]: {} 68 } 69 70 "b": { 71 "x": { 72 "bar": "bar" 73 "baz": "baz" 74 [!={ 75 "a": "baz" 76 }.a & !="bar"]: {} 77 } 78 79 "y": { 80 "bar": "a-value" 81 ({ 82 "a": "bar" 83 }.a): {} 84 } 85 } 86 } 87 88 { 89 foo: {} 90 bar: "foo": foo // removing the quotes would cause a cyclic reference 91 } 92 -- simplify.golden -- 93 import "time" 94 95 foo: bar: "str" 96 97 a: B: 42 98 99 "a.b": "foo-": cc_dd: x 100 101 @attr(3) 102 103 a: b: c: 3 104 105 // references to bar are all shadowed and this can be safely turned into 106 // an identifier. 107 bar: "str" 108 109 // These references would be directly referred to if turned into an identifier. 110 // The quotes should therefore not be removed. 111 "baz1": 3 112 "baz2": 3 113 "baz3": 3 // TODO: could be simplified. 114 115 // These string labels may be turned into an identifier. 116 qux: 4 117 quux: 5 118 119 // TODO(legacy): Don't simplify "hidden" fields for now. 120 "_foo": 3 121 122 // Issue #294 123 "\("x")": "x" 124 125 (x): "foo" 126 (x)?: "foo" 127 (x)!: "foo" 128 129 a: { 130 foo: 2 131 ... 132 } 133 134 "#A": dontSimplify 135 136 x: { 137 @tag0(foo) 138 r1: baz1 139 bar: r2: bar 140 r3: bar 141 E=quux: 3 142 143 @tag1(bar) 144 r4: quux 145 [baz2="str"]: 4 146 r5: baz2 147 [baz3="bar"]: name: baz3 148 Time: time.Time 149 } 150 151 y: { 152 a: { 153 bar: "a-value" 154 [!="bar"]: {} 155 } 156 b: { 157 x: { 158 bar: "bar" 159 baz: "baz" 160 [!={ 161 "a": "baz" 162 }.a & !="bar"]: {} 163 } 164 y: { 165 bar: "a-value" 166 ({ 167 "a": "bar" 168 }.a): {} 169 } 170 } 171 } 172 173 { 174 foo: {} 175 bar: "foo": foo // removing the quotes would cause a cyclic reference 176 }