Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
arpeggio-gm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
backend
arpeggio-gm
Commits
378fbe44
Commit
378fbe44
authored
Aug 04, 2014
by
Igor Dejanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrated one regression test to pytest
parent
71673a7e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
31 deletions
+21
-31
direct_rule_call.py
tests/unit/regressions/direct_rule_call.py
+21
-31
No files found.
tests/unit/regressions/direct_rule_call.py
View file @
378fbe44
'''
Created on Jul 6, 2014
@author: igor
'''
import
unittest
from
arpeggio
import
SemanticAction
,
ParserPython
def
test_direct_rule_call
():
'''
Test regression where in direct rule call semantic action is
erroneously attached to both caller and callee.
'''
class
Test
(
unittest
.
TestCase
):
def
test_direct_rule_call
(
self
):
'''
Test regression where in direct rule call semantic action is
erroneously attached to both caller and callee.
'''
def
grammar
():
return
rule1
,
rule2
def
rule1
():
return
"a"
def
rule2
():
return
rule1
def
grammar
():
return
rule1
,
rule2
def
rule1
():
return
"a"
def
rule2
():
return
rule1
call_count
=
[
0
]
call_count
=
[
0
]
class
DummySemAction
(
SemanticAction
):
def
first_pass
(
self
,
parser
,
node
,
nodes
):
call_count
[
0
]
+=
1
return
SemanticAction
.
first_pass
(
self
,
parser
,
node
,
nodes
)
class
DummySemAction
(
SemanticAction
):
def
first_pass
(
self
,
parser
,
node
,
nodes
):
call_count
[
0
]
+=
1
return
SemanticAction
.
first_pass
(
self
,
parser
,
node
,
nodes
)
# Sem action is attached to rule2 only but
# this bug will attach it to rule1 also resulting in
# wrong call count.
rule2
.
sem
=
DummySemAction
()
# Sem action is attached to rule2 only but
# this bug will attach it to rule1 also resulting in
# wrong call count.
rule2
.
sem
=
DummySemAction
()
parser
=
ParserPython
(
grammar
)
parse_tree
=
parser
.
parse
(
"aa"
)
parser
.
getASG
()
parser
=
ParserPython
(
grammar
)
parse_tree
=
parser
.
parse
(
"aa"
)
parser
.
getASG
()
self
.
assertEqual
(
call_count
[
0
],
1
,
"Semantic action should be called once!"
)
assert
call_count
[
0
]
==
1
,
"Semantic action should be called once!"
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