1
- // RUN: %target-run-simple-swift | FileCheck %s
1
+ // RUN: %target-run-simple-swift
2
2
// REQUIRES: executable_test
3
3
4
4
// REQUIRES: objc_interop
@@ -8,39 +8,41 @@ import StdlibUnittest
8
8
import Foundation
9
9
import SpriteKit
10
10
11
+ var SpriteKitTests = TestSuite ( " SpriteKit " )
12
+
11
13
// Check that the subscript is there.
12
14
@available ( OSX, introduced: 10.10 )
13
15
@available ( iOS, introduced: 8.0 )
14
16
@available ( tvOS, introduced: 8.0 )
15
17
@available ( watchOS, introduced: 2.0 )
16
18
func testSubscript( _ node: SKNode ) {
17
- var _: [ SKNode ] = node [ " me " ]
19
+ var result = node [ " me " ]
20
+ expectType ( Array< SKNode> . self , & result)
18
21
}
19
22
20
- // SKColor is NSColor on OS X and UIColor on iOS.
21
-
22
- var r = CGFloat ( 0 )
23
- var g = CGFloat ( 0 )
24
- var b = CGFloat ( 0 )
25
- var a = CGFloat ( 0 )
26
- var color = SKColor . red
27
- color. getRed ( & r, green: & g, blue: & b, alpha: & a)
28
- print ( " color \( r) \( g) \( b) \( a) " )
29
- // CHECK: color 1.0 0.0 0.0 1.0
30
-
23
+ SpriteKitTests . test ( " SKColor/TypeEquivalence " ) {
24
+ // SKColor is NSColor on OS X and UIColor on iOS.
31
25
#if os(OSX)
32
- func f( _ c: NSColor ) {
33
- print ( " colortastic " )
34
- }
26
+ expectEqualType ( NSColor . self, SKColor . self)
35
27
#elseif os(iOS) || os(tvOS) || os(watchOS)
36
- func f ( _ c : UIColor ) {
37
- print ( " colortastic " )
38
- }
28
+ expectEqualType ( UIColor . self , SKColor . self )
29
+ #else
30
+ _UnknownOSError ( )
39
31
#endif
40
- f ( color)
41
- // CHECK: colortastic
32
+ }
42
33
43
- var SpriteKitTests = TestSuite ( " SpriteKit " )
34
+ SpriteKitTests . test ( " getRed(_:green:blue:alpha:) " ) {
35
+ var r : CGFloat = 0.0
36
+ var g : CGFloat = 0.0
37
+ var b : CGFloat = 0.0
38
+ var a : CGFloat = 0.0
39
+ let color = SKColor . red
40
+ color. getRed ( & r, green: & g, blue: & b, alpha: & a)
41
+ expectEqual ( 1.0 , r)
42
+ expectEqual ( 0.0 , g)
43
+ expectEqual ( 0.0 , b)
44
+ expectEqual ( 1.0 , a)
45
+ }
44
46
45
47
if #available( OSX 10 . 12 , iOS 10 . 0 , tvOS 10 . 0 , watchOS 3 . 0 , * ) {
46
48
SpriteKitTests . test ( " SKNode.setValue(_:forAttribute:) " ) {
@@ -62,11 +64,11 @@ if #available(OSX 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
62
64
warpGrid = warpGrid. replacingByDestinationPositions ( positions: [ float2 ( 1.0 ) , float2 ( 2.0 ) , float2 ( 3.0 ) , float2 ( 4.0 ) ] )
63
65
expectEqual ( warpGrid. destPosition ( at: 0 ) . x, 1.0 )
64
66
65
- warpGrid = SKWarpGeometryGrid ( columns: 1 , rows: 1 , sourcePositions : nil , destinationPositions: [ float2 ( 1.0 ) , float2 ( 2.0 ) , float2 ( 3.0 ) , float2 ( 4.0 ) ] )
67
+ warpGrid = SKWarpGeometryGrid ( columns: 1 , rows: 1 , destinationPositions: [ float2 ( 1.0 ) , float2 ( 2.0 ) , float2 ( 3.0 ) , float2 ( 4.0 ) ] )
66
68
expectEqual ( warpGrid. destPosition ( at: 0 ) . x, 1.0 )
67
69
expectEqual ( warpGrid. sourcePosition ( at: 0 ) . x, 0.0 )
68
70
69
- warpGrid = SKWarpGeometryGrid ( columns: 1 , rows: 1 , sourcePositions: [ float2 ( 1.0 ) , float2 ( 2.0 ) , float2 ( 3.0 ) , float2 ( 4.0 ) ] , destinationPositions : nil )
71
+ warpGrid = SKWarpGeometryGrid ( columns: 1 , rows: 1 , sourcePositions: [ float2 ( 1.0 ) , float2 ( 2.0 ) , float2 ( 3.0 ) , float2 ( 4.0 ) ] )
70
72
expectEqual ( warpGrid. destPosition ( at: 0 ) . x, 0.0 )
71
73
expectEqual ( warpGrid. sourcePosition ( at: 0 ) . x, 1.0 )
72
74
0 commit comments