1
- // RUN: %target-run-simple-swift | FileCheck %s
1
+ // RUN: %target-run-simple-swift
2
2
// REQUIRES: executable_test
3
3
4
+ import StdlibUnittest
5
+
4
6
enum Bewl : Boolean {
5
7
case False, True
6
8
@@ -15,36 +17,35 @@ enum Bewl : Boolean {
15
17
}
16
18
17
19
func truthy( ) -> Bewl {
18
- print ( " truthy " , terminator: " " )
19
20
return . True
20
21
}
21
22
22
23
func falsy( ) -> Bewl {
23
- print ( " falsy " , terminator: " " )
24
24
return . False
25
25
}
26
26
27
- func logicValueTests( ) {
27
+ let LogicValueTests = TestSuite ( " LogicValue " )
28
+ LogicValueTests . test ( " Basic " ) {
28
29
// Logic values should convert to bool.
29
30
struct X : Boolean {
30
31
var boolValue : Bool { return false }
31
32
}
32
33
var anX = X ( )
33
- print ( " Boolean Bool = \( Bool ( anX) ) " ) // CHECK: Boolean Bool = false
34
+ expectFalse ( Bool ( anX) )
34
35
35
- print ( " \( !Bewl. True) " ) // CHECK: false
36
- print ( " \( !Bewl. False) " ) // CHECK: true
36
+ expectFalse ( !Bewl. True)
37
+ expectTrue ( !Bewl. False)
37
38
38
39
// 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 ( ) ) )
48
49
}
49
50
50
- logicValueTests ( )
51
+ runAllTests ( )
0 commit comments