Skip to content

Commit 130bcfd

Browse files
committed
[SE-0206][test] Fix tests that look at Hashable requirements
hash(into:) needs to be included in expectations; tests looking at synthesized Hashable implementation bodies need to be updated for resilient hashing.
1 parent 7d679f8 commit 130bcfd

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

test/IDE/complete_enum_elements.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
// RUN: %FileCheck %s -check-prefix=QUX_ENUM_NO_DOT < %t.enum.txt
5151

5252
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_QUAL_DOT_1 > %t.enum.txt
53-
// RUN: %FileCheck %s -check-prefix=FOO_ENUM_DOT < %t.enum.txt
53+
// RUN: %FileCheck %s -check-prefix=FOO_ENUM_DOT_INVALID < %t.enum.txt
5454

5555
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_QUAL_DOT_2 > %t.enum.txt
5656
// RUN: %FileCheck %s -check-prefix=BAR_ENUM_DOT < %t.enum.txt
@@ -88,17 +88,27 @@ enum FooEnum: CaseIterable {
8888
// FOO_ENUM_NO_DOT: Begin completions
8989
// FOO_ENUM_NO_DOT-NEXT: Decl[EnumElement]/CurrNominal: .Foo1[#FooEnum#]{{; name=.+$}}
9090
// FOO_ENUM_NO_DOT-NEXT: Decl[EnumElement]/CurrNominal: .Foo2[#FooEnum#]{{; name=.+$}}
91+
// FOO_ENUM_NO_DOT-NEXT: Decl[InstanceMethod]/CurrNominal: .hash({#self: FooEnum#})[#(into: inout Hasher) -> Void#]; name=hash(FooEnum)
9192
// FOO_ENUM_NO_DOT-NEXT: Decl[TypeAlias]/CurrNominal: .AllCases[#[FooEnum]#]{{; name=.+$}}
9293
// FOO_ENUM_NO_DOT-NEXT: Decl[StaticVar]/CurrNominal: .allCases[#[FooEnum]#]{{; name=.+$}}
9394
// FOO_ENUM_NO_DOT-NEXT: End completions
9495

9596
// FOO_ENUM_DOT: Begin completions
9697
// FOO_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Foo1[#FooEnum#]{{; name=.+$}}
9798
// FOO_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Foo2[#FooEnum#]{{; name=.+$}}
99+
// FOO_ENUM_DOT-NEXT: Decl[InstanceMethod]/CurrNominal: hash({#self: FooEnum#})[#(into: inout Hasher) -> Void#]; name=hash(FooEnum)
98100
// FOO_ENUM_DOT-NEXT: Decl[TypeAlias]/CurrNominal: AllCases[#[FooEnum]#]{{; name=.+$}}
99101
// FOO_ENUM_DOT-NEXT: Decl[StaticVar]/CurrNominal: allCases[#[FooEnum]#]{{; name=.+$}}
100102
// FOO_ENUM_DOT-NEXT: End completions
101103

104+
// FOO_ENUM_DOT_INVALID: Begin completions
105+
// FOO_ENUM_DOT_INVALID-NEXT: Decl[EnumElement]/CurrNominal: Foo1[#FooEnum#]{{; name=.+$}}
106+
// FOO_ENUM_DOT_INVALID-NEXT: Decl[EnumElement]/CurrNominal: Foo2[#FooEnum#]{{; name=.+$}}
107+
// FOO_ENUM_DOT_INVALID-NEXT: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: hash({#self: FooEnum#})[#(into: inout Hasher) -> Void#]; name=hash(FooEnum)
108+
// FOO_ENUM_DOT_INVALID-NEXT: Decl[TypeAlias]/CurrNominal: AllCases[#[FooEnum]#]{{; name=.+$}}
109+
// FOO_ENUM_DOT_INVALID-NEXT: Decl[StaticVar]/CurrNominal: allCases[#[FooEnum]#]{{; name=.+$}}
110+
// FOO_ENUM_DOT_INVALID-NEXT: End completions
111+
102112
// FOO_ENUM_DOT_ELEMENTS: Begin completions, 2 items
103113
// FOO_ENUM_DOT_ELEMENTS-NEXT: Decl[EnumElement]/ExprSpecific: Foo1[#FooEnum#]{{; name=.+$}}
104114
// FOO_ENUM_DOT_ELEMENTS-NEXT: Decl[EnumElement]/ExprSpecific: Foo2[#FooEnum#]{{; name=.+$}}
@@ -237,17 +247,19 @@ enum QuxEnum : Int {
237247
// QUX_ENUM_TYPE_CONTEXT-DAG: Decl[EnumElement]/ExprSpecific: .Qux2[#QuxEnum#]{{; name=.+$}}
238248
// QUX_ENUM_TYPE_CONTEXT: End completions
239249

240-
// QUX_ENUM_NO_DOT: Begin completions, 4 items
250+
// QUX_ENUM_NO_DOT: Begin completions, 5 items
241251
// QUX_ENUM_NO_DOT-NEXT: Decl[EnumElement]/CurrNominal: .Qux1[#QuxEnum#]{{; name=.+$}}
242252
// QUX_ENUM_NO_DOT-NEXT: Decl[EnumElement]/CurrNominal: .Qux2[#QuxEnum#]{{; name=.+$}}
243253
// QUX_ENUM_NO_DOT-NEXT: Decl[TypeAlias]/CurrNominal: .RawValue[#Int#]{{; name=.+$}}
254+
// QUX_ENUM_NO_DOT-NEXT: Decl[InstanceMethod]/CurrNominal: .hash({#self: QuxEnum#})[#(into: inout Hasher) -> Void#]; name=hash(QuxEnum)
244255
// QUX_ENUM_NO_DOT-NEXT: Decl[Constructor]/CurrNominal: ({#rawValue: Int#})[#QuxEnum?#]{{; name=.+$}}
245256
// QUX_ENUM_NO_DOT-NEXT: End completions
246257

247-
// QUX_ENUM_DOT: Begin completions, 4 items
258+
// QUX_ENUM_DOT: Begin completions, 5 items
248259
// QUX_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Qux1[#QuxEnum#]{{; name=.+$}}
249260
// QUX_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Qux2[#QuxEnum#]{{; name=.+$}}
250261
// QUX_ENUM_DOT-NEXT: Decl[TypeAlias]/CurrNominal: RawValue[#Int#]{{; name=.+$}}
262+
// QUX_ENUM_DOT-NEXT: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: hash({#self: QuxEnum#})[#(into: inout Hasher) -> Void#]; name=hash(QuxEnum)
251263
// QUX_ENUM_DOT-NEXT: Decl[Constructor]/CurrNominal: init({#rawValue: Int#})[#QuxEnum?#]{{; name=.+$}}
252264
// QUX_ENUM_DOT-NEXT: End completions
253265

test/IDE/print_ast_tc_decls.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ struct d0200_EscapedIdentifiers {
587587
// PASS_COMMON-NEXT: {{^}} case `case`{{$}}
588588
// PASS_COMMON-NEXT: {{^}} {{.*}}static func __derived_enum_equals(_ a: d0200_EscapedIdentifiers.`enum`, _ b: d0200_EscapedIdentifiers.`enum`) -> Bool
589589
// PASS_COMMON-NEXT: {{^}} var hashValue: Int { get }{{$}}
590+
// PASS_COMMON-NEXT: {{^}} func hash(into hasher: inout Hasher)
590591
// PASS_COMMON-NEXT: {{^}} }{{$}}
591592

592593
class `class` {}
@@ -1015,6 +1016,7 @@ enum d2000_EnumDecl1 {
10151016
// PASS_COMMON-NEXT: {{^}} case ED1_Second{{$}}
10161017
// PASS_COMMON-NEXT: {{^}} {{.*}}static func __derived_enum_equals(_ a: d2000_EnumDecl1, _ b: d2000_EnumDecl1) -> Bool
10171018
// PASS_COMMON-NEXT: {{^}} var hashValue: Int { get }{{$}}
1019+
// PASS_COMMON-NEXT: {{^}} func hash(into hasher: inout Hasher)
10181020
// PASS_COMMON-NEXT: {{^}}}{{$}}
10191021

10201022
enum d2100_EnumDecl2 {
@@ -1072,6 +1074,7 @@ enum d2300_EnumDeclWithValues1 : Int {
10721074
// PASS_COMMON-NEXT: {{^}} case EDV2_Second{{$}}
10731075
// PASS_COMMON-NEXT: {{^}} typealias RawValue = Int
10741076
// PASS_COMMON-NEXT: {{^}} var hashValue: Int { get }{{$}}
1077+
// PASS_COMMON-NEXT: {{^}} func hash(into hasher: inout Hasher)
10751078
// PASS_COMMON-NEXT: {{^}} init?(rawValue: Int){{$}}
10761079
// PASS_COMMON-NEXT: {{^}} var rawValue: Int { get }{{$}}
10771080
// PASS_COMMON-NEXT: {{^}}}{{$}}
@@ -1085,6 +1088,7 @@ enum d2400_EnumDeclWithValues2 : Double {
10851088
// PASS_COMMON-NEXT: {{^}} case EDV3_Second{{$}}
10861089
// PASS_COMMON-NEXT: {{^}} typealias RawValue = Double
10871090
// PASS_COMMON-NEXT: {{^}} var hashValue: Int { get }{{$}}
1091+
// PASS_COMMON-NEXT: {{^}} func hash(into hasher: inout Hasher)
10881092
// PASS_COMMON-NEXT: {{^}} init?(rawValue: Double){{$}}
10891093
// PASS_COMMON-NEXT: {{^}} var rawValue: Double { get }{{$}}
10901094
// PASS_COMMON-NEXT: {{^}}}{{$}}

test/api-digester/Outputs/cake.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,27 @@
567567
}
568568
]
569569
},
570+
{
571+
"kind": "Function",
572+
"name": "hash",
573+
"printedName": "hash(into:)",
574+
"declKind": "Func",
575+
"usr": "s:4cake6NumberO4hash4intoys6HasherVz_tF",
576+
"location": "",
577+
"moduleName": "cake",
578+
"children": [
579+
{
580+
"kind": "TypeNominal",
581+
"name": "Void",
582+
"printedName": "()"
583+
},
584+
{
585+
"kind": "TypeNominal",
586+
"name": "InOut",
587+
"printedName": "inout Hasher"
588+
}
589+
]
590+
},
570591
{
571592
"kind": "Constructor",
572593
"name": "init",

0 commit comments

Comments
 (0)