Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tla2bAST
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
tla2bAST
Commits
23990b6b
Commit
23990b6b
authored
Oct 18, 2017
by
dohan
Browse files
Options
Downloads
Patches
Plain Diff
add test to ensure that the GOAL definition is translated
parent
a8b04ad0
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/tla2b/translation/BDefinitionsFinder.java
+14
-8
14 additions, 8 deletions
src/main/java/de/tla2b/translation/BDefinitionsFinder.java
src/test/java/de/tla2b/prettyprintb/DefinitionsTest.java
+18
-0
18 additions, 0 deletions
src/test/java/de/tla2b/prettyprintb/DefinitionsTest.java
with
32 additions
and
8 deletions
src/main/java/de/tla2b/translation/BDefinitionsFinder.java
+
14
−
8
View file @
23990b6b
...
...
@@ -15,16 +15,13 @@ import de.tla2b.analysis.BOperation;
import
de.tla2b.analysis.SpecAnalyser
;
import
de.tla2b.global.TranslationGlobals
;
public
class
BDefinitionsFinder
extends
AbstractASTVisitor
implements
ASTConstants
,
ToolGlobals
,
TranslationGlobals
{
private
final
HashSet
<
OpDefNode
>
bDefinitionsSet
=
new
HashSet
<
OpDefNode
>();
public
class
BDefinitionsFinder
extends
AbstractASTVisitor
implements
ASTConstants
,
ToolGlobals
,
TranslationGlobals
{
private
final
HashSet
<
OpDefNode
>
bDefinitionsSet
=
new
HashSet
<>();
public
BDefinitionsFinder
(
SpecAnalyser
specAnalyser
)
{
if
(
specAnalyser
.
getConfigFileEvaluator
()
!=
null
)
{
bDefinitionsSet
.
addAll
(
specAnalyser
.
getConfigFileEvaluator
()
.
getConstantOverrideTable
().
values
());
bDefinitionsSet
.
addAll
(
specAnalyser
.
getConfigFileEvaluator
()
.
getOperatorOverrideTable
().
values
());
bDefinitionsSet
.
addAll
(
specAnalyser
.
getConfigFileEvaluator
().
getConstantOverrideTable
().
values
());
bDefinitionsSet
.
addAll
(
specAnalyser
.
getConfigFileEvaluator
().
getOperatorOverrideTable
().
values
());
}
for
(
BOperation
op
:
specAnalyser
.
getBOperations
())
{
...
...
@@ -52,10 +49,19 @@ public class BDefinitionsFinder extends AbstractASTVisitor implements
bDefinitionsSet
.
add
(
def
);
}
HashSet
<
OpDefNode
>
temp
=
new
HashSet
<
OpDefNode
>(
bDefinitionsSet
);
HashSet
<
OpDefNode
>
temp
=
new
HashSet
<>(
bDefinitionsSet
);
for
(
OpDefNode
opDefNode
:
temp
)
{
visitExprNode
(
opDefNode
.
getBody
());
}
for
(
OpDefNode
opDef
:
specAnalyser
.
getModuleNode
().
getOpDefs
())
{
String
defName
=
opDef
.
getName
().
toString
();
// GOAL, ANIMATION_FUNCTION, ANIMATION_IMGxx, SET_PREF_xxx,
if
(
defName
.
equals
(
"GOAL"
)
||
defName
.
startsWith
(
"ANIMATION_FUNCTION"
)
||
defName
.
startsWith
(
"ANIMATION_IMG"
)
||
defName
.
startsWith
(
"SET_PREF_"
))
{
bDefinitionsSet
.
add
(
opDef
);
}
}
}
public
void
visitUserDefinedNode
(
OpApplNode
n
)
{
...
...
This diff is collapsed.
Click to expand it.
src/test/java/de/tla2b/prettyprintb/DefinitionsTest.java
+
18
−
0
View file @
23990b6b
...
...
@@ -33,4 +33,22 @@ public class DefinitionsTest {
+
"END"
;
compare
(
expected
,
module
);
}
@Test
public
void
testGoalDefinition
()
throws
Exception
{
final
String
module
=
"-------------- MODULE Testing ----------------\n"
+
"EXTENDS Naturals \n"
+
"VARIABLES x, y \n"
+
"Init == x = 1 /\\ y = 1 \n"
+
"GOAL == 1=1 \n"
+
"================================="
;
final
String
expected
=
"MACHINE Testing\n"
+
"DEFINITIONS GOAL == 1 = 1;"
+
"VARIABLES x, y\n"
+
"INVARIANT x : INTEGER & y : INTEGER \n"
+
"INITIALISATION x, y:(x = 1 & y = 1) \n"
+
"END"
;
compare
(
expected
,
module
);
}
}
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