Skip to content

Commit a9ed029

Browse files
committed
Merge pull request #2903 from frootloops/logic-value
Refactoring LogicValue tests
2 parents 6db2927 + d654515 commit a9ed029

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

test/1_stdlib/LogicValue.swift

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
// RUN: %target-run-simple-swift | FileCheck %s
1+
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33

4+
import StdlibUnittest
5+
46
enum Bewl : Boolean {
57
case False, True
68

@@ -15,36 +17,35 @@ enum Bewl : Boolean {
1517
}
1618

1719
func truthy() -> Bewl {
18-
print("truthy ", terminator: "")
1920
return .True
2021
}
2122

2223
func falsy() -> Bewl {
23-
print("falsy ", terminator: "")
2424
return .False
2525
}
2626

27-
func logicValueTests() {
27+
let LogicValueTests = TestSuite("LogicValue")
28+
LogicValueTests.test("Basic") {
2829
// Logic values should convert to bool.
2930
struct X : Boolean {
3031
var boolValue: Bool { return false }
3132
}
3233
var anX = X()
33-
print("Boolean Bool = \(Bool(anX))") // CHECK: Boolean Bool = false
34+
expectFalse(Bool(anX))
3435

35-
print("\(!Bewl.True)") // CHECK: false
36-
print("\(!Bewl.False)") // CHECK: true
36+
expectFalse(!Bewl.True)
37+
expectTrue(!Bewl.False)
3738

3839
// Test short-circuiting operators
39-
print("\(Bool(truthy() && truthy()))") // CHECK: truthy truthy true
40-
print("\(Bool(truthy() && falsy()))") // CHECK: truthy falsy false
41-
print("\(Bool(falsy() && truthy()))") // CHECK: falsy false
42-
print("\(Bool(falsy() && falsy()))") // CHECK: falsy false
43-
44-
print("\(Bool(truthy() || truthy()))") // CHECK: truthy true
45-
print("\(Bool(truthy() || falsy()))") // CHECK: truthy true
46-
print("\(Bool(falsy() || truthy()))") // CHECK: falsy truthy true
47-
print("\(Bool(falsy() || falsy()))") // CHECK: falsy falsy false
40+
expectTrue(Bool(truthy() && truthy()))
41+
expectFalse(Bool(truthy() && falsy()))
42+
expectFalse(Bool(falsy() && truthy()))
43+
expectFalse(Bool(falsy() && falsy()))
44+
45+
expectTrue(Bool(truthy() || truthy()))
46+
expectTrue(Bool(truthy() || falsy()))
47+
expectTrue(Bool(falsy() || truthy()))
48+
expectFalse(Bool(falsy() || falsy()))
4849
}
4950

50-
logicValueTests()
51+
runAllTests()

0 commit comments

Comments
 (0)