Skip to content

Commit

Permalink
Release project version v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
matshou committed Dec 6, 2020
2 parents a5e5fc4 + e8fe257 commit 0a773d1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 43 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
apply from: "https://gist.githubusercontent.com/raw/$spotlessRulesGistId/spotless.gradle"

group 'io.yooksi'
version '1.0.1'
version '1.0.2'

idea {
project {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/yooksi/pz/zdoc/element/LuaMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
/**
* This class represents a parsed Lua method.
*/
@SuppressWarnings("unused")
public class LuaMethod extends Method {

private final String qualifier;
Expand Down Expand Up @@ -78,7 +79,7 @@ public String toString() {
sb.append("function ");

if (!qualifier.isEmpty()) {
sb.append(qualifier).append('.');
sb.append(qualifier).append(':');
}
sb.append(name).append('(');

Expand Down
55 changes: 27 additions & 28 deletions src/test/java/io/yooksi/pz/zdoc/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,33 @@ public class MainTest extends TestWorkspace {
super("sampleLua.lua");
}

private static Executable runMain(@Nullable Command command, String input, String output) {
return () -> Main.main(formatAppArgs(command != null ? command.getName() : "", input, output));
}

@TestOnly
public static String[] formatAppArgs(String command, String input, String output) {

List<String> args = new java.util.ArrayList<>();
args.add(command);
if (!input.isEmpty())
{
args.add("-i");
args.add(input);
}
if (!output.isEmpty())
{
args.add("-o");
args.add(output);
}
return args.toArray(new String[]{});
}

@TestOnly
public static String[] formatAppArgs(Command command, String input, String output) {
return formatAppArgs(command.getName(), input, output);
}

@Test
void shouldThrowExceptionWhenApplicationRunWithMissingCommand() {

Expand Down Expand Up @@ -155,32 +182,4 @@ void whenApplicationRunShouldConvertJavaToLuaDoc() throws Throwable {
Assertions.assertEquals(expected[i], actual.get(i));
}
}

private static Executable runMain(@Nullable Command command, String input, String output) {
return () -> Main.main(formatAppArgs(command != null ? command.getName() : "", input, output));
}

@TestOnly
public static String[] formatAppArgs(String command, String input, String output) {

List<String> args = new java.util.ArrayList<>();
args.add(command);
if (!input.isEmpty())
{
args.add("-i");
args.add(input);
}
if (!output.isEmpty())
{
args.add("-o");
args.add(output);
}
return args.toArray(new String[]{});
}


@TestOnly
public static String[] formatAppArgs(Command command, String input, String output) {
return formatAppArgs(command.getName(), input, output);
}
}
19 changes: 10 additions & 9 deletions src/test/java/io/yooksi/pz/zdoc/cmd/CommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ void shouldRecognizeAllCommands() {
@Test
void shouldDetectAllCommandLineOptions() throws ParseException {

String[][] argArrays = new String[][] {
new String[] { "-i", "input/path", "-o", "output/path" },
new String[] { "-o", "output/path", "-i", "input/path", }
String[][] argArrays = new String[][]{
new String[]{ "-i", "input/path", "-o", "output/path" },
new String[]{ "-o", "output/path", "-i", "input/path", }
};
for (Command command : Command.WORK_COMMANDS)
{
Expand All @@ -72,19 +72,20 @@ void shouldDetectAllCommandLineOptions() throws ParseException {
@Test
void shouldThrowExceptionWhenMissingCommandArguments() {

String[][] missingArgs = new String[][] {
String[][] missingArgs = new String[][]{
// new String[] { "-i", "input/path" }, // missing output path
new String[] { "-o", "output/path" } // missing input path
new String[]{ "-o", "output/path" } // missing input path
};
for (String[] args : missingArgs) {
Arrays.stream(Command.WORK_COMMANDS).forEach(c -> Assertions.assertThrows(ParseException.class,
() -> CommandLine.parse(c.options, ArrayUtils.addFirst(args, c.name))));
}
String[][] correctArgs = new String[][] {
new String[] { "-i", "input/path", "-o", "output/path" },
new String[] { "-o", "output/path", "-i", "input/path", }
String[][] correctArgs = new String[][]{
new String[]{ "-i", "input/path", "-o", "output/path" },
new String[]{ "-o", "output/path", "-i", "input/path", }
};
for (String[] args : correctArgs) {
for (String[] args : correctArgs)
{
Arrays.stream(Command.WORK_COMMANDS).forEach(c -> Assertions.assertDoesNotThrow(() ->
CommandLine.parse(c.options, ArrayUtils.addFirst(args, c.name))));
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/io/yooksi/pz/zdoc/doc/LuaDocTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void shouldNotThrowExceptionWhenParsingTopLineLuaFile() throws IOException {
}

@Test
void shouldNotWriteToFileIfNoDocElementsFound() throws IOException {
void shouldNotWriteToFileIfNoDocElementsFound() {

String[] expected = new String[]{ "--- No doc elements" };
String actual = writeParseAndReadLua(expected).get(0);
Expand All @@ -67,7 +67,7 @@ void shouldNotWriteToFileIfNoDocElementsFound() throws IOException {
}

@Test
void shouldOverwriteExistingLuaAnnotation() throws IOException {
void shouldOverwriteExistingLuaAnnotation() {

List<String> read = writeParseAndReadLua(new String[]{
"--- This is a sample comment",
Expand All @@ -78,7 +78,7 @@ void shouldOverwriteExistingLuaAnnotation() throws IOException {
}

@Test
void shouldReadAnnotationsWithWhitespaces() throws IOException {
void shouldReadAnnotationsWithWhitespaces() {

List<String> read = writeParseAndReadLua(new String[]{
"--- @class otherSampleLua",
Expand All @@ -88,7 +88,7 @@ void shouldReadAnnotationsWithWhitespaces() throws IOException {
}

@Test
void shouldParseAnnotationIncludeParentType() throws IOException {
void shouldParseAnnotationIncludeParentType() {

String[] write = {
"---@class sampleLua",
Expand Down

0 comments on commit 0a773d1

Please sign in to comment.