facets 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +3 -3
- data/README +6 -7
- data/lib/core/facets.rb +1 -46
- data/lib/core/facets/array.rb +3 -0
- data/lib/core/facets/array/indexable.rb +6 -1
- data/lib/core/facets/array/only.rb +20 -0
- data/lib/core/facets/dir/multiglob.rb +12 -1
- data/lib/core/facets/enumerable.rb +0 -1
- data/lib/core/facets/enumerable/collect.rb +1 -0
- data/lib/core/facets/enumerable/combination.rb +44 -90
- data/lib/core/facets/facets.rb +46 -0
- data/lib/core/facets/file/write.rb +46 -58
- data/lib/core/facets/hash.rb +2 -0
- data/lib/core/facets/hash/select.rb +14 -0
- data/lib/core/facets/integer/multiples.rb +12 -55
- data/lib/core/facets/kernel/val.rb +14 -0
- data/lib/core/facets/module/alias.rb +28 -9
- data/lib/core/facets/module/methods.rb +18 -0
- data/lib/core/facets/module/traits.rb +65 -70
- data/lib/core/facets/proc/compose.rb +15 -12
- data/lib/core/facets/stackable.rb +3 -2
- data/lib/core/facets/string/format.rb +4 -6
- data/lib/core/facets/string/tabs.rb +34 -0
- data/lib/core/facets/symbol.rb +1 -0
- data/lib/core/facets/symbol/succ.rb +1 -42
- data/lib/core/facets/symbol/to_proc.rb +34 -0
- data/lib/methods/facets/array/contains.rb +1 -0
- data/lib/methods/facets/facets/require_core.rb +1 -0
- data/lib/methods/facets/file/writelines.rb +1 -0
- data/lib/methods/facets/io/writelines.rb +1 -0
- data/lib/methods/facets/kernel/not_nil.rb +1 -0
- data/lib/methods/facets/module/conflict.rb +1 -0
- data/lib/methods/facets/module/instance_method_defined.rb +1 -0
- data/lib/methods/facets/module/module_method_defined.rb +1 -0
- data/lib/methods/facets/module/private_conflict.rb +1 -0
- data/lib/methods/facets/module/protected_conflict.rb +1 -0
- data/lib/methods/facets/module/public_conflict.rb +1 -0
- data/lib/methods/facets/string/expand_tabs.rb +1 -0
- data/lib/methods/facets/string/outdent.rb +1 -0
- data/lib/methods/facets/string/taballto.rb +1 -0
- data/lib/more/facets/arguments.rb +1 -1
- data/lib/more/facets/association.rb +0 -46
- data/lib/more/facets/autoarray.rb +0 -28
- data/lib/more/facets/command.rb +341 -8
- data/lib/more/facets/dictionary.rb +25 -131
- data/lib/more/facets/downloader.rb +1 -1
- data/lib/more/facets/infinity.rb +3 -3
- data/lib/more/facets/interval.rb +0 -161
- data/lib/more/facets/multiton.rb +16 -12
- data/lib/more/facets/namespace.rb +1 -1
- data/lib/more/facets/ostruct.rb +46 -10
- data/lib/more/facets/overload.rb +0 -51
- data/lib/more/facets/paramix.rb +0 -97
- data/lib/more/facets/pp_s.rb +30 -0
- data/lib/more/facets/progressbar.rb +18 -10
- data/lib/more/facets/prototype.rb +1 -40
- data/lib/more/facets/random.rb +1 -0
- data/lib/more/facets/rbsystem.rb +4 -1
- data/lib/more/facets/snapshot.rb +8 -1
- data/lib/more/facets/stylize.rb +2 -0
- data/meta/{project.yaml → facets-2.0.3.roll} +22 -14
- data/meta/manifest.txt +38 -8
- data/task/{config.yaml → config/general.yaml} +7 -2
- data/task/{rdoc.yaml → config/rdoc.yaml} +1 -1
- data/task/crosstest +309 -0
- data/task/isotest +293 -0
- data/task/loadtest +28 -0
- data/task/methods +4 -4
- data/task/prepare +5 -0
- data/task/publish +2 -2
- data/task/rdoc +1 -0
- data/task/syntax +29 -0
- data/task/test +0 -1
- data/task/testeach +42 -0
- data/task/testpairs +50 -0
- data/test/lib/rq.rb +15 -0
- data/test/unit/array/test_merge.rb +21 -43
- data/test/unit/array/test_only.rb +21 -0
- data/test/unit/enumerable/test_collect.rb +1 -21
- data/test/unit/enumerable/test_combination.rb +50 -44
- data/test/unit/file/test_topath.rb +48 -57
- data/test/unit/file/test_write.rb +82 -0
- data/test/unit/hash/test_select.rb +43 -0
- data/test/unit/integer/test_multiples.rb +28 -32
- data/test/unit/kernel/test_report.rb +9 -12
- data/test/unit/kernel/test_val.rb +50 -45
- data/test/unit/module/test_include.rb +56 -57
- data/test/unit/module/test_name.rb +42 -55
- data/test/unit/module/test_traits.rb +46 -47
- data/test/unit/string/test_filter.rb +19 -34
- data/test/unit/string/test_format.rb +87 -96
- data/test/unit/string/test_regesc.rb +18 -26
- data/test/unit/string/test_tabs.rb +226 -119
- data/test/unit/symbol/test_succ.rb +14 -23
- data/test/unit/symbol/test_to_proc.rb +41 -0
- data/test/unit/test_association.rb +38 -47
- data/test/unit/test_attributes.rb +24 -33
- data/test/unit/test_autoarray.rb +23 -32
- data/test/unit/test_command.rb +26 -0
- data/test/unit/test_dictionary.rb +123 -117
- data/test/unit/test_infinity.rb +41 -47
- data/test/unit/test_inheritor.rb +133 -142
- data/test/unit/test_interval.rb +129 -93
- data/test/unit/test_ostruct.rb +148 -101
- data/test/unit/test_overload.rb +8 -15
- data/test/unit/test_paramix.rb +67 -73
- data/test/unit/test_pp_s.rb +23 -0
- data/test/unit/test_prototype.rb +28 -38
- metadata +47 -11
- data/lib/core/facets/enumerable/instance_map.rb +0 -0
- data/lib/more/facets/command_options.rb +0 -328
- data/meta/version.txt +0 -1
- data/task/load +0 -39
- 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
|
-
|
7
|
+
require 'facets/integer/multiples.rb'
|
14
8
|
|
9
|
+
require 'test/unit'
|
15
10
|
|
11
|
+
class TCInteger < Test::Unit::TestCase
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
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
|
-
|
36
|
-
|
37
|
-
assert(
|
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
|
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
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
27
|
-
include_as :mod => MockModule
|
20
|
+
class TestIncludeAs < Test::Unit::TestCase
|
28
21
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
module MockModule
|
23
|
+
def x; "X"; end
|
24
|
+
def y; @y; end
|
25
|
+
end
|
33
26
|
|
34
|
-
|
35
|
-
|
36
|
-
assert_equal( "X", m.mod.x )
|
37
|
-
end
|
27
|
+
class MockObject
|
28
|
+
include_as :mod => MockModule
|
38
29
|
|
39
|
-
def
|
40
|
-
|
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
|
-
|
40
|
+
def test_02
|
41
|
+
m = MockObject.new
|
42
|
+
assert_equal( "Y", m.mod.y )
|
43
|
+
end
|
47
44
|
|
48
|
-
|
49
|
-
def self.check ; @@check ; end
|
50
|
-
on_included %{
|
51
|
-
@@check = 1
|
52
|
-
}
|
53
|
-
end
|
45
|
+
end
|
54
46
|
|
55
|
-
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
49
|
+
module M
|
50
|
+
def self.check ; @@check ; end
|
51
|
+
on_included %{
|
52
|
+
@@check = 1
|
53
|
+
}
|
54
|
+
end
|
69
55
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
21
|
+
def test_basename
|
22
|
+
assert_equal( "TestCase", ::Test::Unit::TestCase.basename )
|
23
|
+
end
|
35
24
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
|