<commit_before>//
//  PSDSListTests.swift
//  PurelySwiftDS
//
//  Created by <NAME> on 6/25/14.
//  Copyright (c) 2014 <EMAIL>. All rights reserved.
//

import XCTest
import PurelySwiftDS

class PSDSListTests: XCTestCase {
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }

    func testEmpty1() {
        var empty: List<Int> = List.empty();
        XCTAssert(empty.isEmpty(), "Expected isEmpty. empty = \(empty)")
    }
    
    func testEmpty2() {
        var emptyA: List<String> = List.empty();
        var emptyB: List<String> = List.empty();

        XCTAssertEqual(emptyA, emptyB, "Expected two empty instances to be equal")
    }
    
    func testCons1() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 1 =+= List.empty()
        XCTAssertEqual(list1, list2, "Expected identically constructed lists to be equal");
    }
    
    func testCons2() {
        var list1: List<Int> = 1 =+= 2 =+= List.empty()
        var list2: List<Int> = 1 =+= 2 =+= List.empty()
        XCTAssertEqual(list1, list2, "Expected identically constructed lists to be equal");
    }
    
    func testCons3() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 2 =+= List.empty()
        XCTAssertNotEqual(list1, list2, "Expected differently constructed lists to be equal");
    }
    
    func testCons4() {
        var list1: List<Int> = 2 =+= 1 =+= List.empty()
        var list2: List<Int> = 1 =+= 2 =+= List.empty()
        XCTAssertNotEqual(list1, list2, "Expected differently constructed lists to be equal");
    }
    
    func testCons5() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 1 =+= 2 =+= List.empty()
        XCTAssertNotEqual(list1, list2, "Expected differently constructed lists to be equal");
    }

    func testTail1() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 2 =+= 1 =+= List.empty() // fresh list
        XCTAssertEqual(list1, list2.tail, "Expected cons followed by tail to be equal to original");
    }
    
    func testTail2() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 2 =+= list1 // cons-ing onto existing list
        XCTAssertEqual(list1, list2.tail, "Expected cons followed by tail to be equal to original");
    }
    
    /*
    // CCC, 6/26/2014. Swift doesn't currently support any form of exception handling, so this test case doesn't transfer from the Objective-C version. Taking the tail of the empty list throws a run-time error.
    func testTail3() {
        var list1: List<Int> = List.empty()
        XCTAssertThrows(list1.tail, "Can't take the tail of an empty list");
    }
    */
    <commit_msg>Added test cases for List.head.<commit_after>//
//  PSDSListTests.swift
//  PurelySwiftDS
//
//  Created by <NAME> on 6/25/14.
//  Copyright (c) 2014 <EMAIL>. All rights reserved.
//

import XCTest
import PurelySwiftDS

class PSDSListTests: XCTestCase {
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }

    func testEmpty1() {
        var empty: List<Int> = List.empty();
        XCTAssert(empty.isEmpty(), "Expected isEmpty. empty = \(empty)")
    }
    
    func testEmpty2() {
        var emptyA: List<String> = List.empty();
        var emptyB: List<String> = List.empty();

        XCTAssertEqual(emptyA, emptyB, "Expected two empty instances to be equal")
    }
    
    func testCons1() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 1 =+= List.empty()
        XCTAssertEqual(list1, list2, "Expected identically constructed lists to be equal");
    }
    
    func testCons2() {
        var list1: List<Int> = 1 =+= 2 =+= List.empty()
        var list2: List<Int> = 1 =+= 2 =+= List.empty()
        XCTAssertEqual(list1, list2, "Expected identically constructed lists to be equal");
    }
    
    func testCons3() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 2 =+= List.empty()
        XCTAssertNotEqual(list1, list2, "Expected differently constructed lists to be equal");
    }
    
    func testCons4() {
        var list1: List<Int> = 2 =+= 1 =+= List.empty()
        var list2: List<Int> = 1 =+= 2 =+= List.empty()
        XCTAssertNotEqual(list1, list2, "Expected differently constructed lists to be equal");
    }
    
    func testCons5() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 1 =+= 2 =+= List.empty()
        XCTAssertNotEqual(list1, list2, "Expected differently constructed lists to be equal");
    }

    func testTail1() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 2 =+= 1 =+= List.empty() // fresh list
        XCTAssertEqual(list1, list2.tail, "Expected cons followed by tail to be equal to original");
    }
    
    func testTail2() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 2 =+= list1 // cons-ing onto existing list
        XCTAssertEqual(list1, list2.tail, "Expected cons followed by tail to be equal to original");
    }
    
    // CCC, 6/26/2014. Swift doesn't currently support any form of exception handling, so this test case doesn't transfer from the Objective-C version.
    //    func testTail3() {
    //        var list1: List<Int> = List.empty()
    //        XCTAssertThrows(list1.tail, "Can't take the tail of an empty list");
    //    }
    
    func testHead1() {
        var list1: List<Int> = 1 =+= List.empty()
        var list2: List<Int> = 2 =+= 1 =+= List.empty()
        XCTAssertNotEqual(list1.head, list2.head)
        XCTAssertEqual(list1.head, list2.tail.head);
    }

    // CCC, 6/26/2014. Swift doesn't currently support any form of exception handling, so this test case doesn't transfer from the Objective-C version.
    //    func testHead2() {
    //        var empty: List<Int> = List.empty()
    //        XCTAssertThrows(empty.head, "Can't take the head of an empty list");
    //    }

{'fraction_non_alphanumeric': 0.12799389778794812, 'fraction_numerical': 0.02623951182303585, 'mean_word_length': 2.393374741200828, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 46, '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': '6197181', 'n_tokens_mistral': 2154, 'n_tokens_neox': 2036, 'n_words': 662}