예제 #1
0
 def test_foreground(self):
     lexer = Lexer(80, 1)
     lexer.lex('Lorem Ipsum')
     assert lexer.get_line(0) == ('<span foreground="white">Lorem </span>'
                                  '<span foreground="%s">Ipsum'
                                  '%s'
                                  '</span>') % (color[1], ' ' * 69)
예제 #2
0
def bench_simple_text_single_pass():
    for cols, rows in ((10, 10), (50, 25), (50, 100)):
        for size in (10, 100, 1000, 2000, 5000, 10000):
            random = os.urandom(size).decode('latin-1')
            lexer = Lexer(cols, rows)
            lex_timer = Timer()
            get_line_timer = Timer()
            with lex_timer:
                lexer.lex(random)
            with get_line_timer:
                for i in range(rows):
                    lexer.get_line(i)
            print("Term size: \x1b[31m%d, %d\t"
                  "\x1b[mText size: \x1b[32m%d\x1b[m \x1b[65`"
                  "[lex: \x1b[33m%dms\x1b[m\t get_line: \x1b[34m%dms\x1b[m]" %
                  (cols, rows, size, lex_timer.time, get_line_timer.time))
예제 #3
0
 def test_optimize(self):
     lexer = Lexer(80, 1)
     lexer.lex('ABC')
     assert lexer.get_line(0) == ('<span foreground="white">A</span>'
                                  '<span foreground="%s">BC'
                                  '%s'
                                  '</span>') % (color[1], ' ' * 77)
예제 #4
0
def bench_simple_text_single_pass():
    for cols, rows in ((10, 10), (50, 25), (50, 100)):
        for size in (10, 100, 1000, 2000, 5000, 10000):
            random = os.urandom(size).decode('latin-1')
            lexer = Lexer(cols, rows)
            lex_timer = Timer()
            get_line_timer = Timer()
            with lex_timer:
                lexer.lex(random)
            with get_line_timer:
                for i in range(rows):
                    lexer.get_line(i)
            print("Term size: \x1b[31m%d, %d\t"
                  "\x1b[mText size: \x1b[32m%d\x1b[m \x1b[65`"
                  "[lex: \x1b[33m%dms\x1b[m\t get_line: \x1b[34m%dms\x1b[m]" %
              (cols, rows, size, lex_timer.time, get_line_timer.time))
예제 #5
0
 def test_optimize(self):
     lexer = Lexer(80, 1)
     lexer.lex('ABC')
     assert lexer.get_line(0) == (
         '<span foreground="white">A</span>'
         '<span foreground="%s">BC'
         '%s'
         '</span>') % (color[1], ' ' * 77)
예제 #6
0
 def test_foreground(self):
     lexer = Lexer(80, 1)
     lexer.lex('Lorem Ipsum')
     assert lexer.get_line(0) == (
         '<span foreground="white">Lorem </span>'
         '<span foreground="%s">Ipsum'
         '%s'
         '</span>') % (color[1], ' ' * 69)
예제 #7
0
 def test_reverse(self):
     lexer = Lexer(80, 1)
     lexer.lex('ABCD')
     assert lexer.get_line(0) == (
         '<span foreground="white">A</span>'
         '<span foreground="%s" background="%s">B</span>'
         '<span foreground="%s" background="%s">CD</span>'
         '<span foreground="white">'
         '%s'
         '</span>') % (color[1], color[5], color[5], color[1], ' ' * 76)
예제 #8
0
 def test_background(self):
     lexer = Lexer(80, 1)
     lexer.lex('ABCD')
     assert lexer.get_line(0) == (
         '<span foreground="white">A</span>'
         '<span foreground="%s" background="%s">B</span>'
         '<span foreground="white">C</span>'
         '<span foreground="white" background="%s">D</span>'
         '<span foreground="white">'
         '%s'
         '</span>') % (color[1], color[5], color[2], ' ' * 76)
예제 #9
0
 def test_foreground_multi(self):
     lexer = Lexer(80, 1)
     lexer.lex('ABCD')
     assert lexer.get_line(0) == ('<span foreground="white">A</span>'
                                  '<span foreground="%s">B</span>'
                                  '<span foreground="white">C</span>'
                                  '<span foreground="%s">D</span>'
                                  '<span foreground="white">'
                                  '%s'
                                  '</span>') % (color[1], color[2],
                                                ' ' * 76)