<commit_before>"use strict";

var _ = require('../');

var eq = _.test.eq;
var ok = _.test.ok;

var test_hash_key_performance = false;

suite('common');

test("deep_equal", function(){
    eq(false, _.deep_equal({ blah: true }, { blah: false }));
    eq(false, _.deep_equal({ blah: "" }, { blah: false }));
    eq(true, _.deep_equal({ blah: "" }, { blah: false }, false));
});

test("s", function(){
    eq("", _.s());
    eq("null", _.s(null));
    eq("abc", _.s("abc"));
    eq("2", _.s(2));
    eq("{ o: { a: [] }, a: [ {}, {} ] }", _.s({ o: { a: [] }, a: [{}, {}] }));
});

test("sorn", function(){
    function test(f){
        eq("abc", f("abc"));
        eq("2", f(2));
        eq("0", f(0));
        eq("", f(""));
        eq(null, f());
        eq(null, f(null));
        eq(null, f({ o: { a: [] }, a: [{}, {}] }));
        eq(null, f([]));
    }
    test(_.sorn);
});

test("iso_date", function(){
    var now = _.date();
    eq(_.iso_date(), _.iso_date(now));

    var d = _.moment("2015-02-12").toDate();
    eq(_.iso_date(_.iso_date(d)).valueOf(), d.valueOf());

    eq(_.iso_date(" 2015-02-22"), null);
    eq(_.iso_date("use strict 2015-02-22"), null);

    eq(_.iso_date(""), null);
    eq(_.iso_date("blah"), null);
    eq(_.iso_date("2015-22-22"), null);

    var now_la = _.moment.tz("America/Los_Angeles");
    var now_la_iso_date = now_la.format("YYYY-MM-DD");
    eq(now_la_iso_date, _.iso_date("America/Los_Angeles"));

    _.p("tonga date: ", _.iso_date("Pacific/Tongatapu"));
    _.p("tonga time: ", _.moment.tz("Pacific/Tongatapu").format());
    _.p("samoa date: ", _.iso_date("Pacific/Samoa"));
    _.p("samoa time: ", _.moment.tz("Pacific/Samoa").format());
    _.p(_.iso_date("Pacific/Tongatapu") + " !== " + _.iso_date("Pacific/Samoa"));

    ok(_.iso_date("Pacific/Tongatapu") !== _.iso_date("Pacific/Samoa"))
});

test("to_number", function(){
    function to_number_f_test(f){<commit_msg>add test for _.iso_date<commit_after>"use strict";

var _ = require('../');

var eq = _.test.eq;
var ok = _.test.ok;

var test_hash_key_performance = false;

suite('common');

test("deep_equal", function(){
    eq(false, _.deep_equal({ blah: true }, { blah: false }));
    eq(false, _.deep_equal({ blah: "" }, { blah: false }));
    eq(true, _.deep_equal({ blah: "" }, { blah: false }, false));
});

test("s", function(){
    eq("", _.s());
    eq("null", _.s(null));
    eq("abc", _.s("abc"));
    eq("2", _.s(2));
    eq("{ o: { a: [] }, a: [ {}, {} ] }", _.s({ o: { a: [] }, a: [{}, {}] }));
});

test("sorn", function(){
    function test(f){
        eq("abc", f("abc"));
        eq("2", f(2));
        eq("0", f(0));
        eq("", f(""));
        eq(null, f());
        eq(null, f(null));
        eq(null, f({ o: { a: [] }, a: [{}, {}] }));
        eq(null, f([]));
    }
    test(_.sorn);
});

test("iso_date", function(){
    var now = _.date();
    eq(_.iso_date(), _.iso_date(now));

    var d = _.moment("2015-02-12").toDate();
    eq(_.iso_date(_.iso_date(d)).valueOf(), d.valueOf());

    eq(_.iso_date("2015-02-22").minutes(), 0);
    eq(_.iso_date("2015-02-22").hours(), 0);
    eq(_.iso_date("2015-02-22").seconds(), 0);
    eq(_.iso_date("2015-02-22").milliseconds(), 0);

    eq(_.iso_date(" 2015-02-22"), null);
    eq(_.iso_date("use strict 2015-02-22"), null);

    eq(_.iso_date(""), null);
    eq(_.iso_date("blah"), null);
    eq(_.iso_date("2015-22-22"), null);

    var now_la = _.moment.tz("America/Los_Angeles");
    var now_la_iso_date = now_la.format("YYYY-MM-DD");
    eq(now_la_iso_date, _.iso_date("America/Los_Angeles"));

    _.p("tonga date: ", _.iso_date("Pacific/Tongatapu"));
    _.p("tonga time: ", _.moment.tz("Pacific/Tongatapu").format());
    _.p("samoa date: ", _.iso_date("Pacific/Samoa"));
    _.p("samoa time: ", _.moment.tz("Pacific/Samoa").format());
    _.p(_.iso_date("Pacific/Tongatapu") + " !== " + _.iso_date("Pacific/Samoa"));

    ok(_.iso_date("Pacific/Tongatapu") !== _.iso_date("Pacific/Samoa"))
});

test("to_number", function(){
    function to_number_f_test(f){
{'fraction_non_alphanumeric': 0.27162629757785467, 'fraction_numerical': 0.02768166089965398, 'mean_word_length': 3.26, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6494615', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1557, 'n_words': 266}