Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relational-rags
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
JastAdd
relational-rags
Commits
8cbcac32
Commit
8cbcac32
authored
6 years ago
by
Niklas Fors
Browse files
Options
Downloads
Patches
Plain Diff
Add test cases for directed relations
parent
2795cea7
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
spec/jastadd/Backend.jadd
+1
-1
1 addition, 1 deletion
spec/jastadd/Backend.jadd
test/.gitignore
+2
-2
2 additions, 2 deletions
test/.gitignore
test/All.relast
+4
-0
4 additions, 0 deletions
test/All.relast
test/Makefile
+2
-2
2 additions, 2 deletions
test/Makefile
test/Test.java
+91
-0
91 additions, 0 deletions
test/Test.java
with
100 additions
and
5 deletions
spec/jastadd/Backend.jadd
+
1
−
1
View file @
8cbcac32
...
...
@@ -165,7 +165,7 @@ aspect BackendDirectedAPI {
// Get
sb.append(ind(1) + "public java.util.List<" + ofTypeDecl() + "> " + toTypeDecl());
sb.append("." + name() + "() {\n");
sb.append(ind(2) + "ArrayList<
List
> l = get" + getImplAttributeName() + "();\n");
sb.append(ind(2) + "ArrayList<
" + ofTypeDecl() + "
> l = get" + getImplAttributeName() + "();\n");
sb.append(ind(2) + "return l != null ? l : Collections.emptyList();\n");
sb.append(ind(1) + "}\n");
...
...
This diff is collapsed.
Click to expand it.
test/.gitignore
+
2
−
2
View file @
8cbcac32
/AST/*
/All
Bi
Gen.ast
/All
Bi
Gen.jadd
/AllGen.ast
/AllGen.jadd
This diff is collapsed.
Click to expand it.
test/All
Bi
.relast
→
test/All.relast
+
4
−
0
View file @
8cbcac32
...
...
@@ -2,6 +2,10 @@ Root ::= A* B*;
A ::= <Name>;
B ::= <Name>;
rel A.di1 -> B;
rel A.di2? -> B;
rel A.di3* -> B;
rel A.bi1 <-> B.bi1;
rel A.bi2 <-> B.bi2?;
rel A.bi3 <-> B.bi3*;
...
...
This diff is collapsed.
Click to expand it.
test/Makefile
+
2
−
2
View file @
8cbcac32
all
:
compile run
compile
:
(
cd
..
&&
ant jar
)
java
-jar
../compiler.jar All
Bi
.relast
--file
java
-jar
../tools/jastadd2.jar
--package
=
AST All
Bi
Gen.ast All
Bi
Gen.jadd Utils.jadd
java
-jar
../compiler.jar All.relast
--file
java
-jar
../tools/jastadd2.jar
--package
=
AST AllGen.ast AllGen.jadd Utils.jadd
run
:
javac AST/
*
.java Test.java
java Test
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/Test.java
+
91
−
0
View file @
8cbcac32
...
...
@@ -15,6 +15,10 @@ public class Test {
}
public
void
test
()
{
testDi1
();
testDi2
();
testDi3
();
testBi1
();
testBi2
();
testBi3
();
...
...
@@ -26,6 +30,87 @@ public class Test {
testBi9
();
}
/**
* rel A.di1 -> B;
*/
private
void
testDi1
()
{
setup
();
a1
.
setDi1
(
b2
);
a2
.
setDi1
(
b1
);
assertSame
(
a1
.
di1
(),
b2
);
assertSame
(
a2
.
di1
(),
b1
);
a2
.
setDi1
(
b2
);
assertSame
(
a1
.
di1
(),
b2
);
assertSame
(
a2
.
di1
(),
b2
);
try
{
a3
.
setDi1
(
null
);
check
(
false
,
"should throw exception"
);
}
catch
(
Exception
e
)
{
// OK
}
}
/**
* rel A.di2? -> B;
*/
private
void
testDi2
()
{
setup
();
a1
.
setDi2
(
b2
);
a2
.
setDi2
(
b1
);
assertSame
(
a1
.
di2
(),
b2
);
assertSame
(
a2
.
di2
(),
b1
);
a2
.
setDi2
(
b2
);
assertSame
(
a1
.
di2
(),
b2
);
assertSame
(
a2
.
di2
(),
b2
);
a2
.
setDi2
(
null
);
assertSame
(
a1
.
di2
(),
b2
);
assertNull
(
a2
.
di2
());
assertTrue
(
a1
.
hasDi2
());
assertFalse
(
a2
.
hasDi2
());
assertFalse
(
a3
.
hasDi2
());
}
/**
* rel A.di3* -> B;
*/
private
void
testDi3
()
{
setup
();
a1
.
addToDi3
(
b1
);
a1
.
addToDi3
(
b2
);
a1
.
addToDi3
(
b3
);
a2
.
addToDi3
(
b2
);
assertEquals
(
a1
.
di3
(),
Arrays
.
asList
(
b1
,
b2
,
b3
));
assertEquals
(
a2
.
di3
(),
Arrays
.
asList
(
b2
));
assertEquals
(
a3
.
di3
(),
Arrays
.
asList
());
a1
.
addToDi3
(
b1
);
a2
.
addToDi3
(
b1
);
a2
.
addToDi3
(
b2
);
assertEquals
(
a1
.
di3
(),
Arrays
.
asList
(
b1
,
b2
,
b3
,
b1
));
assertEquals
(
a2
.
di3
(),
Arrays
.
asList
(
b2
,
b1
,
b2
));
assertEquals
(
a3
.
di3
(),
Arrays
.
asList
());
a1
.
removeFromDi3
(
b1
);
a2
.
removeFromDi3
(
b2
);
assertEquals
(
a1
.
di3
(),
Arrays
.
asList
(
b2
,
b3
,
b1
));
assertEquals
(
a2
.
di3
(),
Arrays
.
asList
(
b1
,
b2
));
assertEquals
(
a3
.
di3
(),
Arrays
.
asList
());
}
/**
...
...
@@ -263,6 +348,12 @@ public class Test {
r
.
addB
(
b3
);
}
private
void
assertTrue
(
boolean
b
)
{
check
(
b
,
"value should be true (is false)"
);
}
private
void
assertFalse
(
boolean
b
)
{
check
(!
b
,
"value should be flase (is true)"
);
}
private
void
assertNull
(
Object
obj
)
{
check
(
obj
==
null
,
"Object not null: "
+
obj
);
}
...
...
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