Sha256: 4415646ea323b99550e840b49b69911e4d3511377622b3650e166d46292ecb26
Contents?: true
Size: 1.12 KB
Versions: 11
Compression:
Stored size: 1.12 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) // ========================================================================== /*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
11 entries across 11 versions & 1 rubygems