38 lines
817 B
Python
38 lines
817 B
Python
|
|
import pytest
|
|
|
|
from xbc import loads_xbc, ParseError
|
|
|
|
def test_key():
|
|
assert loads_xbc('a') == {'a': True}
|
|
|
|
def test_keyvalue():
|
|
assert loads_xbc('a = 1') == {'a': '1'}
|
|
|
|
def test_keys():
|
|
assert loads_xbc('a;b') == {'a': True, 'b': True}
|
|
|
|
def test_string():
|
|
assert loads_xbc('a = "b"') == {'a': '"b"'}
|
|
|
|
def test_array():
|
|
assert loads_xbc('a = 1, 2') == {'a': ['1', '2']}
|
|
|
|
def test_block():
|
|
assert loads_xbc('a { a = 1 }') == {'a': False, 'a.a': '1'}
|
|
|
|
def test_block2():
|
|
assert loads_xbc('a = 1\na { a = 1 }') == {'a': '1', 'a.a': '1'}
|
|
|
|
def test_reassignment():
|
|
with pytest.raises(ParseError):
|
|
loads_xbc('a = 1\na = 2')
|
|
|
|
def test_ovewrite_nonexistent():
|
|
with pytest.raises(ParseError):
|
|
loads_xbc('a := 1')
|
|
|
|
def test_assign_after_block():
|
|
with pytest.raises(ParseError):
|
|
loads_xbc('a { a = 1 }\na = 1')
|