Files
swift-mirror/test/Interpreter/SDK/Foundation_NSRect.swift
Doug Gregor 8df878c02a Give CGRect/CGSize/CGVector initializers that take Doubles.
Now that CGFloat is its own distinct type, it's useful to have Double
initializers to go along with the Int initializers we added a while
back <rdar://problem/17224725>.

Swift SVN r21156
2014-08-12 21:54:50 +00:00

37 lines
832 B
Swift

// RUN: %target-run-simple-swift | FileCheck %s
// iOS doesn't have NSRect. iOS and OS X CGRect is tested elsewhere.
// REQUIRES: OS=macosx
import Foundation
func printRect(r: NSRect) {
// FIXME: Constraint checker takes too long to typecheck this as an
// interpolation expression
print("NSRect(")
print(r.origin.x)
print(", ")
print(r.origin.y)
print(", ")
print(r.size.width)
print(", ")
print(r.size.height)
println(")")
}
var r = NSRect(x: 0, y: 0, width: 100, height: 50)
// CHECK: NSRect(20.0, 10.0, 60.0, 30.0)
printRect(NSInsetRect(r, 20, 10))
// CHECK: NSRect(100.0, 100.0, 50.0, 50.0)
printRect(NSMakeRect(100,100,50,50))
// CHECK: {0, 0}, {100, 50}
println(NSStringFromRect(r))
// CHECK: NSRect(1.5, 1.5, 1.5, 1.5)
let d = 1.5
var r2 = NSRect(x: d, y: d, width: d, height: d)
printRect(r2)