(t *testing.T)
| 354 | } |
| 355 | |
| 356 | func TestNewSourceInfoRelative(t *testing.T) { |
| 357 | sourceInfo := ast.NewSourceInfo( |
| 358 | mockRelativeSource(t, |
| 359 | "\n \n a || b ?\n cond1 :\n cond2", |
| 360 | []int32{1, 2, 13, 25}, |
| 361 | common.NewLocation(2, 1))) |
| 362 | tests := []struct { |
| 363 | loc common.Location |
| 364 | offset int32 |
| 365 | }{ |
| 366 | // All locations specify a line number starting at 1 |
| 367 | // The location of line 2, offset 1 is the same as the |
| 368 | // relative offset at location 1, 0 (offset 2) |
| 369 | {loc: common.NewLocation(1, 0), offset: 2}, |
| 370 | // Equivalent to line 3, column 4 |
| 371 | {loc: common.NewLocation(2, 3), offset: 6}, |
| 372 | // Equivalent to line 4, column 2 |
| 373 | {loc: common.NewLocation(3, 1), offset: 15}, |
| 374 | } |
| 375 | for _, tst := range tests { |
| 376 | gotOffset := sourceInfo.ComputeOffset(int32(tst.loc.Line()), int32(tst.loc.Column())) |
| 377 | if gotOffset != tst.offset { |
| 378 | t.Errorf("ComputeOffset() got %v, wanted %v", gotOffset, tst.offset) |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | func TestMaxID(t *testing.T) { |
| 384 | checked := mustTypeCheck(t, `has({'a':'key'}.key)`) |
nothing calls this directly
no test coverage detected