-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathInstructionsTests.swift
More file actions
50 lines (41 loc) · 1.38 KB
/
InstructionsTests.swift
File metadata and controls
50 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import Testing
@testable import AnyLanguageModel
@Suite("Instructions")
struct InstructionsTests {
@Test func initializesFromStringRepresentable() {
let instructions = Instructions("Be concise.")
#expect(instructions.description == "Be concise.")
}
@Test func initializesFromInstructionsRepresentable() {
let existing = Instructions("Base instructions")
let wrapped = Instructions(existing)
#expect(wrapped.description == "Base instructions")
}
@Test func builderCombinesLines() throws {
let instructions = Instructions {
"First line"
"Second line"
}
#expect(instructions.description == "First line\nSecond line")
}
@Test func builderSupportsConditionalsAndOptionals() throws {
let includeConditional = true
let includeOptional = false
let instructions = Instructions {
"Always"
if includeConditional {
"Conditional"
} else {
"Other"
}
if includeOptional {
"Optional"
}
}
#expect(instructions.description == "Always\nConditional")
}
@Test func arrayRepresentationJoinsByNewline() {
let array = ["One", "Two", "Three"]
#expect(array.instructionsRepresentation.description == "One\nTwo\nThree")
}
}