<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: "json")!

		it("should parse a JSON Cartfile") {
			let result: Result<Cartfile> = parseJSONAtURL(testCartfileURL)
			expect(result.error()).to(beNil())

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

			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.Exactly(Version(major: 2, minor: 3, patch: 1))))

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

			let depBuildScripts = cartfile.dependencies[2]
			expect(depBuildScripts.repository.owner).to(equal("jspahrsummers"))
			expect(depBuildScripts.repository.name).to(equal("objc-build-scripts"))
			expect(depBuildScripts.version).to(equal(VersionSpecifier.Any))
		}
	}
}<commit_msg>Add tests for version ordering<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: "json")!

		it("should parse a JSON Cartfile") {
			let result: Result<Cartfile> = parseJSONAtURL(testCartfileURL)
			expect(result.error()).to(beNil())

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

			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.Exactly(Version(major: 2, minor: 3, patch: 1))))

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

			let depBuildScripts = cartfile.dependencies[2]
			expect(depBuildScripts.repository.owner).to(equal("jspahrsummers"))
			expect(depBuildScripts.repository.name).to(equal("objc-build-scripts"))
			expect(depBuildScripts.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)))
        }
    }
}
{'fraction_non_alphanumeric': 0.14033680834001605, 'fraction_numerical': 0.017375033413525795, 'mean_word_length': 4.730474732006126, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3085615', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1199, 'n_words': 216}