Beispiel #1
0
def test_current():
    stack = Stack()
    assert_true(stack.current is _undefined)
    stack.push('foo')
    assert_equal(stack.current, 'foo')
    stack.pop()
    assert_true(stack.current is _undefined)
    stack.push('foo, part 2')
    stack.flush()
    assert_true(stack.current is _undefined)
    stack = Stack(['foo', 'bar', 'baz'])
    assert_equal(stack.current, 'baz')
Beispiel #2
0
def test_current():
    stack = Stack()
    assert_true(stack.current is _undefined)
    stack.push('foo')
    assert_equal(stack.current, 'foo')
    stack.pop()
    assert_true(stack.current is _undefined)
    stack.push('foo, part 2')
    stack.flush()
    assert_true(stack.current is _undefined)
    stack = Stack(['foo', 'bar', 'baz'])
    assert_equal(stack.current, 'baz')
Beispiel #3
0
def test_complete_stack():
    l = list
    stack = Stack()
    assert_true(stack.current is _undefined)
    for i, token in enumerate(TEST_TOKENS):
        stack.push(token)
        assert_true(isinstance(token, str))
        assert_equal(stack.current, token)
    for expected, received in zip(TEST_TOKENS, stack.flush()):
        assert_equal(expected, received)
    assert_equal(l(stack._stack), [])
Beispiel #4
0
def test_complete_stack():
    l = list
    stack = Stack()
    assert_true(stack.current is _undefined)
    for i, token in enumerate(TEST_TOKENS):
        stack.push(token)
        assert_true(isinstance(token, str))
        assert_equal(stack.current, token)
    for expected, received in zip(TEST_TOKENS, stack.flush()):
        assert_equal(expected, received)
    assert_equal(l(stack._stack), [])
Beispiel #5
0
def test_flush():
    stack = Stack(['foo', 'bar'])
    flushed = stack.flush()
    assert_true(isinstance(flushed, Stack))
    assert_equal(list(flushed), ['foo', 'bar'])
Beispiel #6
0
def test_flush():
    stack = Stack(['foo', 'bar'])
    flushed = stack.flush()
    assert_true(isinstance(flushed, Stack))
    assert_equal(list(flushed), ['foo', 'bar'])