(t *testing.T)
| 228 | } |
| 229 | |
| 230 | func TestReaderGoLineToDingoLine(t *testing.T) { |
| 231 | dingoSrc := []byte("let x = 10\nlet y = 20\n") |
| 232 | goSrc := []byte("x := 10\ny := 20\n") |
| 233 | |
| 234 | mappings := []sourcemap.LineMapping{ |
| 235 | {DingoLine: 1, GoLineStart: 1, GoLineEnd: 1, Kind: "identifier"}, |
| 236 | {DingoLine: 2, GoLineStart: 2, GoLineEnd: 2, Kind: "identifier"}, |
| 237 | } |
| 238 | |
| 239 | data := createTestDmap(t, dingoSrc, goSrc, mappings) |
| 240 | reader, err := OpenBytes(data) |
| 241 | if err != nil { |
| 242 | t.Fatalf("OpenBytes failed: %v", err) |
| 243 | } |
| 244 | defer reader.Close() |
| 245 | |
| 246 | tests := []struct { |
| 247 | name string |
| 248 | goLine int |
| 249 | wantDingo int |
| 250 | }{ |
| 251 | {"line 1", 1, 1}, |
| 252 | {"line 2", 2, 2}, |
| 253 | // Line 0 is invalid (1-indexed), should clamp to first line |
| 254 | {"unmapped line 0", 0, 1}, |
| 255 | // Line 100 is beyond file (3 lines), should clamp using proportional mapping |
| 256 | {"unmapped line 100", 100, 3}, |
| 257 | } |
| 258 | |
| 259 | for _, tt := range tests { |
| 260 | t.Run(tt.name, func(t *testing.T) { |
| 261 | dingoLine, _ := reader.GoLineToDingoLine(tt.goLine) |
| 262 | |
| 263 | if dingoLine != tt.wantDingo { |
| 264 | t.Errorf("GoLineToDingoLine(%d) = %d, want %d", |
| 265 | tt.goLine, dingoLine, tt.wantDingo) |
| 266 | } |
| 267 | }) |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | func TestReaderMultipleKinds(t *testing.T) { |
| 272 | dingoSrc := []byte("let x = 10\nmatch y { A => 1 }\n") |
nothing calls this directly
no test coverage detected