Sha256: a5e2a4d8ed51f1f89f803254b8cef148a2c933488279f87be1a01c476b80dad8
Contents?: true
Size: 1.25 KB
Versions: 9
Compression:
Stored size: 1.25 KB
Contents
# _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ | # |_|\___||___/\__| # # for lib/facets/compare_on.rb # # Extracted Mon Sep 03 16:23:07 -0700 2007 # w/ Test Extraction Ratchet # require 'facets/compare_on.rb' require 'test/unit' class TestModuleCompare < Test::Unit::TestCase def test_equate_on c = Class.new c.class_eval { attr_accessor :a, :b ; equate_on :a,:b } c1,c2 = c.new,c.new c1.a = 10; c1.b = 20 c2.a = 10; c2.b = 20 assert_equal( c1, c2 ) c1.a = 10; c1.b = 10 c2.a = 10; c2.b = 20 assert_not_equal( c1, c2 ) c1.a = 10; c1.b = 20 c2.a = 20; c2.b = 20 assert_not_equal( c1, c2 ) end def test_sort_on c = Class.new c.class_eval { def initialize(a,b) @a=a; @b=b end sort_on :a,:b } a = [c.new(10,20),c.new(10,30)] assert_equal( a, a.sort ) a = [c.new(10,30),c.new(10,20)] assert_equal( a.reverse, a.sort ) a = [c.new(10,10),c.new(20,10)] assert_equal( a, a.sort ) a = [c.new(20,10),c.new(10,10)] assert_equal( a.reverse, a.sort ) a = [c.new(10,30),c.new(20,10)] assert_equal( a, a.sort ) end end
Version data entries
9 entries across 9 versions & 1 rubygems