Exemplo n.º 1
0
        public void ApplyMap_ExactMatchDeep_ReturnsCorrectMappingEntry()
        {
            // Arrange
            var generated1 = UnitTestUtils.GenerateSourcePosition(lineNumber: 3, colNumber: 5);
            var original1  = UnitTestUtils.GenerateSourcePosition(lineNumber: 2, colNumber: 10);
            var mapLevel2  = UnitTestUtils.GetSimpleEntry(generated1, original1, "sourceThree.js");

            var grandChildMap = new SourceMap
            {
                File    = "sourceTwo.js",
                Sources = new List <string> {
                    "sourceThree.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    mapLevel2
                }
            };

            var generated2 = UnitTestUtils.GenerateSourcePosition(lineNumber: 4, colNumber: 3);
            var original2  = UnitTestUtils.GenerateSourcePosition(lineNumber: 3, colNumber: 5);
            var mapLevel1  = UnitTestUtils.GetSimpleEntry(generated2, original2, "sourceTwo.js");

            var childMap = new SourceMap
            {
                File    = "sourceOne.js",
                Sources = new List <string> {
                    "sourceTwo.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    mapLevel1
                }
            };

            var generated3 = UnitTestUtils.GenerateSourcePosition(lineNumber: 5, colNumber: 5);
            var original3  = UnitTestUtils.GenerateSourcePosition(lineNumber: 4, colNumber: 3);
            var mapLevel0  = UnitTestUtils.GetSimpleEntry(generated3, original3, "sourceOne.js");

            var parentMap = new SourceMap
            {
                File    = "generated.js",
                Sources = new List <string> {
                    "sourceOne.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    mapLevel0
                }
            };

            // Act
            var firstCombinedMap = parentMap.ApplySourceMap(childMap);

            // Assert
            Assert.IsNotNull(firstCombinedMap);
            var secondCombinedMap = firstCombinedMap.ApplySourceMap(grandChildMap);

            Assert.IsNotNull(secondCombinedMap);
            var rootMapping = secondCombinedMap.GetMappingEntryForGeneratedSourcePosition(generated3);

            Assert.AreEqual(0, rootMapping.OriginalSourcePosition.CompareTo(mapLevel2.OriginalSourcePosition));
        }
