Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
JastAdd
relational-rags
Commits
9b86ba17
Commit
9b86ba17
authored
Jan 09, 2020
by
René Schöne
Browse files
Add test case for generated constructors.
parent
1afaf270
Pipeline
#5074
passed with stage
in 2 minutes and 24 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
9b86ba17
...
...
@@ -153,6 +153,13 @@ test.dependsOn compileRelationTest
compileRelationTest
.
dependsOn
doublePreprocessRelationTest
doublePreprocessRelationTest
.
dependsOn
preprocessRelationTest
task
compileConstructorTest
(
type:
RelastTest
)
{
relastFiles
'src/test/jastadd/constructors/Constructors.relast'
grammarName
=
'src/test/jastadd/constructors/Constructors'
packageName
=
'constructors.ast'
moreInputFiles
'src/test/jastadd/constructors/Constructors.jrag'
}
task
compileDefaultNamesTest
(
type:
RelastTest
)
{
relastFiles
'src/test/jastadd/relations/Relations.relast'
grammarName
=
'src/test/jastadd/relations/Relations3'
...
...
src/test/jastadd/constructors/Constructors.jrag
0 → 100644
View file @
9b86ba17
aspect NTAs {
syn A S.getS4() = new A();
syn List<A> S.getS5List() = new List<>();
syn Opt<A> S.getS6Opt() = new Opt<>();
syn String S.getS7() = "";
syn long S.getS8() = 1L;
syn A B.getB4() = new A();
syn List<A> B.getB5List() = new List<>();
syn Opt<A> B.getB6Opt() = new Opt<>();
syn String B.getB7() = "";
syn long B.getB8() = 1L;
}
src/test/jastadd/constructors/Constructors.relast
0 → 100644
View file @
9b86ba17
A;
S ::= S1:A S2:A* [S3:A] /S4:A/ /S5:A*/ /[S6:A]/ /<S7>/ /<S8:long>/;
B : S ::= B1:A B2:A* [B3:A] /B4:A/ /B5:A*/ /[B6:A]/ /<B7>/ /<B8:long>/;
X;
Y;
rel A.r1 -> X;
rel S.r2* <-> Y.r2;
rel B.r3? -> X;
src/test/java/org/jastadd/relast/tests/ConstructorsTest.java
0 → 100644
View file @
9b86ba17
package
org.jastadd.relast.tests
;
import
constructors.ast.*
;
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.Test
;
import
java.util.ArrayList
;
/**
* Testing generated constructors.
*
* @author rschoene - Initial contribution
*/
@SuppressWarnings
(
"unused"
)
public
class
ConstructorsTest
{
@Test
public
void
testX
()
{
X
x
=
new
X
();
Assertions
.
assertEquals
(
1
,
numberOfConstructors
(
X
.
class
));
}
@Test
public
void
testY
()
{
Y
y0
=
new
Y
();
Y
y1
=
new
Y
(
new
S
());
Assertions
.
assertEquals
(
2
,
numberOfConstructors
(
Y
.
class
));
}
@Test
public
void
testA
()
{
A
a0
=
new
A
();
A
a1
=
new
A
(
new
X
());
Assertions
.
assertEquals
(
2
,
numberOfConstructors
(
A
.
class
));
}
@Test
public
void
testS
()
{
A
a
=
new
A
();
S
s0
=
new
S
();
S
s1
=
new
S
(
a
,
new
List
<>(),
new
Opt
<>());
S
s2
=
new
S
(
a
,
new
List
<>(),
new
Opt
<>(),
new
ArrayList
<>());
Assertions
.
assertEquals
(
3
,
numberOfConstructors
(
S
.
class
));
}
@Test
public
void
testB
()
{
A
a
=
new
A
();
B
b0
=
new
B
();
B
b1
=
new
B
(
a
,
new
List
<>(),
new
Opt
<>(),
a
,
new
List
<>(),
new
Opt
<>());
B
b2
=
new
B
(
a
,
new
List
<>(),
new
Opt
<>(),
new
ArrayList
<>(),
a
,
new
List
<>(),
new
Opt
<>(),
null
);
Assertions
.
assertEquals
(
3
,
numberOfConstructors
(
B
.
class
));
}
private
int
numberOfConstructors
(
Class
<?>
clazz
)
{
return
clazz
.
getConstructors
().
length
;
}
}
Johannes Mey
@johannes.mey
mentioned in issue
#18 (closed)
·
Jan 10, 2020
mentioned in issue
#18 (closed)
mentioned in issue #18
Toggle commit list
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