GithubHelp home page GithubHelp logo

swifthamcrest's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swifthamcrest's Issues

Swift 3 compatible release

Is it possible to get an official release of SwiftHamcrest with Swift 3 support?

@nschum if you have not the time anymore to maintain this project, maybe you can grant access to someone else. e.g. @jonreid

Latest release does not build with new Swift (2.2)

Maybe you already know this.

I am moving our project from CocoaPods to Carthage. Carthage requires a tag. The most recent one here is from last September. The following error occurs building it:

The following build commands failed:
    CompileSwift normal x86_64 /Users/robwilliams/Documents/workspaces/xcode/dminder-ios/Carthage/Checkouts/SwiftHamcrest/Hamcrest/Hamcrest.swift
    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)
ft 3, please use #file
public func assertThrows<S, T: ErrorType where T: Equatable>(@autoclosure value: () throws -> S, _ error: T, file: String = __FILE__, line: UInt = __LINE__) -> String {

Xcode 7.3 was just released yesterday so maybe this was working.

XCTest does not contain bitcode

I'm adding SwiftHamcrest to my testing target via CocoaPods as follows:

platform :ios, '13.0'

use_frameworks!

target 'SomeTestingTarget' do
  pod 'SwiftHamcrest', '~> 2.2.1'
end

I can build and run my tests on a Simulator device no problem. However, when I try to build my testing target to run on a real device, I get an error as follows:

'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework/XCTest' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework/XCTest' for architecture arm64

The problem is that the ENABLE_BITCODE build setting for the SwiftHamcrest target in the Pods project resolves to Yes.

I'm aware that I can add a post_install hook in my Podfile which changes the ENABLE_BITCODE build setting for the SwiftHamcrest target to No, as follows:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if ['SwiftHamcrest'].include? target.name
      target.build_configurations.each do |config|
        config.build_settings['ENABLE_BITCODE'] = 'NO'
      end
    end
  end
end

However, this requires all consumers of SwiftHamcrest to modify their Podfile accordingly. It would nicer instead if the SwiftHamcrest.podspec file declared that bitcode is not enabled.

Ambiguous reference to `hasItems`

Im trying to create a function that roughly looks like this:
public static func createMatcher<T: Equatable, S: Sequence>(_ values: T...) -> Matcher<S> where T == S.Element { return hasItems(values) as Matcher<S> }
(the real one being more complex)

Issue is that given the definition of T above, hasItems become ambiguous. Making the argument label public would likely solve that.

Am I misunderstanding something?
Is there perhaps another way to resolve the ambiguity?

MacOS demo project does not compile

When trying to integrate SwiftHamcrest using Carthage, the cloned macOS demo project does not compile. Steps to reproduce:

  1. Create Carthfile exactly as the one described on your README.md at the bottom
  2. Run carthage update --platform macOS
  3. Open cloned project HamcrestDemo-macOS.xcodeproj in XCode 10.1 (XCode 10.2 complains of swift 3.x files and tells us to use 10.1 instead).
  4. Press <command>-U to build and run tests.

Expected result is successfully run tests
Actual result is the error: No such module 'Hamcrest'

Downcasting dictionary value

This is probably a Swift thing, but I don't get it:

let dic: [String: AnyObject] = ["some": "value", "another": 1]

assertThat(dic, hasEntry(equalTo("some"), instanceOfAnd(equalTo("value"))))
assertThat(dic, hasEntry(equalTo("another"), instanceOfAnd(equalTo(1))))

I'm getting runtime error

fatal error: can't unsafeBitCast between types of different sizes

even before iteration of the dictionary begins.

Same thing here:

let dic: [String: String] = ["some": "value", "another": "1"]

assertThat(dic, hasEntry(equalTo("some"), instanceOfAnd(equalTo("value"))))

podspec?

Cocoapods supports swift as of 0.36 beta. Could you add a podspec and submit it to the Cocoapods specs repository please?

Project doesnt compile with swift 3.0.1

Showing All Messages
CompileSwift normal x86_64 
                              _ 
/Users/projectlocation/Pods/SwiftHamcrest/Hamcrest/Hamcrest.swift:8:68: error: function types cannot have argument label 'line'; use '_' instead
public var HamcrestReportFunction: (_: String, file: StaticString, line: UInt) -> () = HamcrestDefaultReportFunction
                                                                   ^
                                                                   _ 
/Users/projectlocation/Pods/SwiftHamcrest/Hamcrest/ReflectionMatchers.swift:29:39: error: expected ',' joining parts of a multi-clause condition
        if let label = property.label where keyMatcher.matches(label) {
                                     ~^~~~~
                                     ,
/Users/projectlocation/Pods/SwiftHamcrest/Hamcrest/ArithmeticMatchers.swift:34:30: error: 'IntervalType' is unavailable: IntervalType has been removed in Swift 3. Use ranges instead.
public func inInterval<T, I: IntervalType where I.Bound == T>(expectedInterval: I) -> Matcher<T> {
                             ^~~~~~~~~~~~
/Users/projectlocation/Pods/SwiftHamcrest/Hamcrest/ArithmeticMatchers.swift:34:51: error: 'Bound' is not a member type of 'I'
public func inInterval<T, I: IntervalType where I.Bound == T>(expectedInterval: I) -> Matcher<T> {
                                                ~ ^
/Users/projectlocation/Pods/SwiftHamcrest/Hamcrest/MatchResult.swift:1:53: error: 'BooleanType' has been renamed to 'Bool'
public enum MatchResult: BooleanLiteralConvertible, BooleanType {
                                                    ^~~~~~~~~~~
                                                    Bool
/Users/projectlocation/Pods/SwiftHamcrest/Hamcrest/Matcher.swift:6:45: error: single argument function types require parentheses
    public init(_ description: String, _ f: T -> MatchResult) {
                                            ^
                                            ()
/Users/projectlocation/Pods/SwiftHamcrest/Hamcrest/Matcher.swift:11:45: error: single argument function types require parentheses
    public init(_ description: String, _ f: T -> Bool) {
                                            ^
                                            ()
/Users/projectlocation/Pods/SwiftHamcrest/Hamcrest/ArithmeticMatchers.swift:14:19: error: argument labels '(_:, _:)' do not match any available overloads
    let matcher = closeTo(Double(expectedValue), delta)
                  ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/projectlocation/Pods/SwiftHamcrest/Hamcrest/ArithmeticMatchers.swift:14:19: note: overloads for 'closeTo' exist with these partially matching parameter lists: (expectedValue: Double, Double), (expectedValue: Float, Double)
    let matcher = closeTo(Double(expectedValue), delta)
                  ^
/Users/projectlocation/Pods/SwiftHamcrest/Hamcrest/ArithmeticMatchers.swift:35:56: error: value of type 'I' has no member 'contains'
    return Matcher("in interval \(expectedInterval)") {expectedInterval.contains($0)}
                                                       ^~~~~~~~~~~~~~~~ ~~~~~~~~


Add 'reason' parameter to 'assertThat' function

Proposal

Add a reason optional parameter to the assertThat(value:matcher:file:line:) function to offer behaviour similar to the reason parameter in Java Hamcrest's assertThat function.

The reason parameter will allow the caller of the assertThat function to provide an additional, custom message to include in the test output in case the assertion fails.

Example

A call to assertThat(true, equalTo(false)) fails right now with a message:

failed - GOT: true, EXPECTED: equal to false

It would be great if I could call assertThat(true, equalTo(false), reason: "Custom error message") and see a failure message something like:

failed: Custom error message โ€“ GOT: true, EXPECTED: equal to false

Carthage fails with Xcode 8

Even if you are using a codebase that is still Swift 2.3, Apple added a switch you have to have in your project file.

Regexp matcher

Would be really nice to have a regular expression matcher for Strings

Matcher.matches not publically visiblie

I'm trying to do a mocking frameworks that extends the functionality of this project to also include things like hasBeenCalledWithArg<ARG1, ARG2>(expectedArg1: Matcher<ARG1>, expectedArg2: Matcher<ARG2>) but I can't since the Matcher.matches is in an internal scope. There seems to be a good function called delegateMatching in the Hamcrest.swift file but that one is also private. Could you please make at least one of them public?

Swift Compile Error: Variable binding in a condition requires an initializer

Lines 109 and 111 of the Hamcrest.swift file as it stands in the master branch presently result in a "Variable binding in a condition requires an initializer" Swift compile error when run in Xcode 13.4.1 (i.e. Swift 5.6.1) and older versions of Xcode.

I will change lines 109 to 111 from...

if let possibleResult {
    let result: String
    if let message {

... to...

if let possibleResult = possibleResult {
    let result: String
    if let message = message {

... for it to work in older versions of Swift.

I will create a pull request for this very shortly.

Signature of `anything()`

When I use anything() in my tests, the compiler sometimes is not able to infer the type of the matcher (e.g. when I use generic convenience methods that will have to pull out objects of an [Any] before checking the type and then applying the matcher).

This will lead to error messages like

Generic parameter W could not be inferred.

where W corresponds to the generic type of a matcher.

Shouldn't it be okay for anything() to return Matcher<Any> instead of Matcher<T>. The generic type T doesn't seem to be used anywhere and I wouldn't have to tell the compiler what to do by adding as Matcher<Any> to my code.

Error when importing with carthage

Here's the Cartfile
github "nschum/SwiftHamcrest"

When run carthage update, gives an error:

*** Fetching SwiftHamcrest
*** Checking out SwiftHamcrest at "0.4"
*** xcodebuild output can be found in /var/folders/2x/tfg2d79s39j768q724bnlj600000gp/T/carthage-xcodebuild.xW3YnS.log
*** Building scheme "Hamcrest iOS" in Hamcrest.xcworkspace
** BUILD FAILED **


The following build commands failed:
	Check dependencies
(1 failure)
warning: no umbrella header found for target 'Hamcrest', module map will not be generated
A shell task failed with exit code 65:
** BUILD FAILED **


The following build commands failed:
	Check dependencies
(1 failure)

Not sure if this is related, but in the log it has warning about umbrella header

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.