<commit_before>//
//  CurryTests.swift
//  Currier
//
//  Created by Liam on 14/02/2017.
//  Copyright © 2017 Tigerpixel Ltd. All rights reserved.
//

import XCTest
@testable import Currier

class CurryTests: XCTestCase {
    
    struct ValueType {
        let value: Float
    }
    
    class ReferenceType {
        
        let value: Float
        
        init(value: Float) {
            self.value = value
        }
        
    }
    
    // MARK: Two parameters with basic types.
    
    func testTwoStringParams() {
        
        func twoStrings(first: String, second: String) -> String {
            return first + second
        }
        
        let curried = curry(twoStrings)
        let partiallyApplied = curried("first")
        let result = partiallyApplied("Second")
        
        XCTAssertEqual("firstSecond", result)
    }
    
    func testTwoIntParams() {
        
        func twoInts(first: Int, second: Int) -> Int {
            return first + second
        }
        
        let curried = curry(twoInts)
        let partiallyApplied = curried(3)
        let result = partiallyApplied(6)
        
        XCTAssertEqual(9, result)
    }
    
    // MARK: Two parameters intermediate types.
    
    func testTwoStructParams() {
        
        func twoStructs(first: ValueType, second: ValueType) -> ValueType {
            return ValueType(value:first.value + second.value)
        }
        
        let curried = curry(twoStructs)
        let partiallyApplied = curried(ValueType(value:3))
        let result = partiallyApplied(ValueType(value:6))
        
        XCTAssertEqual(9, result.value)
    }
    
    func testTwoRefTypeParams() {
        
        func twoReferenceTypes(first: ReferenceType, second: ReferenceType) -> ReferenceType {
            return ReferenceType(value:first.value + second.value)
        }
        
        let curried = curry(twoReferenceTypes)
        let partiallyApplied = curried(ReferenceType(value:3))
        let result = partiallyApplied(ReferenceType(value:6))
        
        XCTAssertEqual(9, result.value)
    }
    
    func testTwoGenericParams() {
        
        func twoGenerics<A: Comparable>(first: A, second: A) -> A {
            return first > second ? first : second
        }
        
        let result = curry(twoGenerics)("alpha")("beta")
        
        XCTAssertEqual("beta", result)
    }
    
    // MARK: Increasing numbers of parameters.
    <commit_msg>Added additional test for two parameters using an operator.<commit_after>//
//  CurryTests.swift
//  Currier
//
//  Created by Liam on 14/02/2017.
//  Copyright © 2017 Tigerpixel Ltd. All rights reserved.
//

import XCTest
@testable import Currier

class CurryTests: XCTestCase {
    
    struct ValueType {
        let value: Float
    }
    
    class ReferenceType {
        
        let value: Float
        
        init(value: Float) {
            self.value = value
        }
        
    }
    
    // MARK: Two parameters with basic types.
    
    func testTwoStringParams() {
        
        func twoStrings(first: String, second: String) -> String {
            return first + second
        }
        
        let curried = curry(twoStrings)
        let partiallyApplied = curried("first")
        let result = partiallyApplied("Second")
        
        XCTAssertEqual("firstSecond", result)
    }
    
    func testTwoIntParams() {
        
        func twoInts(first: Int, second: Int) -> Int {
            return first + second
        }
        
        let curried = curry(twoInts)
        let partiallyApplied = curried(3)
        let result = partiallyApplied(6)
        
        XCTAssertEqual(9, result)
    }
    
    // MARK: Two parameters intermediate types.
    
    func testTwoStructParams() {
        
        func twoStructs(first: ValueType, second: ValueType) -> ValueType {
            return ValueType(value:first.value + second.value)
        }
        
        let curried = curry(twoStructs)
        let partiallyApplied = curried(ValueType(value:3))
        let result = partiallyApplied(ValueType(value:6))
        
        XCTAssertEqual(9, result.value)
    }
    
    func testTwoRefTypeParams() {
        
        func twoReferenceTypes(first: ReferenceType, second: ReferenceType) -> ReferenceType {
            return ReferenceType(value:first.value + second.value)
        }
        
        let curried = curry(twoReferenceTypes)
        let partiallyApplied = curried(ReferenceType(value:3))
        let result = partiallyApplied(ReferenceType(value:6))
        
        XCTAssertEqual(9, result.value)
    }
    
    func testOperatorWithTwoParams() {
        
        let result = curry(*)(2)(3)
        XCTAssertEqual(6, result)
    }
    
    func testTwoGenericParams() {
        
        func twoGenerics<A: Comparable>(first: A, second: A) -> A {
            return first > second ? first : second
        }
        
        let result = curry(twoGenerics)("alpha")("beta")

        XCTAssertEqual("beta", result)
    }
    
    // MARK: Increasing numbers of parameters.
    
{'fraction_non_alphanumeric': 0.08978631640854734, 'fraction_numerical': 0.008821799647128014, 'mean_word_length': 1.812568908489526, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '789910', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1392, 'n_words': 337}