<commit_before><!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">

    <title>kgui-multi-digits test</title>

    <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
    <script src="../../web-component-tester/browser.js"></script>

    <link rel="import" href="../kgui-multi-digits.html">
  </head>
  <body>
    <test-fixture id="basic">
      <template>
        <kgui-multi-digits></kgui-multi-digits>
      </template>
    </test-fixture>

    <script>
      suite('kgui-multi-digits', function () {

        var element;

        function eventFire (el, etype) {
          if (el.fireEvent) {
            el.fireEvent('on' + etype);
          } else {
            var evObj = document.createEvent('Events');
            evObj.initEvent(etype, true, false);
            el.dispatchEvent(evObj);
          }
        }

        // -----------------------------------------------------------------------------------
        // Test preparation
        // -----------------------------------------------------------------------------------

        // Will be executed at the beginning of every test().
        setup(function () {
            element = fixture("basic");
        });

        // -----------------------------------------------------------------------------------
        // Elementary
        // -----------------------------------------------------------------------------------

        test('A01 - Instantiating the default element works', function() {
          assert.equal(element.is, 'kgui-multi-digits');
        });

        test('A02 - Default FORMAT `(#,##)#.#`', function() {
          assert.equal(element.format, "(#,##)#.#");
        });

        test('A03 - Default value 0', function() {
          assert.equal(element.number, 0);
        });

        // -----------------------------------------------------------------------------------
        // Function validateFormat()
        // -----------------------------------------------------------------------------------

        // Writing and testing https://regex101.com/
        test('B01 - validFormat()', function() {
          // default situation
          assert.equal(element.format, "(#,##)#.#");

          // Some acceptable formats
          assert.equal(element.validateFormat("#"), true);                   // Just one digit
          assert.equal(element.validateFormat("#,#"), true);                 // Two digits diveded by a ','
          assert.equal(element.validateFormat("#.#"), true);                 // Two digits diveded by a ','
          assert.equal(element.validateFormat("##.#"), true);                // 00,0
          assert.equal(element.validateFormat("(#)#.#"), true);              // (0)0,0
          assert.equal(element.validateFormat("#,###.##"), true);            // (0.0.)0.0
          assert.equal(element.validateFormat("(#.#).#.#"), true);           // (0.0.)0.0

          // Some un-acceptable formats
          assert.throws(function () {element.validateFormat("a")}, "Always start with '#' OR '(#' and always end with an '#'.");                // unacceptable characters
          assert.throws(function () {element.validateFormat("#(#)")}, "Always start with '#' OR '(#' and always end with an '#'.");                // unacceptable characters
          assert.throws(function () {element.validateFormat("(#a)#")}, "Allowed characters `.,#()`.");                // unacceptable characters
          assert.throws(function () {element.validateFormat("(#")}, "Missing end ')'.");                // unacceptable characters
          assert.throws(function () {element.validateFormat("(#))#")}, "No matching '()'.");                // unacceptable characters
          assert.throws(function () {element.validateFormat("#)#")}, "No matching '()'.");                // unacceptable characters
          assert.throws(function () {element.validateFormat("(#(#))#")}, "No matching '()'.");                // unacceptable characters
          assert.throws(function () {element.validateFormat("(#(#)#")}, "No matching '()'.");                // unacceptable characters
        });
          

        // -----------------------------------------------------------------------------------
        // Functionality
        // -----------------------------------------------------------------------------------

      });

    </script>
  </body>
</html><commit_msg>Errors not THROWN, but console log. Fix layout.<commit_after><!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">

    <title>kgui-multi-digits test</title>

    <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
    <script src="../../web-component-tester/browser.js"></script>

    <link rel="import" href="../kgui-multi-digits.html">
  </head>
  <body>
    <test-fixture id="basic">
      <template>
        <kgui-multi-digits></kgui-multi-digits>
      </template>
    </test-fixture>

    <script>
      suite('kgui-multi-digits', function () {

        var element;

        function eventFire (el, etype) {
          if (el.fireEvent) {
            el.fireEvent('on' + etype);
          } else {
            var evObj = document.createEvent('Events');
            evObj.initEvent(etype, true, false);
            el.dispatchEvent(evObj);
          }
        }

        // -----------------------------------------------------------------------------------
        // Test preparation
        // -----------------------------------------------------------------------------------

        // Will be executed at the beginning of every test().
        setup(function () {
            element = fixture("basic");
        });

        // -----------------------------------------------------------------------------------
        // Elementary
        // -----------------------------------------------------------------------------------

        test('A01 - Instantiating the default element works', function() {
          assert.equal(element.is, 'kgui-multi-digits');
        });

        test('A02 - Default FORMAT `(#,##)#.#`', function() {
          assert.equal(element.format, "(#,##)#.#");
        });

        test('A03 - Default value 0', function() {
          assert.equal(element.number, 0);
        });

        // -----------------------------------------------------------------------------------
        // Function validateFormat()
        // -----------------------------------------------------------------------------------

        // Writing and testing https://regex101.com/
        test('B01 - validateFormat()', function() {
          // default situation
          assert.equal(element.format, "(#,##)#.#");

          // Some acceptable formats
          assert.equal(element.validateFormat("#"), true);                  // Just one digit
          assert.equal(element.validateFormat("#,#"), true);                // Two digits diveded by a ','
          assert.equal(element.validateFormat("#.#"), true);                // Two digits diveded by a ','
          assert.equal(element.validateFormat("##.#"), true);               // 00,0
          assert.equal(element.validateFormat("(#)#.#"), true);             // (0)0,0
          assert.equal(element.validateFormat("#,###.##"), true);           // (0.0.)0.0
          assert.equal(element.validateFormat("(#.#).#.#"), true);          // (0.0.)0.0

          // Some unacceptable formats
          assert.equal(element.validateFormat("a"), false);                 // "Always start with '#' OR '(#' and always end with an '#'
          assert.equal(element.validateFormat("#(#)"), false);              // "Always start with '#' OR '(#' and always end with an '#'
          assert.equal(element.validateFormat("(#a)#"), false);             // "Allowed characters `.,#()`
          assert.equal(element.validateFormat("(#"), false);                // "Missing end ')'
          assert.equal(element.validateFormat("(#))#"), false);             // "No matching '()'
          assert.equal(element.validateFormat("#)#"), false);               // "No matching '()'
          assert.equal(element.validateFormat("(#(#))#"), false);           // "No matching '()'
          assert.equal(element.validateFormat("(#(#)#"), false);            // "No matching '()'
        });
          
        test('B02 - validateNumber()', function() {
          // default situation
          assert.equal(element.number, 0);

          // Some acceptable numbers
          assert.equal(element.validateNumber(1), true, "1");                     // Just one digit
          assert.equal(element.validateNumber('1'), true, "'1'");                 // Just one digit
          assert.equal(element.validateNumber(99), true, "99");                   // two digits
          assert.equal(element.validateNumber(0123456789), true, "0123456789");   // A lot digits

          // Some unacceptable numbers
          assert.equal(element.validateNumber(-1.2), false, "-1.2");              // Negative not supported
          assert.equal(element.validateNumber("9,9"), false, "9,9");              // COMMA is not a floating point indicator
        });

        // -----------------------------------------------------------------------------------
        // Functionality
        // -----------------------------------------------------------------------------------

      });

    </script>
  </body>
</html>
{'fraction_non_alphanumeric': 0.2933485524540832, 'fraction_numerical': 0.01027290650617412, 'mean_word_length': 1.2592592592592593, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, 'https://': 2, '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': '7199493', 'n_tokens_mistral': 2406, 'n_tokens_neox': 2225, 'n_words': 446}