Coder Social home page Coder Social logo

Comments (5)

amichnia avatar amichnia commented on May 21, 2024 2

@andlang - I have fixed that issue, its waiting for code review. I think it will not be released as 1.3 bug fix, but along with version 2.0, which should be available in next few days. Updating release date for the end of the week, but it might be sooner.

In general, that how the test added looks like now. Please note, that there is a requirement to register all custom Type's in order of matcher working fine. Also - in that particular case there is literally no difference between using .value and .any for T.Type attribute.

func test_custom_type_constraint() {
        let mock = GenericProtocolWithTypeConstraintMock()

        let data = Data()
        let otherData = Data(count: 20)
        XCTAssertNotEqual(data, otherData)

        // Required to allow Type matching! Basic types like Int.self, Bool.self etc have already registered comparators
        Matcher.default.register(CustomThing.Type.self)

        Given(mock, .decode(type: .value(Int.self), from: .any, willReturn: 0))
        Given(mock, .decode(type: .value(Int.self), from: .value(data), willReturn: 1))
        Given(mock, .decode(type: .any(CustomThing.Type.self), from: .any, willReturn: CustomThing(id: 0)))
        Given(mock, .decode(type: .any(CustomThing.Type.self), from: .value(data), willReturn: CustomThing(id: 1)))

        XCTAssertEqual(mock.decode(Int.self, from: otherData), 0)
        XCTAssertEqual(mock.decode(Int.self, from: data), 1)

        XCTAssertEqual(mock.decode(CustomThing.self, from: otherData).id, 0)
        XCTAssertEqual(mock.decode(CustomThing.self, from: data).id, 1)
}

from swiftymocky.

amichnia avatar amichnia commented on May 21, 2024 1

@andlang - quick update, code get merged. New version will be available this week I think. I'm marking issue as done.

from swiftymocky.

amichnia avatar amichnia commented on May 21, 2024 1

@andlang Version 2.0 is ready, feel free to check it out :)

from swiftymocky.

amichnia avatar amichnia commented on May 21, 2024

Checking that, we might have issues with .Type - if so, I'll start fixing it right away. Thanks for the info.

from swiftymocky.

andlang avatar andlang commented on May 21, 2024

Perfect, it works! Thank you very much!

from swiftymocky.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.