Exemplo n.º 2
0
        public void FlattenMap_MultipleOriginalLineToSameGeneratedLine_ReturnsFirstOriginalLine()
        {
            // Arrange
            SourcePosition generated1   = UnitTestUtils.generateSourcePosition(lineNumber: 1, colNumber: 2);
            SourcePosition original1    = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 2);
            MappingEntry   mappingEntry = UnitTestUtils.getSimpleEntry(generated1, original1, "sourceOne.js");

            SourcePosition generated2    = UnitTestUtils.generateSourcePosition(lineNumber: 1, colNumber: 3);
            SourcePosition original2     = UnitTestUtils.generateSourcePosition(lineNumber: 3, colNumber: 5);
            MappingEntry   mappingEntry2 = UnitTestUtils.getSimpleEntry(generated2, original2, "sourceOne.js");

            SourceMap map = new SourceMap
            {
                File    = "generated.js",
                Sources = new List <string> {
                    "sourceOne.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    mappingEntry, mappingEntry2
                }
            };

            // Act
            SourceMap linesOnlyMap = SourceMapTransformer.Flatten(map);

            // Assert
            Assert.IsNotNull(linesOnlyMap);
            Assert.AreEqual(1, linesOnlyMap.Sources.Count);
            Assert.AreEqual(1, linesOnlyMap.ParsedMappings.Count);
            Assert.AreEqual(1, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.ZeroBasedLineNumber);
            Assert.AreEqual(0, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.ZeroBasedColumnNumber);
            Assert.AreEqual(2, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition.ZeroBasedLineNumber);
            Assert.AreEqual(0, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition.ZeroBasedColumnNumber);
        }
        public void FlattenMap_ReturnsOnlyLineInformation()
        {
            // Arrange
            SourcePosition generated1   = UnitTestUtils.generateSourcePosition(lineNumber: 1, colNumber: 2);
            SourcePosition original1    = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 2);
            MappingEntry   mappingEntry = UnitTestUtils.getSimpleEntry(generated1, original1, "sourceOne.js");

            SourceMap map = new SourceMap
            {
                File    = "generated.js",
                Sources = new List <string> {
                    "sourceOne.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    mappingEntry
                },
                SourcesContent = new List <string> {
                    "var a = b"
                }
            };

            // Act
            SourceMap linesOnlyMap = SourceMapTransformer.Flatten(map);

            // Assert
            Assert.NotNull(linesOnlyMap);
            Assert.Equal(1, linesOnlyMap.Sources.Count);
            Assert.Equal(1, linesOnlyMap.SourcesContent.Count);
            Assert.Equal(1, linesOnlyMap.ParsedMappings.Count);
            Assert.Equal(1, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.ZeroBasedLineNumber);
            Assert.Equal(0, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.ZeroBasedColumnNumber);
            Assert.Equal(2, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition.ZeroBasedLineNumber);
            Assert.Equal(0, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition.ZeroBasedColumnNumber);
        }
        public void FlattenMap_ReturnsOnlyLineInformation()
        {
            // Arrange
            SourcePosition generated1   = UnitTestUtils.generateSourcePosition(lineNumber: 1, colNumber: 2);
            SourcePosition original1    = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 2);
            MappingEntry   mappingEntry = UnitTestUtils.getSimpleEntry(generated1, original1, "sourceOne.js");

            SourceMap map = new SourceMap(
                version: default,
Exemplo n.º 5
0
        public void ApplyMap_ExactMatchDeep_ReturnsCorrectMappingEntry()
        {
            // Arrange
            SourcePosition generated1 = UnitTestUtils.generateSourcePosition(lineNumber: 3, colNumber: 5);
            SourcePosition original1  = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 10);
            MappingEntry   mapLevel2  = UnitTestUtils.getSimpleEntry(generated1, original1, "sourceThree.js");

            SourceMap grandChildMap = CreateSourceMap(
                file: "sourceTwo.js",
                sources: new List <string>()
            {
                "sourceThree.js"
            },
                parsedMappings: new List <MappingEntry> {
                mapLevel2
            });

            SourcePosition generated2 = UnitTestUtils.generateSourcePosition(lineNumber: 4, colNumber: 3);
            SourcePosition original2  = UnitTestUtils.generateSourcePosition(lineNumber: 3, colNumber: 5);
            MappingEntry   mapLevel1  = UnitTestUtils.getSimpleEntry(generated2, original2, "sourceTwo.js");

            SourceMap childMap = CreateSourceMap(
                file: "sourceOne.js",
                sources: new List <string>()
            {
                "sourceTwo.js"
            },
                parsedMappings: new List <MappingEntry> {
                mapLevel1
            });

            SourcePosition generated3 = UnitTestUtils.generateSourcePosition(lineNumber: 5, colNumber: 5);
            SourcePosition original3  = UnitTestUtils.generateSourcePosition(lineNumber: 4, colNumber: 3);
            MappingEntry   mapLevel0  = UnitTestUtils.getSimpleEntry(generated3, original3, "sourceOne.js");

            SourceMap parentMap = CreateSourceMap(
                file: "generated.js",
                sources: new List <string>()
            {
                "sourceOne.js"
            },
                parsedMappings: new List <MappingEntry> {
                mapLevel0
            });

            // Act
            SourceMap firstCombinedMap = parentMap.ApplySourceMap(childMap);

            // Assert
            Assert.NotNull(firstCombinedMap);
            SourceMap secondCombinedMap = firstCombinedMap.ApplySourceMap(grandChildMap);

            Assert.NotNull(secondCombinedMap);
            MappingEntry?rootMapping = secondCombinedMap.GetMappingEntryForGeneratedSourcePosition(generated3);

            Assert.Equal(0, rootMapping.Value.OriginalSourcePosition.CompareTo(mapLevel2.OriginalSourcePosition));
        }
