Scaffold v1.0.0

This commit is contained in:
T. R. Bernstein
2026-04-17 01:08:29 +02:00
commit 292a2c859b
22 changed files with 983 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import Testing
@testable import EmbedderTool
@Suite("StringLiteralEscaper") struct StringLiteralEscaperTests {
@Test("wraps plain content with a single hash delimiter")
func plainContent() {
let literal = StringLiteralEscaper.rawTripleQuotedLiteral(from: "hello")
#expect(literal == "#\"\"\"\nhello\n\"\"\"#")
}
@Test("uses two hashes when content contains a triple-quote followed by one hash")
func escalatesForSingleHashCollision() {
let literal = StringLiteralEscaper.rawTripleQuotedLiteral(from: "before\"\"\"#after")
#expect(literal == "##\"\"\"\nbefore\"\"\"#after\n\"\"\"##")
}
@Test("escalates hash count past the longest run seen in content")
func escalatesForLongerHashRun() {
let literal = StringLiteralEscaper.rawTripleQuotedLiteral(from: "x\"\"\"####y")
#expect(literal.hasPrefix("#####\"\"\""))
#expect(literal.hasSuffix("\"\"\"#####"))
}
@Test("accepts empty content")
func emptyContent() {
let literal = StringLiteralEscaper.rawTripleQuotedLiteral(from: "")
#expect(literal == "#\"\"\"\n\n\"\"\"#")
}
@Test("leaves triple-quotes without trailing hashes untouched")
func tripleQuotesWithoutHashes() {
let literal = StringLiteralEscaper.rawTripleQuotedLiteral(from: "a\"\"\"b")
#expect(literal.hasPrefix("#\"\"\""))
#expect(literal.hasSuffix("\"\"\"#"))
}
}