<commit_before>//
//  CartfileSpec.swift
//  Carthage
//
//  Created by <NAME> on 2014-10-10.
//  Copyright (c) 2014 Carthage. All rights reserved.
//

import CarthageKit
import Foundation
import LlamaKit
import Nimble
import Quick

class CartfileSpec: QuickSpec {
	override func spec() {
		let testCartfileURL = NSBundle(forClass: self.dynamicType).URLForResource("TestCartfile", withExtension: "")!

		it("should parse a Cartfile") {
			let testCartfile = NSString(contentsOfURL: testCartfileURL, encoding: NSUTF8StringEncoding, error: nil)

			let result = Cartfile.fromString(testCartfile!)
			expect(result.error()).to(beNil())

			let cartfile = result.value()!
			expect(cartfile.dependencies.count).to(equal(4))

			let depReactiveCocoa = cartfile.dependencies[0]
			expect(depReactiveCocoa.repository.name).to(equal("ReactiveCocoa"))
			expect(depReactiveCocoa.repository.owner).to(equal("ReactiveCocoa"))
			expect(depReactiveCocoa.version).to(equal(VersionSpecifier.AtLeast(Version(major: 2, minor: 3, patch: 1))))

			let depMantle = cartfile.dependencies[1]
			expect(depMantle.repository.name).to(equal("Mantle"))
			expect(depMantle.repository.owner).to(equal("Mantle"))
			expect(depMantle.version).to(equal(VersionSpecifier.CompatibleWith(Version(major: 1, minor: 0, patch: 0))))

			let depLibextobjc = cartfile.dependencies[2]
			expect(depLibextobjc.repository.owner).to(equal("jspahrsummers"))
			expect(depLibextobjc.repository.name).to(equal("libextobjc"))
			expect(depLibextobjc.version).to(equal(VersionSpecifier.Exactly(Version(major: 0, minor: 4, patch: 1))))

			let depConfigs = cartfile.dependencies[3]
			expect(depConfigs.repository.owner).to(equal("jspahrsummers"))
			expect(depConfigs.repository.name).to(equal("xcconfigs"))
			expect(depConfigs.version).to(equal(VersionSpecifier.Any))
		}
	}
}

class VersionSpec: QuickSpec {
	override func spec() {
		it("should order versions correctly") {
			let version = Version(major: 2, minor: 1, patch: 1)

			expect(version).to(beLessThan(Version(major: 3, minor: 0, patch: 0)))
			expect(version).to(beLessThan(Version(major: 2, minor: 2, patch: 0)))
			expect(version).to(beLessThan(Version(major: 2, minor: 1, patch: 2)))

			expect(version).to(beGreaterThan(Version(major: 1, minor: 2, patch: 2)))
			expect(version).to(beGreaterThan(Version(major: 2, minor: 0, patch: 2)))
			expect(version).to(beGreaterThan(Version(major: 2, minor: 1, patch: 0)))

			expect(version).to(beLessThan(Version(major: 10, minor: 0, patch: 0)))
			expect(version).to(beLessThan(Version(major: 2, minor: 10, patch: 1)))
			expect(version).to(beLessThan(Version(major: 2, minor: 1, patch: 10)))
		}
	}
}<commit_msg>Start VersionSpecifierSpec<commit_after>//
//  CartfileSpec.swift
//  Carthage
//
//  Created by <NAME> on 2014-10-10.
//  Copyright (c) 2014 Carthage. All rights reserved.
//

import CarthageKit
import Foundation
import LlamaKit
import Nimble
import Quick

class CartfileSpec: QuickSpec {
	override func spec() {
		let testCartfileURL = NSBundle(forClass: self.dynamicType).URLForResource("TestCartfile", withExtension: "")!

		it("should parse a Cartfile") {
			let testCartfile = NSString(contentsOfURL: testCartfileURL, encoding: NSUTF8StringEncoding, error: nil)

			let result = Cartfile.fromString(testCartfile!)
			expect(result.error()).to(beNil())

			let cartfile = result.value()!
			expect(cartfile.dependencies.count).to(equal(4))

			let depReactiveCocoa = cartfile.dependencies[0]
			expect(depReactiveCocoa.repository.name).to(equal("ReactiveCocoa"))
			expect(depReactiveCocoa.repository.owner).to(equal("ReactiveCocoa"))
			expect(depReactiveCocoa.version).to(equal(VersionSpecifier.AtLeast(Version(major: 2, minor: 3, patch: 1))))

			let depMantle = cartfile.dependencies[1]
			expect(depMantle.repository.name).to(equal("Mantle"))
			expect(depMantle.repository.owner).to(equal("Mantle"))
			expect(depMantle.version).to(equal(VersionSpecifier.CompatibleWith(Version(major: 1, minor: 0, patch: 0))))

			let depLibextobjc = cartfile.dependencies[2]
			expect(depLibextobjc.repository.owner).to(equal("jspahrsummers"))
			expect(depLibextobjc.repository.name).to(equal("libextobjc"))
			expect(depLibextobjc.version).to(equal(VersionSpecifier.Exactly(Version(major: 0, minor: 4, patch: 1))))

			let depConfigs = cartfile.dependencies[3]
			expect(depConfigs.repository.owner).to(equal("jspahrsummers"))
			expect(depConfigs.repository.name).to(equal("xcconfigs"))
			expect(depConfigs.version).to(equal(VersionSpecifier.Any))
		}
	}
}

class VersionSpec: QuickSpec {
	override func spec() {
		it("should order versions correctly") {
			let version = Version(major: 2, minor: 1, patch: 1)

			expect(version).to(beLessThan(Version(major: 3, minor: 0, patch: 0)))
			expect(version).to(beLessThan(Version(major: 2, minor: 2, patch: 0)))
			expect(version).to(beLessThan(Version(major: 2, minor: 1, patch: 2)))

			expect(version).to(beGreaterThan(Version(major: 1, minor: 2, patch: 2)))
			expect(version).to(beGreaterThan(Version(major: 2, minor: 0, patch: 2)))
			expect(version).to(beGreaterThan(Version(major: 2, minor: 1, patch: 0)))

			expect(version).to(beLessThan(Version(major: 10, minor: 0, patch: 0)))
			expect(version).to(beLessThan(Version(major: 2, minor: 10, patch: 1)))
			expect(version).to(beLessThan(Version(major: 2, minor: 1, patch: 10)))
		}
	}
}

class VersionSpecifierSpec: QuickSpec {
	override func spec() {
		it("should intersect version specifiers correctly") {
			let versionOne = Version(major: 1, minor: 3, patch: 2)
			let versionTwoOne = Version(major: 2, minor: 1, patch: 1)
			let versionTwoTwo = Version(major: 2, minor: 2, patch: 0)

			func testIntersection(lhs: VersionSpecifier, rhs: VersionSpecifier, #expected: VersionSpecifier) {
				expect(intersection(lhs, rhs)).to(equal(expected))
				expect(intersection(rhs, lhs)).to(equal(expected))
			}

			testIntersection(VersionSpecifier.Any, VersionSpecifier.Any, expected: VersionSpecifier.Any)
			testIntersection(VersionSpecifier.Any, VersionSpecifier.AtLeast(versionOne), expected: VersionSpecifier.AtLeast(versionOne))
			testIntersection(VersionSpecifier.Any, VersionSpecifier.CompatibleWith(versionOne), expected: VersionSpecifier.CompatibleWith(versionOne))
			testIntersection(VersionSpecifier.Any, VersionSpecifier.Exactly(versionOne), expected: VersionSpecifier.Exactly(versionOne))
		}
	}
}
{'fraction_non_alphanumeric': 0.14444444444444443, 'fraction_numerical': 0.020187793427230045, 'mean_word_length': 5.909189189189189, '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': '5089643', 'n_tokens_mistral': 2414, 'n_tokens_neox': 2099, 'n_words': 397}