Skip to content

Commit ed82f7e

Browse files
jonmeowjosh11b
andauthored
Add ranges to where_expr tests (#5630)
Co-authored-by: josh11b <[email protected]>
1 parent 07aec16 commit ed82f7e

File tree

6 files changed

+249
-2453
lines changed

6 files changed

+249
-2453
lines changed

toolchain/check/testdata/where_expr/constraints.carbon

Lines changed: 49 additions & 522 deletions
Large diffs are not rendered by default.

toolchain/check/testdata/where_expr/designator.carbon

Lines changed: 28 additions & 325 deletions
Large diffs are not rendered by default.

toolchain/check/testdata/where_expr/dot_self_index.carbon

Lines changed: 46 additions & 180 deletions
Large diffs are not rendered by default.

toolchain/check/testdata/where_expr/equal_rewrite.carbon

Lines changed: 120 additions & 1240 deletions
Large diffs are not rendered by default.

toolchain/check/testdata/where_expr/fail_not_facet.carbon

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Exceptions. See /LICENSE for license information.
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
//
5-
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
6-
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
7-
//
85
// AUTOUPDATE
96
// TIP: To test this file alone, run:
107
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/where_expr/fail_not_facet.carbon
@@ -40,142 +37,3 @@ library "[[@TEST_NAME]]";
4037
// CHECK:STDERR: ^
4138
// CHECK:STDERR:
4239
var v: e where .x = 3;
43-
44-
// CHECK:STDOUT: --- fail_left_where_not_facet.carbon
45-
// CHECK:STDOUT:
46-
// CHECK:STDOUT: constants {
47-
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
48-
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
49-
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
50-
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
51-
// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [concrete]
52-
// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [concrete]
53-
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
54-
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
55-
// CHECK:STDOUT: }
56-
// CHECK:STDOUT:
57-
// CHECK:STDOUT: imports {
58-
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
59-
// CHECK:STDOUT: .Int = %Core.Int
60-
// CHECK:STDOUT: .Bool = %Core.Bool
61-
// CHECK:STDOUT: import Core//prelude
62-
// CHECK:STDOUT: import Core//prelude/...
63-
// CHECK:STDOUT: }
64-
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
65-
// CHECK:STDOUT: %Core.Bool: %Bool.type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = constants.%Bool]
66-
// CHECK:STDOUT: }
67-
// CHECK:STDOUT:
68-
// CHECK:STDOUT: file {
69-
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
70-
// CHECK:STDOUT: .Core = imports.%Core
71-
// CHECK:STDOUT: .F = %F.decl
72-
// CHECK:STDOUT: }
73-
// CHECK:STDOUT: %Core.import = import Core
74-
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
75-
// CHECK:STDOUT: %T.patt: <error> = symbolic_binding_pattern T, 0 [concrete]
76-
// CHECK:STDOUT: } {
77-
// CHECK:STDOUT: %.loc8_14.1: type = splice_block %.loc8_14.2 [concrete = <error>] {
78-
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
79-
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
80-
// CHECK:STDOUT: %.Self: <error> = bind_symbolic_name .Self [concrete = <error>]
81-
// CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, %.Self [concrete = <error>]
82-
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [concrete = bool]
83-
// CHECK:STDOUT: %.loc8_14.2: type = where_expr %.Self [concrete = <error>] {
84-
// CHECK:STDOUT: requirement_equivalent %.Self.ref, %bool.make_type
85-
// CHECK:STDOUT: }
86-
// CHECK:STDOUT: }
87-
// CHECK:STDOUT: %T: <error> = bind_symbolic_name T, 0 [concrete = <error>]
88-
// CHECK:STDOUT: }
89-
// CHECK:STDOUT: }
90-
// CHECK:STDOUT:
91-
// CHECK:STDOUT: generic fn @F(%T: <error>) {
92-
// CHECK:STDOUT: fn();
93-
// CHECK:STDOUT: }
94-
// CHECK:STDOUT:
95-
// CHECK:STDOUT: specific @F(<error>) {}
96-
// CHECK:STDOUT:
97-
// CHECK:STDOUT: --- fail_left_where_unknown.carbon
98-
// CHECK:STDOUT:
99-
// CHECK:STDOUT: constants {
100-
// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [concrete]
101-
// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [concrete]
102-
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
103-
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
104-
// CHECK:STDOUT: }
105-
// CHECK:STDOUT:
106-
// CHECK:STDOUT: imports {
107-
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
108-
// CHECK:STDOUT: .Bool = %Core.Bool
109-
// CHECK:STDOUT: import Core//prelude
110-
// CHECK:STDOUT: import Core//prelude/...
111-
// CHECK:STDOUT: }
112-
// CHECK:STDOUT: %Core.Bool: %Bool.type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = constants.%Bool]
113-
// CHECK:STDOUT: }
114-
// CHECK:STDOUT:
115-
// CHECK:STDOUT: file {
116-
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
117-
// CHECK:STDOUT: .Core = imports.%Core
118-
// CHECK:STDOUT: .NOT_DECLARED = <poisoned>
119-
// CHECK:STDOUT: .G = %G.decl
120-
// CHECK:STDOUT: }
121-
// CHECK:STDOUT: %Core.import = import Core
122-
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
123-
// CHECK:STDOUT: %U.patt: <error> = symbolic_binding_pattern U, 0 [concrete]
124-
// CHECK:STDOUT: } {
125-
// CHECK:STDOUT: %.loc8_23.1: type = splice_block %.loc8_23.2 [concrete = <error>] {
126-
// CHECK:STDOUT: %NOT_DECLARED.ref: <error> = name_ref NOT_DECLARED, <error> [concrete = <error>]
127-
// CHECK:STDOUT: %.Self: <error> = bind_symbolic_name .Self [concrete = <error>]
128-
// CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, %.Self [concrete = <error>]
129-
// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [concrete = bool]
130-
// CHECK:STDOUT: %.loc8_23.2: type = where_expr %.Self [concrete = <error>] {
131-
// CHECK:STDOUT: requirement_equivalent %.Self.ref, %bool.make_type
132-
// CHECK:STDOUT: }
133-
// CHECK:STDOUT: }
134-
// CHECK:STDOUT: %U: <error> = bind_symbolic_name U, 0 [concrete = <error>]
135-
// CHECK:STDOUT: }
136-
// CHECK:STDOUT: }
137-
// CHECK:STDOUT:
138-
// CHECK:STDOUT: generic fn @G(%U: <error>) {
139-
// CHECK:STDOUT: fn();
140-
// CHECK:STDOUT: }
141-
// CHECK:STDOUT:
142-
// CHECK:STDOUT: specific @G(<error>) {}
143-
// CHECK:STDOUT:
144-
// CHECK:STDOUT: --- fail_var.carbon
145-
// CHECK:STDOUT:
146-
// CHECK:STDOUT: constants {
147-
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
148-
// CHECK:STDOUT: }
149-
// CHECK:STDOUT:
150-
// CHECK:STDOUT: imports {
151-
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
152-
// CHECK:STDOUT: import Core//prelude
153-
// CHECK:STDOUT: import Core//prelude/...
154-
// CHECK:STDOUT: }
155-
// CHECK:STDOUT: }
156-
// CHECK:STDOUT:
157-
// CHECK:STDOUT: file {
158-
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
159-
// CHECK:STDOUT: .Core = imports.%Core
160-
// CHECK:STDOUT: .e = <poisoned>
161-
// CHECK:STDOUT: .v = %v
162-
// CHECK:STDOUT: }
163-
// CHECK:STDOUT: %Core.import = import Core
164-
// CHECK:STDOUT: name_binding_decl {
165-
// CHECK:STDOUT: %v.patt: <error> = binding_pattern v [concrete]
166-
// CHECK:STDOUT: %v.var_patt: <error> = var_pattern %v.patt [concrete]
167-
// CHECK:STDOUT: }
168-
// CHECK:STDOUT: %v.var: ref <error> = var %v.var_patt [concrete = <error>]
169-
// CHECK:STDOUT: %.loc8_10.1: type = splice_block %.loc8_10.2 [concrete = <error>] {
170-
// CHECK:STDOUT: %e.ref: <error> = name_ref e, <error> [concrete = <error>]
171-
// CHECK:STDOUT: %.Self: <error> = bind_symbolic_name .Self [concrete = <error>]
172-
// CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, %.Self [concrete = <error>]
173-
// CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [concrete = <error>]
174-
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
175-
// CHECK:STDOUT: %.loc8_10.2: type = where_expr %.Self [concrete = <error>] {
176-
// CHECK:STDOUT: requirement_rewrite %x.ref, <error>
177-
// CHECK:STDOUT: }
178-
// CHECK:STDOUT: }
179-
// CHECK:STDOUT: %v: <error> = bind_name v, <error> [concrete = <error>]
180-
// CHECK:STDOUT: }
181-
// CHECK:STDOUT:

toolchain/check/testdata/where_expr/non_generic.carbon

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Exceptions. See /LICENSE for license information.
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
//
5-
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
6-
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
7-
//
85
// AUTOUPDATE
96
// TIP: To test this file alone, run:
107
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/where_expr/non_generic.carbon
@@ -14,23 +11,21 @@
1411
interface I { let T:! type; }
1512

1613
// Ensure that we don't crash when checking this `where` in a non-generic context.
14+
//@dump-sem-ir-begin
1715
fn NotGenericF(U: I where .T == i32) {}
16+
//@dump-sem-ir-end
1817

1918
// CHECK:STDOUT: --- non_generic.carbon
2019
// CHECK:STDOUT:
2120
// CHECK:STDOUT: constants {
2221
// CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
23-
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
2422
// CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
2523
// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete]
2624
// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self]
2725
// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self]
2826
// CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %.Self, @I [symbolic_self]
29-
// CHECK:STDOUT: %I.facet: %I.type = facet_value %.Self.as_type, (%I.lookup_impl_witness) [symbolic_self]
3027
// CHECK:STDOUT: %impl.elem0: type = impl_witness_access %I.lookup_impl_witness, element0 [symbolic_self]
3128
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
32-
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
33-
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
3429
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
3530
// CHECK:STDOUT: %I_where.type: type = facet_type <@I where TODO> [concrete]
3631
// CHECK:STDOUT: %pattern_type.f03: type = pattern_type %I_where.type [concrete]
@@ -39,67 +34,34 @@ fn NotGenericF(U: I where .T == i32) {}
3934
// CHECK:STDOUT: }
4035
// CHECK:STDOUT:
4136
// CHECK:STDOUT: imports {
42-
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
43-
// CHECK:STDOUT: .Int = %Core.Int
44-
// CHECK:STDOUT: import Core//prelude
45-
// CHECK:STDOUT: import Core//prelude/...
46-
// CHECK:STDOUT: }
47-
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
4837
// CHECK:STDOUT: }
4938
// CHECK:STDOUT:
5039
// CHECK:STDOUT: file {
51-
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
52-
// CHECK:STDOUT: .Core = imports.%Core
53-
// CHECK:STDOUT: .I = %I.decl
54-
// CHECK:STDOUT: .NotGenericF = %NotGenericF.decl
55-
// CHECK:STDOUT: }
56-
// CHECK:STDOUT: %Core.import = import Core
57-
// CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
5840
// CHECK:STDOUT: %NotGenericF.decl: %NotGenericF.type = fn_decl @NotGenericF [concrete = constants.%NotGenericF] {
5941
// CHECK:STDOUT: %U.patt: %pattern_type.f03 = binding_pattern U [concrete]
6042
// CHECK:STDOUT: %U.param_patt: %pattern_type.f03 = value_param_pattern %U.patt, call_param0 [concrete]
6143
// CHECK:STDOUT: } {
6244
// CHECK:STDOUT: %U.param: %I_where.type = value_param call_param0
63-
// CHECK:STDOUT: %.loc17_21.1: type = splice_block %.loc17_21.2 [concrete = constants.%I_where.type] {
45+
// CHECK:STDOUT: %.loc15_21.1: type = splice_block %.loc15_21.2 [concrete = constants.%I_where.type] {
6446
// CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
65-
// CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
47+
// CHECK:STDOUT: <elided>
6648
// CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
6749
// CHECK:STDOUT: %T.ref: %I.assoc_type = name_ref T, @T.%assoc0 [concrete = constants.%assoc0]
6850
// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type]
69-
// CHECK:STDOUT: %.loc17_27: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type]
51+
// CHECK:STDOUT: %.loc15_27: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type]
7052
// CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
7153
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
7254
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
73-
// CHECK:STDOUT: %.loc17_21.2: type = where_expr %.Self [concrete = constants.%I_where.type] {
55+
// CHECK:STDOUT: %.loc15_21.2: type = where_expr %.Self [concrete = constants.%I_where.type] {
7456
// CHECK:STDOUT: requirement_equivalent %impl.elem0, %i32
7557
// CHECK:STDOUT: }
7658
// CHECK:STDOUT: }
7759
// CHECK:STDOUT: %U: %I_where.type = bind_name U, %U.param
7860
// CHECK:STDOUT: }
7961
// CHECK:STDOUT: }
8062
// CHECK:STDOUT:
81-
// CHECK:STDOUT: interface @I {
82-
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
83-
// CHECK:STDOUT: %T: type = assoc_const_decl @T [concrete] {
84-
// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%T [concrete = constants.%assoc0]
85-
// CHECK:STDOUT: }
86-
// CHECK:STDOUT:
87-
// CHECK:STDOUT: !members:
88-
// CHECK:STDOUT: .Self = %Self
89-
// CHECK:STDOUT: .T = @T.%assoc0
90-
// CHECK:STDOUT: witness = (%T)
91-
// CHECK:STDOUT: }
92-
// CHECK:STDOUT:
93-
// CHECK:STDOUT: generic assoc_const @T(@I.%Self: %I.type) {
94-
// CHECK:STDOUT: assoc_const T:! type;
95-
// CHECK:STDOUT: }
96-
// CHECK:STDOUT:
9763
// CHECK:STDOUT: fn @NotGenericF(%U.param: %I_where.type) {
9864
// CHECK:STDOUT: !entry:
9965
// CHECK:STDOUT: return
10066
// CHECK:STDOUT: }
10167
// CHECK:STDOUT:
102-
// CHECK:STDOUT: specific @T(constants.%Self) {}
103-
// CHECK:STDOUT:
104-
// CHECK:STDOUT: specific @T(constants.%I.facet) {}
105-
// CHECK:STDOUT:

0 commit comments

Comments
 (0)