<commit_before>var fest = require('../lib/fest'),
    vows = require('vows'),
    events = require('events'),
    assert = require('assert');

function transform(file, json,  promise, strict, options){
    options = options || null;
    var template = fest.compile(__dirname + file, options);
    console.log(template)
    template = (new Function('return ' + template))();
    setTimeout(function(){promise.emit('success', template(json));}, 0);
}

vows.describe('Fast tests').addBatch({
    'doctype':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/doctype.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<!DOCTYPE html>');
        }
    },
    'text':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/text.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '  ');
        }
    },
    'shorttag':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/shorttag.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<meta/>');
        }
    },
    'comment':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/comment.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<!--comment-->');
        }
    },
    'value':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/value.xml', {"value":"value"}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'valuevalue<script/>\\"|\\\'');
        }
    },
    'if':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/if.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'truetrue&');
        }
    },
    'choose':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/choose.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'truechoose');
        }
    },
    'for':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/for.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'foo=bar');
        }
    },
    'foreach':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/foreach.xml', {items: [1, 2], subitems:[[1, 2], [1, 2]]}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result.substr(0, 2), '12');
            assert.equal(result.substr(2, result.length - 1), '0102111245');
        }
    },
    'script':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/script.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '"true""true"');
        }
    },
    'insert':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/insert.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<style>.foo{ont: 18px/18px "Helvetica Neue", Arial;}\n.bar{\\"\\"}</style>');
        }
    },
    'use strict':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/strict.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'true');
        }
    },
    'blocks':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/blocks.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            result = result.split('|');
            assert.equal(result[1], 'one');
            assert.equal(result[2], 'two2');
            assert.equal(result[3], 'three1');
            assert.equal(result[4], 'five');
            assert.equal(result[5], 'six');
            assert.equal(result[6], 'seven');
            assert.equal(result[7], 'eight');
        }
    },
    'params': {
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/params.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'Hello, John');
        }
    },
    'include':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/include.xml', {list:[1, 2]}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '12');
        }
    },
    'CDATA':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/cdata.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<script><![CDATA[alert ("2" < 3);]]></script>');
        }
    },
    'setparams': {
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/setparams.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '|text1||text2||text3||text4|');
        }
    },
    'attribute': {
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/attribute.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<input/><div>foobar</div><div class="foo bar"></div><div class="foo"></div><div when="true" otherwise="true"></div><div>foo</div>');
        }
    },
    'first attributes': {
      topic:function(){
        var promise = new(events.EventEmitter);
        transform('/templates/first_attributes.xml', {}, promise, true, {nothrow: true});
        return promise;
      },
      'result':function(result) {
        var res = [
            __dirname + "/templates/first_attributes.xml",
            "4: text",
            "5: <fest:attributes>",
            "6:   <fest:attribute name=\"name\">text1</fest:attribute>",
            "At line 5: fest:attributes must be the first child"
        ].join('\n');

        assert.equal(result, res);
      }
    },
    'nested attributes': {
      topic:function(){
        var promise = new(events.EventEmitter);
        transform('/templates/nested_attributes.xml', {}, promise, true, {nothrow: true});
        return promise;
      },
      'result':function(result) {
        var res = [
            __dirname + "/templates/nested_attributes.xml",
            "4: <fest:attributes>",
            "5:   <fest:attributes>",
            "6:     <fest:attribute name='href'>#</fest:attribute>",
            "At line 5: fest:attributes cannot be nested"
        ].join('\n');

        assert.equal(result, res);
      }
    },
    'document.write': {
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/document.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'foobarbar');
        }
    },
    'unclosed template': {
        topic:function(){
          var promise = new(events.EventEmitter);
          transform('/templates/template.xml', {}, promise, true, {nothrow: true});
          return promise;
        },
        'result':function(result) {
          var res = [
              __dirname + "/templates/template.xml",
              "1: <?xml version=\"1.0\"?>",
              "2: <fest:template xmlns:fest=\"http://fest.mail.ru\" context_name=\"bad\">",
              "At line 2: fest:template is not closed"
          ].join('\n');

          assert.equal(result, res);
        }
    }
}).run();
<commit_msg>Comment console.log<commit_after>var fest = require('../lib/fest'),
    vows = require('vows'),
    events = require('events'),
    assert = require('assert');

function transform(file, json,  promise, strict, options){
    options = options || null;
    var template = fest.compile(__dirname + file, options);
    //console.log(template)
    template = (new Function('return ' + template))();
    setTimeout(function(){promise.emit('success', template(json));}, 0);
}

