Adding tests of _ as a numeric component
This commit is contained in:
parent
d7f175a987
commit
8cd91ecb8c
1 changed files with 19 additions and 6 deletions
|
@ -15,13 +15,20 @@ def test_parse_list():
|
||||||
assert p.parses("()").paren == p.ListType.ROUND
|
assert p.parses("()").paren == p.ListType.ROUND
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('num,', [
|
@pytest.mark.parametrize('txt, val', [
|
||||||
1, 2, 103, 504,
|
('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."""
|
"""Some trivial cases of parsing numbers."""
|
||||||
assert isinstance(p.parses(str(num)), p.IntegerToken)
|
assert isinstance(p.parses(txt), p.IntegerToken)
|
||||||
assert p.parses(str(num)).data == num
|
assert p.parses(txt).data == val
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('frac', [
|
@pytest.mark.parametrize('frac', [
|
||||||
|
@ -33,8 +40,13 @@ def test_parse_ratio(frac):
|
||||||
assert p.parses(frac).data == p.Fraction(frac)
|
assert p.parses(frac).data == p.Fraction(frac)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('sym,', [
|
@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):
|
def test_parse_sym(sym):
|
||||||
"""Some trivial cases of parsing symbols."""
|
"""Some trivial cases of parsing symbols."""
|
||||||
|
@ -76,6 +88,7 @@ def test_list_contents(txt, tokenization):
|
||||||
('1e3', 1e3),
|
('1e3', 1e3),
|
||||||
('1e-3', 1e-3),
|
('1e-3', 1e-3),
|
||||||
('1.01e3', 1.01e3),
|
('1.01e3', 1.01e3),
|
||||||
|
('1_000e0', 1e3),
|
||||||
])
|
])
|
||||||
def test_float_values(txt, value):
|
def test_float_values(txt, value):
|
||||||
"""Some examples of floats."""
|
"""Some examples of floats."""
|
||||||
|
|
Loading…
Reference in a new issue