-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add simple csv test to LvtAssignmentSuggester
- Loading branch information
1 parent
764a50d
commit 8a9d107
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/io/papermc/codebook/lvt/LvtAssignmentSuggesterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* codebook is a remapper utility for the PaperMC project. | ||
* | ||
* Copyright (c) 2023 Kyle Wood (DenWav) | ||
* Contributors | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; | ||
* version 3 only, no later versions. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
*/ | ||
|
||
package io.papermc.codebook.lvt; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvFileSource; | ||
import org.objectweb.asm.tree.MethodInsnNode; | ||
|
||
class LvtAssignmentSuggesterTest { | ||
|
||
@ParameterizedTest | ||
@CsvFileSource(resources = "/io/papermc/codebook/lvt/LvtAssignmentSuggesterTest.csv", numLinesToSkip = 1) | ||
public void testSuggester( | ||
final String methodName, | ||
final String methodOwner, | ||
final String methodDescriptor, | ||
final String expectedName) { | ||
final @Nullable String result = LvtAssignmentSuggester.suggestNameFromAssignment( | ||
methodName, new MethodInsnNode(-1, methodOwner, methodName, methodDescriptor)); | ||
assertEquals(expectedName, result); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/test/resources/io/papermc/codebook/lvt/LvtAssignmentSuggesterTest.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Method Name, Method Owner, Method Descriptor, Expected Name | ||
# generic methods | ||
hashCode,io/paper/Paper,()I,hashCode | ||
size,java/util/List,()I,size | ||
length,[Ljava/lang/String,()I,len | ||
freeze,net/minecraft/core/RegistryAccess,()Lnet/minecraft/core/RegistryAccess.Frozen;,frozen | ||
# getters | ||
getName,io/paper/Paper,()Ljava/lang/String;,name | ||
getSuperLongDumName,io/paper/Paper,()Ljava/lang/String;,superLongDumName | ||
getOrCreateSomething,io/paper/Paper,()Ljava/lang/String;,something | ||
# as | ||
asString,io/paper/Paper,()Ljava/lang/String;,string | ||
asLevel,io/paper/paper,()Lnet/minecraft/Level;,level | ||
# readLine | ||
readLine,some/stream,()Ljava/lang/String;,line | ||
# strings | ||
split,java/lang/String,()Ljava/lang/String;,parts | ||
split,com/google/common/base/Splitter,()Ljava/lang/String;,parts | ||
repeat,java/lang/String,()Ljava/lang/String;,repeated | ||
indexOf,java/lang/String,()I,index | ||
lastIndexOf,java/lang/String,()I,index | ||
substring,java/lang/String,()I,sub | ||
codePointAt,java/lang/String,()I,code | ||
trim,java/lang/String,()Ljava/lang/String;,trimmed | ||
strip,java/lang/String,()Ljava/lang/String;,stripped | ||
stripLeading,java/lang/String,()Ljava/lang/String;,stripped | ||
stripTrailing,java/lang/String,()Ljava/lang/String;,stripped | ||
stripIndent,java/lang/String,()Ljava/lang/String;,stripped | ||
formatted,java/lang/String,()Ljava/lang/String;,formatted | ||
# negative cases | ||
getOrCreate,io/paper/Paper,()Ljava/lang/String;, | ||
gettingBetter,io/paper/Paper,()Ljava/lang/String;, | ||
as,io/paper/paper,()Ljava/lang/String;, | ||
ass,io/paper/paper,()Ljava/lang/String;, |