Commit Graph

40 Commits

Author SHA1 Message Date
Chris Lattner
b8596ffccb move the stdlib to the new syntax for @autoclosure attribute.
Swift SVN r24048
2014-12-20 00:16:36 +00:00
Dmitri Hrybenko
397d2fb8c3 stdlib: coding style: when colon specifies is-a relationship, we put
spaces on both sides of it

Swift SVN r23935
2014-12-15 06:55:30 +00:00
Dmitri Hrybenko
75876f531a XCTest: silence the warning about accessing a property that is not declared
Patch by Chris Hanson.

Swift SVN r23248
2014-11-11 22:19:48 +00:00
Dmitri Hrybenko
741ba42144 Simplify XCTest CMake code
Swift SVN r23054
2014-11-01 02:52:14 +00:00
Chris Hanson
b644ff5888 XCTAssert(true, "Pass") crashes in Swift
Instead of trying to bridge NSDictionary to [String:String], XCTest needs to
just request the objects from the NSDictionary as String.

Also, move the unwrapping of the optional from the might-throw block such that
it only happens when the block hasn't thrown. Unwrapping the optional if the
block has thrown would crash, because the optional would still be unset.

Addresses <rdar://problem/17952584>.

Swift SVN r21119
2014-08-08 22:51:30 +00:00
Chris Hanson
91069e1647 Get XCTAssertEqual working with [T] and [T:U]
XCTest's equality assertions need overrides in order to work with Array<T> and
Dictionary<T,U>.

Addresses <rdar://problem/17257148>.

Swift SVN r20993
2014-08-04 02:10:03 +00:00
Chris Hanson
63a37b29a5 XCTest assertions will eventually EXC_BAD_ACCESS
The SPI that XCTest exposes to the overlay has Objective-C semantics,
while anything exposed to Swift code via @asmname needs Swift semantics.

Add a bridge to the overlay that handles this adaptation.

Addresses <rdar://problem/17408423>.

Swift SVN r20932
2014-08-02 00:17:28 +00:00
Chris Hanson
666e4ee2f3 Further work on handling exceptions in XCTest
Rather than use a header file and -import-objc-header, use @asmname and
@objc_block to tell the overlay about the Objective-C function used to
capture exceptions.

Further addresses <rdar://problem/16453199>.

Swift SVN r20929
2014-08-01 23:36:48 +00:00
Chris Hanson
76631d14bd Catch exceptions thrown during assertions.
Since Swift itself has no exception support, use an Objective-C helper function
to evaluate a block and return an NSDictionary indicating whether an exception
was thrown out of that block (and if so, which exception).

Addresses <rdar://problem/16453199>.

Swift SVN r20880
2014-08-01 02:45:39 +00:00
Greg Parker
1167c1722d Fix XCTest build.
Swift SVN r20813
2014-07-31 05:37:24 +00:00
Chris Hanson
867429b0f4 Make XCTAssertEqualWithAccuracy work with CGFloat
Now that CGFloat is a peer of Float and Double, we need to add appropriate handling
to it for XCTAssertEqualWithAccuracy.

Addresses <rdar://problem/17762421>.

Swift SVN r20800
2014-07-31 01:36:32 +00:00
Joe Pamer
1fec0afbd0 Disallow value-to-optional conversions between argument and parameter types when resolving overloads for operators applied to nil literal operands.
This is a targeted fix to address rdar://problem/16848110 ("Disallow non-optionals to be compared to nil") and its associated dupes.

Swift SVN r20716
2014-07-29 23:24:36 +00:00
Dmitri Hrybenko
d14f17beef Change 'getLogicValue()' into a property 'boolValue'; change
'getArrayBoundValue()' into a property 'arrayBoundValue'.

rdar://17156123


Swift SVN r20304
2014-07-22 12:08:10 +00:00
Doug Gregor
b502010365 s/auto_closure/autoclosure in XCTest
Swift SVN r20255
2014-07-21 15:36:57 +00:00
Chris Hanson
877367add5 Have XCTest use string interpolation everywhere.
Instead of using reflect(), use string interpolation now that it should work everywhere.

Addresses <rdar://problem/17415068>.

