<commit_before>//
//  Contain.swift
//  Quick
//
//  Created by <NAME> on 6/7/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Foundation

class Contain: Matcher {
    override func failureMessage(actual: NSObject?) -> String {
        return "expected '\(_flatten(actual))' to contain '\(expected)'"
    }

    override func negativeFailureMessage(actual: NSObject?) -> String {
        return "expected '\(_flatten(actual))' to not contain '\(expected)'"
    }

    override func match(actual: NSObject?) -> Bool {
        if let array = actual as? NSArray {
            return array.containsObject(expected)
        } else if let set = actual as? NSSet {
            return set.containsObject(expected)
        } else if let string = actual as? NSString {
            if let substring = expected as? NSString {
                return string.rangeOfString(substring).location != NSNotFound
            } else {
                return false
            }
        } else {
            return false
        }
    }

    func _flatten(collection: NSObject?) -> String {
        if let array = collection as? NSArray {
            return "[ " + array.componentsJoinedByString(", ") + " ]"
        } else if let set = collection as? NSSet {
            let array = set.allObjects as NSArray
            return "[ " + array.componentsJoinedByString(", ") + " ]"
        } else {
            return "\(collection)"
        }
    }
}

extension Prediction {
    func contain(expected: NSObject?) {
        evaluate(Contain(expected))
    }
}
<commit_msg>Use switch-case statement in Contain Matcher<commit_after>//
//  Contain.swift
//  Quick
//
//  Created by <NAME> on 6/7/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

import Foundation

class Contain: Matcher {
    override func failureMessage(actual: NSObject?) -> String {
        return "expected '\(_flatten(actual))' to contain '\(expected)'"
    }

    override func negativeFailureMessage(actual: NSObject?) -> String {
        return "expected '\(_flatten(actual))' to not contain '\(expected)'"
    }

    override func match(actual: NSObject?) -> Bool {
        if let x = actual {
            switch x {
            case let array as NSArray:
                return array.containsObject(expected)
            case let set as NSSet:
                return set.containsObject(expected)
            case let string as NSString:
                if let substring = expected as? NSString {
                    return string.rangeOfString(substring).location != NSNotFound
                }
            default:
                break
            }
        }

        return false
    }

    func _flatten(collection: NSObject?) -> String {
        func stringFrom(array: NSArray) -> String {
            return "[ " + array.componentsJoinedByString(", ") + " ]"
        }

        if let x = collection {
            switch x {
            case let array as NSArray: return stringFrom(array)
            case let set as NSSet: return stringFrom(set.allObjects)
            default: break
            }
        }

        return "\(collection)"
    }
}

extension Prediction {
    func contain(expected: NSObject?) {
        evaluate(Contain(expected))
    }
}

{'fraction_non_alphanumeric': 0.10792476102374345, 'fraction_numerical': 0.004933703361085414, 'mean_word_length': 1.8912655971479502, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1540728', 'n_tokens_mistral': 886, 'n_tokens_neox': 848, 'n_words': 253}