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 BeVoid. #250

Merged
merged 1 commit into from Feb 19, 2016
Merged

Add BeVoid. #250

merged 1 commit into from Feb 19, 2016

Conversation

inamiy
Copy link
Contributor

@inamiy inamiy commented Feb 17, 2016

I had a case to compare non-Equatable Void, e.g. expect(result.value) == (), so I added BeVoid matcher.
I hope this will work, but haven't added for wrapped cases yet, e.g. Array<()>, Set<()>, etc.

@jeffh
Copy link
Member

jeffh commented Feb 18, 2016

Hey @inamiy,

Looks good, but I'm trying to see the use case that the compiler couldn't statically know. Could you give a more concrete example use case for this matcher?

Even better, add it to the test case. :)

Other than that, I don't see any reason not to merge it.

@inamiy
Copy link
Contributor Author

inamiy commented Feb 19, 2016

@jeffh
Thanks for reply!
Here's a test code I wrote for next try! conference :)

describe("skipSpaces") {

    let p: Parser<String, ()> = skipSpaces

    it("succeeds") {
        let reply: (input: String, output: ())? = parse(p, " \t\n\rabc")._done
        expect(reply?.input) == "abc"
        expect(reply?.output) == ()
    }

    it("succeeds (no spaces)") {
        let reply: (input: String, output: ())? = parse(p, "123")._done
        expect(reply?.input) == "123"
        expect(reply?.output) == ()
    }

}

I intentionally added type annotations above, but basically they can be omitted.
But if we do so, we will have no idea what type reply?.output will be, and all we can test is using expect(reply?.output).toNot(beNil()), which works fine but it is hard to describe that output actually returns Void.

BTW, test code is already added in BeVoidTest.swift, and I think there's not much to add further.

@inamiy
Copy link
Contributor Author

inamiy commented Feb 19, 2016

Oh I also should mention that above == is actually using the following instead of normal one:

public func ==(lhs: Expectation<()>, rhs: ()) {
    lhs.to(beVoid())
}

jeffh added a commit that referenced this pull request Feb 19, 2016
@jeffh jeffh merged commit e184f22 into Quick:master Feb 19, 2016
@jeffh
Copy link
Member

jeffh commented Feb 19, 2016

Thanks for the context! Merged

@inamiy
Copy link
Contributor Author

inamiy commented Feb 19, 2016

Thanks! I will use this now :)

@inamiy inamiy deleted the BeVoid branch February 19, 2016 04:56
Megal pushed a commit to Megal/Nimble that referenced this pull request Jul 31, 2019
phatblat pushed a commit to phatblat/Nimble that referenced this pull request May 3, 2020
Add "How to Install Quick using Carthage" to table of contents
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

Successfully merging this pull request may close these issues.

None yet

2 participants