mirror of https://github.com/tc39/test262.git
Update test harness to support new negative format
This commit is contained in:
parent
7d4b1d28ae
commit
2915fe8527
|
@ -14,12 +14,16 @@ mYamlListPattern = re.compile(r"^\[(.*)\]$")
|
|||
mYamlMultilineList = re.compile(r"^ *- (.*)$")
|
||||
|
||||
def load(str):
|
||||
return myReadDict(str.splitlines())[1]
|
||||
|
||||
def myReadDict(lines, indent=""):
|
||||
dict = None
|
||||
key = None
|
||||
emptyLines = 0
|
||||
|
||||
lines = str.splitlines()
|
||||
while lines:
|
||||
if not lines[0].startswith(indent):
|
||||
break
|
||||
|
||||
line = lines.pop(0)
|
||||
if myIsAllSpaces(line):
|
||||
emptyLines += 1
|
||||
|
@ -31,7 +35,7 @@ def load(str):
|
|||
dict = {}
|
||||
key = result.group(1).strip()
|
||||
value = result.group(2).strip()
|
||||
(lines, value) = myReadValue(lines, value)
|
||||
(lines, value) = myReadValue(lines, value, indent)
|
||||
dict[key] = value
|
||||
else:
|
||||
if dict and key and key in dict:
|
||||
|
@ -40,17 +44,20 @@ def load(str):
|
|||
else:
|
||||
raise Exception("monkeyYaml is confused at " + line)
|
||||
emptyLines = 0
|
||||
return dict
|
||||
return lines, dict
|
||||
|
||||
def myReadValue(lines, value):
|
||||
def myReadValue(lines, value, indent):
|
||||
if value == ">" or value == "|":
|
||||
(lines, value) = myMultiline(lines, value)
|
||||
value = value + "\n"
|
||||
return (lines, value)
|
||||
if lines and not value and myMaybeList(lines[0]):
|
||||
return myMultilineList(lines, value)
|
||||
else:
|
||||
return lines, myReadOneLine(value)
|
||||
if lines and not value:
|
||||
if myMaybeList(lines[0]):
|
||||
return myMultilineList(lines, value)
|
||||
indentMatch = re.match("(" + indent + r"\s+)", lines[0])
|
||||
if indentMatch:
|
||||
return myReadDict(lines, indentMatch.group(1))
|
||||
return lines, myReadOneLine(value)
|
||||
|
||||
def myMaybeList(value):
|
||||
return mYamlMultilineList.match(value)
|
||||
|
|
|
@ -182,6 +182,27 @@ description: ggg
|
|||
|
||||
jjj
|
||||
es6id: 19.1.2.1
|
||||
"""
|
||||
self.assertEqual(monkeyYaml.load(y), yaml.load(y))
|
||||
|
||||
def test_nested_1(self):
|
||||
y = """
|
||||
es61d: 19.1.2.1
|
||||
negative:
|
||||
stage: early
|
||||
type: ReferenceError
|
||||
description: foo
|
||||
"""
|
||||
self.assertEqual(monkeyYaml.load(y), yaml.load(y))
|
||||
|
||||
def test_nested_2(self):
|
||||
y = """
|
||||
es61d: 19.1.2.1
|
||||
first:
|
||||
second_a:
|
||||
third: 1
|
||||
second_b: 3
|
||||
description: foo
|
||||
"""
|
||||
self.assertEqual(monkeyYaml.load(y), yaml.load(y))
|
||||
|
||||
|
|
Loading…
Reference in New Issue