<commit_before>//
//  NibTests.swift
//  Mechanica
//
//  Copyright © 2016-2017 Tinrobots.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import XCTest
@testable import Mechanica

extension Nib: NibKeyCodable {

  public enum NibName : String {
    case iOS    = "iOS_NibDemo"
    case tvOS   = "tvOS_NibDemo"
    case macOS  = "macOS_NibDemo"
  }

}

#if os(iOS)

  import UIKit
  
  class iOS_NibDemo_View_1: UIView {}
  class iOS_NibDemo_View_2: UIView {}

  /// UILongPressGestureRecognizer is now nib loadable.
  extension UILongPressGestureRecognizer: NibLoadable {}

#elseif os(tvOS)

  import UIKit
  class tvOS_NibDemo_View_1: UIView {}
  class tvOS_NibDemo_View_2: UIView {}

#elseif os(macOS)

  import Cocoa

  class macOS_NibDemo_View_1: NSView {
    override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) }
  }

  class macOS_NibDemo_View_2: NSView {
    override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) }
  }

  /// NSTouchBar is now nib loadable.
  @available(OSX 10.12.2, *)
  extension NSTouchBar : NibLoadable {}
  
#endif


class NibTests: XCTestCase {

  lazy var unitTestBundle: Bundle =  { return Bundle(for: type(of: self)) }()

  func test_instantiate() {

    #if os(iOS)

      let nib = Nib.nib(forKey: .iOS, bundle: unitTestBundle)
      XCTAssertNotNil(nib)

      do {
        let view1 = nib.instantiate() as iOS_NibDemo_View_1
        XCTAssertNotNil(view1)
      }
      do {
        let view1: iOS_NibDemo_View_1 = nib.instantiate()
        XCTAssertNotNil(view1)
      }
      do {
        let view2 = nib.instantiate() as iOS_NibDemo_View_2
        XCTAssertNotNil(view2)
      }
      do {
        let view2: iOS_NibDemo_View_2 = nib.instantiate()
        XCTAssertNotNil(view2)
      }
      do {
        let gesture = nib.instantiate() as UILongPressGestureRecognizer
        XCTAssertNotNil(gesture)
      }
      do {
        let gesture: UILongPressGestureRecognizer = nib.instantiate()
        XCTAssertNotNil(gesture)
      }

    #elseif os(tvOS)

      let nib = Nib.nib(forKey: .tvOS, bundle: unitTestBundle)
      XCTAssertNotNil(nib)

      do {
        let view1 = nib.instantiate() as tvOS_NibDemo_View_1
        XCTAssertNotNil(view1)
      }
      do {
        let view1: tvOS_NibDemo_View_1 = nib.instantiate()
        XCTAssertNotNil(view1)
      }
      do {
        let view2 = nib.instantiate() as tvOS_NibDemo_View_2
        XCTAssertNotNil(view2)
      }
      do {
        let view2: tvOS_NibDemo_View_2 = nib.instantiate()
        XCTAssertNotNil(view2)
      }

    #elseif os(macOS)

      let nib = Nib.nib(forKey: .macOS, bundle: unitTestBundle)
      XCTAssertNotNil(nib)

      do {
        let view1 = nib.instantiate() as macOS_NibDemo_View_1
        XCTAssertNotNil(view1)
      }
      do {
        let view1: macOS_NibDemo_View_1 = nib.instantiate()
        XCTAssertNotNil(view1)
      }
      do {
        let view2 = nib.instantiate() as macOS_NibDemo_View_2
        XCTAssertNotNil(view2)
      }
      do {
        let view2: macOS_NibDemo_View_2 = nib.instantiate()
        XCTAssertNotNil(view2)
      }
      do{
        if #available(OSX 10.12.2, *) {
          let touchBar = nib.instantiate() as NSTouchBar
          XCTAssertNotNil(touchBar)
        }
      }
      do{
        if #available(OSX 10.12.2, *) {
          let touchBar: NSTouchBar = nib.instantiate()
          XCTAssertNotNil(touchBar)
        }
      }
      
    #endif
    
  }
  
}
<commit_msg>cleaning<commit_after>//
//  NibTests.swift
//  Mechanica
//
//  Copyright © 2016-2017 Tinrobots.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import XCTest
@testable import Mechanica

