示例#1
0
    def test_indexed_inline(self):
        indexed_sourcemap = sourcemap_to_index(indexed_sourcemap_example)

        sources = get_inline_content_sources(indexed_sourcemap, 'https://example.com/static/')
        assert sources == [
            ('https://example.com/the/root/one.js', [' ONE.foo = function (bar) {', '   return baz(bar);', ' };']),
            ('https://example.com/the/root/two.js', [' TWO.inc = function (n) {', '   return n + 1;', ' };'])
        ]
示例#2
0
    def test_indexed_inline(self):
        indexed_sourcemap = sourcemap_to_index(indexed_sourcemap_example)

        sources = get_inline_content_sources(indexed_sourcemap, "https://example.com/static/")
        assert sources == [
            ("https://example.com/the/root/one.js", [" ONE.foo = function (bar) {", "   return baz(bar);", " };"]),
            ("https://example.com/the/root/two.js", [" TWO.inc = function (n) {", "   return n + 1;", " };"]),
        ]
示例#3
0
    def test_fuzzy_mapping(self):
        indexed_sourcemap = sourcemap_to_index(indexed_sourcemap_example)

        # one.js
        assert find_source(indexed_sourcemap, 1, 20) == \
            SourceMap(dst_line=0, dst_col=18, src='/the/root/one.js', src_line=0, src_col=21, name='bar')
        assert find_source(indexed_sourcemap, 1, 30) == \
            SourceMap(dst_line=0, dst_col=28, src='/the/root/one.js', src_line=1, src_col=10, name='baz')
        assert find_source(indexed_sourcemap, 2, 12) == \
            SourceMap(dst_line=1, dst_col=9, src='/the/root/two.js', src_line=0, src_col=11, name=None)
示例#4
0
    def test_simple(self):
        indexed_sourcemap = sourcemap_to_index(sourcemap)

        result = find_source(indexed_sourcemap, 1, 56)

        assert result == SourceMap(dst_line=0,
                                   dst_col=50,
                                   src='file2.js',
                                   src_line=0,
                                   src_col=9,
                                   name='multiply')
示例#5
0
    def test_fuzzy_mapping(self):
        indexed_sourcemap = sourcemap_to_index(indexed_sourcemap_example)

        # one.js
        assert find_source(indexed_sourcemap, 1, 20) == SourceMap(
            dst_line=0, dst_col=18, src="/the/root/one.js", src_line=0, src_col=21, name="bar"
        )
        assert find_source(indexed_sourcemap, 1, 30) == SourceMap(
            dst_line=0, dst_col=28, src="/the/root/one.js", src_line=1, src_col=10, name="baz"
        )
        assert find_source(indexed_sourcemap, 2, 12) == SourceMap(
            dst_line=1, dst_col=9, src="/the/root/two.js", src_line=0, src_col=11, name=None
        )
示例#6
0
    def test_exact_mappings(self):
        indexed_sourcemap = sourcemap_to_index(indexed_sourcemap_example)

        # one.js
        assert find_source(indexed_sourcemap, 1, 1) == \
            SourceMap(dst_line=0, dst_col=1, src='/the/root/one.js', src_line=0, src_col=1, name=None)
        assert find_source(indexed_sourcemap, 1, 18) == \
            SourceMap(dst_line=0, dst_col=18, src='/the/root/one.js', src_line=0, src_col=21, name='bar')
        assert find_source(indexed_sourcemap, 1, 28) == \
            SourceMap(dst_line=0, dst_col=28, src='/the/root/one.js', src_line=1, src_col=10, name='baz')

        # two.js
        assert find_source(indexed_sourcemap, 2, 18) == \
            SourceMap(dst_line=1, dst_col=18, src='/the/root/two.js', src_line=0, src_col=21, name='n')
        assert find_source(indexed_sourcemap, 2, 21) == \
            SourceMap(dst_line=1, dst_col=21, src='/the/root/two.js', src_line=1, src_col=3, name=None)
        assert find_source(indexed_sourcemap, 2, 21) == \
            SourceMap(dst_line=1, dst_col=21, src='/the/root/two.js', src_line=1, src_col=3, name=None)
