2020-08-19 01:09:13 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
import Nimble
|
|
|
|
|
|
|
|
// I don't know why the font returned by Typesetter is not equal to the font
|
|
|
|
// it should be equal to. This is a workaround.
|
|
|
|
func equalFont(_ expectedValue: NSFont?) -> Predicate<NSFont> {
|
2020-09-19 00:14:20 +03:00
|
|
|
Predicate { actualExpression in
|
2020-08-19 01:09:13 +03:00
|
|
|
let msg = ExpectationMessage.expectedActualValueTo(
|
|
|
|
"equal <\(String(describing: expectedValue))>"
|
|
|
|
)
|
|
|
|
if let actualValue = try actualExpression.evaluate() {
|
|
|
|
return PredicateResult(
|
2020-09-19 00:14:20 +03:00
|
|
|
bool: NSFont(
|
|
|
|
name: actualValue.fontName,
|
|
|
|
size: actualValue.pointSize
|
|
|
|
) == expectedValue!,
|
2020-08-19 01:09:13 +03:00
|
|
|
message: msg
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return PredicateResult(
|
|
|
|
status: .fail,
|
|
|
|
message: msg.appendedBeNilHint()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|