Skip to content

Commit e5471a2

Browse files
committed
fixed failing tests
1 parent 1f0bab4 commit e5471a2

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

Tests/SyntaxKitTests/Integration/ConditionalsExampleTests.swift

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ import Testing
2222
}
2323
} then: {
2424
Call("print") {
25-
ParameterExp(unlabeled: "\"It's hot!\"")
26-
}
27-
} else: {
28-
Call("print") {
29-
ParameterExp(unlabeled: "\"It's not hot\"")
25+
ParameterExp(unlabeled: "\"It's hot outside!\"")
3026
}
3127
}
3228

@@ -43,7 +39,7 @@ import Testing
4339
}
4440
} then: {
4541
Call("print") {
46-
ParameterExp(unlabeled: "\"A\"")
42+
ParameterExp(unlabeled: "\"Excellent!\"")
4743
}
4844
} else: {
4945
If {
@@ -53,30 +49,26 @@ import Testing
5349
}
5450
} then: {
5551
Call("print") {
56-
ParameterExp(unlabeled: "\"B\"")
52+
ParameterExp(unlabeled: "\"Good job!\"")
5753
}
5854
} else: {
59-
Call("print") {
60-
ParameterExp(unlabeled: "\"C\"")
55+
If {
56+
try! Infix(">=") {
57+
VariableExp("score")
58+
Literal.integer(70)
59+
}
60+
} then: {
61+
Call("print") {
62+
ParameterExp(unlabeled: "\"Passing\"")
63+
}
64+
} else: {
65+
Call("print") {
66+
ParameterExp(unlabeled: "\"Needs improvement\"")
67+
}
6168
}
6269
}
6370
}
6471

65-
If {
66-
try! Infix(">=") {
67-
VariableExp("score")
68-
Literal.integer(70)
69-
}
70-
} then: {
71-
Call("print") {
72-
ParameterExp(unlabeled: "\"Passing\"")
73-
}
74-
} else: {
75-
Call("print") {
76-
ParameterExp(unlabeled: "\"Failing\"")
77-
}
78-
}
79-
8072
// MARK: Optional Binding with If
8173
Variable(.let, name: "possibleNumber", equals: Literal.string("123"))
8274
.comment {

Tests/SyntaxKitTests/Unit/EdgeCases/EdgeCaseTests.swift

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,28 @@ import Testing
55
internal struct EdgeCaseTests {
66
// MARK: - Error Handling Tests
77

8-
@Test("Infix with wrong number of operands throws fatal error")
8+
@Test("Infix with wrong number of operands throws error")
99
internal func testInfixWrongOperandCount() throws {
10-
// This test documents the expected behavior
11-
// In a real scenario, this would cause a fatal error
12-
// We can't easily test fatalError in unit tests, but we can document it
13-
let infix = try Infix("+") {
14-
// Only one operand - should cause fatal error
15-
VariableExp("x")
10+
// Test that Infix throws an error when given wrong number of operands
11+
do {
12+
_ = try Infix("+") {
13+
// Only one operand - should throw error
14+
VariableExp("x")
15+
}
16+
// If we reach here, no error was thrown, which is unexpected
17+
#expect(false, "Expected error to be thrown for wrong operand count")
18+
} catch let error as Infix.InfixError {
19+
// Verify it's the correct error type
20+
switch error {
21+
case .wrongOperandCount(let expected, let got):
22+
#expect(expected == 2)
23+
#expect(got == 1)
24+
case .nonExprCodeBlockOperand:
25+
#expect(false, "Expected wrongOperandCount error, got nonExprCodeBlockOperand")
26+
}
27+
} catch {
28+
#expect(false, "Expected InfixError, got \(type(of: error))")
1629
}
17-
18-
// The fatal error would occur when accessing .syntax
19-
// This test documents the expected behavior
20-
#expect(true) // Placeholder - fatal errors can't be easily tested
2130
}
2231

2332
// MARK: - Default Condition Tests

0 commit comments

Comments
 (0)