public void TestMappingLine() { var map = new SourceMap(new StringReader(_sample)); var testCases = new[] { new { Line = 0, Name = "Greeter", Filename = "test.ts" }, new { Line = 1, Name = "Greeter", Filename = "test.ts" }, new { Line = 1, Name = "Greeter.constructor", Filename = "test.ts" }, new { Line = 1, Name = "Greeter.constructor", Filename = "test.ts" }, new { Line = 2, Name = "Greeter", Filename = "test.ts" }, new { Line = 3, Name = "Greeter.greet", Filename = "test.ts" }, new { Line = 4, Name = "Greeter.greet", Filename = "test.ts" }, new { Line = 5, Name = "Greeter", Filename = "test.ts" }, new { Line = 5, Name = "Greeter", Filename = "test.ts" }, new { Line = 5, Name = "Greeter", Filename = "test.ts" }, new { Line = -1, Name = "", Filename = "" }, }; for (int i = 0; i < testCases.Length; i++) { SourceMapInfo mapping; if (map.TryMapLine(i, out mapping)) { Assert.AreEqual(testCases[i].Filename, mapping.FileName); Assert.AreEqual(testCases[i].Name, mapping.Name); Assert.AreEqual(testCases[i].Line, mapping.Line); } else { Assert.AreEqual(-1, testCases[i].Line); } } }
public void MappingLine() { var map = new SourceMap(new StringReader(_sample)); var testCases = new[] { new { Line = 0, Name = "Greeter", Filename = "test.ts" }, new { Line = 1, Name = "Greeter", Filename = "test.ts" }, new { Line = 1, Name = "Greeter.constructor", Filename = "test.ts" }, new { Line = 1, Name = "Greeter.constructor", Filename = "test.ts" }, new { Line = 2, Name = "Greeter", Filename = "test.ts" }, new { Line = 3, Name = "Greeter.greet", Filename = "test.ts" }, new { Line = 4, Name = "Greeter.greet", Filename = "test.ts" }, new { Line = 5, Name = "Greeter", Filename = "test.ts" }, new { Line = 5, Name = "Greeter", Filename = "test.ts" }, new { Line = 5, Name = "Greeter", Filename = "test.ts" }, new { Line = -1, Name = "", Filename = "" }, }; for (int i = 0; i < testCases.Length; i++) { SourceMapInfo mapping; if (map.TryMapLine(i, out mapping)) { Assert.AreEqual(testCases[i].Filename, mapping.FileName); Assert.AreEqual(testCases[i].Name, mapping.Name); Assert.AreEqual(testCases[i].Line, mapping.Line); } else { Assert.AreEqual(-1, testCases[i].Line); } } }