<commit_before><!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Test suite for Mutil</title>
        <script src="jsunity-0.6.js"></script>
        <script src="../lib/mutil.js"></script>
        <script>
        jsUnity.attachAssertions();
        function MutilTest() {
            function assertSelectedNodes(n, x) {
                assertNotNull(x, 'No result was returned.');
                assertInstanceOf(Mutil.Collection, x, 'The result is not a Mutil.Collection');
                assertEqual(n, x.length, 'Expected query to have ' + n + ' elements');
            }

            function setUp() {
                window.onload = null;
            }

            function testSelectingElements() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(3, $('p'));
                });
            }

            function testSelectingClasses() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(3, $('.foo'));
                    assertSelectedNodes(2, $('a.foo'));
                });
            }

            function testSelectingIds() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(1, $('#page'));
                });
            }

            function testSelectingMultiple() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(4, $('div, p'));
                });
            }

            function testSelectingChildren() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(3, $('div p'));
                    assertSelectedNodes(1, $('li p'));
                });
            }

            function testSelectingDirectDescendents() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(2, $('div > p'));
                    assertSelectedNodes(1, $('div > ul > li > p'));
                });
            }

            function testSelectingAdjacent() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(1, $('p + p'));
                    assertSelectedNodes(4, $('li + li'));
                    assertSelectedNodes(1, $('p + p + ul'));
                });
            }
            
            function testQueryFromCollection() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(3, $('div').query('p'));
                });
            }

            function testSelectingByAttribute() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(2, $('a[href=foo]'));
                    assertSelectedNodes(2, $('a[href=\'foo\']'));
                    assertSelectedNodes(2, $('a[href="foo"]'));
                    assertSelectedNodes(1, $('a[href=foo][title="a b c"]'));
                    assertSelectedNodes(2, $('a[title*=b]'));
                    assertSelectedNodes(0, $('a[title*=e]'));
                    assertSelectedNodes(1, $('a[title~=tag2]'));
                    assertSelectedNodes(1, $('a[title^=tag1]'));
                    assertSelectedNodes(0, $('a[title^=tag2]'));
                    assertSelectedNodes(0, $('a[title$=tag1]'));
                    assertSelectedNodes(1, $('a[title$=tag2]'));
                    assertSelectedNodes(1, $('a[href=foo][title^=b]'));
                    assertSelectedNodes(0, $('a[href=foo][title^=c]'));
                });
            }

            function testSelectingInAnElement() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(3, $('p', document));
                    assertSelectedNodes(1, $('p', document.getElementsByTagName('ul')[0]));
                    assertSelectedNodes(0, $('p', document.getElementsByTagName('pre')[0]));
                });
            }

            function testSelectingNothing() {
                Mutil.App(function(app, $) {
                    var arr = ['', null, false, 2, {}];
                    for(var i = 0, j = arr.length; i--;) {
                        assertException(function() {
                            $(arr[i]);
                        });
                    }
                });
            }

            function testAddingOnloadFunction() {
                var pig = false;
                var fn = function() { pig = true; };
                assertNull(window.onload);
                Mutil.App(function(app, $) {
                    $(fn);
                });
                assertNotNull(window.onload);
                window.onload();
                assertTrue(pig);
            }

            function testAddingMultipleOnloadFunctions() {
                var pig1 = false,
                    pig2 = false;
                var fn1 = function() { pig1 = true; };
                var fn2 = function() { pig2 = true; };
                assertNull(window.onload);
                Mutil.App(function(app, $) {
                    $(fn1);
                    $(fn2);
                });
                assertNotNull(window.onload);
                window.onload();
                assertTrue(pig1);
                assertTrue(pig2);
            }

            function testCollectionFunctionsShouldApplyToEachElement() {
                Mutil.App(function(app, $) {
                    var x = $('p'),
                        i = 0;
                    x.each(function() {
                        i++;
                    });
                    assertEqual(3, i);
                });
            }

            function testAddingElementsToCollectionPrototypeShouldApplyToEachElement() {
                Mutil.App(function(app, $) {
                    var x = $('p'),
                        i = 0;
                    Mutil.Collection.prototype.incrementer = function() { this.each(function() { i++; }); };
                    x.incrementer();
                    assertEqual(3, i);
                });
            }
            
            function testShouldTellTtype() {
                var fn   = function() {},
                    str  = "foo bar",
                    num  = 12,
                    bool = true,<commit_msg>Update tests for new API<commit_after><!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Test suite for Mutil</title>
        <script src="jsunity-0.6.js"></script>
        <script src="../lib/mutil.js"></script>
        <script>
        jsUnity.attachAssertions();
        function MutilTest() {
            function assertSelectedNodes(n, x) {
                assertNotNull(x, 'No result was returned.');
                assertEqual(n, x.length, 'Expected query to have ' + n + ' elements');
            }

            function setUp() {
                window.onload = null;
            }

            function testSelectingElements() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(3, $('p'));
                });
            }

            function testSelectingClasses() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(3, $('.foo'));
                    assertSelectedNodes(2, $('a.foo'));
                });
            }

            function testSelectingIds() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(1, $('#page'));
                });
            }

            function testSelectingMultiple() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(4, $('div, p'));
                });
            }

            function testSelectingChildren() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(3, $('div p'));
                    assertSelectedNodes(1, $('li p'));
                });
            }

            function testSelectingDirectDescendents() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(2, $('div > p'));
                    assertSelectedNodes(1, $('div > ul > li > p'));
                });
            }

            function testSelectingAdjacent() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(1, $('p + p'));
                    assertSelectedNodes(4, $('li + li'));
                    assertSelectedNodes(1, $('p + p + ul'));
                });
            }
            
            function testQueryFromCollection() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(3, $('div').query('p'));
                });
            }

            function testSelectingByAttribute() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(2, $('a[href=foo]'));
                    assertSelectedNodes(2, $('a[href=\'foo\']'));
                    assertSelectedNodes(2, $('a[href="foo"]'));
                    assertSelectedNodes(1, $('a[href=foo][title="a b c"]'));
                    assertSelectedNodes(2, $('a[title*=b]'));
                    assertSelectedNodes(0, $('a[title*=e]'));
                    assertSelectedNodes(1, $('a[title~=tag2]'));
                    assertSelectedNodes(1, $('a[title^=tag1]'));
                    assertSelectedNodes(0, $('a[title^=tag2]'));
                    assertSelectedNodes(0, $('a[title$=tag1]'));
                    assertSelectedNodes(1, $('a[title$=tag2]'));
                    assertSelectedNodes(1, $('a[href=foo][title^=b]'));
                    assertSelectedNodes(0, $('a[href=foo][title^=c]'));
                });
            }

            function testSelectingInAnElement() {
                Mutil.App(function(app, $) {
                    assertSelectedNodes(3, $('p', document));
                    assertSelectedNodes(1, $('p', document.getElementsByTagName('ul')[0]));
                    assertSelectedNodes(0, $('p', document.getElementsByTagName('pre')[0]));
                });
            }

            function testSelectingNothing() {
                Mutil.App(function(app, $) {
                    var arr = ['', null, false, 2, {}];
                    for(var i = 0, j = arr.length; i--;) {
                        assertException(function() {
                            $(arr[i]);
                        });
                    }
                });
            }

            function testAddingOnloadFunction() {
                var pig = false;
                var fn = function() { pig = true; };
                assertNull(window.onload);
                Mutil.App(function(app, $) {
                    $(fn);
                });
                assertNotNull(window.onload);
                window.onload();
                assertTrue(pig);
            }

            function testAddingMultipleOnloadFunctions() {
                var pig1 = false,
                    pig2 = false;
                var fn1 = function() { pig1 = true; };
                var fn2 = function() { pig2 = true; };
                assertNull(window.onload);
                Mutil.App(function(app, $) {
                    $(fn1);
                    $(fn2);
                });
                assertNotNull(window.onload);
                window.onload();
                assertTrue(pig1);
                assertTrue(pig2);
            }

            function testCollectionFunctionsShouldApplyToEachElement() {
                Mutil.App(function(app, $) {
                    var x = $('p'),
                        i = 0;
                    x.each(function() {
                        i++;
                    });
                    assertEqual(3, i);
                });
            }

            function testAddingElementsToCollectionPrototypeShouldApplyToEachElement() {
                Mutil.App(function(app, $) {
                    var x = $('p'),
                        i = 0;
                    app.Collection.prototype.incrementer = function() { this.each(function() { i++; }); };
                    x.incrementer();
                    assertEqual(3, i);
                });
            }
            
            function testShouldTellTtype() {
                var fn   = function() {},
                    str  = "foo bar",
                    num  = 12,
                    bool = true,
{'fraction_non_alphanumeric': 0.1384678076609617, 'fraction_numerical': 0.009290953545232274, 'mean_word_length': 1.1753235241978373, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 33, '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': '4252417', 'n_tokens_mistral': 3245, 'n_tokens_neox': 2923, 'n_words': 487}