mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-11-18 09:43:04 +00:00
test(elixir): gate embedding assertion on grammar install
This commit is contained in:
parent
f6e81db0ae
commit
67df07ab7a
1 changed files with 30 additions and 12 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { createRequire } from 'node:module';
|
||||
import { createHash } from 'crypto';
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { SupportedLanguages } from 'gitnexus-shared';
|
||||
import {
|
||||
contentHashForNode,
|
||||
EMBEDDING_TEXT_VERSION,
|
||||
|
|
@ -17,10 +19,21 @@ import {
|
|||
} from '../../src/core/embeddings/types.js';
|
||||
import { STALE_HASH_SENTINEL } from '../../src/core/lbug/schema.js';
|
||||
import { extractStructuralNames } from '../../src/core/embeddings/structural-extractor.js';
|
||||
import { isLanguageAvailable } from '../../src/core/tree-sitter/parser-loader.js';
|
||||
|
||||
const CLASS_CHUNK_SIZE = 90;
|
||||
const CLASS_OVERLAP = 10;
|
||||
|
||||
const _require = createRequire(import.meta.url);
|
||||
const elixirPackageInstalled = (() => {
|
||||
try {
|
||||
_require.resolve('tree-sitter-elixir');
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
describe('embedding schema column contracts', () => {
|
||||
it('does not query Objective-C protocol/category tables for an isExported column', () => {
|
||||
expect(LABELS_WITH_EXPORTED.has(LABEL_PROTOCOL)).toBe(false);
|
||||
|
|
@ -34,18 +47,23 @@ describe('embedding schema column contracts', () => {
|
|||
expect(EMBEDDABLE_LABELS).toContain(LABEL_CATEGORY);
|
||||
});
|
||||
|
||||
it('extracts defmodule methods without treating ordinary calls as declarations', async () => {
|
||||
await expect(
|
||||
extractStructuralNames(
|
||||
'defmodule Example do\n def run(value), do: value\nend',
|
||||
'example.ex',
|
||||
),
|
||||
).resolves.toMatchObject({ methodNames: ['run'] });
|
||||
it.skipIf(!elixirPackageInstalled)(
|
||||
'extracts defmodule methods without treating ordinary calls as declarations',
|
||||
async () => {
|
||||
expect(isLanguageAvailable(SupportedLanguages.Elixir)).toBe(true);
|
||||
|
||||
await expect(
|
||||
extractStructuralNames('configure do\n def leaked(value), do: value\nend', 'example.ex'),
|
||||
).resolves.toMatchObject({ methodNames: [] });
|
||||
});
|
||||
await expect(
|
||||
extractStructuralNames(
|
||||
'defmodule Example do\n def run(value), do: value\nend',
|
||||
'example.ex',
|
||||
),
|
||||
).resolves.toMatchObject({ methodNames: ['run'] });
|
||||
|
||||
await expect(
|
||||
extractStructuralNames('configure do\n def leaked(value), do: value\nend', 'example.ex'),
|
||||
).resolves.toMatchObject({ methodNames: [] });
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue