Source

jitviewer / _jitviewer / test / test_parser.py

from _jitviewer.parser import ParserWithHtmlRepr, cssclass
import py

def parse(input):
    return ParserWithHtmlRepr.parse_from_input(input)

def test_html_repr():
    ops = parse('''
    [i7]
    i9 = int_lt(i7, 1003)
    guard_true(i9, descr=<Guard2>) []
    i13 = getfield_raw(151937600, descr=<SignedFieldDescr pypysig_long_struct.c_value 0>)
    ''').operations
    assert '<' in ops[0].html_repr()
    assert 'pypysig_long_struct' in ops[2].html_repr()

def test_highlight_var():
    ops = parse('''
    [p0]
    guard_class(p0, 144264192, descr=<Guard0>)
    ''').operations
    assert len(ops) == 1
    op = ops[0]
    assert op.name == 'guard_class'
    html = op.html_repr()
    p0 = cssclass('p0', 'p0', onmouseover="highlight_var(this)", onmouseout="disable_var(this)")
    assert p0 in html

def test_cssclass():
    s = cssclass('asd$%', 'v')
    print s.__class__, s
    assert '$' not in s
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.