Sha256: be35e62e8d4b5100690f8f6205997a122daf64520051836a845ec48272ee23d6

Contents?: true

Size: 1.67 KB

Versions: 17

Compression:

Stored size: 1.67 KB

Contents

// ==========================================================================
// Project:   SproutCore Costello - Property Observing Library
// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
//            Portions ©2008-2009 Apple Inc. All rights reserved.
// License:   Licened under MIT license (see license.js)
// ==========================================================================

// Unit test some standard SC.Array implementations.

// ..........................................................
// BUILT-IN ARRAY
// 

SC.ArraySuite.generate("built-in Array");

// ..........................................................
// DUMMY ARRAY (BASIC FAKE IMPLEMENTATION)
// 

// Test the SproutCore Array interface on a custom object.
var DummyArray = SC.Object.extend(SC.Array, {
  
  length: 0,
  
  content: null,
  
  replace: function(idx, amt, objects) {
    if (!this.content) this.content = [] ;

    this.beginPropertyChanges() ;
    this.content.replace(idx,amt,objects) ;

    this.set('length', this.content.length) ;

    // figure out the range that changed.  If amt + objects are the same, use
    // amt.  Otherwise use total length.
    var len = objects ? objects.get('length') : 0;
    this.enumerableContentDidChange(idx, amt, len - amt) ;
    this.endPropertyChanges() ;
  },
  
  objectAt: function(idx) {
    if (!this.content) this.content = [] ;
    return this.content[idx] ;
  }
  
});

SC.ArraySuite.generate("DummyArray", {
  newObject: function(expected) {
    if (!expected || typeof expected === SC.T_NUMBER) {
      expected = this.expected(expected); 
    }
    return DummyArray.create({ content: expected, length: expected.length }) ;
  }
});

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
sproutit-sproutcore-1.0.20090721145285 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1046 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1043 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1042 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1037 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1035 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1031 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1030 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1029 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1027 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1028 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1026 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1025 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1024 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1009 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1008 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.0.1003 frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js