Skip to content

Commit 958ee1a

Browse files
committed
Add more type checker performance tests.
Also move one from fast to slow based on the fact that it wasn't representative of the original issue (which was an expression that didn't typecheck successfully).
1 parent 287e211 commit 958ee1a

File tree

7 files changed

+64
-10
lines changed

7 files changed

+64
-10
lines changed

test/stdlib/Character.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ CharacterTests.test(
310310
expectEqualMethodsForDomain(
311311
ascii0to126,
312312
ascii1to127,
313-
{ x in { String(x) < String($0) } } as PredicateFn,
314-
{ x in { String(Character(x)) < String(Character($0)) } } as PredicateFn)
313+
{ x in { String(x) < String($0) } },
314+
{ x in { String(Character(x)) < String(Character($0)) } })
315315
}
316316

317317
CharacterTests.test("String.append(_: Character)") {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1 -swift-version 5 -solver-disable-shrink -disable-constraint-solver-performance-hacks -solver-enable-operator-designated-types
2+
// REQUIRES: tools-release,no_asserts
3+
4+
func test(a: [String], b: String, c: String) -> [String] {
5+
return a.map { $0 + ": " + b + "(" + c + $0 + ")" }
6+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
public func expectEqualMethodsForDomain<
5+
SelfType, ArgumentType, Result : Equatable
6+
>(
7+
_ selfs: [SelfType], _ arguments: [ArgumentType],
8+
_ function1: (SelfType) -> (ArgumentType) -> Result,
9+
_ function2: (SelfType) -> (ArgumentType) -> Result
10+
) { fatalError() }
11+
12+
func test(ascii0to126: [UnicodeScalar], ascii1to127: [UnicodeScalar]) {
13+
expectEqualMethodsForDomain(
14+
ascii0to126,
15+
ascii1to127,
16+
{ x in { String(x) < String($0) } },
17+
{ x in { String(Character(x)) < String(Character($0)) } })
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1 -swift-version 5 -solver-disable-shrink -disable-constraint-solver-performance-hacks -solver-enable-operator-designated-types
2+
// REQUIRES: tools-release,no_asserts
3+
4+
func test(strings: [String]) {
5+
for string in strings {
6+
let _ = string.split(omittingEmptySubsequences: false) { $0 == "C" || $0 == "D" || $0 == "H" || $0 == "S"}
7+
}
8+
}

validation-test/Sema/type_checker_perf/fast/rdar19915443.swift.gyb

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
precedencegroup ExponentiationPrecedence {
5+
associativity: right
6+
higherThan: BitwiseShiftPrecedence
7+
}
8+
9+
infix operator ** : ExponentiationPrecedence
10+
11+
func ** (num: Float, power: Float) -> Float {
12+
fatalError()
13+
}
14+
15+
func test(f: Float) {
16+
let v1: Float = 1.1
17+
let v2 = 2.2
18+
let v3 = 3.3
19+
20+
// NOTE: This is using mixed types, and would result in a type checking error if it completed.
21+
let _ = v2*7.1**(1.97276*(1-v1/f)-7.02202*v3+1.70373*1e-3*(1.0-10**(-2.29692*(f/v1-1.0)))+0.32273*1e-3*(10**(3.76977*(1.0-v1/f))-1)-2.2195923)
22+
// expected-error@-1 {{the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions}}
23+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
var counts = [ 0, 0, 0, 0 ]
5+
// NOTE: This is using mixed types, and would result in a type checking error if it completed.
6+
let d = counts[0] * 1000 + counts[1] * 100 + counts[2] * 10 + counts
7+
// expected-error@-1 {{the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions}}

0 commit comments

Comments
 (0)