Adding tests of _ as a numeric component

This commit is contained in:
Reid 'arrdem' McKenzie 2020-07-18 14:02:09 -06:00
parent d7f175a987
commit 8cd91ecb8c

View file

@ -15,13 +15,20 @@ def test_parse_list():
assert p.parses("()").paren == p.ListType.ROUND
@pytest.mark.parametrize('num,', [
1, 2, 103, 504,
@pytest.mark.parametrize('txt, val', [
('1', 1),
('2', 2),
('103', 103),
('504', 504),
('-1', -1),
('+1', +1),
('+1_000', 1000),
('-1_000', -1000),
])
def test_parse_num(num):
def test_parse_num(txt, val):
"""Some trivial cases of parsing numbers."""
assert isinstance(p.parses(str(num)), p.IntegerToken)
assert p.parses(str(num)).data == num
assert isinstance(p.parses(txt), p.IntegerToken)
assert p.parses(txt).data == val
@pytest.mark.parametrize('frac', [
@ -33,8 +40,13 @@ def test_parse_ratio(frac):
assert p.parses(frac).data == p.Fraction(frac)
@pytest.mark.parametrize('sym,', [
'a', 'b', '*earmuff-style*', '+kebab-style+', 'JAVA_CONSTANT_STYLE'
'a',
'b',
'*earmuff-style*',
'+kebab-style+',
'JAVA_CONSTANT_STYLE',
])
def test_parse_sym(sym):
"""Some trivial cases of parsing symbols."""
@ -76,6 +88,7 @@ def test_list_contents(txt, tokenization):
('1e3', 1e3),
('1e-3', 1e-3),
('1.01e3', 1.01e3),
('1_000e0', 1e3),
])
def test_float_values(txt, value):
"""Some examples of floats."""