Ejemplo n.º 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)
Ejemplo n.º 2
0
    def test_simple(self):
        index = fetch_sourcemap(base64_sourcemap)
        states = [SourceMap(1, 0, '/test.js', 0, 0, None)]
        sources = set(['/test.js'])
        keys = [(1, 0)]
        content = {'/test.js': ['console.log("hello, World!")']}

        assert index == SourceMapIndex(states, keys, sources, content)
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
    def test_basic(self):
        smap = json.loads(sourcemap)
        states = list(parse_sourcemap(smap))

        assert states == [
            SourceMap(dst_line=0,
                      dst_col=0,
                      src='file1.js',
                      src_line=0,
                      src_col=0,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=8,
                      src='file1.js',
                      src_line=0,
                      src_col=9,
                      name='add'),
            SourceMap(dst_line=0,
                      dst_col=13,
                      src='file1.js',
                      src_line=0,
                      src_col=13,
                      name='a'),
            SourceMap(dst_line=0,
                      dst_col=15,
                      src='file1.js',
                      src_line=0,
                      src_col=16,
                      name='b'),
            SourceMap(dst_line=0,
                      dst_col=18,
                      src='file1.js',
                      src_line=1,
                      src_col=1,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=30,
                      src='file1.js',
                      src_line=2,
                      src_col=1,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=37,
                      src='file1.js',
                      src_line=2,
                      src_col=8,
                      name='a'),
            SourceMap(dst_line=0,
                      dst_col=40,
                      src='file1.js',
                      src_line=2,
                      src_col=12,
                      name='b'),
            SourceMap(dst_line=0,
                      dst_col=42,
                      src='file2.js',
                      src_line=0,
                      src_col=0,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=50,
                      src='file2.js',
                      src_line=0,
                      src_col=9,
                      name='multiply'),
            SourceMap(dst_line=0,
                      dst_col=60,
                      src='file2.js',
                      src_line=0,
                      src_col=18,
                      name='a'),
            SourceMap(dst_line=0,
                      dst_col=62,
                      src='file2.js',
                      src_line=0,
                      src_col=21,
                      name='b'),
            SourceMap(dst_line=0,
                      dst_col=65,
                      src='file2.js',
                      src_line=1,
                      src_col=1,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=77,
                      src='file2.js',
                      src_line=2,
                      src_col=1,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=84,
                      src='file2.js',
                      src_line=2,
                      src_col=8,
                      name='a'),
            SourceMap(dst_line=0,
                      dst_col=87,
                      src='file2.js',
                      src_line=2,
                      src_col=12,
                      name='b'),
            SourceMap(dst_line=0,
                      dst_col=89,
                      src='file2.js',
                      src_line=4,
                      src_col=0,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=97,
                      src='file2.js',
                      src_line=4,
                      src_col=9,
                      name='divide'),
            SourceMap(dst_line=0,
                      dst_col=105,
                      src='file2.js',
                      src_line=4,
                      src_col=16,
                      name='a'),
            SourceMap(dst_line=0,
                      dst_col=107,
                      src='file2.js',
                      src_line=4,
                      src_col=19,
                      name='b'),
            SourceMap(dst_line=0,
                      dst_col=110,
                      src='file2.js',
                      src_line=5,
                      src_col=1,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=122,
                      src='file2.js',
                      src_line=6,
                      src_col=1,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=127,
                      src='file2.js',
                      src_line=7,
                      src_col=2,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=133,
                      src='file2.js',
                      src_line=7,
                      src_col=9,
                      name='multiply'),
            SourceMap(dst_line=0,
                      dst_col=143,
                      src='file2.js',
                      src_line=7,
                      src_col=18,
                      name='add'),
            SourceMap(dst_line=0,
                      dst_col=147,
                      src='file2.js',
                      src_line=7,
                      src_col=22,
                      name='a'),
            SourceMap(dst_line=0,
                      dst_col=149,
                      src='file2.js',
                      src_line=7,
                      src_col=25,
                      name='b'),
            SourceMap(dst_line=0,
                      dst_col=152,
                      src='file2.js',
                      src_line=7,
                      src_col=29,
                      name='a'),
            SourceMap(dst_line=0,
                      dst_col=154,
                      src='file2.js',
                      src_line=7,
                      src_col=32,
                      name='b'),
            SourceMap(dst_line=0,
                      dst_col=157,
                      src='file2.js',
                      src_line=7,
                      src_col=37,
                      name='c'),
            SourceMap(dst_line=0,
                      dst_col=159,
                      src='file2.js',
                      src_line=8,
                      src_col=3,
                      name=None),
            SourceMap(dst_line=0,
                      dst_col=165,
                      src='file2.js',
                      src_line=8,
                      src_col=10,
                      name='e'),
            SourceMap(dst_line=0,
                      dst_col=168,
                      src='file2.js',
                      src_line=9,
                      src_col=2,
                      name='Raven'),
            SourceMap(dst_line=0,
                      dst_col=174,
                      src='file2.js',
                      src_line=9,
                      src_col=8,
                      name='captureException'),
            SourceMap(dst_line=0,
                      dst_col=191,
                      src='file2.js',
                      src_line=9,
                      src_col=25,
                      name='e'),
        ]