Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Commit

Permalink
Test UIColor matching
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe committed Aug 20, 2017
1 parent ccb22df commit 67074d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
#if os(OSX)
import AppKit.NSColor
typealias Color = NSColor
enum XCTColors { }
enum UIColor { }
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIColor
typealias Color = UIColor
enum XCTColors { }
#endif

// swiftlint:disable file_length

// swiftlint:disable identifier_name line_length type_body_length
extension XCTColors {
extension UIColor {
/// 0x339666ff (r: 51, g: 150, b: 102, a: 255)
static let articleBody = #colorLiteral(red: 0.2, green: 0.588235, blue: 0.4, alpha: 1.0)
/// 0xff66ccff (r: 255, g: 102, b: 204, a: 255)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
#if os(OSX)
import AppKit.NSColor
typealias Color = NSColor
enum XCTColors { }
enum UIColor { }
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIColor
typealias Color = UIColor
enum XCTColors { }
#endif

// swiftlint:disable file_length

// swiftlint:disable identifier_name line_length type_body_length
extension XCTColors {
extension UIColor {
/// 0x339666ff (r: 51, g: 150, b: 102, a: 255)
static let articleBody = #colorLiteral(red: 0.2, green: 0.588235, blue: 0.4, alpha: 1.0)
/// 0xff66ccff (r: 255, g: 102, b: 204, a: 255)
Expand Down
32 changes: 17 additions & 15 deletions Tests/TemplatesTests/ColorsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,52 @@ class ColorsTests: XCTestCase {
}

// generate variations to test customname generation
let variations: VariationGenerator = { name, context in
guard name == "defaults" else { return [(context: context, suffix: "")] }

return [
(context: context,
suffix: ""),
(context: try StencilContext.enrich(context: context,
parameters: ["enumName=XCTColors"]),
suffix: "-customname")
]
func variations(customName: String) -> VariationGenerator {
return { name, context in
guard name == "defaults" else { return [(context: context, suffix: "")] }

return [
(context: context,
suffix: ""),
(context: try StencilContext.enrich(context: context,
parameters: ["enumName=\(customName)"]),
suffix: "-customname")
]
}
}

func testSwift2() {
test(template: "swift2",
contextNames: Contexts.all,
directory: .colors,
contextVariations: variations)
contextVariations: variations(customName: "XCTColors"))
}

func testSwift3() {
test(template: "swift3",
contextNames: Contexts.all,
directory: .colors,
contextVariations: variations)
contextVariations: variations(customName: "XCTColors"))
}

func testSwift4() {
test(template: "swift4",
contextNames: Contexts.all,
directory: .colors,
contextVariations: variations)
contextVariations: variations(customName: "XCTColors"))
}

func testLiteralsSwift3() {
test(template: "literals-swift3",
contextNames: Contexts.all,
directory: .colors,
contextVariations: variations)
contextVariations: variations(customName: "UIColor"))
}

func testLiteralsSwift4() {
test(template: "literals-swift4",
contextNames: Contexts.all,
directory: .colors,
contextVariations: variations)
contextVariations: variations(customName: "UIColor"))
}
}

0 comments on commit 67074d9

Please sign in to comment.