<commit_before>var swig = require('../index'),
    testCase = require('nodeunit').testCase;

exports.compileFile = testCase({
    setUp: function (callback) {
        callback();
    },

    basic: function (test) {
        swig.init({
            root: __dirname + '/templates',
            allowErrors: true
        });

        var tpl = swig.compileFile('included_2.html');
        test.strictEqual('2', tpl.render({ array: [1, 1] }), 'from file is a-ok');
        test.done();
    },

    'allowErrors = false': function (test) {
        swig.init({
            root: __dirname + '/templates',
            allowErrors: false
        });
        var tpl = swig.compileFile('foobar.html');
        test.ok((/<pre>Error\: ENOENT, No such file or directory/).test(tpl.render()), 'pushes a render function with the error');
        tpl = swig.compileFile('includes_notfound.html');
        test.ok((/<pre>Error\: ENOENT, No such file or directory/).test(tpl.render()), 'renders the error when includes a file that is not found');

        test.done();
    },

    'allowErrors = true': function (test) {
        swig.init({ allowErrors: true });
        test.throws(function () {
            swig.compileFile('barfoo.html');
        }, 'throws when allowErrors is true');

        test.done();<commit_msg>fix test for error messages changed in node >0.6.0<commit_after>var swig = require('../index'),
    testCase = require('nodeunit').testCase;

exports.compileFile = testCase({
    setUp: function (callback) {
        callback();
    },

    basic: function (test) {
        swig.init({
            root: __dirname + '/templates',
            allowErrors: true
        });

        var tpl = swig.compileFile('included_2.html');
        test.strictEqual('2', tpl.render({ array: [1, 1] }), 'from file is a-ok');
        test.done();
    },

    'allowErrors = false': function (test) {
        swig.init({
            root: __dirname + '/templates',
            allowErrors: false
        });
        var tpl = swig.compileFile('foobar.html');
        test.ok((/<pre>Error\: ENOENT, no such file or directory/i).test(tpl.render()), 'pushes a render function with the error');
        tpl = swig.compileFile('includes_notfound.html');
        test.ok((/<pre>Error\: ENOENT, no such file or directory/i).test(tpl.render()), 'renders the error when includes a file that is not found');

        test.done();
    },

    'allowErrors = true': function (test) {
        swig.init({ allowErrors: true });
        test.throws(function () {
            swig.compileFile('barfoo.html');
        }, 'throws when allowErrors is true');

        test.done();
{'fraction_non_alphanumeric': 0.15590788976972442, 'fraction_numerical': 0.004152510381275953, 'mean_word_length': 2.3417402269861287, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '767230', 'n_tokens_mistral': 794, 'n_tokens_neox': 781, 'n_words': 199}