cuelang.org/go@v0.13.0/cue/testdata/eval/issue545.txtar (about) 1 title: Simplification of validators. 2 3 -- in.cue -- 4 package main 5 6 import ( 7 "strings" 8 "time" 9 ) 10 11 t1: { 12 #Test: { 13 #HTTP: =~"^http://" 14 #SSH: !~"^ssh://" 15 #USER: strings.MinRunes(3) 16 source: #HTTP | #SSH | #USER | #Test 17 } 18 19 foo: #Test & { 20 source: "http://blablabla" 21 } 22 23 bar: #Test & { 24 source: foo 25 } 26 } 27 28 t2: { 29 str: "foo" 30 a: =~str 31 b: =~"foo" 32 c: a & b & a & b 33 34 d: time.Time 35 e: time.Time() 36 f: d & e & d & e 37 } 38 -- out/evalalpha/stats -- 39 Leaks: 69 40 Freed: 0 41 Reused: 0 42 Allocs: 69 43 Retain: 0 44 45 Unifications: 29 46 Conjuncts: 79 47 Disjuncts: 16 48 49 CloseIDElems: 20 50 NumCloseIDs: 22 51 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- 52 diff old new 53 --- old 54 +++ new 55 @@ -1,9 +1,12 @@ 56 -Leaks: 0 57 -Freed: 121 58 -Reused: 107 59 -Allocs: 14 60 +Leaks: 69 61 +Freed: 0 62 +Reused: 0 63 +Allocs: 69 64 Retain: 0 65 66 -Unifications: 65 67 -Conjuncts: 205 68 -Disjuncts: 121 69 +Unifications: 29 70 +Conjuncts: 79 71 +Disjuncts: 16 72 + 73 +CloseIDElems: 20 74 +NumCloseIDs: 22 75 -- out/eval/stats -- 76 Leaks: 0 77 Freed: 121 78 Reused: 107 79 Allocs: 14 80 Retain: 0 81 82 Unifications: 65 83 Conjuncts: 205 84 Disjuncts: 121 85 -- out/evalalpha -- 86 (struct){ 87 t1: (struct){ 88 #Test: (#struct){ 89 #HTTP: (string){ =~"^http://" } 90 #SSH: (string){ !~"^ssh://" } 91 #USER: (string){ strings.MinRunes(3) } 92 source: (string){ |((string){ =~"^http://" }, (string){ !~"^ssh://" }, (string){ strings.MinRunes(3) }) } 93 } 94 foo: (#struct){ 95 source: (string){ "http://blablabla" } 96 #HTTP: (string){ =~"^http://" } 97 #SSH: (string){ !~"^ssh://" } 98 #USER: (string){ strings.MinRunes(3) } 99 } 100 bar: (#struct){ 101 source: (#struct){ 102 source: (string){ "http://blablabla" } 103 #HTTP: (string){ =~"^http://" } 104 #SSH: (string){ !~"^ssh://" } 105 #USER: (string){ strings.MinRunes(3) } 106 } 107 #HTTP: (string){ =~"^http://" } 108 #SSH: (string){ !~"^ssh://" } 109 #USER: (string){ strings.MinRunes(3) } 110 } 111 } 112 t2: (struct){ 113 str: (string){ "foo" } 114 a: (string){ =~"foo" } 115 b: (string){ =~"foo" } 116 c: (string){ =~"foo" } 117 d: (string){ time.Time() } 118 e: (string){ time.Time() } 119 f: (string){ time.Time() } 120 } 121 } 122 -- diff/-out/evalalpha<==>+out/eval -- 123 diff old new 124 --- old 125 +++ new 126 @@ -7,21 +7,21 @@ 127 source: (string){ |((string){ =~"^http://" }, (string){ !~"^ssh://" }, (string){ strings.MinRunes(3) }) } 128 } 129 foo: (#struct){ 130 - #HTTP: (string){ =~"^http://" } 131 - #SSH: (string){ !~"^ssh://" } 132 - #USER: (string){ strings.MinRunes(3) } 133 source: (string){ "http://blablabla" } 134 + #HTTP: (string){ =~"^http://" } 135 + #SSH: (string){ !~"^ssh://" } 136 + #USER: (string){ strings.MinRunes(3) } 137 } 138 bar: (#struct){ 139 - #HTTP: (string){ =~"^http://" } 140 - #SSH: (string){ !~"^ssh://" } 141 - #USER: (string){ strings.MinRunes(3) } 142 source: (#struct){ 143 + source: (string){ "http://blablabla" } 144 #HTTP: (string){ =~"^http://" } 145 #SSH: (string){ !~"^ssh://" } 146 #USER: (string){ strings.MinRunes(3) } 147 - source: (string){ "http://blablabla" } 148 } 149 + #HTTP: (string){ =~"^http://" } 150 + #SSH: (string){ !~"^ssh://" } 151 + #USER: (string){ strings.MinRunes(3) } 152 } 153 } 154 t2: (struct){ 155 -- diff/todo/p3 -- 156 Reordering. 157 -- out/eval -- 158 (struct){ 159 t1: (struct){ 160 #Test: (#struct){ 161 #HTTP: (string){ =~"^http://" } 162 #SSH: (string){ !~"^ssh://" } 163 #USER: (string){ strings.MinRunes(3) } 164 source: (string){ |((string){ =~"^http://" }, (string){ !~"^ssh://" }, (string){ strings.MinRunes(3) }) } 165 } 166 foo: (#struct){ 167 #HTTP: (string){ =~"^http://" } 168 #SSH: (string){ !~"^ssh://" } 169 #USER: (string){ strings.MinRunes(3) } 170 source: (string){ "http://blablabla" } 171 } 172 bar: (#struct){ 173 #HTTP: (string){ =~"^http://" } 174 #SSH: (string){ !~"^ssh://" } 175 #USER: (string){ strings.MinRunes(3) } 176 source: (#struct){ 177 #HTTP: (string){ =~"^http://" } 178 #SSH: (string){ !~"^ssh://" } 179 #USER: (string){ strings.MinRunes(3) } 180 source: (string){ "http://blablabla" } 181 } 182 } 183 } 184 t2: (struct){ 185 str: (string){ "foo" } 186 a: (string){ =~"foo" } 187 b: (string){ =~"foo" } 188 c: (string){ =~"foo" } 189 d: (string){ time.Time() } 190 e: (string){ time.Time() } 191 f: (string){ time.Time() } 192 } 193 } 194 -- out/compile -- 195 --- in.cue 196 { 197 t1: { 198 #Test: { 199 #HTTP: =~"^http://" 200 #SSH: !~"^ssh://" 201 #USER: 〈import;strings〉.MinRunes(3) 202 source: (〈0;#HTTP〉|〈0;#SSH〉|〈0;#USER〉|〈1;#Test〉) 203 } 204 foo: (〈0;#Test〉 & { 205 source: "http://blablabla" 206 }) 207 bar: (〈0;#Test〉 & { 208 source: 〈1;foo〉 209 }) 210 } 211 t2: { 212 str: "foo" 213 a: =~〈0;str〉 214 b: =~"foo" 215 c: (((〈0;a〉 & 〈0;b〉) & 〈0;a〉) & 〈0;b〉) 216 d: 〈import;time〉.Time 217 e: 〈import;time〉.Time() 218 f: (((〈0;d〉 & 〈0;e〉) & 〈0;d〉) & 〈0;e〉) 219 } 220 }