cuelang.org/go@v0.10.1/cue/testdata/basicrewrite/001_regexp.txtar (about) 1 # DO NOT EDIT; generated by go run testdata/gen.go 2 # 3 #name: regexp 4 #evalPartial 5 -- in.cue -- 6 c1: "a" =~ "a" 7 c2: "foo" =~ "[a-z]{3}" 8 c3: "foo" =~ "[a-z]{4}" 9 c4: "foo" !~ "[a-z]{4}" 10 11 b1: =~"a" 12 b1: "a" 13 b2: =~"[a-z]{3}" 14 b2: "foo" 15 b3: =~"[a-z]{4}" 16 b3: "foo" 17 b4: !~"[a-z]{4}" 18 b4: "foo" 19 20 s1: !="b" & =~"c" // =~"c" 21 s2: =~"c" & !="b" // =~"c" 22 s3: !="b" & =~"[a-z]" // != "b" & =~"[a-z]" 23 s4: =~"[a-z]" & !="b" // != "b" & =~"[a-z]" 24 25 e1: "foo" =~ 1 26 e2: "foo" !~ true 27 e3: !="a" & <5 28 -- out/def -- 29 c1: true 30 c2: true 31 c3: false 32 c4: true 33 b1: "a" 34 b2: "foo" 35 b3: _|_ // invalid value "foo" (does not match =~"[a-z]{4}") 36 b4: "foo" 37 s1: =~"c" 38 s2: !="b" & =~"[a-z]" 39 e1: _|_ // invalid operation "foo" =~ 1 (mismatched types string and int) 40 e2: _|_ // invalid operation "foo" !~ true (mismatched types string and bool) 41 e3: _|_ // conflicting values !="a" and <5 (mismatched types string and number) 42 -- out/legacy-debug -- 43 <0>{c1: true, c2: true, c3: false, c4: true, b1: "a", b2: "foo", b3: _|_((=~"[a-z]{4}" & "foo"):invalid value "foo" (does not match =~"[a-z]{4}")), b4: "foo", s1: =~"c", s2: (!="b" & =~"[a-z]"), e1: _|_(("foo" =~ 1):invalid operation "foo" =~ 1 (mismatched types string and int)), e2: _|_(("foo" !~ true):invalid operation "foo" !~ true (mismatched types string and bool)), e3: _|_((!="a" & <5):conflicting values !="a" and <5 (mismatched types string and number))} 44 -- out/compile -- 45 --- in.cue 46 { 47 c1: ("a" =~ "a") 48 c2: ("foo" =~ "[a-z]{3}") 49 c3: ("foo" =~ "[a-z]{4}") 50 c4: ("foo" !~ "[a-z]{4}") 51 b1: =~"a" 52 b1: "a" 53 b2: =~"[a-z]{3}" 54 b2: "foo" 55 b3: =~"[a-z]{4}" 56 b3: "foo" 57 b4: !~"[a-z]{4}" 58 b4: "foo" 59 s1: (!="b" & =~"c") 60 s2: (=~"c" & !="b") 61 s3: (!="b" & =~"[a-z]") 62 s4: (=~"[a-z]" & !="b") 63 e1: ("foo" =~ 1) 64 e2: ("foo" !~ true) 65 e3: (!="a" & <5) 66 } 67 -- out/eval/stats -- 68 Leaks: 0 69 Freed: 16 70 Reused: 14 71 Allocs: 2 72 Retain: 0 73 74 Unifications: 16 75 Conjuncts: 25 76 Disjuncts: 16 77 -- out/eval -- 78 Errors: 79 e3: conflicting values !="a" and <5 (mismatched types string and number): 80 ./in.cue:22:5 81 ./in.cue:22:13 82 b3: invalid value "foo" (out of bound =~"[a-z]{4}"): 83 ./in.cue:10:5 84 ./in.cue:11:5 85 e1: cannot use 1 (type int) as type (string|bytes): 86 ./in.cue:20:5 87 ./in.cue:20:14 88 e2: cannot use true (type bool) as type (string|bytes): 89 ./in.cue:21:5 90 ./in.cue:21:14 91 92 Result: 93 (_|_){ 94 // [eval] 95 c1: (bool){ true } 96 c2: (bool){ true } 97 c3: (bool){ false } 98 c4: (bool){ true } 99 b1: (string){ "a" } 100 b2: (string){ "foo" } 101 b3: (_|_){ 102 // [eval] b3: invalid value "foo" (out of bound =~"[a-z]{4}"): 103 // ./in.cue:10:5 104 // ./in.cue:11:5 105 } 106 b4: (string){ "foo" } 107 s1: (string){ =~"c" } 108 s2: (string){ =~"c" } 109 s3: (string){ &(!="b", =~"[a-z]") } 110 s4: (string){ &(=~"[a-z]", !="b") } 111 e1: (_|_){ 112 // [eval] e1: cannot use 1 (type int) as type (string|bytes): 113 // ./in.cue:20:5 114 // ./in.cue:20:14 115 } 116 e2: (_|_){ 117 // [eval] e2: cannot use true (type bool) as type (string|bytes): 118 // ./in.cue:21:5 119 // ./in.cue:21:14 120 } 121 e3: (_|_){ 122 // [eval] e3: conflicting values !="a" and <5 (mismatched types string and number): 123 // ./in.cue:22:5 124 // ./in.cue:22:13 125 } 126 }