<commit_before>//
//  GuiseTests.swift
//  Guise
//
//  Created by <NAME> on 3/12/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import XCTest
@testable import Guise

class GuiseKeyTests: XCTestCase {
    
    override func tearDown() {
        Guise.clear()
        super.tearDown()
    }
    
    // MARK: Keys
    
    func testFailableKeyConversion() {
        let untypedKey = AnyKey(type: String.self)
        XCTAssertNil(Key<Int>(untypedKey))
    }
    
    func testKeyEqualityForTypedKeys() {
        /*
         Note that for typed keys, the keys must hold the same type, in this case `String.self`.
         This is enforced by the compiler.
         */
        let key1 = Key<String>(name: "Ludwig von Mises")
        let key2 = Key<String>(name: "Murray Rothbard")
        XCTAssertNotEqual(key1, key2)
        let key3 = Key<String>(name: "Ludwig von Mises")
        XCTAssertEqual(key1, key3)
    }
    
    func testKeyEqualityForUntypedKeys() {
        let key1 = AnyKey(type: String.self, name: "Ludwig von Mises")
        let key2 = AnyKey(type: Int.self, name: "Murray Rothbard")
        XCTAssertNotEqual(key1, key2)
        let key3 = AnyKey(type: Int.self, name: "Murray Rothbard")
        XCTAssertEqual(key2, key3)
    }
    
    func testRegistrationOverwritesPreviousRegistrationWithEqualKey() {
        let shpong = "shpong"
        let key1 = Guise.register(factory: Plink(thibb: shpong))
        let plink1 = Guise.resolve(type: Plink.self)!<commit_msg>untypedKey -> typeErasedKey<commit_after>//
//  GuiseTests.swift
//  Guise
//
//  Created by <NAME> on 3/12/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import XCTest
@testable import Guise

class GuiseKeyTests: XCTestCase {
    
    override func tearDown() {
        Guise.clear()
        super.tearDown()
    }
    
    // MARK: Keys
    
    func testFailableKeyConversion() {
        let typeErasedKey = AnyKey(type: String.self)
        // This fails because Int != String.
        XCTAssertNil(Key<Int>(typeErasedKey))
    }
    
    func testKeyEqualityForTypedKeys() {
        /*
         Note that for typed keys, the keys must hold the same type, in this case `String.self`.
         This is enforced by the compiler.
         */
        let key1 = Key<String>(name: "<NAME>")
        let key2 = Key<String>(name: "<NAME>")
        XCTAssertNotEqual(key1, key2)
        let key3 = Key<String>(name: "Ludwig von Mises")
        XCTAssertEqual(key1, key3)
    }
    
    func testKeyEqualityForUntypedKeys() {
        let key1 = AnyKey(type: String.self, name: "<NAME>")
        let key2 = AnyKey(type: Int.self, name: "<NAME>")
        XCTAssertNotEqual(key1, key2)
        let key3 = AnyKey(type: Int.self, name: "<NAME>")
        XCTAssertEqual(key2, key3)
    }
    
    func testRegistrationOverwritesPreviousRegistrationWithEqualKey() {
        let shpong = "shpong"
        let key1 = Guise.register(factory: Plink(thibb: shpong))
        let plink1 = Guise.resolve(type: Plink.self)!
{'fraction_non_alphanumeric': 0.11336436170212766, 'fraction_numerical': 0.016622340425531915, 'mean_word_length': 2.4, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 21, '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': '2949964', 'n_tokens_mistral': 1022, 'n_tokens_neox': 996, 'n_words': 246}