cuelang.org/go@v0.13.0/cue/testdata/basicrewrite/003_integer-specific_arithmetic.txtar (about) 1 #name: integer-specific arithmetic 2 #evalPartial 3 -- in.cue -- 4 q1: 5 quo 2 // 2 5 q2: 5 quo -2 // -2 6 q3: -5 quo 2 // -2 7 q4: -5 quo -2 // 2 8 qe1: 2.0 quo 1 9 qe2: 2 quo 1.0 10 11 r1: 5 rem 2 // 1 12 r2: 5 rem -2 // 1 13 r3: -5 rem 2 // -1 14 r4: -5 rem -2 // -1 15 re1: 2.0 rem 1 16 re2: 2 rem 1.0 17 18 d1: 5 div 2 // 2 19 d2: 5 div -2 // -2 20 d3: -5 div 2 // -3 21 d4: -5 div -2 // 3 22 de1: 2.0 div 1 23 de2: 2 div 1.0 24 25 m1: 5 mod 2 // 1 26 m2: 5 mod -2 // 1 27 m3: -5 mod 2 // 1 28 m4: -5 mod -2 // 1 29 me1: 2.0 mod 1 30 me2: 2 mod 1.0 31 -- out/def -- 32 q1: 2 33 q2: -2 34 q3: -2 35 q4: 2 36 qe1: _|_ // invalid operation 2.0 quo 1 (mismatched types float and int) 37 qe2: _|_ // invalid operation 2 quo 1.0 (mismatched types int and float) 38 r1: 1 39 r2: 1 40 r3: -1 41 r4: -1 42 re1: _|_ // invalid operation 2.0 rem 1 (mismatched types float and int) 43 re2: _|_ // invalid operation 2 rem 1.0 (mismatched types int and float) 44 d1: 2 45 d2: -2 46 d3: -3 47 d4: 3 48 de1: _|_ // invalid operation 2.0 div 1 (mismatched types float and int) 49 de2: _|_ // invalid operation 2 div 1.0 (mismatched types int and float) 50 m1: 1 51 m2: 1 52 m3: 1 53 m4: 1 54 me1: _|_ // invalid operation 2.0 mod 1 (mismatched types float and int) 55 me2: _|_ // invalid operation 2 mod 1.0 (mismatched types int and float) 56 -- out/legacy-debug -- 57 <0>{q1: 2, q2: -2, q3: -2, q4: 2, qe1: _|_((2.0 quo 1):invalid operation 2.0 quo 1 (mismatched types float and int)), qe2: _|_((2 quo 1.0):invalid operation 2 quo 1.0 (mismatched types int and float)), r1: 1, r2: 1, r3: -1, r4: -1, re1: _|_((2.0 rem 1):invalid operation 2.0 rem 1 (mismatched types float and int)), re2: _|_((2 rem 1.0):invalid operation 2 rem 1.0 (mismatched types int and float)), d1: 2, d2: -2, d3: -3, d4: 3, de1: _|_((2.0 div 1):invalid operation 2.0 div 1 (mismatched types float and int)), de2: _|_((2 div 1.0):invalid operation 2 div 1.0 (mismatched types int and float)), m1: 1, m2: 1, m3: 1, m4: 1, me1: _|_((2.0 mod 1):invalid operation 2.0 mod 1 (mismatched types float and int)), me2: _|_((2 mod 1.0):invalid operation 2 mod 1.0 (mismatched types int and float))} 58 -- out/compile -- 59 --- in.cue 60 { 61 q1: (5 quo 2) 62 q2: (5 quo -2) 63 q3: (-5 quo 2) 64 q4: (-5 quo -2) 65 qe1: (2.0 quo 1) 66 qe2: (2 quo 1.0) 67 r1: (5 rem 2) 68 r2: (5 rem -2) 69 r3: (-5 rem 2) 70 r4: (-5 rem -2) 71 re1: (2.0 rem 1) 72 re2: (2 rem 1.0) 73 d1: (5 div 2) 74 d2: (5 div -2) 75 d3: (-5 div 2) 76 d4: (-5 div -2) 77 de1: (2.0 div 1) 78 de2: (2 div 1.0) 79 m1: (5 mod 2) 80 m2: (5 mod -2) 81 m3: (-5 mod 2) 82 m4: (-5 mod -2) 83 me1: (2.0 mod 1) 84 me2: (2 mod 1.0) 85 } 86 -- out/eval/stats -- 87 Leaks: 0 88 Freed: 25 89 Reused: 23 90 Allocs: 2 91 Retain: 0 92 93 Unifications: 25 94 Conjuncts: 25 95 Disjuncts: 25 96 -- out/eval -- 97 Errors: 98 qe1: invalid operands 2.0 and 1 to 'quo' (type float and int): 99 ./in.cue:5:6 100 ./in.cue:5:14 101 qe2: invalid operands 2 and 1.0 to 'quo' (type int and float): 102 ./in.cue:6:6 103 ./in.cue:6:12 104 re1: invalid operands 2.0 and 1 to 'rem' (type float and int): 105 ./in.cue:12:6 106 ./in.cue:12:14 107 re2: invalid operands 2 and 1.0 to 'rem' (type int and float): 108 ./in.cue:13:6 109 ./in.cue:13:12 110 de1: invalid operands 2.0 and 1 to 'div' (type float and int): 111 ./in.cue:19:6 112 ./in.cue:19:14 113 de2: invalid operands 2 and 1.0 to 'div' (type int and float): 114 ./in.cue:20:6 115 ./in.cue:20:12 116 me1: invalid operands 2.0 and 1 to 'mod' (type float and int): 117 ./in.cue:26:6 118 ./in.cue:26:14 119 me2: invalid operands 2 and 1.0 to 'mod' (type int and float): 120 ./in.cue:27:6 121 ./in.cue:27:12 122 123 Result: 124 (_|_){ 125 // [eval] 126 q1: (int){ 2 } 127 q2: (int){ -2 } 128 q3: (int){ -2 } 129 q4: (int){ 2 } 130 qe1: (_|_){ 131 // [eval] qe1: invalid operands 2.0 and 1 to 'quo' (type float and int): 132 // ./in.cue:5:6 133 // ./in.cue:5:14 134 } 135 qe2: (_|_){ 136 // [eval] qe2: invalid operands 2 and 1.0 to 'quo' (type int and float): 137 // ./in.cue:6:6 138 // ./in.cue:6:12 139 } 140 r1: (int){ 1 } 141 r2: (int){ 1 } 142 r3: (int){ -1 } 143 r4: (int){ -1 } 144 re1: (_|_){ 145 // [eval] re1: invalid operands 2.0 and 1 to 'rem' (type float and int): 146 // ./in.cue:12:6 147 // ./in.cue:12:14 148 } 149 re2: (_|_){ 150 // [eval] re2: invalid operands 2 and 1.0 to 'rem' (type int and float): 151 // ./in.cue:13:6 152 // ./in.cue:13:12 153 } 154 d1: (int){ 2 } 155 d2: (int){ -2 } 156 d3: (int){ -3 } 157 d4: (int){ 3 } 158 de1: (_|_){ 159 // [eval] de1: invalid operands 2.0 and 1 to 'div' (type float and int): 160 // ./in.cue:19:6 161 // ./in.cue:19:14 162 } 163 de2: (_|_){ 164 // [eval] de2: invalid operands 2 and 1.0 to 'div' (type int and float): 165 // ./in.cue:20:6 166 // ./in.cue:20:12 167 } 168 m1: (int){ 1 } 169 m2: (int){ 1 } 170 m3: (int){ 1 } 171 m4: (int){ 1 } 172 me1: (_|_){ 173 // [eval] me1: invalid operands 2.0 and 1 to 'mod' (type float and int): 174 // ./in.cue:26:6 175 // ./in.cue:26:14 176 } 177 me2: (_|_){ 178 // [eval] me2: invalid operands 2 and 1.0 to 'mod' (type int and float): 179 // ./in.cue:27:6 180 // ./in.cue:27:12 181 } 182 }