Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
test262
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pmaksimo
test262
Commits
37b1d7a7
Commit
37b1d7a7
authored
9 years ago
by
Erik Arvidsson
Browse files
Options
Downloads
Patches
Plain Diff
monkeyYaml: Add support for line folding
Fixes #345
parent
1e80bf22
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/packaging/monkeyYaml.py
+10
-1
10 additions, 1 deletion
tools/packaging/monkeyYaml.py
tools/packaging/test/test_monkeyYaml.py
+53
-8
53 additions, 8 deletions
tools/packaging/test/test_monkeyYaml.py
with
63 additions
and
9 deletions
tools/packaging/monkeyYaml.py
+
10
−
1
View file @
37b1d7a7
...
...
@@ -15,13 +15,17 @@ mYamlMultilineList = re.compile(r"^ *- (.*)$")
def
load
(
str
):
dict
=
None
key
=
None
emptyLines
=
0
lines
=
str
.
splitlines
()
while
lines
:
line
=
lines
.
pop
(
0
)
if
myIsAllSpaces
(
line
):
emptyLines
+=
1
continue
result
=
mYamlKV
.
match
(
line
)
if
result
:
if
not
dict
:
dict
=
{}
...
...
@@ -30,7 +34,12 @@ def load(str):
(
lines
,
value
)
=
myReadValue
(
lines
,
value
)
dict
[
key
]
=
value
else
:
raise
Exception
(
"
monkeyYaml is confused at
"
+
line
)
if
dict
and
key
and
key
in
dict
:
c
=
"
"
if
emptyLines
==
0
else
"
\n
"
*
emptyLines
dict
[
key
]
+=
c
+
line
.
strip
()
else
:
raise
Exception
(
"
monkeyYaml is confused at
"
+
line
)
emptyLines
=
0
return
dict
def
myReadValue
(
lines
,
value
):
...
...
This diff is collapsed.
Click to expand it.
tools/packaging/test/test_monkeyYaml.py
+
53
−
8
View file @
37b1d7a7
...
...
@@ -111,30 +111,75 @@ class TestMonkeyYAMLParsing(unittest.TestCase):
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
def
test_oneline_indented
(
self
):
y
=
"
foo: bar
\n
baz: baf
\n
"
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
y
=
"
foo: bar
\n
baz: baf
\n
"
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
def
test_indentation_215
(
self
):
self
.
maxDiff
=
None
y
=
"""
self
.
maxDiff
=
None
y
=
"""
description: >
The method should exist on the Array prototype, and it should be writable
and configurable, but not enumerable.
includes: [propertyHelper.js]
es6id: 22.1.3.13
"""
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
def
test_indentation_215_2
(
self
):
self
.
maxDiff
=
None
y
=
"""
self
.
maxDiff
=
None
y
=
"""
description: >
The method should exist
includes: [propertyHelper.js]
es6id: 22.1.3.13
"""
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
def
test_line_folding
(
self
):
self
.
maxDiff
=
None
y
=
"""
description: aaa
bbb
es6id: 19.1.2.1
"""
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
def
test_line_folding_2
(
self
):
self
.
maxDiff
=
None
y
=
"""
description: ccc
ddd
es6id: 19.1.2.1
"""
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
def
test_line_folding_3
(
self
):
self
.
maxDiff
=
None
y
=
"""
description: eee
fff
es6id: 19.1.2.1
"""
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
def
test_line_folding_4
(
self
):
self
.
maxDiff
=
None
y
=
"""
description: ggg
hhh
iii
jjj
es6id: 19.1.2.1
"""
self
.
assertEqual
(
monkeyYaml
.
load
(
y
),
yaml
.
load
(
y
))
if
__name__
==
'
__main__
'
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment