// The board as data (design note 26203e21): one renderer, `BoardSurface`, // draws a board's parts in order, each kind in one case of its part switch, // and no part draws a board or another part. A kind this build does not know // is passed over and said, never a crash; and the boards this build draws // while its row is read are the crate's own, copied. import CottonKit import Foundation import XCTest @testable import CottonUI final class BoardSurfaceGuardTests: XCTestCase { private static let lane = "the board as data (26203e21)" private static let surface = "apps/cotton/Sources/CottonUI/Surfaces/BoardSurface.swift" /// The files the part views live in. private static let partFiles = [ "apps/cotton/Sources/CottonUI/Surfaces/Board/BoardNotices.swift", "apps/cotton/Sources/CottonUI/Surfaces/Board/BoardSourceParts.swift", "apps/cotton/Sources/CottonUI/Surfaces/Board/BoardPage.swift", "apps/cotton/Sources/CottonUI/Surfaces/Board/BoardHead.swift", ] /// The part switch's function, from its signature to its closing brace. private func partSwitch() throws -> Substring { let code = SourceSweep.withoutComments(try SourceSweep.mustRead(Self.surface, ownedBy: Self.lane)) let start = try XCTUnwrap(code.range(of: "private func part(_ entry: BoardEntry) -> AnyView {"), "the part switch is gone") let end = try XCTUnwrap(code.range(of: "\n }\n", range: start.upperBound..