| 1 | module sourcemap |
| 2 | |
| 3 | fn test_cmp_eq() { |
| 4 | a := Mapping{ |
| 5 | GenPosition: GenPosition{ |
| 6 | gen_line: 1 |
| 7 | gen_column: 0 |
| 8 | } |
| 9 | sources_ind: 2 |
| 10 | names_ind: IndexNumber(3) |
| 11 | source_position: SourcePosition{ |
| 12 | source_line: 4 |
| 13 | source_column: 5 |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | b := Mapping{ |
| 18 | GenPosition: GenPosition{ |
| 19 | gen_line: 1 |
| 20 | gen_column: 0 |
| 21 | } |
| 22 | sources_ind: 2 |
| 23 | names_ind: IndexNumber(3) |
| 24 | source_position: SourcePosition{ |
| 25 | source_line: 4 |
| 26 | source_column: 5 |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | assert !compare_by_generated_positions_inflated(a, b) |
| 31 | } |
| 32 | |
| 33 | fn test_cmp_name() { |
| 34 | a := Mapping{ |
| 35 | GenPosition: GenPosition{ |
| 36 | gen_line: 1 |
| 37 | gen_column: 0 |
| 38 | } |
| 39 | sources_ind: 2 |
| 40 | names_ind: IndexNumber(3) |
| 41 | source_position: SourcePosition{ |
| 42 | source_line: 4 |
| 43 | source_column: 5 |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | b := Mapping{ |
| 48 | GenPosition: GenPosition{ |
| 49 | gen_line: 1 |
| 50 | gen_column: 0 |
| 51 | } |
| 52 | sources_ind: 2 |
| 53 | names_ind: IndexNumber(4) |
| 54 | source_position: SourcePosition{ |
| 55 | source_line: 4 |
| 56 | source_column: 5 |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | assert compare_by_generated_positions_inflated(a, b) |
| 61 | } |
| 62 | |
| 63 | fn test_cmp_name_empty() { |
| 64 | a := Mapping{ |
| 65 | GenPosition: GenPosition{ |
| 66 | gen_line: 1 |
| 67 | gen_column: 0 |
| 68 | } |
| 69 | sources_ind: 2 |
| 70 | names_ind: IndexNumber(3) |
| 71 | source_position: SourcePosition{ |
| 72 | source_line: 4 |
| 73 | source_column: 5 |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | b := Mapping{ |
| 78 | GenPosition: GenPosition{ |
| 79 | gen_line: 1 |
| 80 | gen_column: 0 |
| 81 | } |
| 82 | sources_ind: 2 |
| 83 | names_ind: Empty{} |
| 84 | source_position: SourcePosition{ |
| 85 | source_line: 4 |
| 86 | source_column: 5 |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | assert compare_by_generated_positions_inflated(a, b) |
| 91 | } |
| 92 | |
| 93 | fn test_cmp_name_empty_empty() { |
| 94 | a := Mapping{ |
| 95 | GenPosition: GenPosition{ |
| 96 | gen_line: 1 |
| 97 | gen_column: 0 |
| 98 | } |
| 99 | sources_ind: 2 |
| 100 | names_ind: Empty{} |
| 101 | source_position: SourcePosition{ |
| 102 | source_line: 4 |
| 103 | source_column: 5 |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | b := Mapping{ |
| 108 | GenPosition: GenPosition{ |
| 109 | gen_line: 1 |
| 110 | gen_column: 0 |
| 111 | } |
| 112 | sources_ind: 2 |
| 113 | names_ind: Empty{} |
| 114 | source_position: SourcePosition{ |
| 115 | source_line: 4 |
| 116 | source_column: 5 |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | assert !compare_by_generated_positions_inflated(a, b) |
| 121 | } |
| 122 | |
| 123 | fn test_cmp_source_position_empty_eq() { |
| 124 | a := Mapping{ |
| 125 | GenPosition: GenPosition{ |
| 126 | gen_line: 1 |
| 127 | gen_column: 0 |
| 128 | } |
| 129 | sources_ind: 2 |
| 130 | names_ind: Empty{} |
| 131 | source_position: Empty{} |
| 132 | } |
| 133 | |
| 134 | b := Mapping{ |
| 135 | GenPosition: GenPosition{ |
| 136 | gen_line: 1 |
| 137 | gen_column: 0 |
| 138 | } |
| 139 | sources_ind: 2 |
| 140 | names_ind: Empty{} |
| 141 | source_position: Empty{} |
| 142 | } |
| 143 | |
| 144 | assert !compare_by_generated_positions_inflated(a, b) |
| 145 | } |
| 146 | |
| 147 | fn test_cmp_source_position_empty_diff() { |
| 148 | a := Mapping{ |
| 149 | GenPosition: GenPosition{ |
| 150 | gen_line: 1 |
| 151 | gen_column: 0 |
| 152 | } |
| 153 | sources_ind: 2 |
| 154 | names_ind: Empty{} |
| 155 | source_position: SourcePosition{ |
| 156 | source_line: 4 |
| 157 | source_column: 5 |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | b := Mapping{ |
| 162 | GenPosition: GenPosition{ |
| 163 | gen_line: 1 |
| 164 | gen_column: 0 |
| 165 | } |
| 166 | sources_ind: 2 |
| 167 | names_ind: Empty{} |
| 168 | source_position: Empty{} |
| 169 | } |
| 170 | |
| 171 | assert compare_by_generated_positions_inflated(a, b) |
| 172 | } |
| 173 | |
| 174 | fn test_cmp_source_position_column_diff() { |
| 175 | a := Mapping{ |
| 176 | GenPosition: GenPosition{ |
| 177 | gen_line: 1 |
| 178 | gen_column: 0 |
| 179 | } |
| 180 | sources_ind: 2 |
| 181 | names_ind: Empty{} |
| 182 | source_position: SourcePosition{ |
| 183 | source_line: 4 |
| 184 | source_column: 5 |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | b := Mapping{ |
| 189 | GenPosition: GenPosition{ |
| 190 | gen_line: 1 |
| 191 | gen_column: 0 |
| 192 | } |
| 193 | sources_ind: 2 |
| 194 | names_ind: Empty{} |
| 195 | source_position: SourcePosition{ |
| 196 | source_line: 4 |
| 197 | source_column: 99 |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | assert compare_by_generated_positions_inflated(a, b) |
| 202 | } |
| 203 | |
| 204 | fn test_cmp_source_position_line_diff() { |
| 205 | a := Mapping{ |
| 206 | GenPosition: GenPosition{ |
| 207 | gen_line: 1 |
| 208 | gen_column: 0 |
| 209 | } |
| 210 | sources_ind: 2 |
| 211 | names_ind: Empty{} |
| 212 | source_position: SourcePosition{ |
| 213 | source_line: 4 |
| 214 | source_column: 5 |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | b := Mapping{ |
| 219 | GenPosition: GenPosition{ |
| 220 | gen_line: 1 |
| 221 | gen_column: 0 |
| 222 | } |
| 223 | sources_ind: 2 |
| 224 | names_ind: Empty{} |
| 225 | source_position: SourcePosition{ |
| 226 | source_line: 88 |
| 227 | source_column: 99 |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | assert compare_by_generated_positions_inflated(a, b) |
| 232 | } |
| 233 | |
| 234 | fn test_cmp_sources() { |
| 235 | a := Mapping{ |
| 236 | GenPosition: GenPosition{ |
| 237 | gen_line: 1 |
| 238 | gen_column: 0 |
| 239 | } |
| 240 | sources_ind: 2 |
| 241 | names_ind: Empty{} |
| 242 | source_position: SourcePosition{ |
| 243 | source_line: 4 |
| 244 | source_column: 5 |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | b := Mapping{ |
| 249 | GenPosition: GenPosition{ |
| 250 | gen_line: 1 |
| 251 | gen_column: 0 |
| 252 | } |
| 253 | sources_ind: 99 |
| 254 | names_ind: Empty{} |
| 255 | source_position: SourcePosition{ |
| 256 | source_line: 4 |
| 257 | source_column: 5 |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | assert compare_by_generated_positions_inflated(a, b) |
| 262 | } |
| 263 | |
| 264 | fn test_cmp_gen_column() { |
| 265 | a := Mapping{ |
| 266 | GenPosition: GenPosition{ |
| 267 | gen_line: 1 |
| 268 | gen_column: 0 |
| 269 | } |
| 270 | sources_ind: 2 |
| 271 | names_ind: Empty{} |
| 272 | source_position: SourcePosition{ |
| 273 | source_line: 4 |
| 274 | source_column: 5 |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | b := Mapping{ |
| 279 | GenPosition: GenPosition{ |
| 280 | gen_line: 1 |
| 281 | gen_column: 99 |
| 282 | } |
| 283 | sources_ind: 2 |
| 284 | names_ind: Empty{} |
| 285 | source_position: SourcePosition{ |
| 286 | source_line: 4 |
| 287 | source_column: 5 |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | assert compare_by_generated_positions_inflated(a, b) |
| 292 | } |
| 293 | |
| 294 | fn test_cmp_gen_line() { |
| 295 | a := Mapping{ |
| 296 | GenPosition: GenPosition{ |
| 297 | gen_line: 1 |
| 298 | gen_column: 0 |
| 299 | } |
| 300 | sources_ind: 2 |
| 301 | names_ind: Empty{} |
| 302 | source_position: SourcePosition{ |
| 303 | source_line: 4 |
| 304 | source_column: 5 |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | b := Mapping{ |
| 309 | GenPosition: GenPosition{ |
| 310 | gen_line: 1 |
| 311 | gen_column: 99 |
| 312 | } |
| 313 | sources_ind: 2 |
| 314 | names_ind: Empty{} |
| 315 | source_position: SourcePosition{ |
| 316 | source_line: 4 |
| 317 | source_column: 5 |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | assert compare_by_generated_positions_inflated(a, b) |
| 322 | } |
| 323 | |