Sha256: e0a5e2c43d67db64d986a8220c2000adf3d8944ccb086e65f60261e43e0bbb3d
Contents?: true
Size: 1.65 KB
Versions: 18
Compression:
Stored size: 1.65 KB
Contents
// ========================================================================== // Project: SproutCore - JavaScript Application Framework // Copyright: ©2006-2010 Apple Inc. and contributors. // License: Licensed under MIT license (see license.js) // ========================================================================== /*global module test equals context ok same */ var set ; module("SC.IndexSet#addEach", { setup: function() { set = SC.IndexSet.create(); } }); function iter(s) { var ret = []; set.forEach(function(k) { ret.push(k); }); return ret ; } // .......................................................... // BASIC ADDS // test("adding should iterate over an array", function() { set.addEach([1000, 1010, 1020, 1030]); equals(set.get('length'), 4, 'should have correct index count'); equals(set.get('max'), 1031, 'max should return 1 past last index'); same(iter(set), [1000, 1010, 1020, 1030]); }); test("adding should iterate over a set", function() { // add out of order... var input = SC.Set.create().add(1030).add(1010).add(1020).add(1000); set.addEach(input); equals(set.get('length'), 4, 'should have correct index count'); equals(set.get('max'), 1031, 'max should return 1 past last index'); same(iter(set), [1000, 1010, 1020, 1030]); }); test("adding should iterate over a indexset", function() { // add out of order... var input = SC.IndexSet.create().add(1000,2).add(1010).add(1020).add(1030); set.addEach(input); equals(set.get('length'), 5, 'should have correct index count'); equals(set.get('max'), 1031, 'max should return 1 past last index'); same(iter(set), [1000, 1001, 1010, 1020, 1030]); });
Version data entries
18 entries across 18 versions & 2 rubygems