Swift SVN r20061
2014-07-16 23:58:07 +00:00
Chris Hanson
c3c1489a1c Declare access control for XCTest overlay.
Now that Swift has an access control model, we need to apply it to the XCTest overlay.

This is handy in that it lets us hide some implementation details of the overlay.

Addresses <rdar://problem/17653535>.

Swift SVN r19989
2014-07-15 23:03:29 +00:00
Doug Gregor
71cd9245ba Rename swift_stdlib_core -> swiftCore and swift_runtime -> swiftRuntime.
We can't use underscores in plists, so just makes the names consistent
<rdar://problem/17652418>.

Swift SVN r19954
2014-07-14 22:19:03 +00:00
Dave Abrahams
bf55e6b4ed [stdlib] s/FloatingPointNumberType/FloatingPointType/
Swift SVN r19887
2014-07-13 01:00:51 +00:00
Dave Abrahams
cbcf9aba21 s/LogicValueType/BooleanType/
We're moving toward using that protocol for straight-up Bool types

Swift SVN r19884
2014-07-12 18:58:18 +00:00
Dave Abrahams
6d1095f44e Protocol names end in "Type," "ible," or "able"
Mechanically add "Type" to the end of any protocol names that don't end
in "Type," "ible," or "able."  Also, drop "Type" from the end of any
associated type names, except for those of the *LiteralConvertible
protocols.

There are obvious improvements to make in some of these names, which can
be handled with separate commits.

Fixes <rdar://problem/17165920> Protocols `Integer` etc should get
uglier names.

