Skip to content

Commit

Permalink
Merge d5fe336 into e8391de
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienverge committed Oct 2, 2022
2 parents e8391de + d5fe336 commit dfb9780
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
20 changes: 14 additions & 6 deletions tests/rules/test_float_values.py
Expand Up @@ -40,14 +40,16 @@ def test_numeral_before_decimal(self):
'- 0.0\n'
'- .1\n'
'- \'.1\'\n'
'- string.1\n'
'- .1string\n'
'- !custom_tag .2\n'
'- &angle1 0.0\n'
'- *angle1\n'
'- &angle2 .3\n'
'- *angle2\n',
conf,
problem1=(3, 3),
problem2=(8, 11))
problem2=(10, 11))

def test_scientific_notation(self):
conf = (
Expand All @@ -61,6 +63,8 @@ def test_scientific_notation(self):
'- 10e-6\n'
'- 0.00001\n'
'- \'10e-6\'\n'
'- string10e-6\n'
'- 10e-6string\n'
'- !custom_tag 10e-6\n'
'- &angle1 0.000001\n'
'- *angle1\n'
Expand All @@ -71,8 +75,8 @@ def test_scientific_notation(self):
conf,
problem1=(2, 3),
problem2=(3, 3),
problem3=(9, 11),
problem4=(11, 11))
problem3=(11, 11),
problem4=(13, 11))

def test_nan(self):
conf = (
Expand All @@ -85,13 +89,15 @@ def test_nan(self):
'- .NaN\n'
'- .NAN\n'
'- \'.NaN\'\n'
'- a.NaN\n'
'- .NaNa\n'
'- !custom_tag .NaN\n'
'- &angle .nan\n'
'- *angle\n',
conf,
problem1=(2, 3),
problem2=(3, 3),
problem3=(6, 10))
problem3=(8, 10))

def test_inf(self):
conf = (
Expand All @@ -106,6 +112,8 @@ def test_inf(self):
'- -.inf\n'
'- -.INF\n'
'- \'.inf\'\n'
'- ∞.infinity\n'
'- .infinity∞\n'
'- !custom_tag .inf\n'
'- &angle .inf\n'
'- *angle\n'
Expand All @@ -116,5 +124,5 @@ def test_inf(self):
problem2=(3, 3),
problem3=(4, 3),
problem4=(5, 3),
problem5=(8, 10),
problem6=(10, 10))
problem5=(10, 10),
problem6=(12, 10))
8 changes: 4 additions & 4 deletions yamllint/rules/float_values.py
Expand Up @@ -107,13 +107,13 @@
}

IS_NUMERAL_BEFORE_DECIMAL_PATTERN = (
re.compile('[-+]?(\\.[0-9]+)([eE][-+]?[0-9]+)?')
re.compile('[-+]?(\\.[0-9]+)([eE][-+]?[0-9]+)?$')
)
IS_SCIENTIFIC_NOTATION_PATTERN = re.compile(
'[-+]?(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)([eE][-+]?[0-9]+)'
'[-+]?(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)([eE][-+]?[0-9]+)$'
)
IS_INF_PATTERN = re.compile('[-+]?(\\.inf|\\.Inf|\\.INF)')
IS_NAN_PATTERN = re.compile('\\.nan|\\.NaN|\\.NAN')
IS_INF_PATTERN = re.compile('[-+]?(\\.inf|\\.Inf|\\.INF)$')
IS_NAN_PATTERN = re.compile('(\\.nan|\\.NaN|\\.NAN)$')


def check(conf, token, prev, next, nextnext, context):
Expand Down

0 comments on commit dfb9780

Please sign in to comment.