Sha256: 1d28bb3a99e0dfe05ed40e36b874a8735118dad0a35aed2db5ccc4333d3d4ef6

Contents?: true

Size: 1.97 KB

Versions: 53

Compression:

Stored size: 1.97 KB

Contents

// ========================================================================
// SC.Range Tests
// ========================================================================


module("SC.Range");

test("to find the maxRange() and minRange() values of a given range",function(){
	var obj = {start:15,length:75};
	equals(YES,SC.minRange(obj) == 15,'Minimum range');
    equals(YES,SC.maxRange(obj) == 90,'Maximum range');
});

test("unionRanges() to find the union of two ranges",function(){
	var obj = {start:15,length:75};
	var obj1 = {start:5,length:50};
	var c = SC.unionRanges(obj,obj1);
	equals(obj1.start,SC.minRange(c),'Minimum range');
	equals(85,c.length,'Maximum range');
});

test("rangesEqual() to find if the given ranges are equal",function(){
    var obj = {start:15,length:75};
	var obj1 = {start:15,length:75};
	var obj2 = {start:5,length:50};
	var c = SC.rangesEqual(obj,obj1);
	var d = SC.rangesEqual(obj1,obj2);
	equals(true,c,'Equal ranges');
	equals(false,d,'Unequal ranges');	
});

test("cloneRange() to clone the given range",function(){
	var obj = {start:15,length:75};
	var c = SC.cloneRange(obj);
	equals(obj.start,SC.minRange(c),'Minimum range');
	equals(75,c.length,'Maximum range');
});

test("valueInRange() to find if a given value is in range",function(){
	var obj = {start:15,length:75};
	var c = SC.valueInRange(25,obj);
	var d = SC.valueInRange(10,obj);
	equals(true,c,'In range');
	equals(false,d,'Not in range');
});

// test("valueInRange() to find if a given value is in range",function(){
// 	var obj = {start:15,length:75};
// 	var c = SC.valueInRange(25,obj);
// 	var d = SC.valueInRange(10,obj);
// 	equals(true,c,'In range');
// 	equals(false,d,'Not in range');
// });

test("intersectRanges() to get the intersection of 2 ranges",function(){
	var obj1 = {start:15,length:75};
	var obj2 = {start:5,length:50};
	
	var c = SC.intersectRanges(obj1,obj2);
	equals(SC.minRange(obj1),SC.minRange(c),'Minimum Intersection Range');
	equals(40,c.length,'Maximum Intersection Range');
});

Version data entries

53 entries across 53 versions & 3 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090408130025 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.0.20090416161445 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.0.20090720093355 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.0.20090720202429 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.0.20090721125122 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.126 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.20090721145251 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.20090721145280 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.20090721145281 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.20090721145282 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.20090721145285 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutit-sproutcore-1.0.203 frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
spade-0.0.1 sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutcore-1.5.0.pre.4.1 lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutcore-1.5.0.pre.4 lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutcore-1.5.0.pre.3 lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutcore-1.4.5 lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutcore-1.4.5-java lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js
sproutcore-1.4.4-java lib/frameworks/sproutcore/frameworks/foundation/tests/system/utils/range.js