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
@@ -1,47 +1,31 @@
|
|
1
|
-
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
7
|
-
# for lib/facets/instantise.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# Test lib/facets/instantise.rb
|
12
2
|
|
13
|
-
|
3
|
+
require 'facets/instantise.rb'
|
4
|
+
require 'test/unit'
|
14
5
|
|
6
|
+
# fixture
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
module MyModule
|
22
|
-
extend Instantise
|
23
|
-
def self.jumble( obj, arg )
|
24
|
-
obj + arg
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class String
|
29
|
-
include MyModule
|
8
|
+
module MyModule
|
9
|
+
extend Instantise
|
10
|
+
def self.jumble( obj, arg )
|
11
|
+
obj + arg
|
30
12
|
end
|
13
|
+
end
|
31
14
|
|
32
|
-
|
33
|
-
|
34
|
-
|
15
|
+
class String
|
16
|
+
include MyModule
|
17
|
+
end
|
35
18
|
|
36
|
-
|
37
|
-
assert_equal( 'TryMe', MyModule.jumble( "Try", "Me" ) )
|
38
|
-
end
|
19
|
+
# test
|
39
20
|
|
40
|
-
|
41
|
-
assert_equal( 'TryMe', "Try".jumble( "Me" ) )
|
42
|
-
end
|
21
|
+
class TC_PromoteSelf < Test::Unit::TestCase
|
43
22
|
|
23
|
+
def test01
|
24
|
+
assert_equal( 'TryMe', MyModule.jumble( "Try", "Me" ) )
|
44
25
|
end
|
45
26
|
|
27
|
+
def test02
|
28
|
+
assert_equal( 'TryMe', "Try".jumble( "Me" ) )
|
29
|
+
end
|
46
30
|
|
47
|
-
|
31
|
+
end
|
data/test/unit/test_interface.rb
CHANGED
@@ -1,91 +1,84 @@
|
|
1
|
-
#
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |_
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
1
|
+
# Test facets/interface.rb
|
7
2
|
|
8
|
-
|
9
|
-
|
3
|
+
# get a hold of the original definition _before require_
|
4
|
+
$orginal_instance_methods = Module.instance_method( :instance_methods )
|
10
5
|
|
11
6
|
require 'facets/interface.rb'
|
7
|
+
require 'test/unit'
|
12
8
|
|
13
|
-
require 'test/unit'
|
14
9
|
|
10
|
+
class TestModuleInterface < Test::Unit::TestCase
|
15
11
|
|
16
|
-
|
12
|
+
# fixture
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def a ; end
|
22
|
-
end
|
23
|
-
|
24
|
-
def setup
|
25
|
-
@o = O.new
|
14
|
+
class O
|
15
|
+
def a ; end
|
16
|
+
end
|
26
17
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
18
|
+
def setup
|
19
|
+
@o = O.new
|
30
20
|
|
31
|
-
#
|
21
|
+
# get a hold of the original definition _before require_
|
22
|
+
@om = @o.method( :methods )
|
23
|
+
end
|
32
24
|
|
33
|
-
|
34
|
-
assert_equal( @om.call.sort, @o.interface.sort )
|
35
|
-
end
|
25
|
+
# interface
|
36
26
|
|
37
|
-
|
38
|
-
|
39
|
-
|
27
|
+
def test_interface
|
28
|
+
assert_equal( @om.call.sort, @o.interface.sort )
|
29
|
+
end
|
40
30
|
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
def test_public_interface
|
32
|
+
assert_equal( @o.public_methods.sort, @o.interface(:public).sort )
|
33
|
+
end
|
44
34
|
|
45
|
-
|
46
|
-
|
47
|
-
|
35
|
+
def test_private_interface
|
36
|
+
assert_equal( @o.private_methods.sort, @o.interface(:private).sort )
|
37
|
+
end
|
48
38
|
|
49
|
-
|
50
|
-
|
51
|
-
|
39
|
+
def test_protected_interface
|
40
|
+
assert_equal( @o.protected_methods.sort, @o.interface(:protected).sort )
|
41
|
+
end
|
52
42
|
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
def test_singleton_interface
|
44
|
+
assert_equal( @o.singleton_methods.sort, @o.interface(:singleton).sort )
|
45
|
+
end
|
56
46
|
|
57
|
-
|
47
|
+
def test_local_interface
|
48
|
+
assert_equal( ["a"], @o.interface(:local) )
|
49
|
+
end
|
58
50
|
|
59
|
-
|
60
|
-
m = $orginal_instance_methods #.dup
|
61
|
-
assert_equal( m.bind(O).call.sort, O.instance_interface.sort )
|
62
|
-
end
|
51
|
+
# instance_interface
|
63
52
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
53
|
+
def test_instance_interface
|
54
|
+
m = $orginal_instance_methods #.dup
|
55
|
+
assert_equal( m.bind(O).call.sort, O.instance_interface.sort )
|
56
|
+
end
|
68
57
|
|
69
|
-
|
70
|
-
|
71
|
-
|
58
|
+
def test_instance_interface_true
|
59
|
+
m = $orginal_instance_methods #.dup
|
60
|
+
assert_equal( m.bind(O).call(true).sort, O.instance_interface(true).sort )
|
61
|
+
end
|
72
62
|
|
73
|
-
|
74
|
-
|
75
|
-
|
63
|
+
def test_public_instance_interface
|
64
|
+
assert_equal( O.public_instance_methods.sort, O.instance_interface.sort )
|
65
|
+
end
|
76
66
|
|
77
|
-
|
78
|
-
|
79
|
-
|
67
|
+
def test_private_instance_interface
|
68
|
+
assert_equal( O.private_instance_methods.sort, O.instance_interface(:private).sort )
|
69
|
+
end
|
80
70
|
|
81
|
-
|
82
|
-
|
83
|
-
|
71
|
+
def test_protected_instance_interface
|
72
|
+
assert_equal( O.protected_instance_methods.sort, O.instance_interface(:protected).sort )
|
73
|
+
end
|
84
74
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
75
|
+
def test_local_instance_interface
|
76
|
+
assert_equal( ["a"], O.instance_interface(:local) )
|
77
|
+
end
|
89
78
|
|
79
|
+
def test_instance_interface_local_and_ancestors
|
80
|
+
m = $orginal_instance_methods #.dup
|
81
|
+
assert_equal( m.bind(O).call(true).sort, O.instance_interface(:local, :ancestors).sort )
|
90
82
|
end
|
91
83
|
|
84
|
+
end
|
data/test/unit/test_interval.rb
CHANGED
data/test/unit/test_let.rb
CHANGED
@@ -1,33 +1,19 @@
|
|
1
|
-
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
7
|
-
# for lib/facets/let.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# Test facets/let.rb
|
12
2
|
|
13
|
-
|
3
|
+
require 'facets/let.rb'
|
4
|
+
require 'test/unit'
|
14
5
|
|
6
|
+
class TCthis < Test::Unit::TestCase
|
15
7
|
|
8
|
+
class Foo
|
9
|
+
let.bar = 10
|
10
|
+
end
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
class Foo
|
22
|
-
let.bar = 10
|
23
|
-
end
|
24
|
-
|
25
|
-
def test01
|
26
|
-
x = Foo.new
|
27
|
-
assert_equal( 10, x.bar )
|
28
|
-
end
|
29
|
-
|
12
|
+
def test01
|
13
|
+
x = Foo.new
|
14
|
+
assert_equal( 10, x.bar )
|
30
15
|
end
|
31
16
|
|
17
|
+
end
|
32
18
|
|
33
19
|
|
@@ -1,55 +1,41 @@
|
|
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
|
-
assert_nothing_raised('Failed while deleting an element from the middle of the list.') { d = ll.delete('a') }
|
39
|
-
assert_equal('a',d, 'The prior delete returned the wrong value for the deleted object.')
|
40
|
-
assert_equal(3,ll.length, 'The length of the linked list appears to be incorrect following the prior deletion.')
|
41
|
-
assert_nothing_raised('Failed while popping an element from the end of the list.') { d = ll.pop }
|
42
|
-
assert_equal('b',d, 'The prior pop returned the wrong value.')
|
43
|
-
assert_equal(2,ll.length, 'The length of the linked list appears to be incorrect following the prior pop.')
|
44
|
-
assert_equal(['d','c'],ll.queue, 'The queue of keys for the list is incorrect.')
|
45
|
-
assert_equal(['d',3],ll.to_a, 'Converting the list to an array (of values) seems to have failed.')
|
46
|
-
expected = [['c',3],['d','d']]
|
47
|
-
ll.each do |k,v|
|
48
|
-
e = expected.pop
|
49
|
-
assert_equal(e,[k,v], 'While iterates over the list via each(), the value from this iteration is not what was expected.')
|
50
|
-
end
|
51
|
-
end
|
1
|
+
# Test lib/facets/linkedlist.rb
|
2
|
+
|
3
|
+
require 'facets/linkedlist.rb'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class TC_LinkedList < Test::Unit::TestCase
|
7
|
+
|
8
|
+
@cache #?
|
9
|
+
|
10
|
+
def test_all
|
11
|
+
ll = nil
|
12
|
+
assert_nothing_raised('Failed while creating an LinkedList object.') { ll = LinkedList.new }
|
13
|
+
assert_kind_of(LinkedList,ll,'Strangely, the created object does not appear to be an LinkedList.')
|
14
|
+
|
15
|
+
assert_nothing_raised('Failed while pushing a value onto the linked list.') { ll.push 'a' }
|
16
|
+
ll.push 'b'
|
17
|
+
assert_nothing_raised('Failed while assigning a key/value to the linked list.') { ll['c'] = 3 }
|
18
|
+
assert_equal(3,ll.first, 'First element in the linked list appears to be the wrong one.')
|
19
|
+
assert_equal('b',ll.last, 'Last element in the linked list appears to be the wrong one.')
|
20
|
+
assert_nothing_raised('Failed while unshifting a value onto the linked list.') { ll.unshift 'd' }
|
21
|
+
assert_equal('d',ll.first, 'The prior unshift apparently failed.')
|
22
|
+
assert_equal('a',ll['a'], 'Accessing an element by key failed.')
|
23
|
+
assert_equal(4,ll.length, 'The length of the linked list appears to be incorrect.')
|
24
|
+
d = nil
|
25
|
+
assert_nothing_raised('Failed while deleting an element from the middle of the list.') { d = ll.delete('a') }
|
26
|
+
assert_equal('a',d, 'The prior delete returned the wrong value for the deleted object.')
|
27
|
+
assert_equal(3,ll.length, 'The length of the linked list appears to be incorrect following the prior deletion.')
|
28
|
+
assert_nothing_raised('Failed while popping an element from the end of the list.') { d = ll.pop }
|
29
|
+
assert_equal('b',d, 'The prior pop returned the wrong value.')
|
30
|
+
assert_equal(2,ll.length, 'The length of the linked list appears to be incorrect following the prior pop.')
|
31
|
+
assert_equal(['d','c'],ll.queue, 'The queue of keys for the list is incorrect.')
|
32
|
+
assert_equal(['d',3],ll.to_a, 'Converting the list to an array (of values) seems to have failed.')
|
33
|
+
expected = [['c',3],['d','d']]
|
34
|
+
ll.each do |k,v|
|
35
|
+
e = expected.pop
|
36
|
+
assert_equal(e,[k,v], 'While iterates over the list via each(), the value from this iteration is not what was expected.')
|
37
|
+
end
|
52
38
|
end
|
53
39
|
|
54
|
-
|
40
|
+
end
|
55
41
|
|
data/test/unit/test_lrucache.rb
CHANGED
@@ -1,27 +1,11 @@
|
|
1
|
-
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
7
|
-
# for lib/facets/lrucache.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# Test lib/facets/lrucache.rb
|
12
2
|
|
13
|
-
|
3
|
+
require 'facets/lrucache.rb'
|
4
|
+
require 'test/unit'
|
14
5
|
|
6
|
+
class TC_LRUCache < Test::Unit::TestCase
|
15
7
|
|
16
|
-
|
17
|
-
require 'test/unit'
|
18
|
-
|
19
|
-
class TC_LRUCache < Test::Unit::TestCase
|
20
|
-
|
21
|
-
def test_01
|
22
|
-
end
|
23
|
-
|
8
|
+
def test_01
|
24
9
|
end
|
25
10
|
|
26
|
-
|
27
|
-
|
11
|
+
end
|
data/test/unit/test_mapsend.rb
CHANGED
@@ -1,34 +1,18 @@
|
|
1
|
-
|
2
|
-
# |_ _|__ ___| |_
|
3
|
-
# | |/ _ \/ __| __|
|
4
|
-
# | | __/\__ \ |
|
5
|
-
# |_|\___||___/\__|
|
6
|
-
#
|
7
|
-
# for lib/facets/mapsend.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:08 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# Test facets/mapsend.rb
|
12
2
|
|
13
|
-
|
3
|
+
require 'facets/mapsend.rb'
|
4
|
+
require 'test/unit'
|
14
5
|
|
6
|
+
class TestThreadedMapSend < Test::Unit::TestCase
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
class TestThreadedMapSend < Test::Unit::TestCase
|
20
|
-
|
21
|
-
def test_map_send
|
22
|
-
r = [1,2,3].map_send(:+, 1)
|
23
|
-
assert_equal(r, [2,3,4])
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_map_send_with_block
|
27
|
-
r = [1,2,3].map_send(:+,1){ |x| x + 1 }
|
28
|
-
assert_equal(r, [3,4,5])
|
29
|
-
end
|
30
|
-
|
8
|
+
def test_map_send
|
9
|
+
r = [1,2,3].map_send(:+, 1)
|
10
|
+
assert_equal(r, [2,3,4])
|
31
11
|
end
|
32
12
|
|
13
|
+
def test_map_send_with_block
|
14
|
+
r = [1,2,3].map_send(:+,1){ |x| x + 1 }
|
15
|
+
assert_equal(r, [3,4,5])
|
16
|
+
end
|
33
17
|
|
34
|
-
|
18
|
+
end
|