Sha256: 7fa2940f0c9df57edccb4ae9191f84b27223441a2de6d7281de224b0abfc7b7b

Contents?: true

Size: 1.53 KB

Versions: 9

Compression:

Stored size: 1.53 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2009 Apple, Inc. and contributors.
// License:   Licened under MIT license (see license.js)
// ==========================================================================

/*global module test equals context ok same notest */
var set ;
module("SC.IndexSet#clone", {
  setup: function() {
    set = SC.IndexSet.create();
  }
});

test("clone should return new object with same key properties", function() {
  set.add(100,100).add(200,100);
  set.source = "foo";
  
  var set2 = set.clone();
  ok(set2 !== null, 'return value should not be null');
  ok(set2 !== set, 'cloned set should not be same instance as set');
  ok(set.isEqual(set2), 'set.isEqual(set2) should be true');
  
  equals(set2.get('length'), set.get('length'), 'clone should have same length');
  equals(set2.get('min'), set.get('min'), 'clone should have same min');
  equals(set2.get('max'), set.get('max'), 'clone should have same max');
  equals(set2.get('source'), set.get('source'), 'clone should have same source');

});

test("cloning frozen object returns unfrozen", function() {
  var set2 = set.freeze().clone();
  equals(set2.get('isFrozen'), NO, 'set2.isFrozen should be NO');
});

test("copy works like clone", function() {
  same(set.copy(), set, 'should return copy');
  ok(set.copy() !== set, 'should not return same instance');
  
  set.freeze();
  equals(set.frozenCopy(), set, 'should return same instance when frozen');
});

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090720093355 frameworks/sproutcore/frameworks/runtime/tests/system/index_set/clone.js
sproutit-sproutcore-1.0.0.20090720202429 frameworks/sproutcore/frameworks/runtime/tests/system/index_set/clone.js
sproutit-sproutcore-1.0.0.20090721125122 frameworks/sproutcore/frameworks/runtime/tests/system/index_set/clone.js
sproutit-sproutcore-1.0.126 frameworks/sproutcore/frameworks/runtime/tests/system/index_set/clone.js
sproutit-sproutcore-1.0.20090721145251 frameworks/sproutcore/frameworks/runtime/tests/system/index_set/clone.js
sproutit-sproutcore-1.0.20090721145280 frameworks/sproutcore/frameworks/runtime/tests/system/index_set/clone.js
sproutit-sproutcore-1.0.20090721145281 frameworks/sproutcore/frameworks/runtime/tests/system/index_set/clone.js
sproutit-sproutcore-1.0.20090721145282 frameworks/sproutcore/frameworks/runtime/tests/system/index_set/clone.js
sproutit-sproutcore-1.0.203 frameworks/sproutcore/frameworks/runtime/tests/system/index_set/clone.js