Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dc2af26

Browse filesBrowse files
fossamagnadanielleadams
authored andcommitted
test: improve lib/internal/source_map/source_map.js coverage
PR-URL: #42771 Refs: https://coverage.nodejs.org/coverage-0699150267c08fb2/lib/internal/source_map/source_map.js.html#L154 Refs: https://coverage.nodejs.org/coverage-0699150267c08fb2/lib/internal/source_map/source_map.js.html#L165 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
1 parent 60a05d6 commit dc2af26
Copy full SHA for dc2af26

File tree

Expand file treeCollapse file tree

2 files changed

+51
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+51
-0
lines changed
Open diff view settings
Collapse file
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"version": 3,
3+
"sources": [
4+
"disk.js"
5+
],
6+
"sections": [
7+
{ "offset": {"line": 0, "column": 0 }, "map":
8+
{
9+
"version": 3,
10+
"sources": [
11+
"section.js"
12+
],
13+
"names": [
14+
"Foo",
15+
"[object Object]",
16+
"x",
17+
"this",
18+
"console",
19+
"info",
20+
"methodC",
21+
"a",
22+
"b",
23+
"methodA"
24+
],
25+
"mappings": "MAAMA,IACJC,YAAaC,EAAE,IACbC,KAAKD,EAAIA,EAAIA,EAAI,GACjB,GAAIC,KAAKD,EAAG,CACVE,QAAQC,KAAK,eACR,CACLD,QAAQC,KAAK,aAEfF,KAAKG,UAEPL,UACEG,QAAQC,KAAK,WAEfJ,UACEG,QAAQC,KAAK,aAEfJ,UACEG,QAAQC,KAAK,WAEfJ,UACEG,QAAQC,KAAK,cAIjB,MAAME,EAAI,IAAIP,IAAI,GAClB,MAAMQ,EAAI,IAAIR,IAAI,IAClBO,EAAEE",
26+
"sourceRoot": "./"
27+
}
28+
}
29+
]
30+
}
Collapse file

‎test/parallel/test-source-map-api.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-source-map-api.js
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,27 @@ const { readFileSync } = require('fs');
126126
assert.strictEqual(Object.keys(result).length, 0);
127127
}
128128

129+
// SourceMap can be instantiated with Index Source Map V3 object as payload.
130+
{
131+
const payload = JSON.parse(readFileSync(
132+
require.resolve('../fixtures/source-map/disk-index.map'), 'utf8'
133+
));
134+
const sourceMap = new SourceMap(payload);
135+
const {
136+
originalLine,
137+
originalColumn,
138+
originalSource
139+
} = sourceMap.findEntry(0, 29);
140+
assert.strictEqual(originalLine, 2);
141+
assert.strictEqual(originalColumn, 4);
142+
assert(originalSource.endsWith('section.js'));
143+
// The stored payload should be a clone:
144+
assert.strictEqual(payload.mappings, sourceMap.payload.mappings);
145+
assert.notStrictEqual(payload, sourceMap.payload);
146+
assert.strictEqual(payload.sources[0], sourceMap.payload.sources[0]);
147+
assert.notStrictEqual(payload.sources, sourceMap.payload.sources);
148+
}
149+
129150
// Test various known decodings to ensure decodeVLQ works correctly.
130151
{
131152
function makeMinimalMap(column) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.