-
Couldn't load subscription status.
- Fork 1.4k
fix assertTrue on new instance creation #9832
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
test-tests/shared/src/test/scala-3/zio/test/SmartAssertionScala3Spec.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| package zio.test | ||
|
|
||
| object SmartAssertionScala3Spec extends ZIOBaseSpec { | ||
|
|
||
| override def spec = | ||
| suite("SmartAssertionScala3Spec")( | ||
| suite("new instance creation")( | ||
| test("anonymous class (trait) with overload and type args - new instance") { | ||
| trait ClassWithOverload[X] { | ||
| def overloaded: Int = 1 | ||
| def overloaded(x: Int): Int = 1 | ||
| } | ||
| assertTrue(new ClassWithOverload[Int]() {}.overloaded == 1) | ||
| }, | ||
| test("anonymous class with overload - new instance") { | ||
| class ClassWithOverload { | ||
| def overloaded: Int = 1 | ||
| def overloaded(x: Int): Int = 1 | ||
| } | ||
| assertTrue(new ClassWithOverload() {}.overloaded == 1) | ||
| }, | ||
| test("anonymous class (trait) with overload - new instance") { | ||
| trait ClassWithOverload { | ||
| def overloaded: Int = 1 | ||
| def overloaded(x: Int): Int = 1 | ||
| } | ||
| assertTrue(new ClassWithOverload() {}.overloaded == 1) | ||
| }, | ||
| test("trait with parameter and overloaded methods") { | ||
| trait TraitOverloadedWithParameter(x: Int) { | ||
| def overloaded: Int = 1 | ||
|
|
||
| def overloaded(x: Int) = 1 | ||
| } | ||
|
|
||
| assertTrue(new TraitOverloadedWithParameter(1) {}.overloaded == 1) | ||
| }, | ||
| test("trait with overloaded methods with type args") { | ||
| trait TraitOverloadedAndTypeArgs[A] { | ||
| def overloaded: Int = 1 | ||
|
|
||
| def overloaded(x: Int) = 1 | ||
| } | ||
|
|
||
| assertTrue(new TraitOverloadedAndTypeArgs[Int] {}.overloaded == 1) | ||
| }, | ||
| test("trait with parameter and overloaded methods with type args") { | ||
| trait TraitOverloadedWithParameterAndTypeArgs[A](x: A) { | ||
| def overloaded: Int = 1 | ||
|
|
||
| def overloaded(x: Int) = 1 | ||
| } | ||
|
|
||
| assertTrue(new TraitOverloadedWithParameterAndTypeArgs[Int](1) {}.overloaded == 1) | ||
| }, | ||
| test("inlined trait with overloaded methods and parameter and type arg") { | ||
| trait TraitOverloadedWithParameterAndTypeArgs[A](x: A) { | ||
| def overloaded: Int = 1 | ||
|
|
||
| def overloaded(x: Int) = 1 | ||
| } | ||
| @scala.annotation.nowarn | ||
| inline def create = new TraitOverloadedWithParameterAndTypeArgs[Int](1) {} | ||
|
|
||
| assertTrue(create.overloaded == 1) | ||
| }, | ||
| test("inlined trait with overloaded methods and parameter") { | ||
| trait TraitOverloadedWithParameter(x: Int) { | ||
| def overloaded: Int = 1 | ||
|
|
||
| def overloaded(x: Int) = 1 | ||
| } | ||
| @scala.annotation.nowarn | ||
| inline def create = | ||
| new TraitOverloadedWithParameter(1) {} | ||
|
|
||
| assertTrue(create.overloaded == 1) | ||
| }, | ||
| test("inlined class with overloaded methods and parameter") { | ||
| class ClassOverloadedWithParameter(x: Int) { | ||
| def overloaded: Int = 1 | ||
|
|
||
| def overloaded(x: Int) = 1 | ||
| } | ||
|
|
||
| @scala.annotation.nowarn | ||
| inline def create = | ||
| new ClassOverloadedWithParameter(1) | ||
|
|
||
| assertTrue(create.overloaded == 1) | ||
| } | ||
| ) | ||
| ) | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this only contain Scala 3 specific tests? Do we need the overlap with
SmartAssertionSpec?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, only specific to scala 3 test cases.
If you have any suggestions on improving it - I can do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't think about traits with parameters not being available on Scala 2. Thanks for the clarification.