Skip to content

Commit 6ddc81e

Browse files
authored
Fixing Tests (#75)
1 parent aee9f9a commit 6ddc81e

29 files changed

+424
-170
lines changed

Examples/Completed/conditionals/code.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ print(description)
112112
// Using labeled statements with break
113113
let finalSquare = 25
114114
var board = [Int](repeating: 0, count: finalSquare + 1)
115-
board[03] = +08
116-
board[06] = +11
117-
board[09] = +09
118-
board[10] = +02
115+
board[03] = 8
116+
board[06] = 11
117+
board[09] = 9
118+
board[10] = 2
119119
board[14] = -10
120120
board[19] = -11
121-
board[22] = -02
122-
board[24] = -08
121+
board[22] = -2
122+
board[24] = -8
123123

124124
var square = 0
125125
var diceRoll = 0

Examples/Completed/conditionals/dsl.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,7 @@ Switch("integerToDescribe") {
158158
Call("print", "description")
159159

160160
Variable(.let, name: "finalSquare", equals: 25)
161-
Variable(.var, name: "board", equals: Init("[Int]") {
162-
ParameterExp(name: "repeating", value: Literal.integer(0))
163-
ParameterExp(name: "count", value: Infix("finalSquare", "+", 1))
164-
})
161+
Variable(.var, name: "board", equals: Literal.array(Array(repeating: Literal.integer(0), count: 26)))
165162

166163
Infix("board[03]", "+=", 8)
167164
Infix("board[06]", "+=", 11)

Sources/SyntaxKit/Break.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public struct Break: CodeBlock {
4343
let breakStmt = BreakStmtSyntax(
4444
breakKeyword: .keyword(.break, trailingTrivia: .newline)
4545
)
46-
46+
4747
if let label = label {
4848
return StmtSyntax(
4949
breakStmt.with(
@@ -55,4 +55,4 @@ public struct Break: CodeBlock {
5555
return StmtSyntax(breakStmt)
5656
}
5757
}
58-
}
58+
}

Sources/SyntaxKit/Continue.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public struct Continue: CodeBlock {
4343
let continueStmt = ContinueStmtSyntax(
4444
continueKeyword: .keyword(.continue, trailingTrivia: .newline)
4545
)
46-
46+
4747
if let label = label {
4848
return StmtSyntax(
4949
continueStmt.with(
@@ -55,4 +55,4 @@ public struct Continue: CodeBlock {
5555
return StmtSyntax(continueStmt)
5656
}
5757
}
58-
}
58+
}

Sources/SyntaxKit/Enum.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ public struct EnumCase: CodeBlock {
244244
)
245245
case .tuple:
246246
fatalError("Tuple is not supported as a raw value for enum cases.")
247+
case .array:
248+
fatalError("Array is not supported as a raw value for enum cases.")
249+
case .dictionary:
250+
fatalError("Dictionary is not supported as a raw value for enum cases.")
247251
}
248252
}
249253

Sources/SyntaxKit/Fallthrough.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ public struct Fallthrough: CodeBlock {
4141
)
4242
)
4343
}
44-
}
44+
}

Sources/SyntaxKit/Guard.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public struct Guard: CodeBlock {
7575
pattern: IdentifierPatternSyntax(identifier: .identifier(letCond.name)),
7676
initializer: InitializerClauseSyntax(
7777
equal: .equalToken(leadingTrivia: .space, trailingTrivia: .space),
78-
value: letCond.value.syntax.as(ExprSyntax.self) ?? ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("")))
78+
value: letCond.value.syntax.as(ExprSyntax.self)
79+
?? ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("")))
7980
)
8081
)
8182
)

Sources/SyntaxKit/If.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public struct If: CodeBlock {
8484
pattern: IdentifierPatternSyntax(identifier: .identifier(letCond.name)),
8585
initializer: InitializerClauseSyntax(
8686
equal: .equalToken(leadingTrivia: .space, trailingTrivia: .space),
87-
value: letCond.value.syntax.as(ExprSyntax.self) ?? ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("")))
87+
value: letCond.value.syntax.as(ExprSyntax.self)
88+
?? ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("")))
8889
)
8990
)
9091
)

Sources/SyntaxKit/Init.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public struct Init: CodeBlock, ExprCodeBlock {
4242
self.type = type
4343
self.parameters = params()
4444
}
45-
45+
4646
public var exprSyntax: ExprSyntax {
4747
let args = LabeledExprListSyntax(
4848
parameters.enumerated().compactMap { index, param in
@@ -62,7 +62,7 @@ public struct Init: CodeBlock, ExprCodeBlock {
6262
rightParen: .rightParenToken()
6363
))
6464
}
65-
65+
6666
public var syntax: SyntaxProtocol {
6767
exprSyntax
6868
}

Sources/SyntaxKit/Let.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public struct Let: CodeBlock {
6363
pattern: IdentifierPatternSyntax(identifier: .identifier(name)),
6464
initializer: InitializerClauseSyntax(
6565
equal: .equalToken(leadingTrivia: .space, trailingTrivia: .space),
66-
value: value.syntax.as(ExprSyntax.self) ?? ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("")))
66+
value: value.syntax.as(ExprSyntax.self)
67+
?? ExprSyntax(DeclReferenceExprSyntax(baseName: .identifier("")))
6768
)
6869
)
6970
])

0 commit comments

Comments
 (0)