facets 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/AUTHORS +3 -3
  2. data/README +6 -7
  3. data/lib/core/facets.rb +1 -46
  4. data/lib/core/facets/array.rb +3 -0
  5. data/lib/core/facets/array/indexable.rb +6 -1
  6. data/lib/core/facets/array/only.rb +20 -0
  7. data/lib/core/facets/dir/multiglob.rb +12 -1
  8. data/lib/core/facets/enumerable.rb +0 -1
  9. data/lib/core/facets/enumerable/collect.rb +1 -0
  10. data/lib/core/facets/enumerable/combination.rb +44 -90
  11. data/lib/core/facets/facets.rb +46 -0
  12. data/lib/core/facets/file/write.rb +46 -58
  13. data/lib/core/facets/hash.rb +2 -0
  14. data/lib/core/facets/hash/select.rb +14 -0
  15. data/lib/core/facets/integer/multiples.rb +12 -55
  16. data/lib/core/facets/kernel/val.rb +14 -0
  17. data/lib/core/facets/module/alias.rb +28 -9
  18. data/lib/core/facets/module/methods.rb +18 -0
  19. data/lib/core/facets/module/traits.rb +65 -70
  20. data/lib/core/facets/proc/compose.rb +15 -12
  21. data/lib/core/facets/stackable.rb +3 -2
  22. data/lib/core/facets/string/format.rb +4 -6
  23. data/lib/core/facets/string/tabs.rb +34 -0
  24. data/lib/core/facets/symbol.rb +1 -0
  25. data/lib/core/facets/symbol/succ.rb +1 -42
  26. data/lib/core/facets/symbol/to_proc.rb +34 -0
  27. data/lib/methods/facets/array/contains.rb +1 -0
  28. data/lib/methods/facets/facets/require_core.rb +1 -0
  29. data/lib/methods/facets/file/writelines.rb +1 -0
  30. data/lib/methods/facets/io/writelines.rb +1 -0
  31. data/lib/methods/facets/kernel/not_nil.rb +1 -0
  32. data/lib/methods/facets/module/conflict.rb +1 -0
  33. data/lib/methods/facets/module/instance_method_defined.rb +1 -0
  34. data/lib/methods/facets/module/module_method_defined.rb +1 -0
  35. data/lib/methods/facets/module/private_conflict.rb +1 -0
  36. data/lib/methods/facets/module/protected_conflict.rb +1 -0
  37. data/lib/methods/facets/module/public_conflict.rb +1 -0
  38. data/lib/methods/facets/string/expand_tabs.rb +1 -0
  39. data/lib/methods/facets/string/outdent.rb +1 -0
  40. data/lib/methods/facets/string/taballto.rb +1 -0
  41. data/lib/more/facets/arguments.rb +1 -1
  42. data/lib/more/facets/association.rb +0 -46
  43. data/lib/more/facets/autoarray.rb +0 -28
  44. data/lib/more/facets/command.rb +341 -8
  45. data/lib/more/facets/dictionary.rb +25 -131
  46. data/lib/more/facets/downloader.rb +1 -1
  47. data/lib/more/facets/infinity.rb +3 -3
  48. data/lib/more/facets/interval.rb +0 -161
  49. data/lib/more/facets/multiton.rb +16 -12
  50. data/lib/more/facets/namespace.rb +1 -1
  51. data/lib/more/facets/ostruct.rb +46 -10
  52. data/lib/more/facets/overload.rb +0 -51
  53. data/lib/more/facets/paramix.rb +0 -97
  54. data/lib/more/facets/pp_s.rb +30 -0
  55. data/lib/more/facets/progressbar.rb +18 -10
  56. data/lib/more/facets/prototype.rb +1 -40
  57. data/lib/more/facets/random.rb +1 -0
  58. data/lib/more/facets/rbsystem.rb +4 -1
  59. data/lib/more/facets/snapshot.rb +8 -1
  60. data/lib/more/facets/stylize.rb +2 -0
  61. data/meta/{project.yaml → facets-2.0.3.roll} +22 -14
  62. data/meta/manifest.txt +38 -8
  63. data/task/{config.yaml → config/general.yaml} +7 -2
  64. data/task/{rdoc.yaml → config/rdoc.yaml} +1 -1
  65. data/task/crosstest +309 -0
  66. data/task/isotest +293 -0
  67. data/task/loadtest +28 -0
  68. data/task/methods +4 -4
  69. data/task/prepare +5 -0
  70. data/task/publish +2 -2
  71. data/task/rdoc +1 -0
  72. data/task/syntax +29 -0
  73. data/task/test +0 -1
  74. data/task/testeach +42 -0
  75. data/task/testpairs +50 -0
  76. data/test/lib/rq.rb +15 -0
  77. data/test/unit/array/test_merge.rb +21 -43
  78. data/test/unit/array/test_only.rb +21 -0
  79. data/test/unit/enumerable/test_collect.rb +1 -21
  80. data/test/unit/enumerable/test_combination.rb +50 -44
  81. data/test/unit/file/test_topath.rb +48 -57
  82. data/test/unit/file/test_write.rb +82 -0
  83. data/test/unit/hash/test_select.rb +43 -0
  84. data/test/unit/integer/test_multiples.rb +28 -32
  85. data/test/unit/kernel/test_report.rb +9 -12
  86. data/test/unit/kernel/test_val.rb +50 -45
  87. data/test/unit/module/test_include.rb +56 -57
  88. data/test/unit/module/test_name.rb +42 -55
  89. data/test/unit/module/test_traits.rb +46 -47
  90. data/test/unit/string/test_filter.rb +19 -34
  91. data/test/unit/string/test_format.rb +87 -96
  92. data/test/unit/string/test_regesc.rb +18 -26
  93. data/test/unit/string/test_tabs.rb +226 -119
  94. data/test/unit/symbol/test_succ.rb +14 -23
  95. data/test/unit/symbol/test_to_proc.rb +41 -0
  96. data/test/unit/test_association.rb +38 -47
  97. data/test/unit/test_attributes.rb +24 -33
  98. data/test/unit/test_autoarray.rb +23 -32
  99. data/test/unit/test_command.rb +26 -0
  100. data/test/unit/test_dictionary.rb +123 -117
  101. data/test/unit/test_infinity.rb +41 -47
  102. data/test/unit/test_inheritor.rb +133 -142
  103. data/test/unit/test_interval.rb +129 -93
  104. data/test/unit/test_ostruct.rb +148 -101
  105. data/test/unit/test_overload.rb +8 -15
  106. data/test/unit/test_paramix.rb +67 -73
  107. data/test/unit/test_pp_s.rb +23 -0
  108. data/test/unit/test_prototype.rb +28 -38
  109. metadata +47 -11
  110. data/lib/core/facets/enumerable/instance_map.rb +0 -0
  111. data/lib/more/facets/command_options.rb +0 -328
  112. data/meta/version.txt +0 -1
  113. data/task/load +0 -39
  114. data/test/unit/test_command_options.rb +0 -29