Swift SVN r19883
2014-07-12 17:29:57 +00:00
Jordan Rose
44b93b5ebc [XCTest] Fix enumerator names after r19732.
Swift SVN r19736
2014-07-09 19:48:34 +00:00
Chris Hanson
73d268f0a9 XCTest: Use the new convention for format strings
When asking XCTest to generate format strings for assertions, pass the
requested index + 100 to ask XCTest to generate a string without space
for the expressions themselves, and don't bother passing them either
(since the overlay isn't actually generating stringified expressons).

Addresses <rdar://problem/17597526>.

Swift SVN r19712
2014-07-08 23:27:34 +00:00
Jordan Rose
bd80c74acd [CMake] XCTest is not ready to be a TARGET_LIBRARY.
Sorry for the churn!

Swift SVN r19666
2014-07-08 01:06:16 +00:00
Jordan Rose
22f2cde7f6 [CMake] Mark SpriteKit and XCTest as TARGET_LIBRARY targets.
(i.e. that they should be built for iOS using Doug's new schema.)

Swift SVN r19661
2014-07-08 00:59:07 +00:00
Doug Gregor
0c31ff5681 Move bridging conversions into the type checker.
Previously, bridged value types and their corresponding Objective-C
classes allow inter-conversion via a number of user-defined conversion
functions in the Foundation module. Instead, make this a general
feature of the type checker so we can reason about it more
directly. Fixes <rdar://problem/16956098> and
<rdar://problem/17134986>, and eliminates 11 (half) of the
__conversion functions from the standard library and overlays.

A few notes:
  - The XCTest changes are because a String can no longer directly
  conform to CVarArg: this is a Good Thing (TM), because it should be
  ambiguous: did you mean to pass it as an NSString or a C string?
  - The Objective-C representations for the bridged collections are
  hard-coded in the type checker. This is unfortunate and can be
  remedied by adding another associated type to the
  _BridgedToObjectiveC protocol.

Swift SVN r19618
2014-07-07 18:04:18 +00:00
Anna Zaks
6aadb1a647 APIs in XCTest now uses UInt, not Int.
Fixup for r19536.

Swift SVN r19538
2014-07-03 22:33:07 +00:00
Chris Hanson
d459ee4a3d Since all NSObject subclasses are Equatable, we can just use XCTAssertEqual/XCTAssertNotEqual.
Addresses <rdar://problem/17257148>

Swift SVN r19496
2014-07-03 00:31:08 +00:00
Doug Gregor
a5bde4e3a4 CMake: Add COMPILE_FLAGS support for add_swift_library.
COMPILE_FLAGS is currently used for two purposes:
  - For any target library, add the appropriate Swift optimization flags. This eliminates the add_swift_optimization_flags boilerplate and makes these flags work for all library variants
  - For the runtime, pass the appropriate define down when SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS is set, so that all library variants get this setting.

Swift SVN r19444
2014-07-02 00:37:48 +00:00
Chris Hanson
5b9b67e900 Revert "Remove XCTest overlay"
We need to actually keep the XCTest support in an overlay for now.

This reverts commit 4a2726862634a553483943baf39a251ac8071e37.

Addresses <rdar://problem/17423669>.

Swift SVN r19101
2014-06-23 21:00:47 +00:00
Chris Hanson
7d1cf3d107 Remove XCTest overlay
The XCTest support for Swift is now built as part of XCTest.framework
itself, so the overlay is no longer necessary.

Addresses <rdar://problem/17383462>.

Swift SVN r19016
2014-06-19 22:08:52 +00:00
Greg Parker
4f467b72f5 Fix build break in XCTest.
Swift SVN r18778
2014-06-10 05:36:31 +00:00
Chris Hanson
3298bebb2c Make XCTestCase.className demangle its result.
XCTest needs a way to get the demangled name of a test case class,
so provide one by overriding NSObject.className.

Addresses <rdar://problem/17010812>.

Swift SVN r18606
2014-05-23 22:07:29 +00:00
Joe Pamer
1d34a88477 Revert "Fix two problems with implicit conversions: - rdar://problem/16776273, wherein conversions between nil and .None were permitted due to an implicit conversion between nil and COpaquePointer. - rdar://problem/16877526, where we needed to add new equality overloads to handle conversions between nil and .None given the supression of user conversions. (Thanks to Ted for the overloads and test.)"
This reverts commit r18473.

Swift SVN r18477
2014-05-21 00:28:46 +00:00
Joe Pamer
f469d8f1f6 Fix two problems with implicit conversions:
- rdar://problem/16776273, wherein conversions between nil and .None were permitted
due to an implicit conversion between nil and COpaquePointer.
- rdar://problem/16877526, where we needed to add new equality overloads to handle
conversions between nil and .None given the supression of user conversions.
(Thanks to Ted for the overloads and test.)

Swift SVN r18473
2014-05-20 23:53:34 +00:00
Ted Kremenek
92157d7d55 Change 'isSignMinus', 'isNormal', etc., in FloatingPointNumber to properties.
Swift SVN r18306
2014-05-18 04:20:09 +00:00
Arnold Schwaighofer
da6d9152b6 Differentiate between user assertion and preconditions and the like
assert() and fatalError()
These functions are meant to be used in user code. They are enabled in debug
mode and disabled in release or fast mode.

_precondition() and _preconditionFailure()
These functions are meant to be used in library code to check preconditions at
the api boundry. They are enabled in debug mode (with a verbose message) and
release mode (trap). In fast mode they are disabled.

_debugPrecondition() and _debugPreconditionFailure()
These functions are meant to be used in library code to check preconditions that
are not neccesarily comprehensive for safety (UnsafePointer can be null or an
invalid pointer but we can't check both). They are enabled only in debug mode.

_sanityCheck() and _fatalError()
These are meant to be used for internal consistency checks. They are only
enabled when the library is build with -DSWIFT_STDLIB_INTERNAL_CHECKS=ON.

I modified the code in the standard library to the best of my judgement.

rdar://16477198

Swift SVN r18212
2014-05-16 20:49:54 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Ted Kremenek
05e9efb093 Don't compile XCTest overlay as being Application Extension safe.
Swift SVN r17682
2014-05-08 04:49:00 +00:00
Chris Hanson
8ff35e9c23 Check for a proper XCTest.framework in the platform
Check whether the XCTest.framework in the platform has headers before deciding whether to look there or in the SDK for it.

Swift SVN r16084
2014-04-08 23:55:34 +00:00
Chris Hanson
190c5c8477 Implement an XCTest overlay with basic assertions
Adds an overlay for Xcode's XCTest testing framework.

It implements most of the familiar test assertion macros as equivalent
Swift functions. The assertion macros that aren't currently implemented
are only those that deal specifically with floating-point equality and
Objective-C exceptions. Additionally, the implemented assertions don't
currently handle Objective-C exceptions thrown out of some code called
during an assertion as test failures.

Swift SVN r15917
2014-04-04 01:55:08 +00:00