Skip to content

Commit d5a95ba

Browse files
feat(tests): configuration management system
changes: - file: parsers.py area: analyzer added: [_walk, _extract_js_require_imports, _extract_from_expression_stmt, _extract_js_var_fn, _add_func, _walk_nested_functions] modified: [_parse_js_ts, _extract_js_arrow_fn, UniversalParser, TreeSitterParser] - file: sample_javascript_advanced.js area: test added: [result, innerSort, middleHelper, files, items, fetchResource, +22 more] - file: test_parser_integrity.py area: analyzer added: [parse_js, TestJavaScriptFunctionExtraction] new_tests: 15 testing: new_tests: 15 scenarios: - var_function_expression - class_with_methods - no_duplicate_functions - module_exports_shorthand - const_arrow_function - commonjs_require_imports - regular_function_declaration - const_function_expression - export_clause - iife_named_function # +5 more stats: lines: "+608/-57 (net +551)" files: 3 complexity: "Large structural change (normalized)"
1 parent b92fe20 commit d5a95ba

11 files changed

Lines changed: 631 additions & 64 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## [1.0.48] - 2026-02-26
2+
3+
### Summary
4+
5+
feat(tests): configuration management system
6+
7+
### Test
8+
9+
- update tests/samples/sample_javascript_advanced.js
10+
- update tests/test_parser_integrity.py
11+
12+
### Other
13+
14+
- update code2logic/parsers.py
15+
16+
117
## [1.0.47] - 2026-02-26
218

319
### Summary

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.47
1+
1.0.48

code2logic/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
>>> print(output)
1919
"""
2020

21-
__version__ = "1.0.47"
21+
__version__ = "1.0.48"
2222
__author__ = "Softreck"
2323
__email__ = "info@softreck.dev"
2424
__license__ = "MIT"

code2logic/parsers.py

Lines changed: 319 additions & 57 deletions
Large diffs are not rendered by default.

logic2code/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
from .generator import CodeGenerator, GeneratorConfig, GenerationResult
1515
from .renderers import PythonRenderer
1616

17-
__version__ = '1.0.47'
17+
__version__ = '1.0.48'
1818
__all__ = ['CodeGenerator', 'GeneratorConfig', 'GenerationResult', 'PythonRenderer']

logic2test/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
from .parsers import LogicParser
1616
from .templates import TestTemplate
1717

18-
__version__ = '1.0.47'
18+
__version__ = '1.0.48'
1919
__all__ = ['TestGenerator', 'GeneratorConfig', 'GenerationResult', 'LogicParser', 'TestTemplate']

lolm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
)
7777
from .clients import LLMRateLimitError
7878

79-
__version__ = '1.0.47'
79+
__version__ = '1.0.48'
8080
__all__ = [
8181
# Config
8282
'LLMConfig',

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "code2logic"
7-
version = "1.0.47"
7+
version = "1.0.48"
88
description = "Code2Logic - Source code to logical representation converter for LLM analysis, featuring Tree-sitter parsing, dependency graph analysis, and multi-language support."
99
readme = "README.md"
1010
license = "Apache-2.0"
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/**
2+
* Advanced JavaScript sample for testing TOON parser coverage.
3+
* Covers: IIFEs, nested functions, var declarations, function expressions,
4+
* module.exports, CommonJS require, arrow functions with params.
5+
*/
6+
7+
const fs = require('fs');
8+
const path = require('path');
9+
const { EventEmitter } = require('events');
10+
11+
// Arrow function assigned to const
12+
const getArg = (name, def) => {
13+
const idx = process.argv.indexOf(`--${name}`);
14+
if (idx !== -1) return process.argv[idx + 1];
15+
return def;
16+
};
17+
18+
// Arrow function assigned to let
19+
let processItem = (item) => {
20+
return item.trim().toLowerCase();
21+
};
22+
23+
// Function expression assigned to const
24+
const validate = function(input) {
25+
if (!input || typeof input !== 'string') return false;
26+
return input.length > 0;
27+
};
28+
29+
// Async function expression assigned to const
30+
const fetchResource = async function(url, options) {
31+
const response = await fetch(url, options);
32+
return response.json();
33+
};
34+
35+
// var arrow function
36+
var shouldIgnore = (filePath) => {
37+
return filePath.includes('node_modules');
38+
};
39+
40+
// var function expression
41+
var formatOutput = function(data, indent) {
42+
return JSON.stringify(data, null, indent || 2);
43+
};
44+
45+
// Regular top-level function
46+
function walk(dir, onFile) {
47+
const entries = fs.readdirSync(dir, { withFileTypes: true });
48+
for (const e of entries) {
49+
const full = path.join(dir, e.name);
50+
if (e.isDirectory()) walk(full, onFile);
51+
else onFile(full);
52+
}
53+
}
54+
55+
// Function with nested function inside
56+
function findFiles(dir, extensions) {
57+
const files = [];
58+
59+
function traverse(currentDir) {
60+
const items = fs.readdirSync(currentDir);
61+
for (const item of items) {
62+
const fullPath = path.join(currentDir, item);
63+
if (fs.statSync(fullPath).isDirectory()) {
64+
traverse(fullPath);
65+
} else if (extensions.includes(path.extname(item))) {
66+
files.push(fullPath);
67+
}
68+
}
69+
}
70+
71+
traverse(dir);
72+
return files;
73+
}
74+
75+
// Async top-level function
76+
async function processFiles(pattern) {
77+
const files = findFiles('.', ['.js', '.ts']);
78+
for (const file of files) {
79+
const content = fs.readFileSync(file, 'utf8');
80+
console.log(`Processing: ${file}`);
81+
}
82+
}
83+
84+
// Class with methods
85+
class FileProcessor extends EventEmitter {
86+
constructor(rootDir) {
87+
super();
88+
this.rootDir = rootDir;
89+
this.results = [];
90+
}
91+
92+
async analyze(filePath) {
93+
const content = fs.readFileSync(filePath, 'utf8');
94+
const result = { path: filePath, lines: content.split('\n').length };
95+
this.results.push(result);
96+
this.emit('analyzed', result);
97+
return result;
98+
}
99+
100+
static fromConfig(configPath) {
101+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
102+
return new FileProcessor(config.rootDir);
103+
}
104+
105+
getResults() {
106+
return [...this.results];
107+
}
108+
}
109+
110+
// Deeply nested function
111+
function outerFunction(data) {
112+
function middleHelper(items) {
113+
function innerSort(a, b) {
114+
return a.localeCompare(b);
115+
}
116+
return items.sort(innerSort);
117+
}
118+
return middleHelper(data);
119+
}
120+
121+
// IIFE with named function
122+
(function main() {
123+
const root = getArg('root', '.');
124+
console.log(`Scanning ${root}...`);
125+
walk(root, (file) => {
126+
console.log(file);
127+
});
128+
})();
129+
130+
// module.exports with shorthand properties
131+
module.exports = {
132+
getArg,
133+
processItem,
134+
validate,
135+
fetchResource,
136+
shouldIgnore,
137+
formatOutput,
138+
walk,
139+
findFiles,
140+
processFiles,
141+
FileProcessor,
142+
outerFunction
143+
};

tests/samples/sample_reexport/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"ProcessingError",
1919
]
2020

21-
__version__ = "1.0.47"
21+
__version__ = "1.0.48"

0 commit comments

Comments
 (0)