<commit_before>//
//  MenuBarTests.swift
//  PageController
//
//  Created by <NAME> on 6/29/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import XCTest
import PageController

class MenuBarTests: XCTestCase {

    override func setUp() {
        super.setUp()
    }

    override func tearDown() {
        super.tearDown()
    }

    func testReload() {

        var menuBar: MenuBar!
        var view: MenuCell!

        menuBar = MenuBar(frame: CGRectZero)
        menuBar.frame = CGRect(x: 0, y: 0, width: 300, height: 44)
        menuBar.items = ["1", "2", "3"]
        menuBar.reloadData()

        view = menuBar.scrollView.viewForCurrentPage() as! MenuCell
        XCTAssertEqual(view.index, 0, "is failed")

    }

    func testMoveMinus() {

        let expectation = expectationWithDescription("try move left to index")

        let menuBar = MenuBar(frame: CGRect(x: 0, y: 0, width: 300, height: 44))
        var items = [String]()
        for index in 0 ..< 5 {
            items.append(index.description)
        }
        menuBar.items = items

        menuBar.reloadData()
        menuBar.layoutIfNeeded()
        XCTAssertEqual(menuBar.selectedIndex, 0, "is failed.")
        menuBar.move(from: 0, until: 3)

        let after = 0.3 * Double(NSEC_PER_SEC)
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(after)), dispatch_get_main_queue()) {
            menuBar.layoutIfNeeded()
            XCTAssertEqual(menuBar.selectedIndex, 3, "is failed.")
            expectation.fulfill()
        }

        waitForExpectationsWithTimeout(10, handler: { error in
            if let _ = error {
                XCTAssertTrue(false, "expectations are still finished")
            }
        })
    }

    func testMovePlus() {

        let expectation = expectationWithDescription("try move right to index")

        let menuBar = MenuBar(frame: CGRect(x: 0, y: 0, width: 300, height: 44))
        var items = [String]()
        for index in 0 ..< 5 {
            items.append(index.description)
        }
        menuBar.items = items

        menuBar.reloadData()
        menuBar.layoutIfNeeded()
        XCTAssertEqual(menuBar.selectedIndex, 0, "is failed.")
        menuBar.move(from: 0, until: 3)

        let after = 0.3 * Double(NSEC_PER_SEC)
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(after)), dispatch_get_main_queue()) {
            menuBar.layoutIfNeeded()
            XCTAssertEqual(menuBar.selectedIndex, 3, "is failed.")
            expectation.fulfill()
        }

        waitForExpectationsWithTimeout(10, handler: { error in
            if let _ = error {
                XCTAssertTrue(false, "expectations are still finished")
            }
        })
    }
}<commit_msg>Fix compiler errors in UnitTest<commit_after>//
//  MenuBarTests.swift
//  PageController
//
//  Created by <NAME> on 6/29/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import XCTest
import PageController

class MenuBarTests: XCTestCase {

    override func setUp() {
        super.setUp()
    }

    override func tearDown() {
        super.tearDown()
    }

    func testReload() {

        var menuBar: MenuBar!
        var view: MenuCell!

        menuBar = MenuBar(frame: CGRectZero)
        menuBar.frame = CGRect(x: 0, y: 0, width: 300, height: 44)
        menuBar.items = ["1", "2", "3"]
        menuBar.reloadData(atIndex: 0)

        view = menuBar.scrollView.viewForCurrentPage() as! MenuCell
        XCTAssertEqual(view.index, 0, "is failed")

    }

    func testMoveMinus() {

        let expectation = expectationWithDescription("try move left to index")

        let menuBar = MenuBar(frame: CGRect(x: 0, y: 0, width: 300, height: 44))
        var items = [String]()
        for index in 0 ..< 5 {
            items.append(index.description)
        }
        menuBar.items = items

        menuBar.reloadData(atIndex: 0)
        menuBar.layoutIfNeeded()
        XCTAssertEqual(menuBar.selectedIndex, 0, "is failed.")
        menuBar.move(from: 0, until: 3)

        let after = 0.3 * Double(NSEC_PER_SEC)
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(after)), dispatch_get_main_queue()) {
            menuBar.layoutIfNeeded()
            XCTAssertEqual(menuBar.selectedIndex, 3, "is failed.")
            expectation.fulfill()
        }

        waitForExpectationsWithTimeout(10, handler: { error in
            if let _ = error {
                XCTAssertTrue(false, "expectations are still finished")
            }
        })
    }

    func testMovePlus() {

        let expectation = expectationWithDescription("try move right to index")

        let menuBar = MenuBar(frame: CGRect(x: 0, y: 0, width: 300, height: 44))
        var items = [String]()
        for index in 0 ..< 5 {
            items.append(index.description)
        }
        menuBar.items = items

        menuBar.reloadData(atIndex: 0)
        menuBar.layoutIfNeeded()
        XCTAssertEqual(menuBar.selectedIndex, 0, "is failed.")
        menuBar.move(from: 0, until: 3)

        let after = 0.3 * Double(NSEC_PER_SEC)
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(after)), dispatch_get_main_queue()) {
            menuBar.layoutIfNeeded()
            XCTAssertEqual(menuBar.selectedIndex, 3, "is failed.")
            expectation.fulfill()
        }

        waitForExpectationsWithTimeout(10, handler: { error in
            if let _ = error {
                XCTAssertTrue(false, "expectations are still finished")
            }
        })
    }
}
{'fraction_non_alphanumeric': 0.10961123110151189, 'fraction_numerical': 0.021418286537077034, 'mean_word_length': 2.1754285714285713, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '3383756', 'n_tokens_mistral': 1806, 'n_tokens_neox': 1655, 'n_words': 401}