예제 #1
0
def test_check_all_functions():
  st = SymbolTable()

  foo = [1,2,3]
  bar = 'hi'

  st.add('a', foo)
  st.add('b', bar)
  eq_(st.find('a'), foo)
  eq_(st.find('b'), bar)

  st.remove('a')
  assert not st.find('a')
  assert not st.check_scope('a')
  eq_(st.check_scope('b'), bar)

  st.add('c', foo)

  with st.in_scope() as st:
    assert st.find('c') == foo
    assert st.find('b') == bar
    assert not st.check_scope('c')
    assert not st.check_scope('b')
    st.add('b', foo)
    assert st.find('b') == foo

  eq_(st.find('b'), bar)