@@ -0,0 +1,43 @@
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
+ # |_|\___||___/\__|
6
+ #
7
+ # for lib/facets/hash/select.rb
8
+
9
+ require 'facets/hash/select.rb'
10
+ require 'test/unit'
11
+
12
+ class TestHashSelect < Test::Unit::TestCase
13
+
14
+ def test_select!
15
+ # Empty hash.
16
+ a = {}
17
+ assert_equal(nil, a.select! {false}, "return nil if hash not changed")
18
+ assert_equal({}, a, "hash is not changed")
19
+
20
+ a = {}
21
+ assert_equal(nil, a.select! {true}, "return nil if hash not changed")
22
+ assert_equal({}, a, "hash is not changed")
23
+
24
+ # Non-empty hash.
25
+ a = {0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'}
26
+ assert_equal({0 => 'a', 2 => 'c'}, a.select! {|x,y| x % 2 == 0}, "select even numbers")
27
+ assert_equal({0 => 'a', 2 => 'c'}, a, "select even numbers")
28
+
29
+ a = {0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'}
30
+ assert_equal({1 => 'b'}, a.select! {|x,y| y == 'b'}, "select one member")
31
+ assert_equal({1 => 'b'}, a, "select one member")
32
+
33
+ a = {0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'}
34
+ assert_equal(nil, a.select! {true}, "return nil if hash not changed")
35
+ assert_equal({0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'}, a, "select all")
36
+
37
+ a = {0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'}
38
+ assert_equal({}, a.select! {false}, "select none")
39
+ assert_equal({}, a, "select none")
40
+ end
41
+
42
+ end
43
+
@@ -1,45 +1,41 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
5
- # |_|\___||___/\__|
6
- #
7
- # for lib/facets/integer/multiples.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
+ # |_|\___||___/\__|
12
6
 
13
- require 'facets/integer/multiples.rb'
7
+ require 'facets/integer/multiples.rb'
14
8
 
9
+ require 'test/unit'
15
10
 
11
+ class TCInteger < Test::Unit::TestCase
16
12
 
17
- require 'test/unit'
18
-
19
- class TCInteger < Test::Unit::TestCase
20
-
21
- def test_odd?
22
- assert( ! 0.odd? )
23
- assert( 1.odd? )
24
- assert( ! 2.odd? )
25
- assert( 3.odd? )
13
+ def test_even?
14
+ (-100..100).step(2) do |n|
15
+ assert(n.even? == true)
26
16
  end
27
-
28
- def test_even?
29
- assert( 0.even? )
30
- assert( ! 1.even? )
31
- assert( 2.even? )
32
- assert( ! 3.even? )
17
+ (-101..101).step(2) do |n|
18
+ assert(n.even? == false)
33
19
  end
20
+ end
34
21
 
35
- def test_multiple?
36
- assert( ! 1.multiple?(2) )
37
- assert( 2.multiple?(2) )
38
- assert( ! 5.multiple?(3) )
39
- assert( 6.multiple?(3) )
22
+ def test_odd?
23
+ (-101..101).step(2) do |n|
24
+ assert(n.odd? == true)
40
25
  end
26
+ (-100..100).step(2) do |n|
27
+ assert(n.odd? == false)
28
+ end
29
+ end
41
30
 
31
+ def test_multiple?
32
+ assert( ! 1.multiple?(2) )
33
+ assert( 2.multiple?(2) )
34
+ assert( ! 5.multiple?(3) )
35
+ assert( 6.multiple?(3) )
42
36
  end
43
37
 
38
+ end
39
+
44
40
 
45
41
 
@@ -1,18 +1,15 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
5
  # |_|\___||___/\__|
6
6
  #
7
- # for lib/facets/kernel/silence.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
7
+ # for facets/kernel/report.rb
12
8
 
13
9
  require 'facets/kernel/report.rb'
14
10
  require 'test/unit'
15
11
 
16
- class TestKernelError < Test::Unit::TestCase
17
- # TODO Must silence output to test these methods.
18
- end
12
+ # TODO Must silence output to test these methods.
13
+
14
+ #class TestKernelReport < Test::Unit::TestCase
15
+ #end
@@ -1,50 +1,55 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
5
- # |_|\___||___/\__|
6
- #
7
- # for lib/facets/kernel/val.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
12
-
13
- require 'facets/kernel/val.rb'
14
-
15
-
16
-
17
- require 'test/unit'
18
-
19
- class TestKernelVal < Test::Unit::TestCase
20
-
21
- def test_val_1
22
- f = nil
23
- t = 1
24
- assert( ! f.val? )
25
- assert( t.val? )
26
- end
27
-
28
- def test_val_2
29
- f = []
30
- t = [1]
31
- assert( ! f.val? )
32
- assert( t.val? )
33
- end
34
-
35
- def test_val_3
36
- f = ''
37
- t = '1'
38
- assert( ! f.val? )
39
- assert( t.val? )
40
- end
41
-
42
- def test_in?
43
- assert( 5.in?(0..10) )
44
- assert( 5.in?([1,2,3,4,5]) )
45
- end
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
+ # |_|\___||___/\__|
6
+ #
7
+ # for facets/kernel/val.rb
8
+
9
+ require 'facets/kernel/val.rb'
10
+ require 'test/unit'
11
+
12
+ class TestKernelVal < Test::Unit::TestCase
13
+
14
+ def test_val_1
15
+ f = nil
16
+ t = 1
17
+ assert( ! f.val? )
18
+ assert( t.val? )
19
+ end
20
+
21
+ def test_val_2
22
+ f = []
23
+ t = [1]
24
+ assert( ! f.val? )
25
+ assert( t.val? )
26
+ end
27
+
28
+ def test_val_3
29
+ f = ''
30
+ t = '1'
31
+ assert( ! f.val? )
32
+ assert( t.val? )
33
+ end
34
+
35
+ def test_in?
36
+ assert( 5.in?(0..10) )
37
+ assert( 5.in?([1,2,3,4,5]) )
38
+ end
46
39
 
40
+ def test_not_nil?
41
+ assert_equal(true, 5.not_nil?)
42
+ assert_equal(true, :x.not_nil?)
43
+ assert_equal(false, nil.not_nil?)
44
+ assert_equal(true, false.not_nil?)
47
45
  end
48
46
 
47
+ #def test_non_nil?
48
+ # assert_equal(true, 5.non_nil?)
49
+ # assert_equal(true, :x.non_nil?)
50
+ # assert_equal(false, nil.non_nil?)
51
+ # assert_equal(true, false.non_nil?)
52
+ #end
49
53
 
54
+ end
50
55
 
@@ -1,78 +1,77 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
5
- # |_|\___||___/\__|
6
- #
7
- # for lib/facets/module/include.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
+ # |_|\___||___/\__|
6
+ #
7
+ # for facets/module/include.rb
12
8
 
13
- require 'facets/module/include.rb'
9
+ require 'facets/module/include.rb'
10
+ require 'test/unit'
14
11
 
12
+ class TestInclude < Test::Unit::TestCase
15
13
 
14
+ def test_ancestor
15
+ assert( self.class.ancestor?(::Test::Unit::TestCase) )
16
+ end
16
17
 
17
- require 'test/unit'
18
-
19
- class TestIncludeAs < Test::Unit::TestCase
20
-
21
- module MockModule
22
- def x; "X"; end
23
- def y; @y; end
24
- end
18
+ end
25
19
 
26
- class MockObject
27
- include_as :mod => MockModule
20
+ class TestIncludeAs < Test::Unit::TestCase
28
21
 
29
- def initialize
30
- @y = "Y"
31
- end
32
- end
22
+ module MockModule
23
+ def x; "X"; end
24
+ def y; @y; end
25
+ end
33
26
 
34
- def test_01
35
- m = MockObject.new
36
- assert_equal( "X", m.mod.x )
37
- end
27
+ class MockObject
28
+ include_as :mod => MockModule
38
29
 
39
- def test_02
40
- m = MockObject.new
41
- assert_equal( "Y", m.mod.y )
30
+ def initialize
31
+ @y = "Y"
42
32
  end
33
+ end
43
34
 
35
+ def test_01
36
+ m = MockObject.new
37
+ assert_equal( "X", m.mod.x )
44
38
  end
45
39
 
46
- class TestOnInclude < Test::Unit::TestCase
40
+ def test_02
41
+ m = MockObject.new
42
+ assert_equal( "Y", m.mod.y )
43
+ end
47
44
 
48
- module M
49
- def self.check ; @@check ; end
50
- on_included %{
51
- @@check = 1
52
- }
53
- end
45
+ end
54
46
 
55
- module Q
56
- def self.check ; @@check ; end
57
- on_included %{
58
- @@check = 1
59
- }
60
- on_included %{
61
- @@check = 2
62
- }
63
- end
47
+ class TestOnInclude < Test::Unit::TestCase
64
48
 
65
- class C
66
- include M
67
- include Q
68
- end
49
+ module M
50
+ def self.check ; @@check ; end
51
+ on_included %{
52
+ @@check = 1
53
+ }
54
+ end
69
55
 
70
- def test_included
71
- assert_equal(1, M.check)
72
- assert_equal(2, Q.check)
73
- end
56
+ module Q
57
+ def self.check ; @@check ; end
58
+ on_included %{
59
+ @@check = 1
60
+ }
61
+ on_included %{
62
+ @@check = 2
63
+ }
64
+ end
74
65
 
66
+ class C
67
+ include M
68
+ include Q
75
69
  end
76
70
 
71
+ def test_included
72
+ assert_equal(1, M.check)
73
+ assert_equal(2, Q.check)
74
+ end
77
75
 
76
+ end
78
77
 
@@ -1,66 +1,53 @@
1
- # _____ _
2
- # |_ _|__ ___| |_
3
- # | |/ _ \/ __| __|
4
- # | | __/\__ \ |
5
- # |_|\___||___/\__|
6
- #
7
- # for lib/facets/module/name.rb
8
- #
9
- # Extracted Mon Sep 03 16:23:07 -0700 2007
10
- # w/ Test Extraction Ratchet
11
- #
12
-
13
- require 'facets/module/name.rb'
14
-
15
-
16
-
17
- require 'test/unit'
18
-
19
- class TestModuleName < Test::Unit::TestCase
20
-
21
- def test_ancestor
22
- assert( self.class.ancestor?(::Test::Unit::TestCase) )
23
- end
24
-
25
- def test_by_name
26
- c = ::Test::Unit::TestCase.name
27
- assert_equal( ::Test::Unit::TestCase, Module.by_name(c) )
28
- c = "Test::Unit::TestCase"
29
- assert_equal( ::Test::Unit::TestCase, Class.by_name(c) )
30
- end
1
+ # _____ _
2
+ # |_ _|__ ___| |_
3
+ # | |/ _ \/ __| __|
4
+ # | | __/\__ \ |
5
+ # |_|\___||___/\__|
6
+ #
7
+ # for facets/module/name.rb
8
+
9
+ require 'facets/module/name.rb'
10
+ require 'test/unit'
11
+
12
+ class TestModuleName < Test::Unit::TestCase
13
+
14
+ def test_by_name
15
+ c = ::Test::Unit::TestCase.name
16
+ assert_equal( ::Test::Unit::TestCase, Module.by_name(c) )
17
+ c = "Test::Unit::TestCase"
18
+ assert_equal( ::Test::Unit::TestCase, Class.by_name(c) )
19
+ end
31
20
 
32
- def test_basename
33
- assert_equal( "TestCase", ::Test::Unit::TestCase.basename )
34
- end
21
+ def test_basename
22
+ assert_equal( "TestCase", ::Test::Unit::TestCase.basename )
23
+ end
35
24
 
36
- def test_dirname
37
- assert_equal( 'Test::Unit', Test::Unit::TestCase.dirname )
38
- assert_equal( 'Test::Unit', ::Test::Unit::TestCase.dirname )
39
- assert_equal( '', Test.dirname )
40
- assert_equal( '', ::Test.dirname )
41
- end
25
+ def test_dirname
26
+ assert_equal( 'Test::Unit', Test::Unit::TestCase.dirname )
27
+ assert_equal( 'Test::Unit', ::Test::Unit::TestCase.dirname )
28
+ assert_equal( '', Test.dirname )
29
+ assert_equal( '', ::Test.dirname )
30
+ end
42
31
 
43
- def test_modspace
44
- assert_equal( Test::Unit, Test::Unit::TestCase.modspace )
45
- assert_equal( ::Test::Unit, ::Test::Unit::TestCase.modspace )
46
- assert_equal( Object, ::Test.modspace )
47
- end
32
+ def test_modspace
33
+ assert_equal( Test::Unit, Test::Unit::TestCase.modspace )
34
+ assert_equal( ::Test::Unit, ::Test::Unit::TestCase.modspace )
35
+ assert_equal( Object, ::Test.modspace )
36
+ end
48
37
 
49
- module M
50
- module N
51
- class C
52
- def n
53
- self.class.nesting
54
- end
38
+ module M
39
+ module N
40
+ class C
41
+ def n
42
+ self.class.nesting
55
43
  end
56
44
  end
57
45
  end
58
-
59
- def test_nesting
60
- assert_equal( [TestModuleName, M, M::N, M::N::C], M::N::C.new.n )
61
- end
62
-
63
46
  end
64
47
 
48
+ def test_nesting
49
+ assert_equal( [TestModuleName, M, M::N, M::N::C], M::N::C.new.n )
50
+ end
65
51
 
52
+ end
66
53