mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Add support of TeaVMProperties annotation
This commit is contained in:
parent
5576275998
commit
4819eee3ef
|
@ -4,13 +4,15 @@ import static org.junit.Assert.*;
|
|||
import java.text.NumberFormat;
|
||||
import java.util.Currency;
|
||||
import java.util.Locale;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.teavm.junit.SkipJVM;
|
||||
import org.teavm.junit.TeaVMProperties;
|
||||
import org.teavm.junit.TeaVMProperty;
|
||||
import org.teavm.junit.TeaVMTestRunner;
|
||||
|
||||
@RunWith(TeaVMTestRunner.class)
|
||||
@TeaVMProperties(@TeaVMProperty(key = "java.util.Locale.available", value = "en, en_US, en_GB, ru, ru_RU"))
|
||||
public class NumberFormatTest {
|
||||
@Test
|
||||
public void formatsNumber() {
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface TeaVMProperties {
|
||||
TeaVMProperty[] value();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
@ -352,6 +353,10 @@ public class TeaVMTestRunner extends Runner {
|
|||
new TestExceptionPlugin().install(vm);
|
||||
new TestEntryPointTransformer(runnerType.getName(), methodHolder.getReference()).install(vm);
|
||||
|
||||
Properties properties = new Properties();
|
||||
applyProperties(method.getDeclaringClass(), properties);
|
||||
vm.setProperties(properties);
|
||||
|
||||
try (Writer innerWriter = new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")) {
|
||||
MethodReference exceptionMsg = new MethodReference(ExceptionHelper.class, "showException",
|
||||
Throwable.class, String.class);
|
||||
|
@ -367,6 +372,18 @@ public class TeaVMTestRunner extends Runner {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void applyProperties(Class<?> cls, Properties result) {
|
||||
if (cls.getSuperclass() != null) {
|
||||
applyProperties(cls.getSuperclass(), result);
|
||||
}
|
||||
TeaVMProperties properties = cls.getAnnotation(TeaVMProperties.class);
|
||||
if (properties != null) {
|
||||
for (TeaVMProperty property : properties.value()) {
|
||||
result.setProperty(property.key(), property.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MethodDescriptor getDescriptor(Method method) {
|
||||
ValueType[] signature = Stream.concat(Arrays.stream(method.getParameterTypes()).map(ValueType::parse),
|
||||
Stream.of(ValueType.parse(method.getReturnType())))
|
||||
|
|
Loading…
Reference in New Issue
Block a user