Update parseTestRecord and monkeyYaml to handle new tests

Changes:
- Allow zero indent for lists
- Handle list with zero elements
- Handle public domain license block
This commit is contained in:
André Bargull 2024-12-16 15:49:03 +01:00 committed by Ms2ger
parent 36687a502c
commit 9e915f9b3c
2 changed files with 23 additions and 7 deletions

View File

@ -71,9 +71,12 @@ def myMultilineList(lines, value):
leading = myLeadingSpaces(line)
if myIsAllSpaces(line):
pass
elif indent is not None and leading < indent:
elif indent is not None and (
leading < indent or
(leading == indent and line[leading] != "-")
):
lines.insert(0, line)
break;
break
else:
indent = indent or leading
value += [myReadOneLine(myRemoveListHeader(indent, line))]
@ -100,7 +103,10 @@ def myReadOneLine(value):
def myFlowList(value):
result = mYamlListPattern.match(value)
values = result.group(1).split(",")
values = result.group(1)
if values == "":
return []
values = values.split(",")
return [myReadOneLine(v.strip()) for v in values]
def myMultiline(lines, value):
@ -113,7 +119,7 @@ def myMultiline(lines, value):
value += ["\n"]
elif myLeadingSpaces(line) < indent:
lines.insert(0, line)
break;
break
else:
value += [line[(indent):]]
value = " ".join(value)

View File

@ -29,6 +29,12 @@ _LICENSE_PATTERN = re.compile(
r'// See LICENSE or https://github\.com/tc39/test262/blob/HEAD/LICENSE' +
r')[\r\n]{1,2}' + _BLANK_LINES, re.IGNORECASE)
_LICENSE_PATTERN_PUBLIC_DOMAIN = re.compile(
r'/\*[\r\n]{1,2}' +
r' \* Any copyright is dedicated to the Public Domain\.[\r\n]{1,2}' +
r' \* http://creativecommons\.org/licenses/publicdomain/[\r\n]{1,2}' +
r' \*/[\r\n]{1,2}' + _BLANK_LINES, re.IGNORECASE)
yamlLoad = None
def yamlAttrParser(testRecord, attrs, name, onerror):
@ -51,10 +57,14 @@ def yamlAttrParser(testRecord, attrs, name, onerror):
def findLicense(src):
match = _LICENSE_PATTERN.search(src)
if not match:
return None
if match:
return match.group(0)
return match.group(0)
match = _LICENSE_PATTERN_PUBLIC_DOMAIN.search(src)
if match:
return match.group(0)
return None
def findAttrs(src):
match = _YAML_PATTERN.search(src)