import CottonFaces import CottonValues import XCTest @testable import CottonUI /// RULE (Round 17's fan, 5 Nov 2026): an app that holds one tool lays that /// tool's ground under its deck whether or not a card is up — an empty /// Cotton Books deck lies on the navy felt its books do /// (`FaceGround.feltNavy`), never on cream paper. An app of many tools /// (Cotton, Rigby) keeps paper under an empty deck, and any deck with a card /// up lies on that card's face's ground, as before (`DeckGround.laid`). @MainActor final class DeckGroundTests: XCTestCase { /// Many tools, as Cotton and Rigby hold. private let cotton = ["people", "todos", "notebook", "calendar", "books", "films", "music"] private func table(_ face: String) throws -> DefinitionCardFace { DefinitionCardFace(_generated: (), face: try XCTUnwrap(DefinitionCardKind(rawValue: face))) } func testAOneToolAppLaysItsToolsGroundUnderAnEmptyDeck() throws { XCTAssertEqual(DeckGround.laid(front: nil, table: try table("book.hardback"), installed: ["books"]), .feltNavy) XCTAssertEqual(DeckGround.laid(front: nil, table: try table("highlight.passage"), installed: ["books"]), .feltNavy, "an empty Highlights deck lies on the same felt") } func testAManyToolAppKeepsPaperUnderAnEmptyDeck() throws { XCTAssertNil(DeckGround.laid(front: nil, table: try table("book.hardback"), installed: cotton)) XCTAssertNil(DeckGround.laid(front: nil, table: try table("book.hardback"), installed: []), "before the tools are read, paper") } func testAPaperFaceOrNoCardFaceKeepsPaperInAOneToolApp() throws { XCTAssertNil(DeckGround.laid(front: nil, table: try table("plain"), installed: ["notes"])) XCTAssertNil(DeckGround.laid(front: nil, table: nil, installed: ["notes"])) } func testACardUpLiesOnItsOwnGroundInEveryApp() throws { let book = DeckCard(face: "book.hardback", corner: nil, pressing: false, pace: nil, plate: nil, fields: [:]) for installed in [["books"], cotton, []] { XCTAssertEqual(DeckGround.laid(front: book, table: try table("plain"), installed: installed), .feltNavy) } let plain = DeckCard(face: "plain", corner: nil, pressing: false, pace: nil, plate: nil, fields: [:]) XCTAssertNil(DeckGround.laid(front: plain, table: try table("book.hardback"), installed: ["books"]), "a paper card up keeps paper even where the table's face has a ground") } }