GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — commitwork/codegraph/test/unit-query-callers-of.test.mjs at main · Portll/commitwork

Expand file tree

/

unit-query-callers-of.test.mjs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
99 lines (92 loc) · 3.49 KB
/

unit-query-callers-of.test.mjs

Copy path

File metadata and controls

99 lines (92 loc) · 3.49 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Returns sorted caller edges for a symbol (codegraph/query.mjs callersOf).
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { callersOf } from '../query.mjs';
test('returns empty array when no calls target the symbol', () => {
const graph = {
nodes: [
{ id: 'sym:foo#bar', kind: 'symbol', path: 'foo' },
{ id: 'sym:baz#qux', kind: 'symbol', path: 'baz' }
],
edges: []
};
assert.deepEqual(callersOf(graph, 'sym:foo#bar'), []);
});
test('returns single caller when one call edge targets the symbol', () => {
const graph = {
nodes: [
{ id: 'sym:foo#bar', kind: 'symbol', path: 'foo' },
{ id: 'sym:baz#qux', kind: 'symbol', path: 'baz' }
],
edges: [
{ kind: 'calls', from: 'sym:baz#qux', to: 'sym:foo#bar', evidence: 'line 10' }
]
};
assert.deepEqual(callersOf(graph, 'sym:foo#bar'), [{ from: "sym:baz#qux", evidence: "line 10" }]);
});
test('returns multiple callers sorted by from id', () => {
const graph = {
nodes: [
{ id: 'sym:foo#bar', kind: 'symbol', path: 'foo' },
{ id: 'sym:zeta#alpha', kind: 'symbol', path: 'zeta' },
{ id: 'sym:beta#gamma', kind: 'symbol', path: 'beta' },
{ id: 'sym:alpha#delta', kind: 'symbol', path: 'alpha' }
],
edges: [
{ kind: 'calls', from: 'sym:zeta#alpha', to: 'sym:foo#bar', evidence: 'e1' },
{ kind: 'calls', from: 'sym:beta#gamma', to: 'sym:foo#bar', evidence: 'e2' },
{ kind: 'calls', from: 'sym:alpha#delta', to: 'sym:foo#bar', evidence: 'e3' }
]
};
assert.deepEqual(callersOf(graph, 'sym:foo#bar'), [{ from: "sym:alpha#delta", evidence: "e3" }, { from: "sym:beta#gamma", evidence: "e2" }, { from: "sym:zeta#alpha", evidence: "e1" }]);
});
test('returns empty array when calls target a different symbol', () => {
const graph = {
nodes: [
{ id: 'sym:foo#bar', kind: 'symbol', path: 'foo' },
{ id: 'sym:baz#qux', kind: 'symbol', path: 'baz' }
],
edges: [
{ kind: 'calls', from: 'sym:baz#qux', to: 'sym:other#thing', evidence: 'e1' }
]
};
assert.deepEqual(callersOf(graph, 'sym:foo#bar'), []);
});
test('returns empty array for unknown symbol id', () => {
const graph = {
nodes: [
{ id: 'sym:foo#bar', kind: 'symbol', path: 'foo' }
],
edges: [
{ kind: 'calls', from: 'sym:baz#qux', to: 'sym:foo#bar', evidence: 'e1' }
]
};
assert.deepEqual(callersOf(graph, 'sym:unknown#id'), []);
});
test('ignores non-call edges when computing callers', () => {
const graph = {
nodes: [
{ id: 'sym:foo#bar', kind: 'symbol', path: 'foo' },
{ id: 'sym:baz#qux', kind: 'symbol', path: 'baz' }
],
edges: [
{ kind: 'imports', from: 'sym:baz#qux', to: 'sym:foo#bar', evidence: 'imp' },
{ kind: 'binds', from: 'sym:baz#qux', to: 'sym:foo#bar', evidence: 'bind' }
]
};
assert.deepEqual(callersOf(graph, 'sym:foo#bar'), []);
});
test('returns callers with evidence preserved from edges', () => {
const graph = {
nodes: [
{ id: 'sym:foo#bar', kind: 'symbol', path: 'foo' },
{ id: 'sym:aaa#bbb', kind: 'symbol', path: 'aaa' },
{ id: 'sym:ccc#ddd', kind: 'symbol', path: 'ccc' }
],
edges: [
{ kind: 'calls', from: 'sym:aaa#bbb', to: 'sym:foo#bar', evidence: 'call at 5' },
{ kind: 'calls', from: 'sym:ccc#ddd', to: 'sym:foo#bar', evidence: 'call at 9' }
]
};
assert.deepEqual(callersOf(graph, 'sym:foo#bar'), [{ from: "sym:aaa#bbb", evidence: "call at 5" }, { from: "sym:ccc#ddd", evidence: "call at 9" }]);
});
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.