Exemplo n.º 6
0
        public void ApplyMap_PartialMatchingSources_ReturnsCorrectMap()
        {
            // Expect mappings with same source filename as the applied source-map to be replaced
            // mappings with a different source filename should stay the same

            // Arrange
            var generated1   = UnitTestUtils.GenerateSourcePosition(lineNumber: 2, colNumber: 10);
            var original1    = UnitTestUtils.GenerateSourcePosition(lineNumber: 1, colNumber: 5);
            var childMapping = UnitTestUtils.GetSimpleEntry(generated1, original1, "sourceTwo.js");

            var childMap = new SourceMap
            {
                File    = "sourceOne.js",
                Sources = new List <string> {
                    "sourceTwo.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    childMapping
                }
            };

            var generated2 = UnitTestUtils.GenerateSourcePosition(lineNumber: 3, colNumber: 2);
            var original2  = UnitTestUtils.GenerateSourcePosition(lineNumber: 2, colNumber: 10);
            var mapping    = UnitTestUtils.GetSimpleEntry(generated2, original2, "sourceOne.js");

            var generated3 = UnitTestUtils.GenerateSourcePosition(lineNumber: 4, colNumber: 3);
            var original3  = UnitTestUtils.GenerateSourcePosition(lineNumber: 3, colNumber: 2);
            var mapping2   = UnitTestUtils.GetSimpleEntry(generated3, original3, "noMapForThis.js");

            var parentMap = new SourceMap
            {
                File    = "generated.js",
                Sources = new List <string> {
                    "sourceOne.js", "noMapForThis.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    mapping, mapping2
                }
            };

            // Act
            var combinedMap = parentMap.ApplySourceMap(childMap);

            // Assert
            Assert.IsNotNull(combinedMap);
            Assert.AreEqual(2, combinedMap.ParsedMappings.Count);
            Assert.AreEqual(2, combinedMap.Sources.Count);
            var firstCombinedMapping = combinedMap.GetMappingEntryForGeneratedSourcePosition(generated3);

            Assert.IsTrue(firstCombinedMapping.IsValueEqual(mapping2));
            var secondCombinedMapping = combinedMap.GetMappingEntryForGeneratedSourcePosition(generated2);

            Assert.AreEqual(0,
                            secondCombinedMapping.OriginalSourcePosition.CompareTo(childMapping.OriginalSourcePosition));
        }
Exemplo n.º 7
0
        public void ApplyMap_PartialMatchingSources_ReturnsCorrectMap()
        {
            // Expect mappings with same source filename as the applied source-map to be replaced
            // mappings with a different source filename should stay the same

            // Arrange
            SourcePosition generated1   = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 10);
            SourcePosition original1    = UnitTestUtils.generateSourcePosition(lineNumber: 1, colNumber: 5);
            MappingEntry   childMapping = UnitTestUtils.getSimpleEntry(generated1, original1, "sourceTwo.js");

            SourceMap childMap = CreateSourceMap(
                file: "sourceOne.js",
                sources: new List <string>()
            {
                "sourceTwo.js"
            },
                parsedMappings: new List <MappingEntry> {
                childMapping
            });

            SourcePosition generated2 = UnitTestUtils.generateSourcePosition(lineNumber: 3, colNumber: 2);
            SourcePosition original2  = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 10);
            MappingEntry   mapping    = UnitTestUtils.getSimpleEntry(generated2, original2, "sourceOne.js");

            SourcePosition generated3 = UnitTestUtils.generateSourcePosition(lineNumber: 4, colNumber: 3);
            SourcePosition original3  = UnitTestUtils.generateSourcePosition(lineNumber: 3, colNumber: 2);
            MappingEntry   mapping2   = UnitTestUtils.getSimpleEntry(generated3, original3, "noMapForThis.js");

            SourceMap parentMap = CreateSourceMap(
                file: "generated.js",
                sources: new List <string> {
                "sourceOne.js", "noMapForThis.js"
            },
                parsedMappings: new List <MappingEntry> {
                mapping, mapping2
            });

            // Act
            SourceMap combinedMap = parentMap.ApplySourceMap(childMap);

            // Assert
            Assert.NotNull(combinedMap);
            Assert.Equal(2, combinedMap.ParsedMappings.Count);
            Assert.Equal(2, combinedMap.Sources.Count);
            MappingEntry?firstCombinedMapping = combinedMap.GetMappingEntryForGeneratedSourcePosition(generated3);

            Assert.True(firstCombinedMapping.Equals(mapping2));
            MappingEntry?secondCombinedMapping = combinedMap.GetMappingEntryForGeneratedSourcePosition(generated2);

            Assert.Equal(0, secondCombinedMapping.Value.OriginalSourcePosition.CompareTo(childMapping.OriginalSourcePosition));
        }
