<commit_before>//
//  KvoTests.swift
//  SwiftRebound
//
//  Created by <NAME> on 15/07/2016.
//
//

import Foundation
import XCTest
@testable import SwiftRebound

private class Observable : NSObject {
    dynamic var someNumber = 0;
}

class KvoTests : XCTestCase {
    func testCanBindToObservableKeyPath() {
        let observable  = Observable();
        let binding     = observable.bindKeyPath("someNumber");
        
        var changeCount = 0;
        binding.observe { newValue in changeCount += 1 }.forever();
        
        XCTAssertEqual(1, changeCount);
        XCTAssertEqual(0, binding.value as? Int);
        
        observable.someNumber = 2;
        XCTAssertEqual(2, binding.value as? Int);
        XCTAssertEqual(2, changeCount);
    }<commit_msg>Add note about why XCode crashes on this test sometimes<commit_after>//
//  KvoTests.swift
//  SwiftRebound
//
//  Created by <NAME> on 15/07/2016.
//
//

import Foundation
import XCTest
@testable import SwiftRebound

private class Observable : NSObject {
    dynamic var someNumber = 0;
}

class KvoTests : XCTestCase {
    func testCanBindToObservableKeyPath() {
        let observable  = Observable();
        let binding     = observable.bindKeyPath("someNumber");
        
        var changeCount = 0;
        binding.observe { newValue in changeCount += 1 }.forever();
        
        XCTAssertEqual(1, changeCount);
        XCTAssertEqual(0, binding.value as? Int);
        
        observable.someNumber = 2;
        XCTAssertEqual(2, binding.value as? Int);
        XCTAssertEqual(2, changeCount);
        
        // Note: triggering the inconsistency exception here when built for release will crash XCode instead of failing the test
    }
{'fraction_non_alphanumeric': 0.09465737514518002, 'fraction_numerical': 0.018583042973286876, 'mean_word_length': 2.502032520325203, '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': '3845231', 'n_tokens_mistral': 532, 'n_tokens_neox': 496, 'n_words': 141}