fix: add scoped error logging for lexer/parser errors
- Add std.log.scoped(.pugz) to template.zig and view_engine.zig - Log detailed error info (code, line, column, message) when parsing fails - Log template path context in ViewEngine on parse errors - Remove debug print from lexer, use proper scoped logging instead - Move benchmarks, docs, examples, playground, tests out of src/ to project root - Update build.zig and documentation paths accordingly - Bump version to 0.3.1
This commit is contained in:
46
tests/sample_data/pug-linker/test/index.test.js
Normal file
46
tests/sample_data/pug-linker/test/index.test.js
Normal file
@@ -0,0 +1,46 @@
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var link = require('../');
|
||||
|
||||
function testDir(dir) {
|
||||
fs.readdirSync(dir).forEach(function(name) {
|
||||
if (!/\.input\.json$/.test(name)) return;
|
||||
test(name, function() {
|
||||
var actual = link(JSON.parse(fs.readFileSync(dir + '/' + name, 'utf8')));
|
||||
expect(actual).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testDirError(dir) {
|
||||
fs.readdirSync(dir).forEach(function(name) {
|
||||
if (!/\.input\.json$/.test(name)) return;
|
||||
test(name, function() {
|
||||
var input = JSON.parse(fs.readFileSync(dir + '/' + name, 'utf8'));
|
||||
var err;
|
||||
try {
|
||||
link(input);
|
||||
} catch (ex) {
|
||||
err = {
|
||||
msg: ex.msg,
|
||||
code: ex.code,
|
||||
line: ex.line,
|
||||
};
|
||||
}
|
||||
if (!err) throw new Error('Expected error');
|
||||
expect(err).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe('cases from pug', function() {
|
||||
testDir(__dirname + '/cases');
|
||||
});
|
||||
|
||||
describe('special cases', function() {
|
||||
testDir(__dirname + '/special-cases');
|
||||
});
|
||||
|
||||
describe('error handling', function() {
|
||||
testDirError(__dirname + '/errors');
|
||||
});
|
||||
Reference in New Issue
Block a user