Skip to content

Core Spec Test Coverage

Asumu Takikawa edited this page Oct 9, 2024 · 29 revisions

Consumer / validator tests

  • Explicitly not tested

    • Source map being an invalid JSON document (depending on the implementation, this may only test the test harness itself, rather than any interesting properties about the tool)
  • Encoding

    • Base64 VLQ
      • VLQs should decode correctly
        • A VLQ with a non-base64 character will fail to decode. (test)
        • A VLQ with one digit and no continuation digits should decode. (test)
        • A negative VLQ with the sign bit set to 1 should decode. (test)
        • A VLQ with non-zero continuation bits (and more than one digit) should decode. (test)
        • A VLQ with a non-zero continuation bit with no further digits should fail to decode. (test)
        • A VLQ should decode with the correct order of digits (least to most significant). (tested indirectly by other VLQ tests)
        • A long VLQ with many trailing zero digits will decode. (test)
      • A VLQ exceeding the 32-bit size limit is invalid. (test)
      • A VLQ at exactly the 32-bit size limit should be decoded (positive and negative). (test)
  • Basic format

    • version field
      • Must be present (test)
      • Must be a number (test)
      • Must be 3 (test)
    • file field
      • Optional, allow missing (many tests)
      • Must be a string (test)
    • sourceRoot field
      • Optional, allow missing (many tests)
      • Must be a string (test)
    • sources field
      • Must be present (test)
      • Must be an array (test)
      • Array elements must be null or a string (test)
    • sourcesContent field
      • Optional, may be missing (test)
      • Must be an array (test)
      • Array elements must be null or a string (test)
    • names field
      • Optional, may be missing (test)
      • Must be an array (test)
      • Array elements must be strings (test)
    • mappings field
      • Must be present (test)
      • Must be a string (test)
      • Empty string is valid (test)
    • ignoreList field: see below under "Ignore List"
    • Extra unrecognized fields are allowed (test)
  • Index maps

    • map with sections is treated as index map (covered by tests below)
    • file field
      • Optional, allow missing (test)
      • Must be a string (test)
    • sections field
      • Must be present (without "sections" it is a regular map, so it's indirectly tested)
      • Must be an array (test)
      • An empty sections array is valid (test)
      • Array elements are valid section objects
        • offset field
          • Must be present (test)
          • line field
            • Must be present (test)
            • Must be a number (test)
          • column field
            • Must be present (test)
            • Must be a number (test)
        • map field
          • Must be present (test)
          • Must be an object (test)
          • Must be a valid source map (test)
      • Sections are in order (the spec is not 100% clear, but assumption is increasing numeric order, may need subtests) (test)
      • Sections are non-overlapping (the definition of overlap is not clear, may need subtests) (test)
  • Mappings format

    • Each line is separated by ";", segments by "," (test)
    • A line may consist of zero segments (e.g., ";;") (test)
    • Must have 1, 4, or 5 fields
      • Must have greater than zero fields (test)
      • Cannot have 2 fields (test)
      • Cannot have 3 fields (test)
    • The source index must not be out of bounds of the sources array (test)
    • The name index must not be out of bounds of the names array (test)
    • Absolute VLQ values must be non-negative
      • The column must be non-negative (test)
      • The source index must be non-negative (test)
      • The original line must be non-negative (test)
      • The original column must be non-negative (test)
      • The name index must be non-negative (test)
    • Relative VLQ values must be non-negative after adding to previous value
      • The column must be non-negative (test)
      • The source index must be non-negative (test)
      • The original line must be non-negative (test)
      • The original column must be non-negative (test)
      • The name index must be non-negative (test)
  • Ignore list

    • An ignore list is optional, may be missing (many tests indirectly)
    • An ignore list can't be a non-array value (test)
    • An ignore list can be empty (test)
    • An ignore list entry must be a non-negative integer (test)
    • An ignore list entry cannot be out-of-bounds of the sources array (test)
    • Ignore list entries are detected and are present (test)
    • Items not specified in the ignore list don't show up as ignored
  • Mappings semantics

    • A source map with no mappings does not map any position. (negative mapping tests not supported yet)
    • A single field segment gets mapped to the correct line and column. (test)
    • A four field segment gets mapped to the correct line and column. (test)
    • A five field segment gets mapped to the correct line and column. (test)
    • When a name is present in a segment, it is correctly mapped. (test)
    • When a source is present in a segment, it is correctly mapped. (test)
    • The second occurrence of a field segment in a line is mapped relative to the previous one. (test)
    • When a new line starts, the generated column field resets to zero rather than being relative to the previous line. (test)
    • For fields other than the generated column, a segment field that has occurred once in a previous line is mapped relatively when it occurs in the next line. (test)
    • Ensure that a transitive source map mapping works as expected (see issue 13)
    • Index maps are correctly used in mappings
      • An index map with one sub-map will map correctly. (test)
      • An index map with multiple sub-maps will map correctly, with appropriate offsets for the second and later sub-maps. (test)
  • Resolution of sources

    • When sourceRoot is provided, it is prepended to any sources entries and will be mapped with the full URL. (test)
    • If the source URL is an absolute URL, it is resolved as an absolute URL. (it's hard to test this aspect of URL resolution in a platform independent way, currently not tested)
    • If the source URL is a relative URL, it is resolved relative to the source map path. (see above)
  • Other formats

    • Wasm support
      • Test a generated source that is Wasm format (.wasm file with custom section).
    • CSS
      • Test a generated source that is a CSS file.

Proposals

Scopes proposal

  • Format validation
    • originalScopes
      • originalScopes is optional (NB: check with spec text)
      • Must be an array
      • Array items must be strings (NB: or null?)
      • The length of originalScopes should be less than or equal to the length of sources
    • generatedRanges
      • generatedRanges is optional
      • Must be a string
  • Decoding scopes
    • Scope strings are composed of VLQ fields, ;, or ,
    • Invalid base64 characters are rejected
    • Original scope items
    • Generated range items
      • Length of an item is 1 field or greater
  • Scope semantics
Clone this wiki locally