< prev index next >
test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java
Print this page
*** 28,38 ****
import jdk.test.lib.jittester.OperatorKind;
import jdk.test.lib.jittester.ProductionFailedException;
import jdk.test.lib.jittester.Type;
import jdk.test.lib.jittester.TypeList;
import jdk.test.lib.jittester.utils.TypeUtil;
- import jdk.test.lib.jittester.types.TypeInt;
import jdk.test.lib.jittester.types.TypeKlass;
import jdk.test.lib.jittester.utils.PseudoRandom;
import java.util.Collection;
--- 28,37 ----
*** 45,66 ****
@Override
protected boolean isApplicable(Type resultType) {
// arithmetic for built-in types less capacious than "int" is not supported.
if (TypeList.isBuiltIn(resultType)) {
BuiltInType builtInType = (BuiltInType) resultType;
! return builtInType.equals(new TypeInt()) || builtInType.isMoreCapaciousThan(new TypeInt());
} else {
return false;
}
}
@Override
! protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
Collection<Type> castableFromResultType = TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType);
// built-in types less capacious than int are automatically casted to int in arithmetic.
final Type leftType = PseudoRandom.randomElement(castableFromResultType);
! final Type rightType = resultType.equals(new TypeInt()) ?
PseudoRandom.randomElement(castableFromResultType) : resultType;
//TODO: is there sense to swap them randomly as it was done in original code?
return PseudoRandom.randomBoolean() ? new Pair<>(leftType, rightType) : new Pair<>(rightType, leftType);
}
}
--- 44,65 ----
@Override
protected boolean isApplicable(Type resultType) {
// arithmetic for built-in types less capacious than "int" is not supported.
if (TypeList.isBuiltIn(resultType)) {
BuiltInType builtInType = (BuiltInType) resultType;
! return builtInType.equals(TypeList.INT) || builtInType.isMoreCapaciousThan(TypeList.INT);
} else {
return false;
}
}
@Override
! protected Pair<Type, Type> generateTypes() {
Collection<Type> castableFromResultType = TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType);
// built-in types less capacious than int are automatically casted to int in arithmetic.
final Type leftType = PseudoRandom.randomElement(castableFromResultType);
! final Type rightType = resultType.equals(TypeList.INT) ?
PseudoRandom.randomElement(castableFromResultType) : resultType;
//TODO: is there sense to swap them randomly as it was done in original code?
return PseudoRandom.randomBoolean() ? new Pair<>(leftType, rightType) : new Pair<>(rightType, leftType);
}
}
< prev index next >