vows.describe('Fast tests').addBatch({
    'doctype':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/doctype.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<!DOCTYPE html>');
        }
    },
    'text':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/text.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '  ');
        }
    },
    'shorttag':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/shorttag.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<meta/>');
        }
    },
    'comment':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/comment.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<!--comment-->');
        }
    },
    'value':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/value.xml', {"value":"value"}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'valuevalue<script/>\\"|\\\'');
        }
    },
    'if':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/if.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'truetrue&');
        }
    },
    'choose':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/choose.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'truechoose');
        }
    },
    'for':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/for.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'foo=bar');
        }
    },
    'foreach':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/foreach.xml', {items: [1, 2], subitems:[[1, 2], [1, 2]]}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result.substr(0, 2), '12');
            assert.equal(result.substr(2, result.length - 1), '0102111245');
        }
    },
    'script':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/script.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '"true""true"');
        }
    },
    'insert':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/insert.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<style>.foo{ont: 18px/18px "Helvetica Neue", Arial;}\n.bar{\\"\\"}</style>');
        }
    },
    'use strict':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/strict.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'true');
        }
    },
    'blocks':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/blocks.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            result = result.split('|');
            assert.equal(result[1], 'one');
            assert.equal(result[2], 'two2');
            assert.equal(result[3], 'three1');
            assert.equal(result[4], 'five');
            assert.equal(result[5], 'six');
            assert.equal(result[6], 'seven');
            assert.equal(result[7], 'eight');
        }
    },
    'params': {
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/params.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'Hello, John');
        }
    },
    'include':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/include.xml', {list:[1, 2]}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '12');
        }
    },
    'CDATA':{
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/cdata.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<script><![CDATA[alert ("2" < 3);]]></script>');
        }
    },
    'setparams': {
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/setparams.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '|text1||text2||text3||text4|');
        }
    },
    'attribute': {
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/attribute.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, '<input/><div>foobar</div><div class="foo bar"></div><div class="foo"></div><div when="true" otherwise="true"></div><div>foo</div>');
        }
    },
    'first attributes': {
      topic:function(){
        var promise = new(events.EventEmitter);
        transform('/templates/first_attributes.xml', {}, promise, true, {nothrow: true});
        return promise;
      },
      'result':function(result) {
        var res = [
            __dirname + "/templates/first_attributes.xml",
            "4: text",
            "5: <fest:attributes>",
            "6:   <fest:attribute name=\"name\">text1</fest:attribute>",
            "At line 5: fest:attributes must be the first child"
        ].join('\n');

        assert.equal(result, res);
      }
    },
    'nested attributes': {
      topic:function(){
        var promise = new(events.EventEmitter);
        transform('/templates/nested_attributes.xml', {}, promise, true, {nothrow: true});
        return promise;
      },
      'result':function(result) {
        var res = [
            __dirname + "/templates/nested_attributes.xml",
            "4: <fest:attributes>",
            "5:   <fest:attributes>",
            "6:     <fest:attribute name='href'>#</fest:attribute>",
            "At line 5: fest:attributes cannot be nested"
        ].join('\n');

        assert.equal(result, res);
      }
    },
    'document.write': {
        topic:function(){
            var promise = new(events.EventEmitter);
            transform('/templates/document.xml', {}, promise);
            return promise;
        },
        'result':function(result){
            assert.equal(result, 'foobarbar');
        }
    },
    'unclosed template': {
        topic:function(){
          var promise = new(events.EventEmitter);
          transform('/templates/template.xml', {}, promise, true, {nothrow: true});
          return promise;
        },
        'result':function(result) {
          var res = [
              __dirname + "/templates/template.xml",
              "1: <?xml version=\"1.0\"?>",
              "2: <fest:template xmlns:fest=\"http://fest.mail.ru\" context_name=\"bad\">",
              "At line 2: fest:template is not closed"
          ].join('\n');

          assert.equal(result, res);
        }
    }
}).run();

{'fraction_non_alphanumeric': 0.1689887379542552, 'fraction_numerical': 0.006966213862765587, 'mean_word_length': 1.873561301084237, 'pattern_counts': {'":': 2, '<': 63, '<?xml version=': 2, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 54}, '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': '6570660', 'n_tokens_mistral': 4665, 'n_tokens_neox': 4666, 'n_words': 825}