<commit_before>var parser = require('khepri-parse').parse.parser;
var lexer = require('khepri-parse').lex.lexer;

var unparse = require('ecma-unparse').unparse;
var unparse_print = require('ecma-unparse').print;

var compile = require('../index').compile;


var testParser = function(input) {
    return eval(unparse_print.print(unparse.unparse(compile.compile(parser.parseStream(lexer.lex(input))))));
};


exports.single_curry = function(test) {
    test.equal(
        testParser("(\\x, y -> x + y)@2 3;"),
        5);
    
    test.done();
};

exports.curry_multi_arg = function(test) {
    test.equal(
        testParser("(\\x, y, z -> (x + y) / z)@(5, 10) 5;"),
        3);
    
    test.done();
};

exports.multi_curry = function(test) {
    test.equal(
        testParser("(\\x, y, z -> (x + y) / z)@5@10 5;"),
        3);
    
    test.done();
};

exports.curried_args_evaled_once = function(test) {
    test.equal(
        testParser(
            "var g = 0, f = \\x -> { g = g + 1; return x;};"+
            "var c = (\\x, y -> x + y)@(f(10));" +
            "c(3); c(5); g;"),
        1);
    
    test.done();
};<commit_msg>Adding tests for pipe and curry<commit_after>var parser = require('khepri-parse').parse.parser;
var lexer = require('khepri-parse').lex.lexer;

var unparse = require('ecma-unparse').unparse;
var unparse_print = require('ecma-unparse').print;

var compile = require('../index').compile;


var testParser = function(input) {
    return eval(unparse_print.print(unparse.unparse(compile.compile(parser.parseStream(lexer.lex(input))))));
};


exports.single_curry = function(test) {
    test.equal(
        testParser("(\\x, y -> x + y)@2 3;"),
        5);
    
    test.done();
};

exports.curry_multi_arg = function(test) {
    test.equal(
        testParser("(\\x, y, z -> (x + y) / z)@(5, 10) 5;"),
        3);
    
    test.done();
};

exports.multi_curry = function(test) {
    test.equal(
        testParser("(\\x, y, z -> (x + y) / z)@5@10 5;"),
        3);
    
    test.done();
};

exports.curried_args_evaled_once = function(test) {
    test.equal(
        testParser(
            "var g = 0, f = \\x -> { g = g + 1; return x;};"+
            "var c = (\\x, y -> x + y)@(f(10));" +
            "c(3); c(5); g;"),
        1);
    
    test.done();
};

exports.curried_results_in_new_function = function(test) {
    test.equal(
        testParser(
            "var add = \\x, y -> x + y; add.displayName = 'x';"+
            "var c = add@2; c.displayName;"),
        1);
    
    test.done();
};
{'fraction_non_alphanumeric': 0.20149842271293375, 'fraction_numerical': 0.016561514195583597, 'mean_word_length': 2.3647214854111405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '7170485', 'n_tokens_mistral': 969, 'n_tokens_neox': 938, 'n_words': 183}