Introduce WITH_UNSIGNED directive to use unsigned types in tests
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// !SKIP_METADATA_VERSION_CHECK
|
||||
// WITH_UNSIGNED
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER")
|
||||
fun box(): String {
|
||||
val u1 = UInt(1)
|
||||
val u2 = UInt(2)
|
||||
val u3 = u1 + u2
|
||||
return if (u3.toInt() == 3) "OK" else "fail"
|
||||
}
|
||||
+7
-1
@@ -19,6 +19,7 @@ const val EXPERIMENTAL_DIRECTIVE = "EXPERIMENTAL"
|
||||
const val USE_EXPERIMENTAL_DIRECTIVE = "USE_EXPERIMENTAL"
|
||||
const val IGNORE_DATA_FLOW_IN_ASSERT_DIRECTIVE = "IGNORE_DATA_FLOW_IN_ASSERT"
|
||||
const val JVM_DEFAULT_MODE = "JVM_DEFAULT_MODE"
|
||||
const val SKIP_METADATA_VERSION_CHECK = "SKIP_METADATA_VERSION_CHECK"
|
||||
|
||||
data class CompilerTestLanguageVersionSettings(
|
||||
private val initialLanguageFeatures: Map<LanguageFeature, LanguageFeature.State>,
|
||||
@@ -52,6 +53,7 @@ fun parseLanguageVersionSettings(directiveMap: Map<String, String>): LanguageVer
|
||||
val useExperimental = directiveMap[USE_EXPERIMENTAL_DIRECTIVE]?.split(' ')?.let { AnalysisFlag.useExperimental to it }
|
||||
val ignoreDataFlowInAssert = AnalysisFlag.ignoreDataFlowInAssert to directiveMap.containsKey(IGNORE_DATA_FLOW_IN_ASSERT_DIRECTIVE)
|
||||
val enableJvmDefault = directiveMap[JVM_DEFAULT_MODE]?.let { AnalysisFlag.jvmDefaultMode to JvmDefaultMode.fromStringOrNull(it)!! }
|
||||
val skipMetadataVersionCheck = AnalysisFlag.skipMetadataVersionCheck to directiveMap.containsKey(SKIP_METADATA_VERSION_CHECK)
|
||||
|
||||
if (apiVersionString == null && languageFeaturesString == null && experimental == null && useExperimental == null && !ignoreDataFlowInAssert.second) return null
|
||||
|
||||
@@ -64,7 +66,11 @@ fun parseLanguageVersionSettings(directiveMap: Map<String, String>): LanguageVer
|
||||
|
||||
return CompilerTestLanguageVersionSettings(
|
||||
languageFeatures, apiVersion, languageVersion,
|
||||
mapOf(*listOfNotNull(experimental, useExperimental, enableJvmDefault, ignoreDataFlowInAssert).toTypedArray())
|
||||
mapOf(
|
||||
*listOfNotNull(
|
||||
experimental, useExperimental, enableJvmDefault, ignoreDataFlowInAssert, skipMetadataVersionCheck
|
||||
).toTypedArray()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -410,13 +410,29 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
||||
|
||||
@NotNull
|
||||
protected GeneratedClassLoader createClassLoader() {
|
||||
ClassLoader classLoader;
|
||||
if (configurationKind.getWithReflection() && configurationKind.getWithCoroutines()) {
|
||||
classLoader = ForTestCompileRuntime.reflectAndCoroutinesJarClassLoader();
|
||||
}
|
||||
else if (configurationKind.getWithUnsignedTypes() && configurationKind.getWithReflection()) {
|
||||
classLoader = ForTestCompileRuntime.reflectAndUnsignedTypesJarClassLoader();
|
||||
}
|
||||
else if (configurationKind.getWithReflection()) {
|
||||
classLoader = ForTestCompileRuntime.runtimeAndReflectJarClassLoader();
|
||||
}
|
||||
else if (configurationKind.getWithCoroutines()) {
|
||||
classLoader = ForTestCompileRuntime.runtimeAndCoroutinesJarClassLoader();
|
||||
}
|
||||
else if (configurationKind.getWithUnsignedTypes()) {
|
||||
classLoader = ForTestCompileRuntime.runtimeAndUnsignedTypesJarClassLoader();
|
||||
}
|
||||
else {
|
||||
classLoader = ForTestCompileRuntime.runtimeJarClassLoader();
|
||||
}
|
||||
|
||||
return new GeneratedClassLoader(
|
||||
generateClassesInFile(),
|
||||
configurationKind.getWithReflection()
|
||||
? ForTestCompileRuntime.runtimeAndReflectJarClassLoader()
|
||||
: configurationKind.getWithCoroutines()
|
||||
? ForTestCompileRuntime.runtimeAndCoroutinesJarClassLoader()
|
||||
: ForTestCompileRuntime.runtimeJarClassLoader(),
|
||||
classLoader,
|
||||
getClassPathURLs()
|
||||
);
|
||||
}
|
||||
@@ -671,6 +687,9 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
||||
if (configurationKind.getWithCoroutines()) {
|
||||
javaClasspath.add(ForTestCompileRuntime.coroutinesJarForTests().getPath());
|
||||
}
|
||||
if (configurationKind.getWithUnsignedTypes()) {
|
||||
javaClasspath.add(ForTestCompileRuntime.unsignedTypesJarForTests().getPath());
|
||||
}
|
||||
|
||||
javaClassesOutputDirectory = CodegenTestUtil.compileJava(
|
||||
findJavaSourcesInDirectory(javaSourceDir), javaClasspath, javacOptions
|
||||
@@ -683,6 +702,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
||||
boolean addRuntime = false;
|
||||
boolean addReflect = false;
|
||||
boolean addCoroutines = false;
|
||||
boolean addUnsignedTypes = false;
|
||||
for (TestFile file : files) {
|
||||
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "COMMON_COROUTINES_TEST")) {
|
||||
addCoroutines = true;
|
||||
@@ -693,11 +713,16 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
||||
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_REFLECT")) {
|
||||
addReflect = true;
|
||||
}
|
||||
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_UNSIGNED")) {
|
||||
addUnsignedTypes = true;
|
||||
}
|
||||
}
|
||||
|
||||
return (addReflect && addCoroutines) ? ConfigurationKind.ALL :
|
||||
return (addReflect && addCoroutines && addUnsignedTypes) ? ConfigurationKind.ALL :
|
||||
(addReflect && addCoroutines) ? ConfigurationKind.WITH_COROUTINES_AND_REFLECT :
|
||||
addReflect ? ConfigurationKind.WITH_REFLECT :
|
||||
addCoroutines ? ConfigurationKind.WITH_COROUTINES :
|
||||
addUnsignedTypes ? ConfigurationKind.WITH_UNSIGNED_TYPES :
|
||||
addRuntime ? ConfigurationKind.NO_KOTLIN_REFLECT :
|
||||
ConfigurationKind.JDK_ONLY;
|
||||
}
|
||||
|
||||
+44
@@ -20,6 +20,9 @@ public class ForTestCompileRuntime {
|
||||
private static volatile SoftReference<ClassLoader> reflectJarClassLoader = new SoftReference<>(null);
|
||||
private static volatile SoftReference<ClassLoader> runtimeJarClassLoader = new SoftReference<>(null);
|
||||
private static volatile SoftReference<ClassLoader> coroutinesJarClassLoader = new SoftReference<>(null);
|
||||
private static volatile SoftReference<ClassLoader> unsignedTypesJarClassLoader = new SoftReference<>(null);
|
||||
private static volatile SoftReference<ClassLoader> unsignedTypesAndReflectJarClassLoader = new SoftReference<>(null);
|
||||
private static volatile SoftReference<ClassLoader> coroutinesAndReflectJarClassLoader = new SoftReference<>(null);
|
||||
|
||||
@NotNull
|
||||
public static File runtimeJarForTests() {
|
||||
@@ -31,6 +34,11 @@ public class ForTestCompileRuntime {
|
||||
return assertExists(new File("dist/kotlin-stdlib-coroutines.jar"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File unsignedTypesJarForTests() {
|
||||
return assertExists(new File("dist/kotlin-stdlib-unsigned.jar"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File minimalRuntimeJarForTests() {
|
||||
return assertExists(new File("dist/kotlin-stdlib-minimal-for-test.jar"));
|
||||
@@ -105,6 +113,42 @@ public class ForTestCompileRuntime {
|
||||
return loader;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static synchronized ClassLoader runtimeAndUnsignedTypesJarClassLoader() {
|
||||
ClassLoader loader = unsignedTypesJarClassLoader.get();
|
||||
if (loader == null) {
|
||||
loader = createClassLoader(runtimeJarForTests(), unsignedTypesJarForTests(), scriptRuntimeJarForTests(), kotlinTestJarForTests());
|
||||
unsignedTypesJarClassLoader = new SoftReference<>(loader);
|
||||
}
|
||||
return loader;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static synchronized ClassLoader reflectAndUnsignedTypesJarClassLoader() {
|
||||
ClassLoader loader = unsignedTypesAndReflectJarClassLoader.get();
|
||||
if (loader == null) {
|
||||
loader = createClassLoader(
|
||||
runtimeJarForTests(), reflectJarForTests(), unsignedTypesJarForTests(),
|
||||
scriptRuntimeJarForTests(), kotlinTestJarForTests()
|
||||
);
|
||||
unsignedTypesAndReflectJarClassLoader = new SoftReference<>(loader);
|
||||
}
|
||||
return loader;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static synchronized ClassLoader reflectAndCoroutinesJarClassLoader() {
|
||||
ClassLoader loader = coroutinesAndReflectJarClassLoader.get();
|
||||
if (loader == null) {
|
||||
loader = createClassLoader(
|
||||
runtimeJarForTests(), reflectJarForTests(), coroutinesJarForTests(),
|
||||
scriptRuntimeJarForTests(), kotlinTestJarForTests()
|
||||
);
|
||||
coroutinesAndReflectJarClassLoader = new SoftReference<>(loader);
|
||||
}
|
||||
return loader;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static synchronized ClassLoader runtimeJarClassLoader() {
|
||||
ClassLoader loader = runtimeJarClassLoader.get();
|
||||
|
||||
@@ -9,7 +9,8 @@ enum class ConfigurationKind(
|
||||
val withRuntime: Boolean = false,
|
||||
val withMockRuntime: Boolean = false,
|
||||
val withReflection: Boolean = false,
|
||||
val withCoroutines: Boolean = false
|
||||
val withCoroutines: Boolean = false,
|
||||
val withUnsignedTypes: Boolean = false
|
||||
) {
|
||||
/** JDK without any kotlin runtime */
|
||||
JDK_NO_RUNTIME(),
|
||||
@@ -19,8 +20,12 @@ enum class ConfigurationKind(
|
||||
NO_KOTLIN_REFLECT(withRuntime = true),
|
||||
/** JDK + kotlin runtime + coroutines */
|
||||
WITH_COROUTINES(withCoroutines = true, withRuntime = true),
|
||||
/** JDK + kotlin runtime + unsigned types */
|
||||
WITH_UNSIGNED_TYPES(withUnsignedTypes = true, withRuntime = true, withReflection = true),
|
||||
/** JDK + kotlin runtime + kotlin reflection */
|
||||
WITH_REFLECT(withRuntime = true, withReflection = true),
|
||||
/** JDK + kotlin runtime + kotlin reflection + coroutines*/
|
||||
ALL(withRuntime = true, withReflection = true, withCoroutines = true)
|
||||
/** JDK + kotlin runtime + kotlin reflection + coroutines */
|
||||
WITH_COROUTINES_AND_REFLECT(withRuntime = true, withReflection = true, withCoroutines = true),
|
||||
/** JDK + kotlin runtime + kotlin reflection + coroutines + unsigned types */
|
||||
ALL(withRuntime = true, withReflection = true, withCoroutines = true, withUnsignedTypes = true)
|
||||
}
|
||||
|
||||
@@ -576,6 +576,9 @@ public class KotlinTestUtils {
|
||||
if (configurationKind.getWithCoroutines()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests());
|
||||
}
|
||||
if (configurationKind.getWithUnsignedTypes()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.unsignedTypesJarForTests());
|
||||
}
|
||||
if (configurationKind.getWithRuntime()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests());
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests());
|
||||
|
||||
@@ -576,6 +576,9 @@ public class KotlinTestUtils {
|
||||
if (configurationKind.getWithCoroutines()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests());
|
||||
}
|
||||
if (configurationKind.getWithUnsignedTypes()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.unsignedTypesJarForTests());
|
||||
}
|
||||
if (configurationKind.getWithRuntime()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests());
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests());
|
||||
|
||||
@@ -576,6 +576,9 @@ public class KotlinTestUtils {
|
||||
if (configurationKind.getWithCoroutines()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests());
|
||||
}
|
||||
if (configurationKind.getWithUnsignedTypes()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.unsignedTypesJarForTests());
|
||||
}
|
||||
if (configurationKind.getWithRuntime()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests());
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests());
|
||||
|
||||
@@ -576,6 +576,9 @@ public class KotlinTestUtils {
|
||||
if (configurationKind.getWithCoroutines()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.coroutinesJarForTests());
|
||||
}
|
||||
if (configurationKind.getWithUnsignedTypes()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.unsignedTypesJarForTests());
|
||||
}
|
||||
if (configurationKind.getWithRuntime()) {
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests());
|
||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.scriptRuntimeJarForTests());
|
||||
|
||||
Generated
+5
@@ -11224,6 +11224,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkLambdaWithInlineClassesInFunctionalType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("checkPlusOfUInt.kt")
|
||||
public void testCheckPlusOfUInt() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("checkUnboxingResultFromTypeVariable.kt")
|
||||
public void testCheckUnboxingResultFromTypeVariable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkUnboxingResultFromTypeVariable.kt");
|
||||
|
||||
+5
@@ -11224,6 +11224,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkLambdaWithInlineClassesInFunctionalType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("checkPlusOfUInt.kt")
|
||||
public void testCheckPlusOfUInt() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("checkUnboxingResultFromTypeVariable.kt")
|
||||
public void testCheckUnboxingResultFromTypeVariable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkUnboxingResultFromTypeVariable.kt");
|
||||
|
||||
+5
@@ -11224,6 +11224,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkLambdaWithInlineClassesInFunctionalType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("checkPlusOfUInt.kt")
|
||||
public void testCheckPlusOfUInt() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("checkUnboxingResultFromTypeVariable.kt")
|
||||
public void testCheckUnboxingResultFromTypeVariable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkUnboxingResultFromTypeVariable.kt");
|
||||
|
||||
+5
@@ -9760,6 +9760,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkLambdaWithInlineClassesInFunctionalType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("checkPlusOfUInt.kt")
|
||||
public void testCheckPlusOfUInt() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkPlusOfUInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("checkUnboxingResultFromTypeVariable.kt")
|
||||
public void testCheckUnboxingResultFromTypeVariable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/checkUnboxingResultFromTypeVariable.kt");
|
||||
|
||||
Reference in New Issue
Block a user