Skip to content

Commit

Permalink
Fix --nilInit insert test case error
Browse files Browse the repository at this point in the history
  • Loading branch information
rakuyoMo committed Jun 17, 2024
1 parent dd989a4 commit 736615e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Tests/RulesTests+Redundancy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2045,14 +2045,14 @@ class RedundancyTests: RulesTests {
}

func testNoInsertLazyVarNilInit() {
let input = "lazy var foo: Int? = nil"
let input = "lazy var foo: Int?"
let options = FormatOptions(nilInit: .insert)
testFormatting(for: input, rule: FormatRules.redundantNilInit,
options: options)
}

func testNoInsertLazyPublicPrivateSetVarNilInit() {
let input = "lazy private(set) public var foo: Int? = nil"
let input = "lazy private(set) public var foo: Int?"
let options = FormatOptions(nilInit: .insert)
testFormatting(for: input, rule: FormatRules.redundantNilInit, options: options,
exclude: ["modifierOrder"])
Expand All @@ -2066,28 +2066,28 @@ class RedundancyTests: RulesTests {
}

func testNoInsertNilInitWithPropertyWrapper() {
let input = "@Foo var foo: Int? = nil"
let input = "@Foo var foo: Int?"
let options = FormatOptions(nilInit: .insert)
testFormatting(for: input, rule: FormatRules.redundantNilInit,
options: options)
}

func testNoInsertNilInitWithLowercasePropertyWrapper() {
let input = "@foo var foo: Int? = nil"
let input = "@foo var foo: Int?"
let options = FormatOptions(nilInit: .insert)
testFormatting(for: input, rule: FormatRules.redundantNilInit,
options: options)
}

func testNoInsertNilInitWithPropertyWrapperWithArgument() {
let input = "@Foo(bar: baz) var foo: Int? = nil"
let input = "@Foo(bar: baz) var foo: Int?"
let options = FormatOptions(nilInit: .insert)
testFormatting(for: input, rule: FormatRules.redundantNilInit,
options: options)
}

func testNoInsertNilInitWithLowercasePropertyWrapperWithArgument() {
let input = "@foo(bar: baz) var foo: Int? = nil"
let input = "@foo(bar: baz) var foo: Int?"
let options = FormatOptions(nilInit: .insert)
testFormatting(for: input, rule: FormatRules.redundantNilInit,
options: options)
Expand Down Expand Up @@ -2157,6 +2157,7 @@ class RedundancyTests: RulesTests {
}

func testNoInsertNilInitInViewBuilder() {
// Not insert `nil` in result builder
let input = """
struct TestView: View {
var body: some View {
Expand All @@ -2170,7 +2171,8 @@ class RedundancyTests: RulesTests {
options: options)
}

func testInsertNilInitInIfStatementInViewBuilder() {
func testNoInsertNilInitInIfStatementInViewBuilder() {
// Not insert `nil` in result builder
let input = """
struct TestView: View {
var body: some View {
Expand All @@ -2183,12 +2185,13 @@ class RedundancyTests: RulesTests {
}
}
"""
let options = FormatOptions(nilInit: .remove)
let options = FormatOptions(nilInit: .insert)
testFormatting(for: input, rule: FormatRules.redundantNilInit,
options: options)
}

func testInsertNilInitInSwitchStatementInViewBuilder() {
func testNoInsertNilInitInSwitchStatementInViewBuilder() {
// Not insert `nil` in result builder
let input = """
struct TestView: View {
var body: some View {
Expand All @@ -2203,7 +2206,7 @@ class RedundancyTests: RulesTests {
}
}
"""
let options = FormatOptions(nilInit: .remove)
let options = FormatOptions(nilInit: .insert)
testFormatting(for: input, rule: FormatRules.redundantNilInit,
options: options)
}
Expand Down

0 comments on commit 736615e

Please sign in to comment.