PageRenderTime 26ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/more/test_equatable.rb

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 42 lines | 21 code | 5 blank | 16 comment | 0 complexity | cacc0cd916294f8f62dfeb240ced3fdf MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
  1. require 'facets/equatable.rb'
  2. require 'test/unit'
  3. class TestModuleEquatable < Test::Unit::TestCase
  4. def test_equatable_with_arguments
  5. c = Class.new
  6. c.class_eval {
  7. include Equatable(:a,:b)
  8. attr_accessor :a, :b
  9. }
  10. c1,c2 = c.new,c.new
  11. c1.a = 10; c1.b = 20
  12. c2.a = 10; c2.b = 20
  13. assert_equal( c1, c2 )
  14. c1.a = 10; c1.b = 10
  15. c2.a = 10; c2.b = 20
  16. assert_not_equal( c1, c2 )
  17. c1.a = 10; c1.b = 20
  18. c2.a = 20; c2.b = 20
  19. assert_not_equal( c1, c2 )
  20. end
  21. =begin
  22. def test_equate_on_old
  23. c = Class.new
  24. c.class_eval { attr_accessor :a, :b ; equate_on :a,:b }
  25. c1,c2 = c.new,c.new
  26. c1.a = 10; c1.b = 20
  27. c2.a = 10; c2.b = 20
  28. assert_equal( c1, c2 )
  29. c1.a = 10; c1.b = 10
  30. c2.a = 10; c2.b = 20
  31. assert_not_equal( c1, c2 )
  32. c1.a = 10; c1.b = 20
  33. c2.a = 20; c2.b = 20
  34. assert_not_equal( c1, c2 )
  35. end
  36. =end
  37. end