From b4c2bbe5b7f3138f291c89892fee5a3a78075237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matya=CC=81s=CC=8C=20Kr=CC=8Ci=CC=81z=CC=8C?= Date: Wed, 15 May 2019 17:48:16 +0200 Subject: [PATCH] Fix incorrect test and simplify two ternary operators. --- .../CuckooGeneratorFramework/Tokens/InstanceVariable.swift | 2 +- Tests/GenericProtocolTest.swift | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Generator/Source/CuckooGeneratorFramework/Tokens/InstanceVariable.swift b/Generator/Source/CuckooGeneratorFramework/Tokens/InstanceVariable.swift index 4f1d6b0..b33f23f 100644 --- a/Generator/Source/CuckooGeneratorFramework/Tokens/InstanceVariable.swift +++ b/Generator/Source/CuckooGeneratorFramework/Tokens/InstanceVariable.swift @@ -31,7 +31,7 @@ public struct InstanceVariable: Token, HasAccessibility { public func serialize() -> [String : Any] { let readOnlyString = readOnly ? "ReadOnly" : "" - let optionalString = type.isOptional ? (readOnly ? "" : "Optional") : "" + let optionalString = type.isOptional && !readOnly ? "Optional" : "" return [ "name": name, "type": type.sugarized, diff --git a/Tests/GenericProtocolTest.swift b/Tests/GenericProtocolTest.swift index f487d8f..1017c9e 100644 --- a/Tests/GenericProtocolTest.swift +++ b/Tests/GenericProtocolTest.swift @@ -90,6 +90,8 @@ class GenericProtocolTest: XCTestCase { when(mock.readOnlyPropertyC.get).thenReturn(MockTestedClass()) } + _ = mock.readOnlyPropertyC + verify(mock).readOnlyPropertyC.get() }