Sha256: 05acc95ea0f3df2cb5fbe940972effdce8e8709b1d6d677ff1b7d1b4c9425caa

Contents?: true

Size: 1.67 KB

Versions: 11

Compression:

Stored size: 1.67 KB

Contents

// ==========================================================================
// Project:   SproutCore Costello - Property Observing Library
// Copyright: ©2006-2010 Sprout Systems, Inc. and contributors.
//            Portions ©2008-2010 Apple Inc. All rights reserved.
// License:   Licensed 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

11 entries across 11 versions & 1 rubygems

Version Path
sproutcore-1.4.4-java lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.4.4 lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.4.3.1 lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.4.3-java lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.4.3 lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.4.2-java lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.4.2 lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.4.1-java lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.4.1 lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.4.0-java lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js
sproutcore-1.4.0 lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js