Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit ac22267

Browse files
author
Hendrik van Antwerpen
committed
Consolidate test expectations
1 parent 2926cba commit ac22267

File tree

2 files changed

+147
-262
lines changed

2 files changed

+147
-262
lines changed

stack-graphs/tests/it/c/can_find_partial_paths_in_file.rs

Lines changed: 10 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -142,64 +142,17 @@ fn class_field_through_function_parameter() {
142142
check_partial_paths_in_file(
143143
&graph,
144144
"main.py",
145-
&[
146-
// definition of `__main__` module
147-
"<__main__,%1> ($1) [root] -> [main.py(0) definition __main__] <%1> ($1)",
148-
// reference to `a` in import statement
149-
"<%1> ($1) [main.py(17) reference a] -> [root] <a,%1> ($1)",
150-
// `from a import *` means we can rewrite any lookup of `__main__.*` → `a.*`
151-
"<__main__.,%2> ($1) [root] -> [root] <a.,%2> ($1)",
152-
// reference to `b` in import statement
153-
"<%1> ($1) [main.py(15) reference b] -> [root] <b,%1> ($1)",
154-
// `from b import *` means we can rewrite any lookup of `__main__.*` → `b.*`
155-
"<__main__.,%2> ($1) [root] -> [root] <b.,%2> ($1)",
156-
// we can look for every reference in either `a` or `b`
157-
"<%1> ($1) [main.py(9) reference A] -> [root] <a.A,%1> ($1)",
158-
"<%1> ($1) [main.py(9) reference A] -> [root] <b.A,%1> ($1)",
159-
"<%1> ($1) [main.py(10) reference bar] -> [root] <a.foo()/([main.py(7)],$1).bar,%1> ($1)",
160-
"<%1> ($1) [main.py(10) reference bar] -> [root] <b.foo()/([main.py(7)],$1).bar,%1> ($1)",
161-
"<%1> ($1) [main.py(13) reference foo] -> [root] <a.foo,%1> ($1)",
162-
"<%1> ($1) [main.py(13) reference foo] -> [root] <b.foo,%1> ($1)",
163-
// parameter 0 of function call is `A`, which we can look up in either `a` or `b`
164-
"<0,%1> ($1) [main.py(7) exported scope] -> [root] <a.A,%1> ($1)",
165-
"<0,%1> ($1) [main.py(7) exported scope] -> [root] <b.A,%1> ($1)",
166-
],
145+
crate::can_find_partial_paths_in_file::CLASS_FIELD_THROUGH_FUNCTION_PARAMETER_MAIN_PATHS,
167146
);
168147
check_partial_paths_in_file(
169148
&graph,
170149
"a.py",
171-
&[
172-
// definition of `a` module
173-
"<a,%1> ($1) [root] -> [a.py(0) definition a] <%1> ($1)",
174-
// definition of `foo` function
175-
"<a.foo,%2> ($1) [root] -> [a.py(5) definition foo] <%2> ($1)",
176-
// reference to `x` in function body can resolve to formal parameter, and may have passed in parameters...
177-
"<%1> ($1) [a.py(8) reference x] -> [a.py(14) definition x] <%1> ()",
178-
// ...which we can look up either the 0th actual positional parameter...
179-
"<%1> ($1) [a.py(8) reference x] -> [jump to scope] <0,%1> ($1)",
180-
// ...or the actual named parameter `x`
181-
"<%1> ($1) [a.py(8) reference x] -> [jump to scope] <x,%1> ($1)",
182-
// result of function is `x`, which is passed in as a formal parameter...
183-
"<a.foo()/($3),%3> ($1) [root] -> [a.py(14) definition x] <%3> ()",
184-
// ...which we can look up either the 0th actual positional parameter...
185-
"<a.foo()/($3),%3> ($1) [root] -> [jump to scope] <0,%3> ($3)",
186-
// ...or the actual named parameter `x`
187-
"<a.foo()/($3),%3> ($1) [root] -> [jump to scope] <x,%3> ($3)",
188-
],
150+
crate::can_find_partial_paths_in_file::CLASS_FIELD_THROUGH_FUNCTION_PARAMETER_A_PATHS,
189151
);
190152
check_partial_paths_in_file(
191153
&graph,
192154
"b.py",
193-
&[
194-
// definition of `b` module
195-
"<b,%1> ($1) [root] -> [b.py(0) definition b] <%1> ($1)",
196-
// definition of class `A`
197-
"<b.A,%2> ($1) [root] -> [b.py(5) definition A] <%2> ($1)",
198-
// definition of class member `A.bar`
199-
"<b.A.bar,%3> ($1) [root] -> [b.py(8) definition bar] <%3> ($1)",
200-
// `bar` can also be accessed as an instance member
201-
"<b.A()/($3).bar,%3> ($1) [root] -> [b.py(8) definition bar] <%3> ($3)",
202-
],
155+
crate::can_find_partial_paths_in_file::CLASS_FIELD_THROUGH_FUNCTION_PARAMETER_B_PATHS,
203156
);
204157
}
205158

