GitNexus/gitnexus/test/unit/scope-resolution/resolver-parity-expected-failures.test.ts
Copilot 813acd7ec5
feat: C++ ADL V2: include base-class associated namespaces via MRO (#1597)
* Initial plan

* fix(cpp): include base-class namespaces in ADL candidate selection

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/7df6f692-1af9-43e6-82de-099ed43a60cb

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* test(cpp): clarify ADL base-namespace test names

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/7df6f692-1af9-43e6-82de-099ed43a60cb

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* test(cpp): remove stale legacy parity expected-failure entry

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/1a55a5e8-ae91-44bc-9b21-9324cdfea3de

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* test(cpp): assert base-namespace ADL tests are not parity skips

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/b3726b70-e797-4f37-955d-7d61fd28d338

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix(cpp): avoid MRO amplification on ambiguous class-name ADL lookup

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/b3726b70-e797-4f37-955d-7d61fd28d338

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* test(cpp): strengthen ADL base-namespace target identity assertions

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/b3726b70-e797-4f37-955d-7d61fd28d338

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* test(cpp): add ADL negative cases for anonymous and unresolved bases

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/b3726b70-e797-4f37-955d-7d61fd28d338

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* test(cpp): fix anonymous-base parity expectation and formatting

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/6a2e3cf9-beea-435c-8494-6a7a00af0f1e

* fix(cpp): propagate unnamed-namespace members through #include in registry-primary resolver

Anonymous-namespace contents in a header (e.g. `namespace { void f(); }`)
are reachable by unqualified lookup in any TU that #includes the header
per ISO C++ [basic.namespace.anon]/1 (the unnamed namespace behaves as
if a `using namespace unique;` is inserted into the enclosing scope, with
per-TU `unique`). The registry-primary path was filtering these defs out
of `expandCppWildcardNames` via both the structural Namespace-owner check
and the `isFileLocal` mark, so `hidden_probe(d)` from a TU including the
header resolved to nothing while the legacy DAG returned the correct edge.

Track anonymous-`namespace_definition` source ranges at capture time,
resolve them to ScopeIds in `populateOwners` (parallels inline-namespace
handling), and exempt those scopes from the two wildcard-expansion filters
plus the `populateCppNonGloballyVisible` structural set. `markFileLocal`
is preserved so the global free-call fallback still blocks cross-TU leaks
for files that do NOT #include the declaring file (cpp-anon-ns-cross-file
guard still passes).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
Co-authored-by: Gergo Magyar <gergomagyar@icloud.com>
2026-05-15 07:54:23 +01:00

62 lines
2.3 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
isLegacyResolverParityExpectedFailure,
isLegacyResolverParityRun,
resolverParityFlagName,
} from '../../integration/resolvers/helpers.js';
const csharpNamespaceRootImportTest =
'emits the using-import edge App/Program.cs -> Models/User.cs through the scope-resolution path';
const cppBaseNamespaceAdlTests = [
'resolves log(d) to base_lib::log via ADL when Derived inherits from base_lib::Base',
'resolves trace(m) via full MRO walk when MultiLevel inherits via middle_lib::Mid -> base_lib::Root',
'diamond inheritance contributes base namespace once (no duplicate/crash)',
] as const;
describe('resolver parity expected legacy failures', () => {
it('uses the same env var convention as the parity workflow', () => {
expect(resolverParityFlagName('csharp')).toBe('REGISTRY_PRIMARY_CSHARP');
expect(resolverParityFlagName('c-plus-plus')).toBe('REGISTRY_PRIMARY_C_PLUS_PLUS');
});
it('recognizes only legacy parity runs', () => {
expect(isLegacyResolverParityRun('csharp', { REGISTRY_PRIMARY_CSHARP: '0' })).toBe(true);
expect(isLegacyResolverParityRun('csharp', { REGISTRY_PRIMARY_CSHARP: 'false' })).toBe(true);
expect(isLegacyResolverParityRun('csharp', { REGISTRY_PRIMARY_CSHARP: '1' })).toBe(false);
expect(isLegacyResolverParityRun('csharp', {})).toBe(false);
});
it('matches configured expected failures only during the legacy run', () => {
expect(
isLegacyResolverParityExpectedFailure('csharp', csharpNamespaceRootImportTest, {
REGISTRY_PRIMARY_CSHARP: '0',
}),
).toBe(true);
expect(
isLegacyResolverParityExpectedFailure('csharp', csharpNamespaceRootImportTest, {
REGISTRY_PRIMARY_CSHARP: '1',
}),
).toBe(false);
expect(
isLegacyResolverParityExpectedFailure(
'csharp',
'detects exactly 3 classes and 2 interfaces',
{
REGISTRY_PRIMARY_CSHARP: '0',
},
),
).toBe(false);
});
it('does not mark cpp base-namespace ADL coverage as expected failures in legacy parity', () => {
for (const testName of cppBaseNamespaceAdlTests) {
expect(
isLegacyResolverParityExpectedFailure('cpp', testName, {
REGISTRY_PRIMARY_CPP: '0',
}),
).toBe(false);
}
});
});