Skip to content

Commit ca7beda

Browse files
authored
Merge pull request #4213 from apple/test-cleanups
Assorted test cleanups and fixes
2 parents 42a4537 + ad48cf2 commit ca7beda

8 files changed

+36
-81
lines changed

test/1_stdlib/BitwiseOperationsType.swift

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
// RUN: %target-run-simple-swift | FileCheck %s
1+
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
3+
4+
import StdlibUnittest
5+
36
struct MyInt32 : BitwiseOperations {
47
var underlying: Int32
58

@@ -22,18 +25,19 @@ prefix func ~(x: MyInt32) -> MyInt32 {
2225
return MyInt32(underlying: ~x.underlying)
2326
}
2427

25-
// |=
26-
var a = MyInt32(underlying: 0x3)
27-
a |= MyInt32(underlying: 0x4)
28-
assert(a.underlying == 0x7)
28+
let BitwiseOperationsTests = TestSuite("BitwiseOperations")
29+
30+
BitwiseOperationsTests.test("smoke test") {
31+
var a = MyInt32(underlying: 0x3)
32+
a |= MyInt32(underlying: 0x4)
33+
expectEqual(0x7, a.underlying)
2934

30-
// &=
31-
a &= MyInt32(underlying: 0x5)
32-
assert(a.underlying == 0x5)
35+
a &= MyInt32(underlying: 0x5)
36+
expectEqual(0x5, a.underlying)
37+
38+
a ^= MyInt32(underlying: 0x6)
39+
expectEqual(0x3, a.underlying)
40+
}
3341

34-
// ^=
35-
a ^= MyInt32(underlying: 0x6)
36-
assert(a.underlying == 0x3)
42+
runAllTests()
3743

38-
// CHECK: done
39-
print("done")

test/1_stdlib/Float.swift

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
// RUN: rm -rf %t &&mkdir %t
1+
// RUN: rm -rf %t && mkdir %t
22
// RUN: cp %s %t/main.swift
33

44
// RUN: echo "typealias TestFloat = Float" > %t/float_type.swift
55
// RUN: %target-build-swift %t/main.swift %t/float_type.swift -o %t/float.out
6-
// RUN: %target-run %t/float.out | FileCheck %s
6+
// RUN: %target-run %t/float.out
77

88
// RUN: echo "typealias TestFloat = Double" > %t/double_type.swift
99
// RUN: %target-build-swift %t/main.swift %t/double_type.swift -o %t/double.out
10-
// RUN: %target-run %t/double.out | FileCheck %s
10+
// RUN: %target-run %t/double.out
1111
// REQUIRES: executable_test
1212

13+
import StdlibUnittest
14+
15+
var FloatTests = TestSuite("Float")
16+
1317
//===---
1418
// Helpers
1519
//===---
@@ -36,7 +40,7 @@ func checkNormal(_ normal: TestFloat) {
3640
_precondition(!normal.isSignalingNaN)
3741
}
3842

39-
func testNormal() {
43+
FloatTests.test("normal") {
4044
let positiveNormal: TestFloat = 42.0
4145
checkNormal(positiveNormal)
4246
_precondition(positiveNormal.sign == .plus)
@@ -53,11 +57,7 @@ func testNormal() {
5357
_precondition(negativeNormal != positiveNormal)
5458
_precondition(positiveNormal == -negativeNormal)
5559
_precondition(negativeNormal == -positiveNormal)
56-
57-
print("testNormal done")
5860
}
59-
testNormal()
60-
// CHECK: testNormal done
6161

6262
//===---
6363
// Zeroes
@@ -73,7 +73,7 @@ func checkZero(_ zero: TestFloat) {
7373
_precondition(!zero.isSignalingNaN)
7474
}
7575

76-
func testZero() {
76+
FloatTests.test("zero") {
7777
let plusZero = noinlinePlusZero()
7878
checkZero(plusZero)
7979
_precondition(plusZero.sign == .plus)
@@ -90,11 +90,7 @@ func testZero() {
9090
_precondition(minusZero == -0.0)
9191
_precondition(minusZero == plusZero)
9292
_precondition(minusZero == minusZero)
93-
94-
print("testZero done")
9593
}
96-
testZero()
97-
// CHECK: testZero done
9894

9995
//===---
10096
// Subnormals
@@ -118,7 +114,8 @@ func asUInt64(_ a: UInt32) -> UInt64 {
118114
return UInt64(a)
119115
}
120116

121-
func testSubnormal() {
117+
#if !arch(arm)
118+
FloatTests.test("subnormal") {
122119
var iterations: Int
123120
switch asUInt64(TestFloat.RawSignificand.max) {
124121
case UInt64.max:
@@ -145,16 +142,8 @@ func testSubnormal() {
145142
_precondition(negativeSubnormal.sign == .minus)
146143
_precondition(negativeSubnormal.floatingPointClass == .negativeSubnormal)
147144
_precondition(negativeSubnormal != -0.0)
148-
149-
print("testSubnormal done")
150145
}
151-
152-
#if arch(arm)
153-
print("testSubnormal done")
154-
#else
155-
testSubnormal()
156146
#endif
157-
// CHECK: testSubnormal done
158147

159148
//===---
160149
// Infinities
@@ -170,7 +159,7 @@ func checkInf(_ inf: TestFloat) {
170159
_precondition(!inf.isSignalingNaN)
171160
}
172161

173-
func testInf() {
162+
FloatTests.test("infinity") {
174163
var stdlibPlusInf = TestFloat.infinity
175164
checkInf(stdlibPlusInf)
176165
_precondition(stdlibPlusInf.sign == .plus)
@@ -196,11 +185,7 @@ func testInf() {
196185

197186
_precondition(stdlibPlusInf != computedMinusInf)
198187
_precondition(stdlibMinusInf != computedPlusInf)
199-
200-
print("testInf done")
201188
}
202-
testInf()
203-
// CHECK: testInf done
204189

205190
//===---
206191
// NaNs
@@ -231,7 +216,7 @@ func checkSNaN(_ snan: TestFloat) {
231216
#endif
232217
}
233218

234-
func testNaN() {
219+
FloatTests.test("nan") {
235220
var stdlibDefaultNaN = TestFloat.nan
236221
checkQNaN(stdlibDefaultNaN)
237222

@@ -240,11 +225,7 @@ func testNaN() {
240225

241226
var stdlibSNaN = TestFloat.signalingNaN
242227
checkSNaN(stdlibSNaN)
243-
print("testNaN done")
244228
}
245-
testNaN()
246-
// CHECK: testNaN done
247229

248-
print("all done.")
249-
// CHECK: all done.
230+
runAllTests()
250231

test/1_stdlib/Zip.swift

Lines changed: 0 additions & 30 deletions
This file was deleted.

test/IDE/complete_at_eof_in_call_no_newline_1.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
// A-DAG: Pattern/ExprSpecific: ['(']{#(x): Int#})[#Void#]{{; name=.+$}}
88
// A: End completions
99
func f(_ x: Int) {}
10-
f(#^A^#
10+
f(#^A^#

test/IDE/complete_at_eof_no_newline_1.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ struct FooStruct {
1313
}
1414
var fooObject: FooStruct
1515
// There is no newline on the following line. Don't fix this!
16-
fooObject.#^A^#
16+
fooObject.#^A^#

test/IDE/complete_at_eof_no_newline_2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
// A: End completions
1111
func f() {}
1212
// There is no newline on the following line. Don't fix this!
13-
#^A^#
13+
#^A^#
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// RUN: %target-parse-verify-swift
22

33
// This file does not end in a trailing newline; this is deliberate!
4-
/* unterminated block comment expected-note{{comment started here}} expected-error{{unterminated '/*' comment}}{{126-126=*/}}
4+
/* unterminated block comment expected-note{{comment started here}} expected-error{{unterminated '/*' comment}}{{126-126=*/}}

test/Parse/EOF/unterminated-string-literal-missing-newline.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
// This file does not end in a trailing newline; this is deliberate, don't fix it!
66

7-
/* expected-error {{unterminated string literal}} */ "
7+
/* expected-error {{unterminated string literal}} */ "

0 commit comments

Comments
 (0)