@@ -209,42 +162,17 @@ fn cyclic_imports_python() {
209162
check_partial_paths_in_file(
210163
&graph,
211164
"main.py",
212-
&[
213-
// definition of `__main__` module
214-
"<__main__,%1> ($1) [root] -> [main.py(0) definition __main__] <%1> ($1)",
215-
// reference to `a` in import statement
216-
"<%1> ($1) [main.py(8) reference a] -> [root] <a,%1> ($1)",
217-
// `from a import *` means we can rewrite any lookup of `__main__.*` → `a.*`
218-
"<__main__.,%2> ($1) [root] -> [root] <a.,%2> ($1)",
219-
// reference to `foo` becomes `a.foo` because of import statement
220-
"<%1> ($1) [main.py(6) reference foo] -> [root] <a.foo,%1> ($1)",
221-
],
165+
crate::can_find_partial_paths_in_file::CYCLIC_IMPORTS_PYTHON_MAIN_PATHS,
222166
);
223167
check_partial_paths_in_file(
224168
&graph,
225169
"a.py",
226-
&[
227-
// definition of `a` module
228-
"<a,%1> ($1) [root] -> [a.py(0) definition a] <%1> ($1)",
229-
// reference to `b` in import statement
230-
"<%1> ($1) [a.py(6) reference b] -> [root] <b,%1> ($1)",
231-
// `from b import *` means we can rewrite any lookup of `a.*` → `b.*`
232-
"<a.,%2> ($1) [root] -> [root] <b.,%2> ($1)",
233-
],
170+
crate::can_find_partial_paths_in_file::CYCLIC_IMPORTS_PYTHON_A_PATHS,
234171
);
235172
check_partial_paths_in_file(
236173
&graph,
237174
"b.py",
238-
&[
239-
// definition of `b` module
240-
"<b,%1> ($1) [root] -> [b.py(0) definition b] <%1> ($1)",
241-
// reference to `a` in import statement
242-
"<%1> ($1) [b.py(8) reference a] -> [root] <a,%1> ($1)",
243-
// `from a import *` means we can rewrite any lookup of `b.*` → `a.*`
244-
"<b.,%2> ($1) [root] -> [root] <a.,%2> ($1)",
245-
// definition of `foo`
246-
"<b.foo,%2> ($1) [root] -> [b.py(6) definition foo] <%2> ($1)",
247-
],
175+
crate::can_find_partial_paths_in_file::CYCLIC_IMPORTS_PYTHON_B_PATHS,
248176
);
249177
}
250178

@@ -254,21 +182,7 @@ fn cyclic_imports_rust() {
254182
check_partial_paths_in_file(
255183
&graph,
256184
"test.rs",
257-
// NOTE: Because everything in this example is local to one file, there aren't any partial
258-
// paths involving the root node.
259-
&[
260-
// reference to `a` in `main` function
261-
"<%1> ($1) [test.rs(103) reference a] -> [test.rs(201) definition a] <%1> ($1)",
262-
// reference to `a` in `b` function
263-
"<%1> ($1) [test.rs(307) reference a] -> [test.rs(201) definition a] <%1> ($1)",
264-
// reference to `b` in `a` function
265-
"<%1> ($1) [test.rs(206) reference b] -> [test.rs(301) definition b] <%1> ($1)",
266-
// reference to `FOO` in `main` can resolve either to `a::BAR` or `b::FOO`
267-
"<%1> ($1) [test.rs(101) reference FOO] -> [test.rs(204) definition BAR] <%1> ($1)",
268-
"<%1> ($1) [test.rs(101) reference FOO] -> [test.rs(304) definition FOO] <%1> ($1)",
269-
// reference to `BAR` in `b` resolves _only_ to `a::BAR`
270-
"<%1> ($1) [test.rs(305) reference BAR] -> [test.rs(204) definition BAR] <%1> ($1)",
271-
],
185+
crate::can_find_partial_paths_in_file::CYCLIC_IMPORTS_RUST_PATHS,
272186
);
273187
}
274188

@@ -278,37 +192,16 @@ fn sequenced_import_star() {
278192
check_partial_paths_in_file(
279193
&graph,
280194
"main.py",
281-
&[
282-
// definition of `__main__` module
283-
"<__main__,%1> ($1) [root] -> [main.py(0) definition __main__] <%1> ($1)",
284-
// reference to `a` in import statement
285-
"<%1> ($1) [main.py(8) reference a] -> [root] <a,%1> ($1)",
286-
// `from a import *` means we can rewrite any lookup of `__main__.*` → `a.*`
287-
"<__main__.,%2> ($1) [root] -> [root] <a.,%2> ($1)",
288-
// reference to `foo` becomes `a.foo` because of import statement
289-
"<%1> ($1) [main.py(6) reference foo] -> [root] <a.foo,%1> ($1)",
290-
],
195+
crate::can_find_partial_paths_in_file::SEQUENCED_IMPORT_STAR_MAIN_PATHS,
291196
);
292197
check_partial_paths_in_file(
293198
&graph,
294199
"a.py",
295-
&[
296-
// definition of `a` module
297-
"<a,%1> ($1) [root] -> [a.py(0) definition a] <%1> ($1)",
298-
// reference to `b` in import statement
299-
"<%1> ($1) [a.py(6) reference b] -> [root] <b,%1> ($1)",
300-
// `from b import *` means we can rewrite any lookup of `a.*` → `b.*`
301-
"<a.,%2> ($1) [root] -> [root] <b.,%2> ($1)",
302-
],
200+
crate::can_find_partial_paths_in_file::SEQUENCED_IMPORT_STAR_A_PATHS,
303201
);
304202
check_partial_paths_in_file(
305203
&graph,
306204
"b.py",
307-
&[
308-
// definition of `b` module
309-
"<b,%1> ($1) [root] -> [b.py(0) definition b] <%1> ($1)",
310-
// definition of `foo` inside of `b` module
311-
"<b.foo,%2> ($1) [root] -> [b.py(5) definition foo] <%2> ($1)",
312-
],
205+
crate::can_find_partial_paths_in_file::SEQUENCED_IMPORT_STAR_B_PATHS,
313206
);
314207
}

0 commit comments

Comments
 (0)