+
+ describe('slice', function(){
+
+ var array;
+
+ describe('with Array', function(){
+ beforeEach(function(){
+ array = [{0:0}, {1:1}, {2:2}, {3:3}];
+ });
+ tests();
+ });
+
+ describe('with arguments', function(){
+ beforeEach(function(){
+ array = (function(){ return arguments; })({0:0}, {1:1}, {2:2}, {3:3});
+ });
+ tests();
+ });
+
+ function tests(){
+ it('should shallow clone', function(){
+ var newArray = Ext.Array.slice(array, 0);
+ expect(newArray === array).toBe(false);
+ expect(newArray[0] === array[0]).toBe(true);
+ });
+ it('should not require a begin or end', function(){
+ var newArray = Ext.Array.slice(array);
+ expect(newArray === array).toBe(false);
+ expect(newArray[0]).toBe(array[0]);
+ });
+ it('should slice off the first item', function(){
+ var newArray = Ext.Array.slice(array, 1);
+ expect(newArray.length).toBe(3);
+ expect(newArray[0]).toBe(array[1]);
+ expect(newArray[2]).toBe(array[3]);
+ });
+ it('should ignore `end` if undefined', function(){
+ var newArray = Ext.Array.slice(array, 1, undefined);
+ expect(newArray.length).toBe(3);
+ expect(newArray[0]).toBe(array[1]);
+ expect(newArray[2]).toBe(array[3]);
+ });
+ it('should ignore `begin` if undefined', function(){
+ var newArray = Ext.Array.slice(array, undefined);
+ expect(newArray.length).toBe(4);
+ expect(newArray[0]).toBe(array[0]);
+ expect(newArray[3]).toBe(array[3]);
+ });
+ it('should ignore `begin` and `end` if undefined', function(){
+ var newArray = Ext.Array.slice(array, undefined, undefined);
+ expect(newArray.length).toBe(4);
+ expect(newArray[0]).toBe(array[0]);
+ expect(newArray[3]).toBe(array[3]);
+ });
+ it('should slice out the middle', function(){
+ var newArray = Ext.Array.slice(array, 1, -1);
+ expect(newArray.length).toBe(2);
+ expect(newArray[0]).toBe(array[1]);
+ expect(newArray[1]).toBe(array[2]);
+ });
+ }
+ });