Sha256: b8acc4bfe009f78442b4fbcf91d8525f7a0712ebe81dbf7eb65c99a86f49899c

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

(function(env) {
  function hasFunctioningSets() {
    if (typeof Set === 'undefined') { return false; }

    try {
      var s = new Set();
      s.add(1);
      s.add(2);

      if (s.size !== 2) { return false; }
      if (s.has(1) !== true) { return false; }

      var iterations = 0;
      var isForEachWorking = true;
      s.forEach(function(value, key, set) {
        isForEachWorking = isForEachWorking && set === s;

        if (iterations===0) {
          isForEachWorking = isForEachWorking && (key===value) && value===1;
        } else if (iterations===1) {
          isForEachWorking = isForEachWorking && (key===value) && value===2;
        }

        iterations++;
      });
      if (iterations !== 2) { return false; }
      if (isForEachWorking !== true) { return false; }

      return true;
    } catch(e) {
      return false;
    }
  }

  env.requireFunctioningSets = function() {
    if (!hasFunctioningSets()) {
      env.pending("Browser has incomplete or missing support for Sets");
    }
  };

})(jasmine.getEnv());

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jasmine-core-2.99.1 ./lib/jasmine-core/spec/helpers/checkForSet.js
jasmine-core-3.0.0 ./lib/jasmine-core/spec/helpers/checkForSet.js
jasmine-core-2.99.0 ./lib/jasmine-core/spec/helpers/checkForSet.js
jasmine-core-2.9.1 ./lib/jasmine-core/spec/helpers/checkForSet.js
jasmine-core-2.9.0 ./lib/jasmine-core/spec/helpers/checkForSet.js