-
Notifications
You must be signed in to change notification settings - Fork 10.6k
More evolution tests #20821
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
slavapestov
merged 9 commits into
swiftlang:master
from
slavapestov:more-evolution-tests
Nov 28, 2018
Merged
More evolution tests #20821
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b791453
Sema: More consistent @_fixed_layout diagnostics
slavapestov 62d44a3
Evolution: Rename some tests in preparation for testing @_fixed_layou…
slavapestov 0781ab8
Evolution: Add test changing a lazy property a computed property with…
slavapestov 16fccd6
Evolution: Test moving methods between class/struct and extension
slavapestov 890bf2e
Evolution: Test adding a class deinit
slavapestov 6028912
Evolution: Test that adding or removing weak/unowned is a resilient c…
slavapestov e24c4c3
Evolution: Test that adding willSet/didSet to a stored property works
slavapestov 5477467
Evolution: Test adding a new convenience init to an open class
slavapestov ee8a3ea
Evolution: Build tests with optimizations if required
slavapestov 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
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
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
26 changes: 26 additions & 0 deletions
26
validation-test/Evolution/Inputs/class_add_convenience_init.swift
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,26 @@ | ||
| open class AddConvenienceInit { | ||
| public let age: Int | ||
|
|
||
| public init(x: Int) { | ||
| self.age = x | ||
| } | ||
|
|
||
| #if BEFORE | ||
|
|
||
| public convenience init(z: Int) { | ||
| self.init(x: z * z + 2) | ||
| } | ||
|
|
||
| #else | ||
|
|
||
| public convenience init(z: Int) { | ||
| self.init(y: z * z) | ||
| } | ||
|
|
||
| public convenience init(y: Int) { | ||
| self.init(x: y + 2) | ||
| } | ||
|
|
||
| #endif | ||
|
|
||
| } |
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,25 @@ | ||
| public var count = 0 | ||
|
|
||
| public func getVersion() -> Int { | ||
| #if BEFORE | ||
| return 0 | ||
| #else | ||
| return 1 | ||
| #endif | ||
| } | ||
|
|
||
| open class Base { | ||
| public init() {} | ||
|
|
||
| #if AFTER | ||
| deinit { | ||
| count += 1 | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| open class Derived : Base { | ||
| deinit { | ||
| count += 10 | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
validation-test/Evolution/Inputs/class_add_property_attribute.swift
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,28 @@ | ||
| public var count = 0 | ||
|
|
||
| public func getVersion() -> Int { | ||
| #if BEFORE | ||
| return 0 | ||
| #else | ||
| return 1 | ||
| #endif | ||
| } | ||
|
|
||
| public class MathClass { | ||
| public init() {} | ||
| } | ||
|
|
||
| public class Attributed { | ||
| public init(x: MathClass, y: MathClass) { | ||
| self.x = x | ||
| self.y = y | ||
| } | ||
|
|
||
| #if BEFORE | ||
| public var x: MathClass? | ||
| public var y: MathClass | ||
| #else | ||
| public weak var x: MathClass? | ||
| public unowned var y: MathClass | ||
| #endif | ||
| } |
33 changes: 33 additions & 0 deletions
33
validation-test/Evolution/Inputs/class_change_lazy_to_computed.swift
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,33 @@ | ||
|
|
||
| #if BEFORE | ||
|
|
||
| public class ChangeLazyToComputed { | ||
| private var celsius: Int | ||
|
|
||
| public init(celsius: Int) { | ||
| self.celsius = celsius | ||
| } | ||
|
|
||
| public lazy var fahrenheit: Int = (celsius * 9) / 5 + 32 | ||
| } | ||
|
|
||
| #else | ||
|
|
||
| public class ChangeLazyToComputed { | ||
| private var celsius: Int | ||
|
|
||
| public init(celsius: Int) { | ||
| self.celsius = celsius | ||
| } | ||
|
|
||
| public var fahrenheit: Int { | ||
| get { | ||
| return (celsius * 9) / 5 + 32 | ||
| } | ||
| set { | ||
| celsius = ((newValue - 32) * 5) / 9 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
40 changes: 40 additions & 0 deletions
40
validation-test/Evolution/Inputs/class_change_stored_to_observed.swift
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,40 @@ | ||
|
|
||
| #if BEFORE | ||
|
|
||
| public func getVersion() -> Int { | ||
| return 0 | ||
| } | ||
|
|
||
| public class ChangeStoredToObserved { | ||
| public var friends: [String] = [] | ||
| public var count: Int = 0 | ||
|
|
||
| public var friend: String = "cat" | ||
|
|
||
| public init() {} | ||
| } | ||
|
|
||
| #else | ||
|
|
||
| public func getVersion() -> Int { | ||
| return 1 | ||
|
|
||
| } | ||
|
|
||
| public class ChangeStoredToObserved { | ||
| public var friends: [String] = [] | ||
| public var count: Int = 0 | ||
|
|
||
| public var friend: String = "cat" { | ||
| willSet { | ||
| friends.append(friend) | ||
| } | ||
| didSet { | ||
| count += 1 | ||
| } | ||
| } | ||
|
|
||
| public init() {} | ||
| } | ||
|
|
||
| #endif |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
validation-test/Evolution/Inputs/move_method_to_extension.swift
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,25 @@ | ||
| public struct Rain { | ||
| public init() {} | ||
|
|
||
| #if BEFORE | ||
| public func doIt() {} | ||
| #endif | ||
| } | ||
|
|
||
| public class Snow { | ||
| public init() {} | ||
|
|
||
| #if BEFORE | ||
| public final func doIt() {} | ||
| #endif | ||
| } | ||
|
|
||
| #if AFTER | ||
| extension Rain { | ||
| public func doIt() {} | ||
| } | ||
|
|
||
| extension Snow { | ||
| public func doIt() {} | ||
| } | ||
| #endif |
28 changes: 28 additions & 0 deletions
28
validation-test/Evolution/Inputs/struct_add_property_attribute.swift
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,28 @@ | ||
| public var count = 0 | ||
|
|
||
| public func getVersion() -> Int { | ||
| #if BEFORE | ||
| return 0 | ||
| #else | ||
| return 1 | ||
| #endif | ||
| } | ||
|
|
||
| public class MathClass { | ||
| public init() {} | ||
| } | ||
|
|
||
| public struct Attributed { | ||
| public init(x: MathClass, y: MathClass) { | ||
| self.x = x | ||
| self.y = y | ||
| } | ||
|
|
||
| #if BEFORE | ||
| public var x: MathClass? | ||
| public var y: MathClass | ||
| #else | ||
| public weak var x: MathClass? | ||
| public unowned var y: MathClass | ||
| #endif | ||
| } |
33 changes: 33 additions & 0 deletions
33
validation-test/Evolution/Inputs/struct_change_lazy_to_computed.swift
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,33 @@ | ||
|
|
||
| #if BEFORE | ||
|
|
||
| public struct ChangeLazyToComputed { | ||
| private var celsius: Int | ||
|
|
||
| public init(celsius: Int) { | ||
| self.celsius = celsius | ||
| } | ||
|
|
||
| public lazy var fahrenheit: Int = (celsius * 9) / 5 + 32 | ||
| } | ||
|
|
||
| #else | ||
|
|
||
| public struct ChangeLazyToComputed { | ||
| private var celsius: Int | ||
|
|
||
| public init(celsius: Int) { | ||
| self.celsius = celsius | ||
| } | ||
|
|
||
| public var fahrenheit: Int { | ||
| mutating get { | ||
| return (celsius * 9) / 5 + 32 | ||
| } | ||
| set { | ||
| celsius = ((newValue - 32) * 5) / 9 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif |
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.
These are backwards, no? BEFORE should be the lazy one. (I mean, we're testing in both directions, but the names should match the code.)
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.
Done