<commit_before><!doctype html>
<!--
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
  <meta charset="utf-8">
  <script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
  <script src="../../../web-component-tester/browser.js"></script>
  <link rel="import" href="../../polymer.html">
</head>
<body>
  <script>
  suite('Mixin Utilities', () => {
    suite('Mixin Caching', () => {
      let mixinFn;
      let cachingMixinFn;
      suiteSetup(() => {
        mixinFn = (base) => class mixin extends base {
          mixed(){ return true; }
        };
        cachingMixinFn = Polymer.Utils.cachingMixin(mixinFn);
      });
      test('cachingMixin applies mixins', () => {
        let app = cachingMixinFn(class {});
        let inst = new app();
        assert.isFunction(inst.mixed);
        assert.equal(inst.mixed(), true);
      });
      test('Mixins are cached when the base class is identical', () => {
        class base {}
        let applicationOne = cachingMixinFn(base);
        let applicationTwo = cachingMixinFn(base);
        assert.equal(applicationOne, applicationTwo);
      });
      test('Original Mixin function keeps the cache', () => {
        assert.ok(mixinFn.__mixinApplications);
        assert.instanceOf(mixinFn.__mixinApplications, WeakMap);
        assert.notOk(cachingMixinFn.__mixinApplications);
      });
    });
    suite('Mixin Deduplicating', () => {
      let mixinFn, dedupingMixinFn;
      suiteSetup(() => {
        mixinFn = (base) => class mixin extends base {
          mixed(){ return true; }
        };
        dedupingMixinFn = Polymer.Utils.dedupingMixin(mixinFn);
      });
      test('dedupingMixin applies mixins', () => {
        let app = dedupingMixinFn(class {});
        let inst = new app();
        assert.isFunction(inst.mixed);
        assert.equal(inst.mixed(), true);
      });
      test('dedupingMixin also caches', () => {
        class base {}
        let appOne = dedupingMixinFn(base);
        let appTwo = dedupingMixinFn(base);
        assert.equal(appOne, appTwo);
      });
      test('Mixins apply only if unique on the base class', () => {
        class base {}
        let appOne = dedupingMixinFn(base);
        class intermediate extends appOne {}
        let appTwo = dedupingMixinFn(intermediate);
        assert.equal(intermediate, appTwo);
        let inst = new appTwo();
        assert.equal(inst.mixed(), true);
      });
      test('Multiple deduplicating mixins apply uniquely', () => {
        let mixinFn1 = Polymer.Utils.dedupingMixin((base) => class one extends base {
          one(){ return true }
        });
        let mixinFn2 = Polymer.Utils.dedupingMixin((base) => class two extends base {
          two(){ return true }
        });
        class base {}
        let app1 = mixinFn1(base);
        let app2 = mixinFn2(app1);
        let app3 = mixinFn1(app2);
        assert.equal(app3, app2);
        let inst = new app3();
        assert.equal(inst.one(), true);
        assert.equal(inst.two(), true);
      });
    });
  });
  </script>
</body>
</html><commit_msg>test for unique mixin applications across a shared base class<commit_after><!doctype html>
<!--
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
  <meta charset="utf-8">
  <script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
  <script src="../../../web-component-tester/browser.js"></script>
  <link rel="import" href="../../polymer.html">
</head>
<body>
  <script>
  suite('Mixin Utilities', () => {
    suite('Mixin Caching', () => {
      let mixinFn;
      let cachingMixinFn;
      suiteSetup(() => {
        mixinFn = (base) => class mixin extends base {
          mixed(){ return true; }
        };
        cachingMixinFn = Polymer.Utils.cachingMixin(mixinFn);
      });
      test('cachingMixin applies mixins', () => {
        let app = cachingMixinFn(class {});
        let inst = new app();
        assert.isFunction(inst.mixed);
        assert.equal(inst.mixed(), true);
      });
      test('Mixins are cached when the base class is identical', () => {
        class base {}
        let applicationOne = cachingMixinFn(base);
        let applicationTwo = cachingMixinFn(base);
        assert.equal(applicationOne, applicationTwo);
      });
      test('Original Mixin function keeps the cache', () => {
        assert.ok(mixinFn.__mixinApplications);
        assert.instanceOf(mixinFn.__mixinApplications, WeakMap);
        assert.notOk(cachingMixinFn.__mixinApplications);
      });
    });
    suite('Mixin Deduplicating', () => {
      let mixinFn, dedupingMixinFn;
      suiteSetup(() => {
        mixinFn = (base) => class mixin extends base {
          mixed(){ return true; }
        };
        dedupingMixinFn = Polymer.Utils.dedupingMixin(mixinFn);
      });
      test('dedupingMixin applies mixins', () => {
        let app = dedupingMixinFn(class {});
        let inst = new app();
        assert.isFunction(inst.mixed);
        assert.equal(inst.mixed(), true);
      });
      test('dedupingMixin also caches', () => {
        class base {}
        let appOne = dedupingMixinFn(base);
        let appTwo = dedupingMixinFn(base);
        assert.equal(appOne, appTwo);
      });
      test('Mixins apply only if unique on the base class', () => {
        class base {}
        let appOne = dedupingMixinFn(base);
        class intermediate extends appOne {}
        let appTwo = dedupingMixinFn(intermediate);
        assert.equal(intermediate, appTwo);
        let inst = new appTwo();
        assert.equal(inst.mixed(), true);
      });
      test('Multiple deduplicating mixins apply uniquely', () => {
        let mixinFn1 = Polymer.Utils.dedupingMixin((base) => class one extends base {
          one(){ return true }
        });
        let mixinFn2 = Polymer.Utils.dedupingMixin((base) => class two extends base {
          two(){ return true }
        });
        class base {}
        let app1 = mixinFn1(base);
        let app2 = mixinFn2(app1);
        let app3 = mixinFn1(app2);
        assert.equal(app3, app2);
        let inst = new app3();
        assert.equal(inst.one(), true);
        assert.equal(inst.two(), true);
      });
      test('Classes with mixins do not share mixin sets', () => {
        let mixinFn1 = Polymer.Utils.dedupingMixin((base) => class one extends base {
          one(){ return true }
        });
        let mixinFn2 = Polymer.Utils.dedupingMixin((base) => class two extends base {
          two(){ return true }
        });
        let mixinFn3 = Polymer.Utils.dedupingMixin((base) => class three extends base {
          three(){ return true }
        });
        class base {}
        let app1 = mixinFn1(base);
        let app2 = mixinFn2(app1);
        let app3 = mixinFn3(app2);
        let appNot2 = mixinFn3(app1);
        assert.notEqual(appNot2.__mixinSet, app3.__mixinSet);
        let inst = new appNot2();
        assert.isFunction(inst.one);
        assert.isFunction(inst.three);
        assert.isNotFunction(inst.two);
      });
    });
  });
  </script>
</body>
</html>
{'fraction_non_alphanumeric': 0.1379655086228443, 'fraction_numerical': 0.00662334416395901, 'mean_word_length': 2.4841097083151937, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 71, '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': '6058738', 'n_tokens_mistral': 2413, 'n_tokens_neox': 2333, 'n_words': 601}