Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases for constructors with SFVC as a parameter. #5269

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

k163377
Copy link
Contributor

@k163377 k163377 commented Feb 23, 2024

Completed missing test cases regarding the type that value class wraps and nullability as a parameter.


For SFCV, these test cases are largely missing.
I would like to continue to contribute to the completion of such test cases.

By the way, are there any rules on how to write commit messages?
Also, are there any recommended per-commit guidelines?
I have had these corrected several times and I apologize for that.

@udalov udalov self-assigned this Feb 23, 2024
@k163377 k163377 marked this pull request as draft February 23, 2024 08:22
@udalov
Copy link
Member

udalov commented Feb 23, 2024

By the way, are there any rules on how to write commit messages?
Also, are there any recommended per-commit guidelines?

Take a look here and here, but these are rather guidelines than strictly enforced rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate test cases were removed.

Comment on lines +8 to +10
data class TestCtor1_1(val x: A = A("0"))
data class TestCtor1_2(val x: A? = A("0"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am adding a function to verify the nullability of a parameter.
Should I add a case where the default argument is null?

@k163377 k163377 marked this pull request as ready for review February 23, 2024 08:35
@k163377
Copy link
Contributor Author

k163377 commented Feb 23, 2024

@udalov
Thanks for the quick reply, I will check it.
And sorry for the force push after opened the PR.

Comment on lines +112 to +123
assertEquals(TestCtor1_1(), ::TestCtor1_1.callBy(mapOf()))
assertEquals(TestCtor1_2(), ::TestCtor1_2.callBy(mapOf()))
assertEquals(TestCtor32_1(), ::TestCtor32_1.callBy(mapOf()))
assertEquals(TestCtor32_2(), ::TestCtor32_2.callBy(mapOf()))
assertEquals(TestCtor33_1(), ::TestCtor33_1.callBy(mapOf()))
assertEquals(TestCtor33_2(), ::TestCtor33_2.callBy(mapOf()))
assertEquals(TestCtor64_1(), ::TestCtor64_1.callBy(mapOf()))
assertEquals(TestCtor64_2(), ::TestCtor64_2.callBy(mapOf()))
assertEquals(TestCtor65_1(), ::TestCtor65_1.callBy(mapOf()))
assertEquals(TestCtor65_2(), ::TestCtor65_2.callBy(mapOf()))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, I apologize for not confirming the success of the test due to a misunderstanding.


I discovered that bytecode compatibility had been broken.

This test is not inherently successful due to KT-57357.
In fact, FireLightTreeBlackBoxCodegenTestGenerated, FirePsiBlackBoxCodegenTestGenerated and IrBlackBoxCodegenTestGenerated fail.

So I attempted to change the test as follows to make it a failing test (I am referring to this)

    assertFailsWith<Error>("Remove assertFailsWith and try again, as KT-57357 may have been fixed.") {
        assertEquals(TestCtor1_1(), ::TestCtor1_1.callBy(mapOf()))
        assertEquals(TestCtor1_2(), ::TestCtor1_2.callBy(mapOf()))
        assertEquals(TestCtor32_1(), ::TestCtor32_1.callBy(mapOf()))
        assertEquals(TestCtor32_2(), ::TestCtor32_2.callBy(mapOf()))
        assertEquals(TestCtor33_1(), ::TestCtor33_1.callBy(mapOf()))
        assertEquals(TestCtor33_2(), ::TestCtor33_2.callBy(mapOf()))
        assertEquals(TestCtor64_1(), ::TestCtor64_1.callBy(mapOf()))
        assertEquals(TestCtor64_2(), ::TestCtor64_2.callBy(mapOf()))
        assertEquals(TestCtor65_1(), ::TestCtor65_1.callBy(mapOf()))
        assertEquals(TestCtor65_2(), ::TestCtor65_2.callBy(mapOf()))
    }

However, after making this change, BlackBoxCodegenTestGenerated now fails.
This indicates that the bytecode has been destructively modified.

What should I do in such a case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add // IGNORE_BACKEND: JVM directive to this test, it will make the test pass only for the combination of K1 + old JVM backend.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this and several other errors occurred. 8880205
I am sorry, but could you please confirm this?

BlackBoxCodegenTestGenerated

Looks like this test can be unmuted. Remove JVM from the IGNORE_BACKEND directive for ClassicFrontend for JVM
java.lang.AssertionError: Looks like this test can be unmuted. Remove JVM from the IGNORE_BACKEND directive for ClassicFrontend for JVM

IrBlackBoxCodegenTestGenerated/FirPsiBlackBoxCodegenTestGenerated/FirLightTreeBlackBoxCodegenTestGenerated(Only the hash values after @ were different)


This callable does not support a default call: public constructor TestCtor1_1(x: A = ...) defined in TestCtor1_1[DeserializedClassConstructorDescriptor@2e04b974]
kotlin.reflect.jvm.internal.KotlinReflectionInternalError: This callable does not support a default call: public constructor TestCtor1_1(x: A = ...) defined in TestCtor1_1[DeserializedClassConstructorDescriptor@2e04b974]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was wrong, instead of // IGNORE_BACKEND: JVM use // IGNORE_BACKEND: JVM_IR and regenerate tests one more time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, the test is now successful!
I have pushed the fix.
ced6ebc

k163377 added a commit to k163377/kotlin that referenced this pull request Feb 23, 2024
@k163377
Copy link
Contributor Author

k163377 commented Apr 21, 2024

Too much time had passed, so I rebased and force pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants