Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
DHParser
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
badw-it
DHParser
Commits
4ac99699
Commit
4ac99699
authored
Feb 13, 2019
by
eckhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- tests/ a bit of cleaning up
parent
7f0f2467
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
28 deletions
+0
-28
test/test_ebnf.py
test/test_ebnf.py
+0
-6
test/test_parse.py
test/test_parse.py
+0
-14
test/test_syntaxtree.py
test/test_syntaxtree.py
+0
-3
test/test_testing.py
test/test_testing.py
+0
-5
No files found.
test/test_ebnf.py
View file @
4ac99699
...
...
@@ -165,16 +165,12 @@ class TestParserNameOverwriteBug:
def
test_term_bug
(
self
):
grammar
=
get_ebnf_grammar
()
st
=
grammar
(
'impossible = [§"an optional requirement"]'
)
# print(st.as_sxpr())
get_ebnf_transformer
()(
st
)
# print(st.as_sxpr())
lang
=
"""series = "A" "B" §"C" "D"
"""
parser
=
get_ebnf_grammar
()
st
=
grammar
(
lang
)
# print(st.as_sxpr())
get_ebnf_transformer
()(
st
)
# print(st.as_sxpr())
result
=
get_ebnf_compiler
()(
st
)
messages
=
st
.
errors_sorted
assert
not
has_errors
(
messages
),
str
(
messages
)
...
...
@@ -182,7 +178,6 @@ class TestParserNameOverwriteBug:
def
test_single_mandatory_bug
(
self
):
lang
=
"""series = § /B/"""
result
,
messages
,
ast
=
compile_ebnf
(
lang
)
# print(result)
assert
result
.
find
(
'Required'
)
<
0
parser
=
grammar_provider
(
lang
)()
st
=
parser
(
'B'
)
...
...
@@ -477,7 +472,6 @@ class TestErrorCustomization:
st
=
parser
(
"ABCD"
);
assert
not
st
.
error_flag
st
=
parser
(
"A_CD"
);
assert
not
st
.
error_flag
st
=
parser
(
"AB_D"
);
assert
st
.
error_flag
print
(
st
.
errors_sorted
)
assert
st
.
errors_sorted
[
0
].
code
==
Error
.
MANDATORY_CONTINUATION
assert
st
.
errors_sorted
[
0
].
message
==
"a user defined error message"
# transitivity of mandatory-operator
...
...
test/test_parse.py
View file @
4ac99699
...
...
@@ -55,7 +55,6 @@ class TestParserClass:
l
=
[]
gr
.
root__
.
apply
(
visitor
)
s3
=
", "
.
join
(
l
)
# print(s1); print(s2); print(s3)
assert
s1
==
s2
==
s3
...
...
@@ -119,8 +118,6 @@ class TestInfiLoopsAndRecursion:
parser
=
grammar_provider
(
minilang
)()
syntax_tree
=
parser
(
snippet
)
assert
syntax_tree
.
error_flag
# print(syntax_tree.as_sxpr())
# print(syntax_tree.errors())
class
TestFlowControl
:
...
...
@@ -325,7 +322,6 @@ class TestSeries:
st
=
parser
(
"ABCD"
);
assert
not
st
.
error_flag
st
=
parser
(
"A_CD"
);
assert
not
st
.
error_flag
st
=
parser
(
"AB_D"
);
assert
st
.
error_flag
# print(st.errors())
assert
st
.
errors_sorted
[
0
].
code
==
Error
.
MANDATORY_CONTINUATION
# transitivity of mandatory-operator
st
=
parser
(
"ABC_"
);
assert
st
.
error_flag
...
...
@@ -646,7 +642,6 @@ class TestReentryAfterError:
gr
=
self
.
gr
;
gr
.
resume_rules
=
dict
()
content
=
'ALPHA acb BETA bac GAMMA cab .'
cst
=
gr
(
content
)
# print(cst.as_sxpr())
assert
cst
.
error_flag
assert
cst
.
content
==
content
assert
cst
.
pick
(
'alpha'
).
content
.
startswith
(
'ALPHA'
)
...
...
@@ -655,7 +650,6 @@ class TestReentryAfterError:
gr
=
self
.
gr
;
gr
.
resume_rules
=
dict
()
content
=
'ALPHA acb'
cst
=
gr
(
content
,
'alpha'
)
# print(cst.as_sxpr())
assert
cst
.
error_flag
assert
cst
.
content
==
content
assert
cst
.
pick
(
'alpha'
).
content
.
startswith
(
'ALPHA'
)
...
...
@@ -665,7 +659,6 @@ class TestReentryAfterError:
gr
.
resume_rules__
[
'alpha'
]
=
[
'BETA'
]
content
=
'ALPHA acb BETA bac GAMMA cab .'
cst
=
gr
(
content
)
# print(cst.as_sxpr())
assert
cst
.
error_flag
assert
cst
.
content
==
content
assert
cst
.
pick
(
'alpha'
).
content
.
startswith
(
'ALPHA'
)
...
...
@@ -677,7 +670,6 @@ class TestReentryAfterError:
gr
.
resume_rules__
[
'alpha'
]
=
[
'XXX'
]
content
=
'ALPHA acb BETA bac GAMMA cab .'
cst
=
gr
(
content
)
# print(cst.as_sxpr())
assert
cst
.
error_flag
assert
cst
.
content
==
content
# assert cst.pick('alpha').content.startswith('ALPHA')
...
...
@@ -688,7 +680,6 @@ class TestReentryAfterError:
gr
.
resume_rules__
[
'alpha'
]
=
[
'BETA'
,
'GAMMA'
]
content
=
'ALPHA acb BETA bac GAMMA cab .'
cst
=
gr
(
content
)
# print(cst.as_sxpr())
assert
cst
.
error_flag
assert
cst
.
content
==
content
assert
cst
.
pick
(
'alpha'
).
content
.
startswith
(
'ALPHA'
)
...
...
@@ -700,7 +691,6 @@ class TestReentryAfterError:
gr
.
resume_rules__
[
'alpha'
]
=
[
'BETA'
,
'GAMMA'
]
content
=
'ALPHA acb GAMMA cab .'
cst
=
gr
(
content
)
# print(cst.as_sxpr())
assert
cst
.
error_flag
assert
cst
.
content
==
content
assert
cst
.
pick
(
'alpha'
).
content
.
startswith
(
'ALPHA'
)
...
...
@@ -714,7 +704,6 @@ class TestReentryAfterError:
gr
.
resume_rules__
[
'bac'
]
=
[
'GAMMA'
]
content
=
'ALPHA abc BETA bad GAMMA cab .'
cst
=
gr
(
content
)
# print(cst.as_sxpr())
assert
cst
.
error_flag
assert
cst
.
content
==
content
assert
cst
.
pick
(
'alpha'
).
content
.
startswith
(
'ALPHA'
)
...
...
@@ -723,7 +712,6 @@ class TestReentryAfterError:
# multiple failures
content
=
'ALPHA acb BETA bad GAMMA cab .'
cst
=
gr
(
content
)
# print(cst.as_sxpr())
assert
cst
.
error_flag
assert
cst
.
content
==
content
assert
cst
.
pick
(
'alpha'
).
content
.
startswith
(
'ALPHA'
)
...
...
@@ -743,7 +731,6 @@ class TestConfiguredErrorMessages:
st
=
parser
(
"AB_D"
);
assert
st
.
error_flag
assert
st
.
errors_sorted
[
0
].
code
==
Error
.
MALFORMED_ERROR_STRING
assert
st
.
errors_sorted
[
1
].
code
==
Error
.
MANDATORY_CONTINUATION
# print(st.errors())
class
TestUnknownParserError
:
...
...
@@ -773,7 +760,6 @@ class TestEarlyTokenWhitespaceDrop:
def
test_drop
(
self
):
cst
=
self
.
gr
(
'4 + 3 * 5'
)
# print(cst.as_sxpr())
assert
not
cst
.
pick
(
':Token'
)
assert
not
cst
.
pick
(
':Whitespace'
)
cst
=
self
.
gr
(
'A + B'
)
...
...
test/test_syntaxtree.py
View file @
4ac99699
...
...
@@ -98,8 +98,6 @@ class TestNode:
tree
[
'd'
].
result
=
"x"
assert
not
tree
.
equals
(
tree_copy
)
assert
tree_copy
.
equals
(
parse_sxpr
(
'(a (b c) (d (e f) (h i)))'
))
# print(tree.as_sxpr())
# print(parse_sxpr('(a (b c) (d x))').as_sxpr())
assert
tree
.
equals
(
parse_sxpr
(
'(a (b c) (d x))'
))
# this also checks for errors equality...
...
...
@@ -301,7 +299,6 @@ class TestSerialization:
assert
tree
.
as_xml
()
==
"<A>
\n
<B>C</B>
\n
<D>E</D>
\n
</A>"
,
xml
tree
.
attr
[
'xml:space'
]
=
'preserve'
# print(tree.attr)
xml
=
tree
.
as_xml
()
assert
xml
==
'<A xml:space="preserve"><B>C</B><D>E</D></A>'
,
xml
...
...
test/test_testing.py
View file @
4ac99699
...
...
@@ -224,8 +224,6 @@ class TestGrammarTest:
report
=
get_report
(
self
.
cases
)
assert
report
.
find
(
'### CST'
)
>=
0
errata
=
grammar_unit
(
self
.
failure_cases
,
parser_fac
,
trans_fac
)
# for e in errata:
# print(e)
assert
len
(
errata
)
==
3
,
str
(
errata
)
# def test_get_report(self):
...
...
@@ -310,9 +308,6 @@ class TestLookahead:
grammar
=
self
.
grammar_fac
()
cst
=
grammar
(
doc
)
assert
not
cst
.
error_flag
# trans = self.trans_fac()
# trans(cst)
# print(cst.as_sxpr())
def
test_unit_lookahead
(
self
):
errata
=
grammar_unit
(
self
.
cases
,
self
.
grammar_fac
,
self
.
trans_fac
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment