github.com/solo-io/cue@v0.4.7/cue/testdata/basicrewrite/007_strings_and_bytes.txtar (about) 1 # DO NOT EDIT; generated by go run testdata/gen.go 2 # 3 #name: strings and bytes 4 #evalPartial 5 -- in.cue -- 6 s0: "foo" + "bar" 7 s1: 3 * "abc" 8 s2: "abc" * 2 9 10 b0: 'foo' + 'bar' 11 b1: 3 * 'abc' 12 b2: 'abc' * 2 13 14 // TODO: consider the semantics of this and perhaps allow this. 15 e0: "a" + '' 16 e1: 'b' + "c" 17 -- out/def -- 18 s0: "foobar" 19 s1: "abcabcabc" 20 s2: "abcabc" 21 b0: 'foobar' 22 b1: 'abcabcabc' 23 b2: 'abcabc' 24 25 // TODO: consider the semantics of this and perhaps allow this. 26 e0: _|_ // invalid operation "a" + '' (mismatched types string and bytes) 27 e1: _|_ // invalid operation 'b' + "c" (mismatched types bytes and string) 28 -- out/legacy-debug -- 29 <0>{s0: "foobar", s1: "abcabcabc", s2: "abcabc", b0: 'foobar', b1: 'abcabcabc', b2: 'abcabc', e0: _|_(("a" + ''):invalid operation "a" + '' (mismatched types string and bytes)), e1: _|_(('b' + "c"):invalid operation 'b' + "c" (mismatched types bytes and string))} 30 -- out/compile -- 31 --- in.cue 32 { 33 s0: ("foo" + "bar") 34 s1: (3 * "abc") 35 s2: ("abc" * 2) 36 b0: ('foo' + 'bar') 37 b1: (3 * 'abc') 38 b2: ('abc' * 2) 39 e0: ("a" + '') 40 e1: ('b' + "c") 41 } 42 -- out/eval -- 43 Errors: 44 e0: invalid operands "a" and '' to '+' (type string and bytes): 45 ./in.cue:10:5 46 ./in.cue:10:11 47 e1: invalid operands 'b' and "c" to '+' (type bytes and string): 48 ./in.cue:11:5 49 ./in.cue:11:11 50 51 Result: 52 (_|_){ 53 // [eval] 54 s0: (string){ "foobar" } 55 s1: (string){ "abcabcabc" } 56 s2: (string){ "abcabc" } 57 b0: (bytes){ 'foobar' } 58 b1: (bytes){ 'abcabcabc' } 59 b2: (bytes){ 'abcabc' } 60 e0: (_|_){ 61 // [eval] e0: invalid operands "a" and '' to '+' (type string and bytes): 62 // ./in.cue:10:5 63 // ./in.cue:10:11 64 } 65 e1: (_|_){ 66 // [eval] e1: invalid operands 'b' and "c" to '+' (type bytes and string): 67 // ./in.cue:11:5 68 // ./in.cue:11:11 69 } 70 }