<commit_before>//
//  WeekdayTests.swift
//  SwiftCron
//
//  Created by <NAME> on 2016/05/06.
//  Copyright © 2016 Rush42. All rights reserved.
//

import XCTest
import SwiftCron

class WeekdayTests: 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 testEveryWeekOnMonday() {
		let calendar = Calendar.current
		let dateToTestFrom = TestData.may11
		let nextMonday = TestData.may16

		let everyMondayCron = CronExpression(minute: "0", hour: "0", weekday: "1")
		let nextRunDate = everyMondayCron?.getNextRunDate(dateToTestFrom)

		XCTAssertTrue(calendar.isDate(nextMonday, inSameDayAs: nextRunDate!))
	}

	func testEveryWeekday() {
		let calendar = Calendar.current
		let weekendDateToTestFrom = TestData.may14
		let nextMonday = TestData.may16

		let everyWeekdayCron = CronExpression(cronString: "0 0 * * 1,2,3,4,5 *")
		let nextRunDateFromWeekend = everyWeekdayCron?.getNextRunDate(weekendDateToTestFrom)

		XCTAssertTrue(calendar.isDate(nextMonday, inSameDayAs: nextRunDateFromWeekend!))

		var wednesday = TestData.may11
		// Add a minute to ensure we're not at midnight to prevent a match for wednesday
		wednesday = (calendar as NSCalendar).date(byAdding: .minute, value: 1, to: wednesday, options: [])!
		let thursday = TestData.may12
		let nextRunDateFromWednesday = everyWeekdayCron?.getNextRunDate(wednesday)
		XCTAssertTrue(calendar.isDate(thursday, inSameDayAs: nextRunDateFromWednesday!))
	}

}<commit_msg>Add test for last weekday (L)<commit_after>//
//  WeekdayTests.swift
//  SwiftCron
//
//  Created by <NAME> on 2016/05/06.
//  Copyright © 2016 Rush42. All rights reserved.
//

import XCTest
import SwiftCron

class WeekdayTests: 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 testEveryWeekOnMonday() {
		let calendar = Calendar.current
		let dateToTestFrom = TestData.may11
		let nextMonday = TestData.may16

		let everyMondayCron = CronExpression(minute: "0", hour: "0", weekday: "1")
		let nextRunDate = everyMondayCron?.getNextRunDate(dateToTestFrom)

		XCTAssertTrue(calendar.isDate(nextMonday, inSameDayAs: nextRunDate!))
	}

	func testEveryWeekday() {
		let calendar = Calendar.current
		let weekendDateToTestFrom = TestData.may14
		let nextMonday = TestData.may16

		let everyWeekdayCron = CronExpression(cronString: "0 0 * * 1,2,3,4,5 *")
		let nextRunDateFromWeekend = everyWeekdayCron?.getNextRunDate(weekendDateToTestFrom)

		XCTAssertTrue(calendar.isDate(nextMonday, inSameDayAs: nextRunDateFromWeekend!))

		var wednesday = TestData.may11
		// Add a minute to ensure we're not at midnight to prevent a match for wednesday
		wednesday = (calendar as NSCalendar).date(byAdding: .minute, value: 1, to: wednesday, options: [])!
		let thursday = TestData.may12
		let nextRunDateFromWednesday = everyWeekdayCron?.getNextRunDate(wednesday)
		XCTAssertTrue(calendar.isDate(thursday, inSameDayAs: nextRunDateFromWednesday!))
	}
    
    func testGetNextDateForL() {
        let dateToTestFrom = TestData.july11_2016
        let cronExpression = CronExpression(minute: "0", hour: "0", day: "1", weekday: "3L")!
        
        let lastWednesdayOfMonth = TestData.july27_2016
        let nextRunDate = cronExpression.getNextRunDate(dateToTestFrom)!
        
        XCTAssertTrue(Calendar.current.isDate(lastWednesdayOfMonth, inSameDayAs: nextRunDate))
    }

}
{'fraction_non_alphanumeric': 0.09479166666666666, 'fraction_numerical': 0.0234375, 'mean_word_length': 4.3495821727019495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4035448', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1228, 'n_words': 331}