Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/tools/lint/lib/checks/esid.py

raw
1 from ..check import Check
2 import re
3
4 class CheckEsid(Check):
5 '''Ensure tests specify only valid `es6id's'''
6 ID = 'ESID'
7
8 def __init__(self):
9 #self.es5idRegex = re.compile(r"^S?(B|\d+)(\.\d+)+(-(\d+|[a-z]|i+))*(_A\d(\.\d+)?(_T\d(\.\d+)?)?)?$")
10 self.es6idRegex = re.compile(r"^(S?(B|\d+)(\.\d+)+(((_A\d\.\d)?_T?\d)|[ _]S\d+(\.[a-z])*)?(, |$))+")
11 self.esidRegex = re.compile(r"^(pending|(prod|sec|sup)-[-_A-Za-z0-9.%@]+)$")
12
13 def run(self, name, meta, source):
14 if not meta:
15 return
16
17 if 'es6id' not in meta and 'esid' not in meta:
18 return
19
20 # es5ids are a mess
21 #if 'es5id' in meta:
22 # es5id = str(meta['es5id'])
23 # if self.es5idRegex.match(es5id) == None:
24 # return 'The `es5id` tag has the wrong format: %s' % es5id
25
26 if 'es6id' in meta:
27 es6id = str(meta['es6id'])
28 if self.es6idRegex.match(es6id) == None:
29 return 'The `es6id` tag has the wrong format: %s' % es6id
30
31 if 'esid' in meta:
32 esid = str(meta['esid'])
33 if self.esidRegex.match(esid) == None:
34 return 'The `esid` tag has the wrong format: %s' % esid
35
36