<commit_before>//
//  EditablePropertySpec.swift
//  EditableProperty
//
//  Created by <NAME> on 2015-05-01.
//  Copyright (c) 2015 ReactiveCocoa. All rights reserved.
//

import Nimble
import Quick
import EditableProperty
import ReactiveCocoa

typealias TestEditor = Editor<Int, NoError>

class EditablePropertySpec: QuickSpec {
	override func spec() {
		it("should do some binding magic") {
			let defaultValue = MutableProperty(0)

			let property = EditableProperty<Int, NoError>(defaultValue: defaultValue, editsTakePriority: false)
			expect(property.value).to(equal(defaultValue.value))

			let (editsProducer, editsSink) = SignalProducer<TestEditor.EditSession, NoError>.buffer(0)
			let editor = Editor(edits: editsProducer) { committed, proposed in
				return SignalProducer(value: max(committed.value, proposed))
			}

			property <~ editor

			defaultValue.value = 1
			expect(property.value).to(equal(defaultValue.value))

			let tryEdit: Int -> () = { proposed in
				let (editSignal, editSink) = TestEditor.EditSession.pipe()
				sendNext(editsSink, editSignal)
				expect(property.value).to(equal(defaultValue.value))

				sendNext(editSink, proposed)
				expect(property.value).to(equal(defaultValue.value))

				sendCompleted(editSink)
			}

			tryEdit(2)
			expect(property.value).to(equal(2))

			defaultValue.value = 3
			expect(property.value).to(equal(defaultValue.value))

			tryEdit(2)
			expect(property.value).to(equal(defaultValue.value))

			tryEdit(4)
			expect(property.value).to(equal(4))
		}
	}
}
<commit_msg>Fix the test spec as well<commit_after>//
//  EditablePropertySpec.swift
//  EditableProperty
//
//  Created by <NAME> on 2015-05-01.
//  Copyright (c) 2015 ReactiveCocoa. All rights reserved.
//

import Nimble
import Quick
import EditableProperty
import ReactiveCocoa

typealias TestEditor = Editor<Int, NoError>

class EditablePropertySpec: QuickSpec {
	override func spec() {
		it("should do some binding magic") {
			let defaultValue
            = MutableProperty(0)

			let property = EditableProperty<Int, NoError>(defaultValue: defaultValue, editsTakePriority: false)
			expect(property.value).to(equal(defaultValue.value))

			let (editsProducer, editsSink) = SignalProducer<TestEditor.EditSession, NoError>.buffer(0)
			let editor = Editor(edits: editsProducer) { committed, proposed in
				return SignalProducer(value: max(committed.value, proposed))
			}

			property <~ editor

			defaultValue.value = 1
			expect(property.value).to(equal(defaultValue.value))

			let tryEdit: Int -> () = { proposed in
				let (editSignal, editSink) = TestEditor.EditSession.pipe()
				editsSink.sendNext(editSignal)
				expect(property.value).to(equal(defaultValue.value))

				editSink.sendNext(proposed)
				expect(property.value).to(equal(defaultValue.value))

				editSink.sendCompleted()
			}

			tryEdit(2)
			expect(property.value).to(equal(2))

			defaultValue.value = 3
			expect(property.value).to(equal(defaultValue.value))

			tryEdit(2)
			expect(property.value).to(equal(defaultValue.value))

			tryEdit(4)
			expect(property.value).to(equal(4))
		}
	}
}

{'fraction_non_alphanumeric': 0.12061756191701511, 'fraction_numerical': 0.013509166934705693, 'mean_word_length': 4.334476843910807, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5519092', 'n_tokens_mistral': 1149, 'n_tokens_neox': 982, 'n_words': 193}