All files / types/__testUtils__ testSourceSpan.ts

100% Statements 1/1
100% Branches 5/5
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                                                4516x                    
import type ISourceSpan from "../ISourceSpan";
 
/**
 * Span builder for symbol mocks.
 *
 * Symbols carry a four-integer span rather than a bare line (#1318), and almost
 * every test that builds one cares about the line alone -- it is asserting which
 * declaration a diagnostic names, not how wide it is. Spelling the other three
 * fields at each site would bury that intent in noise, and a `as never` cast to
 * dodge them is what let mocks drift from the interface before. `ITypeAccessors`
 * had a sibling builder for exactly that reason; #1445 removed the last mock it
 * served, because the module that took those accessors takes a classified plan
 * now and has no accessor literal left to get wrong.
 *
 * Defaults to a zero-width span at the start of the line. A test that asserts a
 * column or a range passes them explicitly.
 */
class TestSourceSpan {
  static at(
    line: number,
    column = 0,
    endLine?: number,
    endColumn?: number,
  ): ISourceSpan {
    return {
      line,
      column,
      endLine: endLine ?? line,
      endColumn: endColumn ?? column,
    };
  }
}
 
export default TestSourceSpan;