Skip to content

Commit

Permalink
+ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kniazkov committed Nov 15, 2024
1 parent 5e37912 commit b76651a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ public void setBody(final String text) {

@Override
public void build(final int indent, final SourceCodeBuilder code) throws BaseException {
if (this.doc.hasNonEmptyBrief()) {
this.doc.build(indent, code);
}
this.doc.build(indent, code);
code.add(indent, this.composeHeader());
this.buildBody(indent + 1, code);
code.add(indent, "}");
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/cqfn/astranaut/codegen/java/MethodTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,16 @@ void methodWithSyntaxError() {
Assertions.assertTrue(oops);
}

@Test
void methodWithLineThatIsTooLong() {
final Method method = new Method("void", "doSomething");
method.setBody(
"System.out.println(\"The infantile goat accompanies this delightful sunset with an indifferent stare.\")"
);
final SourceCodeBuilder builder = new SourceCodeBuilder();
Assertions.assertThrows(BaseException.class, ()->{method.build(0, builder);});
}

/**
* Tests the source code generation from an object describing a method.
* @param method Object describing a method
Expand Down

0 comments on commit b76651a

Please sign in to comment.