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

Difference finds difference between two equally objects #34

Closed
subdan opened this issue Aug 4, 2022 · 8 comments
Closed

Difference finds difference between two equally objects #34

subdan opened this issue Aug 4, 2022 · 8 comments

Comments

@subdan
Copy link

subdan commented Aug 4, 2022

Hello.

I have found a bug where Difference finds difference between two equally objects.

Example code that represents the issue:

import UIKit
import Difference

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let vm1 = ViewModel(
            benchmarkValue: BenchmarkValue(state: .neutral),
            chartValue: ChartValue(values: [0, 0.5, 1], state: .neutral)
        )

        let vm2 = ViewModel(
            benchmarkValue: BenchmarkValue(state: .neutral),
            chartValue: ChartValue(values: [0, 0.1, 1], state: .neutral)
        )

        print(diff(vm1, vm2).joined(separator: ", "))
    }
}

struct ViewModel: Hashable {
    let benchmarkValue: BenchmarkValue
    let chartValue: ChartValue
}

struct BenchmarkValue: Hashable {
    var state: MetricState
}

enum MetricState: Hashable {
    case positive
    case warning
    case neutral
}

struct ChartValue: Hashable {
    let values: [Double]
    let state: MetricState
}

Actual output:

benchmarkValue:
|	state:
|	|	Received: 13108825602
|	|	Expected: 2
, chartValue:
|	state:
|	|	Received: 13108825602
|	|	Expected: 2
|	values:
|	|	Collection[1]:
|	|	|	Received: 0.1
|	|	|	Expected: 0.5

Expected output:

chartValue:
|	values:
|	|	Collection[1]:
|	|	|	Received: 0.1
|	|	|	Expected: 0.5
@subdan subdan changed the title Difference finds difference between two equally objects Difference finds difference between two equally objects Aug 4, 2022
@subdan subdan changed the title Difference finds difference between two equally objects Difference finds difference between two equally objects Aug 4, 2022
@subdan
Copy link
Author

subdan commented Oct 7, 2022

@krzysztofzablocki Hello. FYI there is no issue in 1.0.0 version. The issue did appear after Add Objective-C enums support commit from @karolpiateknet.

@krzysztofzablocki
Copy link
Owner

@subdan ah that's good hint, maybe we can recognize if it's objective-c or standard enum and use old logic

@krzysztofzablocki
Copy link
Owner

krzysztofzablocki commented Oct 11, 2022

@subdan found a workaround I think (it's meh but it works so it's good? 😂), let me know if it fixed it for you or you see anything funky, released in 1.0.2

@subdan
Copy link
Author

subdan commented Oct 12, 2022

Thank You, @krzysztofzablocki! Could you please release 1.0.2 version to CocoaPods?

@krzysztofzablocki
Copy link
Owner

@subdan done, sorry about that, forgot I still had cocoapods xD

@subdan
Copy link
Author

subdan commented Oct 12, 2022

@krzysztofzablocki
Copy link
Owner

should be ok now

@subdan
Copy link
Author

subdan commented Oct 12, 2022

Yes, thanks!

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

No branches or pull requests

2 participants