Exemplo n.º 8
0
        public void ApplyMap_MatchingSources_ReturnsCorrectMap()
        {
            // Expect mapping with same source filename as the applied source-map to be replaced

            // Arrange
            var generated1   = UnitTestUtils.GenerateSourcePosition(lineNumber: 2, colNumber: 4);
            var original1    = UnitTestUtils.GenerateSourcePosition(lineNumber: 1, colNumber: 3);
            var childMapping = UnitTestUtils.GetSimpleEntry(generated1, original1, "sourceTwo.js");

            var childMap = new SourceMap
            {
                File    = "sourceOne.js",
                Sources = new List <string> {
                    "sourceTwo.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    childMapping
                }
            };

            var generated2    = UnitTestUtils.GenerateSourcePosition(lineNumber: 3, colNumber: 5);
            var original2     = UnitTestUtils.GenerateSourcePosition(lineNumber: 2, colNumber: 4);
            var parentMapping = UnitTestUtils.GetSimpleEntry(generated2, original2, "sourceOne.js");

            var parentMap = new SourceMap
            {
                File    = "generated.js",
                Sources = new List <string> {
                    "sourceOne.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    parentMapping
                }
            };

            // Act
            var combinedMap = parentMap.ApplySourceMap(childMap);

            // Assert
            Assert.IsNotNull(combinedMap);
            Assert.AreEqual(1, combinedMap.ParsedMappings.Count);
            Assert.AreEqual(1, combinedMap.Sources.Count);
            var rootMapping = combinedMap.GetMappingEntryForGeneratedSourcePosition(generated2);

            Assert.AreEqual(0, rootMapping.OriginalSourcePosition.CompareTo(childMapping.OriginalSourcePosition));
        }
Exemplo n.º 9
0
        public void ApplyMap_MatchingSources_ReturnsCorrectMap()
        {
            // Expect mapping with same source filename as the applied source-map to be replaced

            // Arrange
            SourcePosition generated1   = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 4);
            SourcePosition original1    = UnitTestUtils.generateSourcePosition(lineNumber: 1, colNumber: 3);
            MappingEntry   childMapping = UnitTestUtils.getSimpleEntry(generated1, original1, "sourceTwo.js");

            SourceMap childMap = CreateSourceMap(
                file: "sourceOne.js",
                sources: new List <string>()
            {
                "sourceTwo.js"
            },
                parsedMappings: new List <MappingEntry> {
                childMapping
            });

            SourcePosition generated2    = UnitTestUtils.generateSourcePosition(lineNumber: 3, colNumber: 5);
            SourcePosition original2     = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 4);
            MappingEntry   parentMapping = UnitTestUtils.getSimpleEntry(generated2, original2, "sourceOne.js");

            SourceMap parentMap = CreateSourceMap(
                file: "generated.js",
                sources: new List <string>()
            {
                "sourceOne.js"
            },
                parsedMappings: new List <MappingEntry> {
                parentMapping
            });

            // Act
            SourceMap combinedMap = parentMap.ApplySourceMap(childMap);

            // Assert
            Assert.NotNull(combinedMap);
            Assert.Single(combinedMap.ParsedMappings);
            Assert.Single(combinedMap.Sources);
            MappingEntry?rootMapping = combinedMap.GetMappingEntryForGeneratedSourcePosition(generated2);

            Assert.Equal(0, rootMapping.Value.OriginalSourcePosition.CompareTo(childMapping.OriginalSourcePosition));
        }