示例#7
0
    def test_simple(self):
        indexed_sourcemap = sourcemap_to_index(sourcemap)

        result = find_source(indexed_sourcemap, 1, 56)
        assert result == SourceMap(dst_line=0, dst_col=50, src="foo/file2.js", src_line=0, src_col=9, name="multiply")

        # Start of minified file (exact match first line/col tuple)
        result = find_source(indexed_sourcemap, 1, 0)
        assert result == SourceMap(dst_line=0, dst_col=0, src="foo/file1.js", src_line=0, src_col=0, name=None)

        # Last character in mapping
        result = find_source(indexed_sourcemap, 1, 36)
        assert result == SourceMap(dst_line=0, dst_col=30, src="foo/file1.js", src_line=2, src_col=1, name=None)

        # First character in mapping (exact match line/col tuple)
        result = find_source(indexed_sourcemap, 1, 37)
        assert result == SourceMap(dst_line=0, dst_col=37, src="foo/file1.js", src_line=2, src_col=8, name="a")

        # End of minified file (character *beyond* last line/col tuple)
        result = find_source(indexed_sourcemap, 1, 192)
        assert result == SourceMap(dst_line=0, dst_col=191, src="foo/file2.js", src_line=9, src_col=25, name="e")
示例#8
0
    def test_simple(self):
        indexed_sourcemap = sourcemap_to_index(sourcemap)

        result = find_source(indexed_sourcemap, 1, 56)
        assert result == SourceMap(dst_line=0, dst_col=50, src='foo/file2.js', src_line=0, src_col=9, name='multiply')

        # Start of minified file (exact match first line/col tuple)
        result = find_source(indexed_sourcemap, 1, 0)
        assert result == SourceMap(dst_line=0, dst_col=0, src='foo/file1.js', src_line=0, src_col=0, name=None)

        # Last character in mapping
        result = find_source(indexed_sourcemap, 1, 36)
        assert result == SourceMap(dst_line=0, dst_col=30, src='foo/file1.js', src_line=2, src_col=1, name=None)

        # First character in mapping (exact match line/col tuple)
        result = find_source(indexed_sourcemap, 1, 37)
        assert result == SourceMap(dst_line=0, dst_col=37, src='foo/file1.js', src_line=2, src_col=8, name='a')

        # End of minified file (character *beyond* last line/col tuple)
        result = find_source(indexed_sourcemap, 1, 192)
        assert result == SourceMap(dst_line=0, dst_col=191, src='foo/file2.js', src_line=9, src_col=25, name='e')
示例#9
0
    def test_exact_mappings(self):
        indexed_sourcemap = sourcemap_to_index(indexed_sourcemap_example)

        # one.js
        assert find_source(indexed_sourcemap, 1, 1) == SourceMap(
            dst_line=0, dst_col=1, src="/the/root/one.js", src_line=0, src_col=1, name=None
        )
        assert find_source(indexed_sourcemap, 1, 18) == SourceMap(
            dst_line=0, dst_col=18, src="/the/root/one.js", src_line=0, src_col=21, name="bar"
        )
        assert find_source(indexed_sourcemap, 1, 28) == SourceMap(
            dst_line=0, dst_col=28, src="/the/root/one.js", src_line=1, src_col=10, name="baz"
        )

        # two.js
        assert find_source(indexed_sourcemap, 2, 18) == SourceMap(
            dst_line=1, dst_col=18, src="/the/root/two.js", src_line=0, src_col=21, name="n"
        )
        assert find_source(indexed_sourcemap, 2, 21) == SourceMap(
            dst_line=1, dst_col=21, src="/the/root/two.js", src_line=1, src_col=3, name=None
        )
        assert find_source(indexed_sourcemap, 2, 21) == SourceMap(
            dst_line=1, dst_col=21, src="/the/root/two.js", src_line=1, src_col=3, name=None
        )
示例#10
0
    def test_no_inline(self):
        # basic sourcemap fixture has no inlined sources, so expect an empty list
        indexed_sourcemap = sourcemap_to_index(sourcemap)

        sources = get_inline_content_sources(indexed_sourcemap, "https://example.com/static/")
        assert sources == []
示例#11
0
    def test_simple(self):
        indexed_sourcemap = sourcemap_to_index(sourcemap)

        result = find_source(indexed_sourcemap, 1, 56)

        assert result == SourceMap(dst_line=0, dst_col=50, src='foo/file2.js', src_line=0, src_col=9, name='multiply')
示例#12
0
    def test_no_inline(self):
        # basic sourcemap fixture has no inlined sources, so expect an empty list
        indexed_sourcemap = sourcemap_to_index(sourcemap)

        sources = get_inline_content_sources(indexed_sourcemap, 'https://example.com/static/')
        assert sources == []