1- // RUN: %target-run-simple-swift | FileCheck %s
1+ // RUN: %target-run-simple-swift
22// REQUIRES: executable_test
33
44// REQUIRES: objc_interop
@@ -8,39 +8,41 @@ import StdlibUnittest
88import Foundation
99import SpriteKit
1010
11+ var SpriteKitTests = TestSuite ( " SpriteKit " )
12+
1113// Check that the subscript is there.
1214@available ( OSX, introduced: 10.10 )
1315@available ( iOS, introduced: 8.0 )
1416@available ( tvOS, introduced: 8.0 )
1517@available ( watchOS, introduced: 2.0 )
1618func testSubscript( _ node: SKNode ) {
17- var _: [ SKNode ] = node [ " me " ]
19+ var result = node [ " me " ]
20+ expectType ( Array< SKNode> . self , & result)
1821}
1922
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.
3125#if os(OSX)
32- func f( _ c: NSColor ) {
33- print ( " colortastic " )
34- }
26+ expectEqualType ( NSColor . self, SKColor . self)
3527#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 ( )
3931#endif
40- f ( color)
41- // CHECK: colortastic
32+ }
4233
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+ }
4446
4547if #available( OSX 10 . 12 , iOS 10 . 0 , tvOS 10 . 0 , watchOS 3 . 0 , * ) {
4648 SpriteKitTests . test ( " SKNode.setValue(_:forAttribute:) " ) {
@@ -62,11 +64,11 @@ if #available(OSX 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
6264 warpGrid = warpGrid. replacingByDestinationPositions ( positions: [ float2 ( 1.0 ) , float2 ( 2.0 ) , float2 ( 3.0 ) , float2 ( 4.0 ) ] )
6365 expectEqual ( warpGrid. destPosition ( at: 0 ) . x, 1.0 )
6466
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 ) ] )
6668 expectEqual ( warpGrid. destPosition ( at: 0 ) . x, 1.0 )
6769 expectEqual ( warpGrid. sourcePosition ( at: 0 ) . x, 0.0 )
6870
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 ) ] )
7072 expectEqual ( warpGrid. destPosition ( at: 0 ) . x, 0.0 )
7173 expectEqual ( warpGrid. sourcePosition ( at: 0 ) . x, 1.0 )
7274
0 commit comments