jeffrifwald / babel-istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
144 stars 23 forks source link

Location of function on first line is off #9

Closed Swatinem closed 9 years ago

Swatinem commented 9 years ago

consider the following code:

function a() {}
function b() {}

The resulting coverage json has the following function map:

    "fnMap": {
      "1": {
        "name": "a",
        "line": 1,
        "loc": {
          "start": {
            "source": "/home/swatinem/Coding/yavd/covtest/test.js",
            "line": 1,
            "column": -15,
            "name": null
          },
          "end": {
            "source": "/home/swatinem/Coding/yavd/covtest/test.js",
            "line": 1,
            "column": -2,
            "name": null
          }
        }
      },
      "2": {
        "name": "b",
        "line": 2,
        "loc": {
          "start": {
            "source": "/home/swatinem/Coding/yavd/covtest/test.js",
            "line": 2,
            "column": 0,
            "name": null
          },
          "end": {
            "source": "/home/swatinem/Coding/yavd/covtest/test.js",
            "line": 2,
            "column": 13,
            "name": null
          }
        }
      },

for function a, start and end columns are both offset by -15. Also, I don’t see a reason that the location has a source that is redundant and name that is always 0.