extension Nib: NibKeyCodable {

  public enum NibName : String {
    case iOS    = "iOS_NibDemo"
    case tvOS   = "tvOS_NibDemo"
    case macOS  = "macOS_NibDemo"
  }

}

#if os(iOS)

  import UIKit
  class iOS_NibDemo_View_1: UIView {}
  class iOS_NibDemo_View_2: UIView {}
  /// UILongPressGestureRecognizer is now nib loadable.
  extension UILongPressGestureRecognizer: NibLoadable {}

#elseif os(tvOS)

  import UIKit
  class tvOS_NibDemo_View_1: UIView {}
  class tvOS_NibDemo_View_2: UIView {}

#elseif os(macOS)

  import Cocoa
  class macOS_NibDemo_View_1: NSView {}
  class macOS_NibDemo_View_2: NSView {}
  /// NSTouchBar is now nib loadable.
  @available(OSX 10.12.2, *)
  extension NSTouchBar : NibLoadable {}
  
#endif


class NibTests: XCTestCase {

  lazy var unitTestBundle: Bundle =  { return Bundle(for: type(of: self)) }()

  func test_instantiate() {

    #if os(iOS)

      let nib = Nib.nib(forKey: .iOS, bundle: unitTestBundle)
      XCTAssertNotNil(nib)

      do {
        let view1 = nib.instantiate() as iOS_NibDemo_View_1
        XCTAssertNotNil(view1)
      }
      do {
        let view1: iOS_NibDemo_View_1 = nib.instantiate()
        XCTAssertNotNil(view1)
      }
      do {
        let view2 = nib.instantiate() as iOS_NibDemo_View_2
        XCTAssertNotNil(view2)
      }
      do {
        let view2: iOS_NibDemo_View_2 = nib.instantiate()
        XCTAssertNotNil(view2)
      }
      do {
        let gesture = nib.instantiate() as UILongPressGestureRecognizer
        XCTAssertNotNil(gesture)
      }
      do {
        let gesture: UILongPressGestureRecognizer = nib.instantiate()
        XCTAssertNotNil(gesture)
      }

    #elseif os(tvOS)

      let nib = Nib.nib(forKey: .tvOS, bundle: unitTestBundle)
      XCTAssertNotNil(nib)

      do {
        let view1 = nib.instantiate() as tvOS_NibDemo_View_1
        XCTAssertNotNil(view1)
      }
      do {
        let view1: tvOS_NibDemo_View_1 = nib.instantiate()
        XCTAssertNotNil(view1)
      }
      do {
        let view2 = nib.instantiate() as tvOS_NibDemo_View_2
        XCTAssertNotNil(view2)
      }
      do {
        let view2: tvOS_NibDemo_View_2 = nib.instantiate()
        XCTAssertNotNil(view2)
      }

    #elseif os(macOS)

      let nib = Nib.nib(forKey: .macOS, bundle: unitTestBundle)
      XCTAssertNotNil(nib)

      do {
        let view1 = nib.instantiate() as macOS_NibDemo_View_1
        XCTAssertNotNil(view1)
      }
      do {
        let view1: macOS_NibDemo_View_1 = nib.instantiate()
        XCTAssertNotNil(view1)
      }
      do {
        let view2 = nib.instantiate() as macOS_NibDemo_View_2
        XCTAssertNotNil(view2)
      }
      do {
        let view2: macOS_NibDemo_View_2 = nib.instantiate()
        XCTAssertNotNil(view2)
      }
      do{
        if #available(OSX 10.12.2, *) {
          let touchBar = nib.instantiate() as NSTouchBar
          XCTAssertNotNil(touchBar)
        }
      }
      do{
        if #available(OSX 10.12.2, *) {
          let touchBar: NSTouchBar = nib.instantiate()
          XCTAssertNotNil(touchBar)
        }
      }
      
    #endif
    
  }
  
}

{'fraction_non_alphanumeric': 0.0841058105358354, 'fraction_numerical': 0.014695907754917477, 'mean_word_length': 2.5558681672025725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1335758', 'n_tokens_mistral': 3156, 'n_tokens_neox': 2915, 'n_words': 792}