コード例 #1
0
def test_clear():
    eo = em_list(ascii_lowercase)
    l = List(bind=eo)

    setq(_('test'), eo)
    l = List(bind=_('test'))
    l.clear()
    assert list(l) == []
コード例 #2
0
def test_empty():
    l = List()

    setq(_('test'), er.intern('nil'))
    l = List(bind='test')
    l.push(_('a'))
    l.push(_('b'))
    l.push(_('c'))
    assert list(l) == py_list('cba')
コード例 #3
0
def test_delete():
    eo = em_list(ascii_lowercase)

    l = List(bind=eo)

    setq(_('test'), eo)
    l = List(bind='test')
    l.delete([0, 4, 9, 10, 11, 25])
    assert list(l) == py_list('bcdfghimnopqrstuvwxy')
コード例 #4
0
def test_insert():
    l = List()

    setq(_('test'), er.intern('nil'))
    l = List(bind=_('test'))
    l.insert(0, _('a'))
    l.insert(0, _('b'))
    l.insert(1, _('c'))
    assert list(l) == py_list('bca')

    l.insert(3, _('d'))
    assert list(l) == py_list('bcad')
コード例 #5
0
def test_construct():
    eo = em_list('abc')

    l = List(bind=eo)
    assert list(l) == py_list('abc')

    setq(_('test'), eo)
    l = List(bind='test')
    assert list(l) == py_list('abc')

    import emacs
    l = List(bind=emacs.test)
    assert list(l) == py_list('abc')
コード例 #6
0
def test_initializer():
    l = List(ascii_lowercase)
    assert list(l) == list(ascii_lowercase)

    l = List(ascii_lowercase, prefer_symbol=True)
    assert list(l) == py_list(ascii_lowercase)

    l = List(ascii_lowercase, bind='test')
    assert er.eq(l.place, _('symbol-value')(_('test')))
    assert list(l) == list(ascii_lowercase)

    l = List((a for a in ascii_lowercase))
    assert list(l) == list(ascii_lowercase)
コード例 #7
0
def test_delitem():
    eo = em_list('abcde')

    l = List(bind=eo)
    del l[1]
    assert list(l) == py_list('acde')

    eo = em_list('abcde')
    setq(_('test'), eo)
    l = List(bind='test')
    del l[0]
    assert list(l) == py_list('bcde')

    with pytest.raises(IndexError):
        del l[10]
コード例 #8
0
def test_setitem():
    eo = em_list('abc')

    l = List(bind=eo)
    l[1] = _('y')
    assert list(l) == py_list('ayc')
    l[0] = _('q')
    assert list(l) == py_list('qyc')
コード例 #9
0
def test_getitem():
    eo = em_list('abcde')

    l = List(bind=eo)
    assert l[0] == _('a')
    assert l[1] == _('b')
    assert l[2] == _('c')
    assert l[3] == _('d')
    assert l[4] == _('e')

    with pytest.raises(IndexError):
        l[5]