mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 00:14:10 -08:00
Add tests and implement proper behavior for arrays
This commit is contained in:
parent
a2a679b2e3
commit
d86c424aad
|
@ -77,11 +77,15 @@ public class TClass<T> extends TObject implements TAnnotatedElement {
|
|||
|
||||
public TString getSimpleName() {
|
||||
if (simpleName == null) {
|
||||
if (isArray()) {
|
||||
simpleName = getComponentType().getSimpleName().concat(TString.wrap("[]"));
|
||||
return simpleName;
|
||||
}
|
||||
String name = platformClass.getMetadata().getName();
|
||||
int lastDollar = name.lastIndexOf('$');
|
||||
if (lastDollar != -1) {
|
||||
name = name.substring(lastDollar + 1);
|
||||
if (name.charAt(0) >= 0 && name.charAt(0) <= 9) {
|
||||
if (name.charAt(0) >= '0' && name.charAt(0) <= '9') {
|
||||
name = "";
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -38,6 +38,16 @@ public class ClassTest {
|
|||
assertEquals("[I", int[].class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classSimpleNameEvaluated() {
|
||||
assertEquals("Object", Object.class.getSimpleName());
|
||||
assertEquals("Object[]", Object[].class.getSimpleName());
|
||||
assertEquals("int", int.class.getSimpleName());
|
||||
assertEquals("int[]", int[].class.getSimpleName());
|
||||
assertEquals("InnerClass", InnerClass.class.getSimpleName());
|
||||
assertEquals("", new Object(){}.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void objectClassNameEvaluated() {
|
||||
assertEquals("java.lang.Object", new Object().getClass().getName());
|
||||
|
@ -205,4 +215,7 @@ public class ClassTest {
|
|||
|
||||
Class<?> n();
|
||||
}
|
||||
|
||||
static class InnerClass {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user