facets 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/core/facets.rb +1 -1
- data/lib/core/facets/conversion.rb +6 -1
- data/lib/core/facets/enumerable/collate.rb +13 -24
- data/lib/core/facets/{main.rb → facets.rb} +0 -0
- data/lib/methods/facets/facets/require_core.rb +1 -1
- data/lib/more/facets/advice.rb +28 -1
- data/lib/more/facets/aop.rb +2 -9
- data/log/history.rd +5 -0
- data/meta/MANIFEST +2 -4
- data/meta/{rollrc → ROLLRC} +1 -1
- data/task/release +1 -3
- data/task/test/general +2 -2
- data/task/test/loadtest +1 -1
- data/test/unit/enumerable/test_collate.rb +46 -50
- data/test/unit/test_advice.rb +2 -0
- data/test/unit/test_annotations.rb +2 -0
- data/test/unit/test_arguments.rb +45 -61
- data/test/unit/test_association.rb +1 -7
- data/test/unit/test_attributes.rb +1 -7
- data/test/unit/test_autoarray.rb +1 -8
- data/test/unit/test_basicobject.rb +40 -56
- data/test/unit/test_bbcode.rb +14 -30
- data/test/unit/test_binreadable.rb +35 -51
- data/test/unit/test_boolean.rb +64 -80
- data/test/unit/test_buildable.rb +26 -41
- data/test/unit/test_buildingblock.rb +24 -39
- data/test/unit/test_bytes.rb +50 -66
- data/test/unit/test_class_extension.rb +43 -59
- data/test/unit/test_classmethods.rb +42 -58
- data/test/unit/test_compare_on.rb +40 -54
- data/test/unit/test_conversion.rb +143 -159
- data/test/unit/test_coroutine.rb +31 -47
- data/test/unit/test_crypt.rb +2 -11
- data/test/unit/test_curry.rb +19 -35
- data/test/unit/test_cut.rb +14 -30
- data/test/unit/test_date.rb +31 -47
- data/test/unit/test_dependency.rb +49 -64
- data/test/unit/test_dictionary.rb +1 -7
- data/test/unit/test_elementor.rb +45 -61
- data/test/unit/test_enumerablepass.rb +57 -73
- data/test/unit/test_functor.rb +21 -34
- data/test/unit/test_getoptlong.rb +17 -33
- data/test/unit/test_infinity.rb +1 -7
- data/test/unit/test_inheritor.rb +1 -7
- data/test/unit/test_instantiable.rb +14 -30
- data/test/unit/test_instantise.rb +20 -36
- data/test/unit/test_interface.rb +58 -65
- data/test/unit/test_interval.rb +1 -7
- data/test/unit/test_let.rb +11 -25
- data/test/unit/test_linkedlist.rb +38 -52
- data/test/unit/test_lrucache.rb +6 -22
- data/test/unit/test_mapsend.rb +12 -28
- data/test/unit/test_memoize.rb +17 -32
- data/test/unit/test_multipliers.rb +72 -87
- data/test/unit/test_namespace.rb +35 -51
- data/test/unit/test_opencascade.rb +47 -63
- data/test/unit/test_openobject.rb +94 -110
- data/test/unit/test_ostruct.rb +1 -7
- data/test/unit/test_overload.rb +1 -6
- data/test/unit/test_paramix.rb +1 -7
- data/test/unit/test_pp_s.rb +1 -7
- data/test/unit/test_prototype.rb +1 -6
- data/test/unit/test_recorder.rb +22 -37
- data/test/unit/test_snapshot.rb +2 -14
- data/test/unit/test_stylize.rb +113 -127
- data/test/unit/test_syncarray.rb +2 -15
- data/test/unit/test_synchash.rb +16 -28
- data/test/unit/test_timer.rb +2 -14
- data/test/unit/test_times.rb +64 -80
- data/test/unit/test_tuple.rb +40 -56
- data/test/unit/test_typecast.rb +29 -40
- data/test/unit/test_uninheritable.rb +30 -42
- metadata +4 -8
- data/test/lib/rq.rb +0 -15
data/test/unit/test_coroutine.rb
CHANGED
@@ -1,62 +1,46 @@
|
|
1
|
-
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
7
|
-
# for lib/facets/coroutine.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# Test facets/coroutine.rb
|
12
2
|
|
13
|
-
|
3
|
+
require 'facets/coroutine.rb'
|
4
|
+
require 'test/unit'
|
14
5
|
|
6
|
+
class TC_Coroutine < Test::Unit::TestCase
|
15
7
|
|
8
|
+
def test_run
|
9
|
+
assert_nothing_raised {
|
16
10
|
|
17
|
-
|
11
|
+
count = 100
|
12
|
+
input = (1..count).map { (rand * 10000).round.to_f / 100 }
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
count = 100
|
25
|
-
input = (1..count).map { (rand * 10000).round.to_f / 100 }
|
26
|
-
|
27
|
-
@producer = Coroutine.new do |me|
|
28
|
-
loop do
|
29
|
-
1.upto(6) do
|
30
|
-
me[:last_input] = input.shift
|
31
|
-
me.resume(@printer)
|
32
|
-
end
|
33
|
-
input.shift # discard every seventh input number
|
14
|
+
@producer = Coroutine.new do |me|
|
15
|
+
loop do
|
16
|
+
1.upto(6) do
|
17
|
+
me[:last_input] = input.shift
|
18
|
+
me.resume(@printer)
|
34
19
|
end
|
20
|
+
input.shift # discard every seventh input number
|
35
21
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
me.resume(@controller)
|
22
|
+
end
|
23
|
+
|
24
|
+
@printer = Coroutine.new do |me|
|
25
|
+
loop do
|
26
|
+
1.upto(8) do
|
27
|
+
me.resume(@producer)
|
28
|
+
if @producer[:last_input]
|
29
|
+
@producer[:last_input] = nil
|
45
30
|
end
|
31
|
+
me.resume(@controller)
|
46
32
|
end
|
47
33
|
end
|
34
|
+
end
|
48
35
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
36
|
+
@controller = Coroutine.new do |me|
|
37
|
+
until input.empty? do
|
38
|
+
me.resume(@printer)
|
53
39
|
end
|
54
|
-
|
55
|
-
|
56
|
-
}
|
57
|
-
end
|
40
|
+
end
|
41
|
+
@controller.run
|
58
42
|
|
43
|
+
}
|
59
44
|
end
|
60
45
|
|
61
|
-
|
62
|
-
|
46
|
+
end
|
data/test/unit/test_crypt.rb
CHANGED
@@ -1,13 +1,6 @@
|
|
1
|
-
#
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
7
|
-
# for facets/crypt.rb
|
8
|
-
|
9
|
-
require 'facets/crypt.rb'
|
1
|
+
# Test facets/crypt.rb
|
10
2
|
|
3
|
+
require "facets/crypt.rb"
|
11
4
|
require "test/unit"
|
12
5
|
|
13
6
|
class CryptTest < Test::Unit::TestCase
|
@@ -37,5 +30,3 @@ class CryptTest < Test::Unit::TestCase
|
|
37
30
|
end
|
38
31
|
|
39
32
|
end
|
40
|
-
|
41
|
-
|
data/test/unit/test_curry.rb
CHANGED
@@ -1,43 +1,27 @@
|
|
1
|
-
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
7
|
-
# for lib/facets/curry.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# Test lib/facets/curry.rb
|
12
2
|
|
13
|
-
|
3
|
+
require 'facets/curry.rb'
|
4
|
+
require 'test/unit'
|
14
5
|
|
6
|
+
class TestCurry < Test::Unit::TestCase
|
15
7
|
|
8
|
+
def setup
|
9
|
+
@p = Proc.new{ |a,b,c| a + b + c }
|
10
|
+
end
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def setup
|
22
|
-
@p = Proc.new{ |a,b,c| a + b + c }
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_first
|
26
|
-
n = @p.curry(__,2,3)
|
27
|
-
assert_equal( 6, n[1] )
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_second
|
31
|
-
n = @p.curry(1,__,3)
|
32
|
-
assert_equal( 6, n[2] )
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_third
|
36
|
-
n = @p.curry(1,2,__)
|
37
|
-
assert_equal( 6, n[3] )
|
38
|
-
end
|
39
|
-
|
12
|
+
def test_first
|
13
|
+
n = @p.curry(__,2,3)
|
14
|
+
assert_equal( 6, n[1] )
|
40
15
|
end
|
41
16
|
|
17
|
+
def test_second
|
18
|
+
n = @p.curry(1,__,3)
|
19
|
+
assert_equal( 6, n[2] )
|
20
|
+
end
|
42
21
|
|
22
|
+
def test_third
|
23
|
+
n = @p.curry(1,2,__)
|
24
|
+
assert_equal( 6, n[3] )
|
25
|
+
end
|
43
26
|
|
27
|
+
end
|
data/test/unit/test_cut.rb
CHANGED
@@ -1,37 +1,21 @@
|
|
1
|
-
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
7
|
-
# for lib/facets/cut.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# Test facets/cut.rb
|
12
2
|
|
13
|
-
|
3
|
+
require 'facets/cut.rb'
|
4
|
+
require 'test/unit'
|
14
5
|
|
6
|
+
class TestCut < Test::Unit::TestCase
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
class TestCut < Test::Unit::TestCase
|
20
|
-
|
21
|
-
class X
|
22
|
-
def x; "x"; end
|
23
|
-
end
|
24
|
-
|
25
|
-
Xc = Cut.new(X) do
|
26
|
-
def x; '{' + super + '}'; end
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_method_is_wrapped_by_advice
|
30
|
-
o = X.new
|
31
|
-
assert_equal("{x}", o.x)
|
32
|
-
end
|
33
|
-
|
8
|
+
class X
|
9
|
+
def x; "x"; end
|
34
10
|
end
|
35
11
|
|
12
|
+
Xc = Cut.new(X) do
|
13
|
+
def x; '{' + super + '}'; end
|
14
|
+
end
|
36
15
|
|
16
|
+
def test_method_is_wrapped_by_advice
|
17
|
+
o = X.new
|
18
|
+
assert_equal("{x}", o.x)
|
19
|
+
end
|
37
20
|
|
21
|
+
end
|
data/test/unit/test_date.rb
CHANGED
@@ -1,61 +1,45 @@
|
|
1
|
-
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
7
|
-
# for lib/facets/date.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# Test facets/date.rb
|
12
2
|
|
13
|
-
|
3
|
+
require 'facets/date.rb'
|
4
|
+
require 'test/unit'
|
14
5
|
|
6
|
+
class TC_Date < Test::Unit::TestCase
|
15
7
|
|
8
|
+
def setup
|
9
|
+
@d = Date.civil( 2005, 04, 20 )
|
10
|
+
end
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def setup
|
22
|
-
@d = Date.civil( 2005, 04, 20 )
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_to_date
|
26
|
-
assert_instance_of( ::Date, @d.to_date )
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_to_time
|
30
|
-
assert_instance_of( ::Time, @d.to_time )
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_to_s
|
34
|
-
assert_equal( "2005-04-20", @d.to_s )
|
35
|
-
end
|
36
|
-
|
12
|
+
def test_to_date
|
13
|
+
assert_instance_of( ::Date, @d.to_date )
|
14
|
+
end
|
37
15
|
|
38
|
-
|
39
|
-
|
40
|
-
|
16
|
+
def test_to_time
|
17
|
+
assert_instance_of( ::Time, @d.to_time )
|
18
|
+
end
|
41
19
|
|
42
|
-
|
43
|
-
|
44
|
-
|
20
|
+
def test_to_s
|
21
|
+
assert_equal( "2005-04-20", @d.to_s )
|
22
|
+
end
|
45
23
|
|
46
|
-
def test_stamp_3
|
47
|
-
assert_equal( "April 20, 2005", @d.stamp(:long) )
|
48
|
-
end
|
49
24
|
|
50
|
-
|
51
|
-
|
52
|
-
|
25
|
+
def test_stamp_1
|
26
|
+
assert_equal( "2005-04-20", @d.stamp )
|
27
|
+
end
|
53
28
|
|
54
|
-
|
55
|
-
|
56
|
-
|
29
|
+
def test_stamp_2
|
30
|
+
assert_equal( "20 Apr", @d.stamp(:short) )
|
31
|
+
end
|
57
32
|
|
33
|
+
def test_stamp_3
|
34
|
+
assert_equal( "April 20, 2005", @d.stamp(:long) )
|
58
35
|
end
|
59
36
|
|
37
|
+
def test_days_in_month
|
38
|
+
assert_equal( 31, Date.new(2004,1,1).days_in_month )
|
39
|
+
end
|
60
40
|
|
41
|
+
def test_days_of_month
|
42
|
+
assert_equal( (1..@d.days_in_month).to_a, @d.days_of_month )
|
43
|
+
end
|
61
44
|
|
45
|
+
end
|
@@ -1,84 +1,69 @@
|
|
1
|
-
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
7
|
-
# for lib/facets/dependency.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# Test lib/facets/dependency.rb
|
12
2
|
|
13
|
-
|
3
|
+
require 'facets/dependency.rb'
|
14
4
|
|
5
|
+
require 'test/unit'
|
15
6
|
|
7
|
+
class DependableTest1 < Test::Unit::TestCase
|
16
8
|
|
17
|
-
|
9
|
+
class C
|
10
|
+
#extend MethodDependency
|
18
11
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
#extend MethodDependency
|
23
|
-
|
24
|
-
attr :s
|
25
|
-
def initialize
|
26
|
-
@s = ''
|
27
|
-
end
|
28
|
-
|
29
|
-
def x ; @s << 'x'; end
|
30
|
-
def y ; @s << 'y'; end
|
31
|
-
def z ; @s << 'z'; end
|
32
|
-
|
33
|
-
depend :x => :y
|
34
|
-
depend :z => [:x, :y]
|
12
|
+
attr :s
|
13
|
+
def initialize
|
14
|
+
@s = ''
|
35
15
|
end
|
36
16
|
|
37
|
-
|
38
|
-
|
17
|
+
def x ; @s << 'x'; end
|
18
|
+
def y ; @s << 'y'; end
|
19
|
+
def z ; @s << 'z'; end
|
39
20
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
def x ; @s << 'x'; end
|
46
|
-
def y ; @s << 'y'; end
|
47
|
-
def z ; @s << 'z'; end
|
21
|
+
depend :x => :y
|
22
|
+
depend :z => [:x, :y]
|
23
|
+
end
|
48
24
|
|
49
|
-
|
50
|
-
|
51
|
-
end
|
25
|
+
module M
|
26
|
+
#extend MethodDependency
|
52
27
|
|
53
|
-
|
54
|
-
|
28
|
+
attr :s
|
29
|
+
def initialize
|
30
|
+
@s = ''
|
55
31
|
end
|
56
32
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
60
|
-
assert_equal( 'yx', c.s )
|
61
|
-
end
|
33
|
+
def x ; @s << 'x'; end
|
34
|
+
def y ; @s << 'y'; end
|
35
|
+
def z ; @s << 'z'; end
|
62
36
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
assert_equal( 'yxz', c.s )
|
67
|
-
end
|
37
|
+
depend :x => :y
|
38
|
+
depend :z => [:x, :y]
|
39
|
+
end
|
68
40
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
assert_equal( 'yx', c.s )
|
73
|
-
end
|
41
|
+
class D
|
42
|
+
include M
|
43
|
+
end
|
74
44
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
45
|
+
def test_01
|
46
|
+
c = C.new
|
47
|
+
c.x
|
48
|
+
assert_equal( 'yx', c.s )
|
49
|
+
end
|
80
50
|
|
51
|
+
def test_02
|
52
|
+
c = C.new
|
53
|
+
c.z
|
54
|
+
assert_equal( 'yxz', c.s )
|
81
55
|
end
|
82
56
|
|
57
|
+
def test_03
|
58
|
+
c = D.new
|
59
|
+
c.x
|
60
|
+
assert_equal( 'yx', c.s )
|
61
|
+
end
|
83
62
|
|
63
|
+
def test_04
|
64
|
+
c = D.new
|
65
|
+
c.z
|
66
|
+
assert_equal( 'yxz', c.s )
|
67
|
+
end
|
84
68
|
|
69
|
+
end
|