Exemplo n.º 10
0
        public void ParseSourceMap_SimpleSourceMap_CorrectlyParsed()
        {
            // Arrange
            SourceMapParser sourceMapParser = new SourceMapParser();
            string          input           = "{ \"version\":3, \"file\":\"CommonIntl\", \"lineCount\":65, \"mappings\":\"AACAA,aAAA,CAAc\", \"sources\":[\"input/CommonIntl.js\"], \"names\":[\"CommonStrings\",\"afrikaans\"]}";

            // Act
            SourceMap output = sourceMapParser.ParseSourceMap(UnitTestUtils.StreamReaderFromString(input));

            // Assert
            Assert.Equal(3, output.Version);
            Assert.Equal("CommonIntl", output.File);
            Assert.Equal("AACAA,aAAA,CAAc", output.Mappings);
            Assert.Equal(1, output.Sources.Count);
            Assert.Equal("input/CommonIntl.js", output.Sources[0]);
            Assert.Equal(2, output.Names.Count);
            Assert.Equal("CommonStrings", output.Names[0]);
            Assert.Equal("afrikaans", output.Names[1]);
        }
Exemplo n.º 11
0
        public void ApplyMap_NoMatchingMappings_ReturnsSameMap()
        {
            // Arrange
            var generated1   = UnitTestUtils.GenerateSourcePosition(lineNumber: 2, colNumber: 2);
            var original1    = UnitTestUtils.GenerateSourcePosition(lineNumber: 1, colNumber: 10);
            var childMapping = UnitTestUtils.GetSimpleEntry(generated1, original1, "sourceTwo.js");

            var childMap = new SourceMap
            {
                File    = "sourceOne.js",
                Sources = new List <string> {
                    "sourceTwo.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    childMapping
                }
            };

            var generated2    = UnitTestUtils.GenerateSourcePosition(lineNumber: 3, colNumber: 4);
            var original2     = UnitTestUtils.GenerateSourcePosition(lineNumber: 2, colNumber: 5);
            var parentMapping = UnitTestUtils.GetSimpleEntry(generated2, original2, "sourceOne.js");

            var parentMap = new SourceMap
            {
                File    = "generated.js",
                Sources = new List <string> {
                    "sourceOne.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    parentMapping
                }
            };

            // Act
            var combinedMap = parentMap.ApplySourceMap(childMap);

            // Assert
            Assert.IsNotNull(combinedMap);
            var firstMapping = combinedMap.ParsedMappings[0];

            Assert.IsTrue(firstMapping.IsValueEqual(parentMapping));
        }
Exemplo n.º 12
0
        public void ApplyMap_NoMatchingSources_ReturnsSameMap()
        {
            // Arrange
            SourcePosition generated1   = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 3);
            SourcePosition original1    = UnitTestUtils.generateSourcePosition(lineNumber: 1, colNumber: 2);
            MappingEntry   childMapping = UnitTestUtils.getSimpleEntry(generated1, original1, "someOtherSource.js");

            SourceMap childMap = new SourceMap
            {
                File    = "notSourceOne.js",
                Sources = new List <string> {
                    "someOtherSource.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    childMapping
                }
            };

            SourcePosition generated2    = UnitTestUtils.generateSourcePosition(lineNumber: 3, colNumber: 7);
            SourcePosition original2     = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 3);
            MappingEntry   parentMapping = UnitTestUtils.getSimpleEntry(generated2, original2, "sourceOne.js");

            SourceMap parentMap = new SourceMap
            {
                File    = "generated.js",
                Sources = new List <string> {
                    "sourceOne.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    parentMapping
                }
            };

            // Act
            SourceMap combinedMap = parentMap.ApplySourceMap(childMap);

            // Assert
            Assert.IsNotNull(combinedMap);
            MappingEntry firstMapping = combinedMap.ParsedMappings[0];

            Assert.IsTrue(firstMapping.IsValueEqual(parentMapping));
        }
