Sha256: a2e0520cc777e07738a3560b4b1b3b31ea46289c20bbaefdba65cdab48106aba
Contents?: true
Size: 1.12 KB
Versions: 7
Compression:
Stored size: 1.12 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: Licensed under MIT license (see license.js) // ========================================================================== /*globals module test ok isObj equals expects */ var Rectangle = SC.Object.extend({ length: 0, width: 0, area: function() { return this.get('length') * this.get('width'); } }); Rectangle.mixin(SC.Comparable, { compare: function(a, b) { return SC.compare(a.area(), b.area()); } }); var r1, r2; module("Comparable", { setup: function() { r1 = Rectangle.create({length: 6, width: 12}); r2 = Rectangle.create({length: 6, width: 13}); }, teardown: function() { } }); test("should be comparable and return the correct result", function() { equals(r1.constructor.isComparable, YES); equals(SC.compare(r1, r1), 0); equals(SC.compare(r1, r2), -1); equals(SC.compare(r2, r1), 1); });
Version data entries
7 entries across 7 versions & 1 rubygems