Beispiel #1
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)
Beispiel #2
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
        )
Beispiel #3
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')
Beispiel #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="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")
Beispiel #5
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')
Beispiel #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)
Beispiel #7
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
        )
Beispiel #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')