Exemplo n.º 13
0
        public void ApplyMap_NoMatchingMappings_ReturnsSameMap()
        {
            // Arrange
            SourcePosition generated1   = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 2);
            SourcePosition original1    = UnitTestUtils.generateSourcePosition(lineNumber: 1, colNumber: 10);
            MappingEntry   childMapping = UnitTestUtils.getSimpleEntry(generated1, original1, "sourceTwo.js");

            SourceMap childMap = CreateSourceMap(
                file: "sourceOne.js",
                sources: new List <string>()
            {
                "sourceTwo.js"
            },
                parsedMappings: new List <MappingEntry> {
                childMapping
            });

            SourcePosition generated2    = UnitTestUtils.generateSourcePosition(lineNumber: 3, colNumber: 4);
            SourcePosition original2     = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 5);
            MappingEntry   parentMapping = UnitTestUtils.getSimpleEntry(generated2, original2, "sourceOne.js");

            SourceMap parentMap = CreateSourceMap(
                file: "generated.js",
                sources: new List <string>()
            {
                "sourceOne.js"
            },
                parsedMappings: new List <MappingEntry> {
                parentMapping
            });

            // Act
            SourceMap combinedMap = parentMap.ApplySourceMap(childMap);

            // Assert
            Assert.NotNull(combinedMap);
            MappingEntry firstMapping = combinedMap.ParsedMappings[0];

            Assert.True(firstMapping.Equals(parentMapping));
        }
Exemplo n.º 14
0
        public void GetRootMappingEntryForGeneratedSourcePosition_NoChildren_ReturnsSameEntry()
        {
            // Arrange
            SourcePosition generated1   = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 5);
            SourcePosition original1    = UnitTestUtils.generateSourcePosition(lineNumber: 1, colNumber: 5);
            MappingEntry   mappingEntry = UnitTestUtils.getSimpleEntry(generated1, original1, "generated.js");

            SourceMap sourceMap = CreateSourceMap(
                sources: new List <string>()
            {
                "generated.js"
            },
                parsedMappings: new List <MappingEntry> {
                mappingEntry
            });

            // Act
            MappingEntry?rootEntry = sourceMap.GetMappingEntryForGeneratedSourcePosition(generated1);

            // Assert
            Assert.Equal(rootEntry, mappingEntry);
        }
Exemplo n.º 15
0
        public void ApplyMap_NullSubmap_ThrowsException()
        {
            // Arrange
            SourcePosition generated2 = UnitTestUtils.generateSourcePosition(lineNumber: 3, colNumber: 5);
            SourcePosition original2  = UnitTestUtils.generateSourcePosition(lineNumber: 2, colNumber: 5);
            MappingEntry   mapping    = UnitTestUtils.getSimpleEntry(generated2, original2, "sourceOne.js");

            SourceMap map = CreateSourceMap(
                file: "generated.js",
                sources: new List <string>()
            {
                "sourceOne.js"
            },
                parsedMappings: new List <MappingEntry> {
                mapping
            });

            // Act
            Assert.Throws <ArgumentNullException>(() => map.ApplySourceMap(null));

            // Assert (decorated expected exception)
        }
Exemplo n.º 16
0
        public void ApplyMap_NullSubmap_ThrowsException()
        {
            // Arrange
            var generated2 = UnitTestUtils.GenerateSourcePosition(lineNumber: 3, colNumber: 5);
            var original2  = UnitTestUtils.GenerateSourcePosition(lineNumber: 2, colNumber: 5);
            var mapping    = UnitTestUtils.GetSimpleEntry(generated2, original2, "sourceOne.js");

            var map = new SourceMap
            {
                File    = "generated.js",
                Sources = new List <string> {
                    "sourceOne.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    mapping
                }
            };

            // Act
            var combinedMap = map.ApplySourceMap(null);

            // Assert (decorated expected exception)
        }
Exemplo n.º 17
0
        public void GetRootMappingEntryForGeneratedSourcePosition_NoChildren_ReturnsSameEntry()
        {
            // Arrange
            var generated1   = UnitTestUtils.GenerateSourcePosition(lineNumber: 2, colNumber: 5);
            var original1    = UnitTestUtils.GenerateSourcePosition(lineNumber: 1, colNumber: 5);
            var mappingEntry = UnitTestUtils.GetSimpleEntry(generated1, original1, "generated.js");

            var sourceMap = new SourceMap
            {
                Sources = new List <string> {
                    "generated.js"
                },
                ParsedMappings = new List <MappingEntry> {
                    mappingEntry
                }
            };

            // Act
            var rootEntry = sourceMap.GetMappingEntryForGeneratedSourcePosition(generated1);

            // Assert
            Assert.AreEqual(rootEntry, mappingEntry);
        }