forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIKit.swift
67 lines (58 loc) · 2.71 KB
/
UIKit.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// RUN: %target-run-simple-swift | FileCheck %s
// REQUIRES: executable_test
// REQUIRES: OS=ios
import UIKit
func printOrientation(o: UIDeviceOrientation) {
print("\(o.isPortrait) \(UIDeviceOrientationIsPortrait(o)), ", terminator: "")
print("\(o.isLandscape) \(UIDeviceOrientationIsLandscape(o)), ", terminator: "")
print("\(o.isFlat), ", terminator: "")
print("\(o.isValidInterfaceOrientation) \(UIDeviceOrientationIsValidInterfaceOrientation(o))")
}
print("Device orientations")
printOrientation(UIDeviceOrientation.Unknown)
printOrientation(UIDeviceOrientation.Portrait)
printOrientation(UIDeviceOrientation.PortraitUpsideDown)
printOrientation(UIDeviceOrientation.LandscapeLeft)
printOrientation(UIDeviceOrientation.LandscapeRight)
printOrientation(UIDeviceOrientation.FaceUp)
printOrientation(UIDeviceOrientation.FaceDown)
// CHECK: Device orientations
// CHECK-NEXT: false false, false false, false, false false
// CHECK-NEXT: true true, false false, false, true true
// CHECK-NEXT: true true, false false, false, true true
// CHECK-NEXT: false false, true true, false, true true
// CHECK-NEXT: false false, true true, false, true true
// CHECK-NEXT: false false, false false, true, false false
// CHECK-NEXT: false false, false false, true, false false
func printOrientation(o: UIInterfaceOrientation) {
print("\(o.isPortrait) \(UIInterfaceOrientationIsPortrait(o)), ", terminator: "")
print("\(o.isLandscape) \(UIInterfaceOrientationIsLandscape(o))")
}
print("Interface orientations")
printOrientation(UIInterfaceOrientation.Unknown)
printOrientation(UIInterfaceOrientation.Portrait)
printOrientation(UIInterfaceOrientation.PortraitUpsideDown)
printOrientation(UIInterfaceOrientation.LandscapeLeft)
printOrientation(UIInterfaceOrientation.LandscapeRight)
// CHECK: Interface orientations
// CHECK-NEXT: false false, false false
// CHECK-NEXT: true true, false false
// CHECK-NEXT: true true, false false
// CHECK-NEXT: false false, true true
// CHECK-NEXT: false false, true true
var inset1 = UIEdgeInsets(top: 1.0, left: 2.0, bottom: 3.0, right: 4.0)
var inset2 = UIEdgeInsets(top: 1.0, left: 2.0, bottom: 3.1, right: 4.0)
print("inset1 == inset1: \(inset1 == inset1)")
print("inset1 != inset1: \(inset1 != inset1)")
print("inset1 == inset2: \(inset1 == inset2)")
// CHECK: inset1 == inset1: true
// CHECK: inset1 != inset1: false
// CHECK: inset1 == inset2: false
var offset1 = UIOffset(horizontal: 1.0, vertical: 2.0)
var offset2 = UIOffset(horizontal: 1.0, vertical: 3.0)
print("offset1 == offset1: \(offset1 == offset1)")
print("offset1 != offset1: \(offset1 != offset1)")
print("offset1 == offset2: \(offset1 == offset2)")
// CHECK: offset1 == offset1: true
// CHECK: offset1 != offset1: false
// CHECK: offset1 == offset2: false