svoid test_tok_recordDecls() {
LS tok = jtok("record $HappensBefore$(A event1, B event2) extends Fact {}");
tok_recordDecls(tok);
print(join(tok));
assertTrueVerbose(jMatchStart([[
class $HappensBefore$ extends Fact implements IFieldsToList {
A event1;
B event2;
]], tok));
test_tok_recordDecls_2();
}
// we can omit the field types if the type is Object
svoid test_tok_recordDecls_2() {
LS tok = jtok("record Blubb(a, b) {}");
tok_recordDecls(tok);
print(join(tok));
assertTrueVerbose(jMatchStart([[
class Blubb implements IFieldsToList {
Object a;
Object b;
]], tok));
test_tok_recordDecls_3();
}
// handle existing "implements"
svoid test_tok_recordDecls_3() {
LS tok = jtok("record Blubb implements Bla {}");
tok_recordDecls(tok);
print(join(tok));
assertTrueVerbose(jMatchStart([[
class Blubb implements Bla, IFieldsToList {
]], tok));
test_tok_recordDecls_4();
}
svoid test_tok_recordDecls_4() {
LS tok = jtok("record Blubb extends Bla {}");
tok_recordDecls(tok);
print(join(tok));
assertTrueVerbose(join(tok), jMatchStart([[
class Blubb extends Bla implements IFieldsToList {
]], tok));
test_tok_recordDecls_5();
}
// existing constructor
svoid test_tok_recordDecls_5() {
// constructor in star syntax
LS tok = jtok("record Blubb(S a) { *(S *a) { otherStuff(); } }");
tok_recordDecls(tok);
print(join(tok));
assertEqualsVerbose(1, l(jfindAll(tok, "*(S *a)")));
// with ...
tok = jtok("record Blubb(S a) { *(S... *a) { otherStuff(); } }");
tok_recordDecls(tok);
print(join(tok));
assertEqualsVerbose(1, l(jfindAll(tok, "*(S... *a)")));
// !customConstructor
tok = jtok([[record Blubb(S a) {
// !customConstructor
Blubb(S a) { otherStuff(); }
}]]);
tok_recordDecls(tok);
print(join(tok));
assertEqualsVerbose(0, l(jfindAll(tok, "*(S *a)")));
// !customConstructor in some inner class
tok = jtok([[record Blubb(S a) {
class Bla {
// !customConstructor
}
}]]);
tok_recordDecls(tok);
print(join(tok));
assertEqualsVerbose(1, l(jfindAll(tok, "*(S *a)")));
}