facets 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +331 -35
- data/MANIFEST +685 -826
- data/{doc/guide/notes.rd → NOTES} +0 -0
- data/README.rdoc +73 -25
- data/Rakefile +245 -2
- data/TODO +5 -0
- data/demo/hook.rd +47 -0
- data/demo/scenario_require.rd +9 -0
- data/doc/README.more +24 -6
- data/doc/manual/about.rb +47 -0
- data/doc/manual/annotations.rdoc +60 -0
- data/doc/manual/associations.rdoc +55 -0
- data/doc/manual/blockups.rdoc +101 -0
- data/doc/manual/capsule.rdoc +34 -0
- data/doc/manual/command.rdoc +177 -0
- data/doc/manual/core.rdoc +37 -0
- data/doc/manual/faq.rdoc +32 -0
- data/doc/manual/typecast.html +112 -0
- data/lib/core/facets.rb +359 -11
- data/lib/core/facets/array/combination.rb +3 -3
- data/lib/core/facets/array/index.rb +4 -1
- data/lib/core/facets/array/permutation.rb +2 -2
- data/lib/core/facets/array/product.rb +1 -1
- data/lib/core/facets/binding/eval.rb +1 -1
- data/lib/core/facets/denumerable.rb +76 -0
- data/lib/core/facets/duplicable.rb +34 -0
- data/lib/core/facets/enumerable/count.rb +10 -4
- data/lib/core/facets/enumerable/defer.rb +77 -0
- data/lib/core/facets/enumerable/each_by.rb +1 -1
- data/lib/core/facets/enumerable/every.rb +35 -0
- data/lib/{more/facets/elementwise.rb → core/facets/enumerable/ewise.rb} +0 -0
- data/lib/core/facets/enumerable/filter.rb +25 -0
- data/lib/core/facets/enumerable/group_by.rb +1 -1
- data/lib/core/facets/enumerable/none.rb +3 -2
- data/lib/core/facets/enumerable/one.rb +3 -2
- data/lib/core/facets/enumerable/per.rb +61 -0
- data/lib/core/facets/exception/raised.rb +14 -0
- data/lib/core/facets/integer/odd.rb +5 -1
- data/lib/core/facets/kernel/__dir__.rb +13 -3
- data/lib/core/facets/kernel/__here__.rb +14 -0
- data/lib/core/facets/kernel/__method__.rb +9 -3
- data/lib/core/facets/kernel/ask.rb +1 -0
- data/lib/core/facets/kernel/equate.rb +13 -0
- data/lib/core/facets/kernel/extension.rb +9 -0
- data/lib/core/facets/kernel/identical.rb +4 -0
- data/lib/core/facets/kernel/instance_exec.rb +2 -1
- data/lib/core/facets/kernel/method.rb +49 -0
- data/lib/core/facets/kernel/object_send.rb +2 -2
- data/lib/core/facets/kernel/{state.rb → object_state.rb} +23 -12
- data/lib/core/facets/kernel/require_all.rb +6 -1
- data/lib/core/facets/kernel/require_local.rb +8 -1
- data/lib/core/facets/kernel/require_relative.rb +52 -0
- data/lib/core/facets/kernel/source_location.rb +13 -0
- data/lib/core/facets/kernel/tap.rb +13 -6
- data/lib/core/facets/module/attr_setter.rb +57 -0
- data/lib/core/facets/module/instance_method.rb +24 -0
- data/lib/core/facets/module/module_load.rb +60 -44
- data/lib/core/facets/module/module_require.rb +1 -0
- data/lib/core/facets/nilclass/to_f.rb +1 -1
- data/lib/core/facets/objectspace/op_fetch.rb +3 -0
- data/lib/core/facets/proc/curry.rb +4 -3
- data/lib/core/facets/string/bytes.rb +10 -4
- data/lib/core/facets/string/camelcase.rb +6 -5
- data/lib/core/facets/string/chars.rb +5 -1
- data/lib/core/facets/string/each_char.rb +1 -1
- data/lib/core/facets/string/each_word.rb +1 -1
- data/lib/core/facets/string/lines.rb +11 -4
- data/lib/core/facets/string/start_with.rb +9 -2
- data/lib/core/facets/string/unfold.rb +27 -0
- data/lib/core/facets/symbol/succ.rb +3 -3
- data/lib/core/facets/symbol/thrown.rb +20 -0
- data/lib/core/facets/symbol/to_proc.rb +3 -2
- data/lib/core/facets/time/to_time.rb +1 -1
- data/lib/core/facets/to_hash.rb +41 -100
- data/lib/core/facets/unboundmethod/name.rb +20 -23
- data/lib/more/facets/ansicode.rb +1 -10
- data/lib/more/facets/autoarray.rb +3 -31
- data/lib/more/facets/basicobject.rb +73 -0
- data/lib/more/facets/blankslate.rb +2 -66
- data/lib/{lore → more}/facets/cgi.rb +0 -0
- data/lib/more/facets/class_extend.rb +1 -0
- data/lib/{lore → more}/facets/continuation.rb +0 -0
- data/lib/{lore → more}/facets/date.rb +3 -3
- data/lib/more/facets/enumargs.rb +192 -0
- data/lib/more/facets/enumerablepass.rb +2 -216
- data/lib/more/facets/enumerator.rb +62 -0
- data/lib/more/facets/{equatable.rb → equitable.rb} +11 -11
- data/lib/more/facets/expirable.rb +13 -41
- data/lib/{lore → more}/facets/fileutils.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/head.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/safe_ln.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/slice.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/tail.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/wc.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/whereis.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/which.rb +0 -0
- data/lib/{lore → more}/facets/getoptlong.rb +0 -0
- data/lib/more/facets/hook.rb +2 -29
- data/lib/more/facets/inheritor.rb +2 -2
- data/lib/more/facets/instance_eval.rb +50 -0
- data/lib/more/facets/instance_function.rb +78 -0
- data/lib/more/facets/main.rb +20 -15
- data/lib/more/facets/memoize.rb +1 -113
- data/lib/more/facets/module/attr.rb +83 -0
- data/lib/more/facets/module/attr_tester.rb +44 -0
- data/lib/more/facets/module/attr_toggler.rb +59 -0
- data/lib/more/facets/module/attr_validator.rb +34 -0
- data/lib/more/facets/{class_extension.rb → module/class_extend.rb} +21 -13
- data/lib/more/facets/once.rb +59 -0
- data/lib/more/facets/openmodule.rb +1 -0
- data/lib/more/facets/orderedhash.rb +1 -33
- data/lib/{lore → more}/facets/ostruct.rb +0 -0
- data/lib/more/facets/ostructable.rb +1 -4
- data/lib/more/facets/partial.rb +18 -16
- data/lib/{lore → more}/facets/pathname.rb +0 -0
- data/lib/more/facets/preinitialize.rb +157 -0
- data/lib/{lore → more}/facets/rbconfig.rb +0 -0
- data/lib/more/facets/recorder.rb +1 -2
- data/lib/{lore → more}/facets/set.rb +0 -0
- data/lib/{lore → more}/facets/shellwords.rb +0 -0
- data/lib/{lore → more}/facets/uri.rb +0 -0
- data/lib/{lore → more}/facets/yaml.rb +0 -0
- data/lib/{lore → more}/facets/zlib.rb +0 -0
- data/meta/loadpath +0 -1
- data/meta/sitemap +4 -0
- data/meta/version +1 -1
- data/test/core/enumerable/test_count.rb +1 -1
- data/test/{more/test_filter.rb → core/enumerable/test_defer.rb} +24 -22
- data/test/{more/test_elementor.rb → core/enumerable/test_every.rb} +2 -15
- data/test/core/enumerable/test_ewise.rb +23 -0
- data/test/core/enumerable/test_per.rb +18 -0
- data/test/core/enumerable/test_take.rb +13 -0
- data/test/core/kernel/test_deepcopy.rb +1 -1
- data/test/{more/test_1stclassmethod.rb → core/kernel/test_method.rb} +2 -7
- data/test/core/kernel/test_tap.rb +1 -1
- data/test/core/proc/test_curry.rb +11 -0
- data/test/core/string/test_bytes.rb +1 -1
- data/test/core/string/test_camelcase.rb +23 -6
- data/test/core/string/test_lines.rb +1 -1
- data/test/core/string/test_unfold.rb +14 -0
- data/test/{more → core}/test_blank.rb +0 -0
- data/test/{more → core}/test_boolean.rb +0 -0
- data/test/{more → core}/test_functor.rb +0 -0
- data/test/{lore → more}/test_basicobject.rb +0 -0
- data/test/more/{test_class_extension.rb → test_class_extend.rb} +6 -6
- data/test/{lore → more}/test_continuation.rb +0 -0
- data/test/{lore → more}/test_date.rb +0 -0
- data/test/more/{test_enumerablepass.rb → test_enumargs.rb} +2 -4
- data/test/more/{test_equatable.rb → test_equitable.rb} +2 -2
- data/test/more/{test_instantise.rb → test_instance_function.rb} +3 -2
- data/test/more/test_memoize.rb +1 -1
- data/test/{lore → more}/test_ostruct.rb +0 -0
- metadata +865 -1016
- data/RELEASE +0 -38
- data/doc/README.lore +0 -51
- data/doc/log/basic_stats/index.html +0 -39
- data/doc/log/changelog.html +0 -648
- data/doc/log/changelog.txt +0 -217
- data/doc/log/stats/index.html +0 -39
- data/doc/log/testlog.txt +0 -278
- data/doc/notes/CHANGES +0 -2529
- data/doc/rdoc/lore/classes/Array.html +0 -176
- data/doc/rdoc/lore/classes/CGI.html +0 -191
- data/doc/rdoc/lore/classes/Config.html +0 -135
- data/doc/rdoc/lore/classes/Continuation.html +0 -113
- data/doc/rdoc/lore/classes/Date.html +0 -631
- data/doc/rdoc/lore/classes/DateTime.html +0 -583
- data/doc/rdoc/lore/classes/Enumerable.html +0 -89
- data/doc/rdoc/lore/classes/Enumerable/Enumerator.html +0 -147
- data/doc/rdoc/lore/classes/File.html +0 -128
- data/doc/rdoc/lore/classes/FileUtils.html +0 -434
- data/doc/rdoc/lore/classes/GetoptLong.html +0 -118
- data/doc/rdoc/lore/classes/GetoptLong/DSL.html +0 -208
- data/doc/rdoc/lore/classes/Kernel.html +0 -135
- data/doc/rdoc/lore/classes/Logger.html +0 -229
- data/doc/rdoc/lore/classes/Logger/Ansicolor.html +0 -277
- data/doc/rdoc/lore/classes/Logger/LogDevice.html +0 -121
- data/doc/rdoc/lore/classes/NilClass.html +0 -119
- data/doc/rdoc/lore/classes/OpenStruct.html +0 -432
- data/doc/rdoc/lore/classes/Pathname.html +0 -353
- data/doc/rdoc/lore/classes/Set.html +0 -117
- data/doc/rdoc/lore/classes/Shellwords.html +0 -111
- data/doc/rdoc/lore/classes/String.html +0 -140
- data/doc/rdoc/lore/classes/Time.html +0 -154
- data/doc/rdoc/lore/classes/URI.html +0 -454
- data/doc/rdoc/lore/classes/URI/Hash.html +0 -105
- data/doc/rdoc/lore/classes/URI/Kernel.html +0 -122
- data/doc/rdoc/lore/classes/Zlib.html +0 -188
- data/doc/rdoc/lore/created.rid +0 -1
- data/doc/rdoc/lore/files/README.html +0 -286
- data/doc/rdoc/lore/files/doc/README_lore.html +0 -155
- data/doc/rdoc/lore/files/lib/lore/facets/basicobject_rb.html +0 -118
- data/doc/rdoc/lore/files/lib/lore/facets/cgi_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/continuation_rb.html +0 -147
- data/doc/rdoc/lore/files/lib/lore/facets/date_rb.html +0 -97
- data/doc/rdoc/lore/files/lib/lore/facets/enumerator_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/head_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/safe_ln_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/slice_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/tail_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/wc_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/whereis_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/which_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils_rb.html +0 -131
- data/doc/rdoc/lore/files/lib/lore/facets/getoptlong_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/logger_rb.html +0 -142
- data/doc/rdoc/lore/files/lib/lore/facets/ostruct_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/pathname_rb.html +0 -145
- data/doc/rdoc/lore/files/lib/lore/facets/rbconfig_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/set_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/shellwords_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/uri_rb.html +0 -125
- data/doc/rdoc/lore/files/lib/lore/facets/yaml_rb.html +0 -146
- data/doc/rdoc/lore/files/lib/lore/facets/zlib_rb.html +0 -97
- data/doc/rdoc/lore/fr_class_index.html +0 -73
- data/doc/rdoc/lore/fr_file_index.html +0 -71
- data/doc/rdoc/lore/fr_method_index.html +0 -177
- data/doc/rdoc/lore/index.html +0 -26
- data/doc/rdoc/lore/rdoc-style.css +0 -177
- data/doc/release-notes/RELEASE-2.0.5 +0 -8
- data/doc/release-notes/RELEASE-2.1.0 +0 -9
- data/doc/release-notes/RELEASE-2.1.1 +0 -5
- data/doc/release-notes/RELEASE-2.1.2 +0 -6
- data/doc/release-notes/RELEASE-2.1.3 +0 -5
- data/doc/release-notes/RELEASE-2.2.0 +0 -14
- data/doc/release-notes/RELEASE-2.2.1 +0 -4
- data/doc/release-notes/RELEASE-2.3.0 +0 -6
- data/doc/release-notes/RELEASE-2.4.0 +0 -70
- data/doc/release-notes/RELEASE-2.4.1 +0 -8
- data/doc/release-notes/RELEASE-2.4.2 +0 -4
- data/doc/release-notes/RELEASE-2.4.3 +0 -78
- data/doc/release-notes/RELEASE-2.4.4 +0 -38
- data/doc/release-notes/RELEASE-2.4.5 +0 -37
- data/doc/release-notes/RELEASE-2.5.0 +0 -83
- data/lib/core/facets/kernel/instance.rb +0 -19
- data/lib/lore/facets/basicobject.rb +0 -14
- data/lib/lore/facets/enumerator.rb +0 -67
- data/lib/lore/facets/logger.rb +0 -291
- data/lib/more/facets/1stclassmethod.rb +0 -140
- data/lib/more/facets/advisable.rb +0 -162
- data/lib/more/facets/association.rb +0 -210
- data/lib/more/facets/attr.rb +0 -209
- data/lib/more/facets/basex.rb +0 -37
- data/lib/more/facets/bbcode.rb +0 -397
- data/lib/more/facets/bicrypt.rb +0 -265
- data/lib/more/facets/binreadable.rb +0 -221
- data/lib/more/facets/censor.rb +0 -97
- data/lib/more/facets/classmethods.rb +0 -199
- data/lib/more/facets/consoleutils.rb +0 -99
- data/lib/more/facets/crypt.rb +0 -166
- data/lib/more/facets/dependency.rb +0 -151
- data/lib/more/facets/downloader.rb +0 -281
- data/lib/more/facets/duplicable.rb +0 -43
- data/lib/more/facets/elementor.rb +0 -133
- data/lib/more/facets/filter.rb +0 -121
- data/lib/more/facets/heap.rb +0 -22
- data/lib/more/facets/infinity.rb +0 -193
- data/lib/more/facets/ini.rb +0 -264
- data/lib/more/facets/instantise.rb +0 -1
- data/lib/more/facets/instantize.rb +0 -95
- data/lib/more/facets/interval.rb +0 -282
- data/lib/more/facets/iteration.rb +0 -65
- data/lib/more/facets/linkedlist.rb +0 -222
- data/lib/more/facets/lrucache.rb +0 -157
- data/lib/more/facets/matcher.rb +0 -140
- data/lib/more/facets/memoizer.rb +0 -74
- data/lib/more/facets/minitar.rb +0 -1063
- data/lib/more/facets/nackclass.rb +0 -41
- data/lib/more/facets/net/smtp_tls.rb +0 -131
- data/lib/more/facets/nilstatus.rb +0 -48
- data/lib/more/facets/overload.rb +0 -94
- data/lib/more/facets/paramix.rb +0 -202
- data/lib/more/facets/pool.rb +0 -91
- data/lib/more/facets/pqueue.rb +0 -449
- data/lib/more/facets/pry.rb +0 -32
- data/lib/more/facets/reflection.rb +0 -145
- data/lib/more/facets/semaphore.rb +0 -92
- data/lib/more/facets/settings.rb +0 -248
- data/lib/more/facets/snapshot.rb +0 -209
- data/lib/more/facets/sparse_array.rb +0 -809
- data/lib/more/facets/string/mask.rb +0 -278
- data/lib/more/facets/string/obfuscate.rb +0 -65
- data/lib/more/facets/string/stylize.rb +0 -169
- data/lib/more/facets/string/words.rb +0 -167
- data/lib/more/facets/syncarray.rb +0 -114
- data/lib/more/facets/synchash.rb +0 -157
- data/lib/more/facets/typecast.rb +0 -261
- data/lib/more/facets/uninheritable.rb +0 -50
- data/lib/more/facets/xmlhash.rb +0 -112
- data/lib/more/facets/xoxo.rb +0 -259
- data/lib/more/facets/ziputils.rb +0 -490
- data/task/conflicts +0 -63
- data/task/coverage.rake +0 -37
- data/task/methods +0 -49
- data/task/rdoc.rake +0 -17
- data/task/setup.rake +0 -38
- data/task/test.rake +0 -145
- data/test/more/test_advisable.rb +0 -71
- data/test/more/test_association.rb +0 -38
- data/test/more/test_bbcode.rb +0 -21
- data/test/more/test_binreadable.rb +0 -50
- data/test/more/test_buildable.rb +0 -73
- data/test/more/test_classmethods.rb +0 -56
- data/test/more/test_crypt.rb +0 -32
- data/test/more/test_dependency.rb +0 -69
- data/test/more/test_elementwise.rb +0 -25
- data/test/more/test_infinity.rb +0 -40
- data/test/more/test_interval.rb +0 -151
- data/test/more/test_linkedlist.rb +0 -41
- data/test/more/test_lrucache.rb +0 -14
- data/test/more/test_overload.rb +0 -160
- data/test/more/test_paramix.rb +0 -170
- data/test/more/test_prototype.rb +0 -35
- data/test/more/test_snapshot.rb +0 -21
- data/test/more/test_sparsearray.rb +0 -279
- data/test/more/test_syncarray.rb +0 -15
- data/test/more/test_synchash.rb +0 -16
- data/test/more/test_typecast.rb +0 -54
- data/test/more/test_uninheritable.rb +0 -31
- data/test/more/test_xoxo.rb +0 -274
- data/test/test_facets.rb +0 -9
@@ -1,41 +0,0 @@
|
|
1
|
-
# Test 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
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
data/test/more/test_lrucache.rb
DELETED
data/test/more/test_overload.rb
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
# Test facets/overload.rb
|
2
|
-
require 'facets/overload.rb'
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
#
|
6
|
-
#
|
7
|
-
class TC_Overload_01 < Test::Unit::TestCase
|
8
|
-
|
9
|
-
class X
|
10
|
-
|
11
|
-
def x
|
12
|
-
"hello"
|
13
|
-
end
|
14
|
-
|
15
|
-
overload :x, Array do |x|
|
16
|
-
[Array, x]
|
17
|
-
end
|
18
|
-
|
19
|
-
overload :x, Symbol do |x|
|
20
|
-
[Symbol, x]
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def setup
|
26
|
-
@x = X.new
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_x
|
30
|
-
assert_equal( "hello", @x.x )
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_a
|
34
|
-
assert_equal( [Array, [1]], @x.x([1]) )
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_s
|
38
|
-
assert_equal( [Symbol, :a], @x.x(:a) )
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
#
|
45
|
-
class TC_Overload_02 < Test::Unit::TestCase
|
46
|
-
|
47
|
-
class X
|
48
|
-
|
49
|
-
def x
|
50
|
-
"hello"
|
51
|
-
end
|
52
|
-
|
53
|
-
overload :x, Integer do |i|
|
54
|
-
i
|
55
|
-
end
|
56
|
-
|
57
|
-
overload :x, String, String do |s1, s2|
|
58
|
-
[s1, s2]
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
def setup
|
64
|
-
@x = X.new
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_x
|
68
|
-
assert_equal( "hello", @x.x )
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_i
|
72
|
-
assert_equal( 1, @x.x(1) )
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_s
|
76
|
-
assert_equal( ["a","b"], @x.x("a","b") )
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
#
|
82
|
-
#
|
83
|
-
class TC_Overload_03 < Test::Unit::TestCase
|
84
|
-
|
85
|
-
class SubArray < Array
|
86
|
-
end
|
87
|
-
|
88
|
-
class SubSubArray < SubArray
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
class X
|
93
|
-
|
94
|
-
def x
|
95
|
-
"hello"
|
96
|
-
end
|
97
|
-
|
98
|
-
overload :x, Integer do |i|
|
99
|
-
i
|
100
|
-
end
|
101
|
-
|
102
|
-
overload :x, Symbol do |s|
|
103
|
-
s
|
104
|
-
end
|
105
|
-
|
106
|
-
overload :x, String, String do |s1, s2|
|
107
|
-
[s1, s2]
|
108
|
-
end
|
109
|
-
|
110
|
-
overload :x, Symbol, String do |s1, s2|
|
111
|
-
[s1, s2]
|
112
|
-
end
|
113
|
-
|
114
|
-
overload :x, Array do |a|
|
115
|
-
"array"
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
def setup
|
121
|
-
@x = X.new
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_x
|
125
|
-
assert_equal( "hello", @x.x )
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_i
|
129
|
-
assert_equal( 1, @x.x(1) )
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_strings
|
133
|
-
assert_equal( ["a","b"], @x.x("a","b") )
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_symbol_string
|
137
|
-
assert_equal( [:a,"b"], @x.x(:a,"b") )
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_sym
|
141
|
-
assert_equal( :sym, @x.x(:sym) )
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_subarray
|
145
|
-
assert_equal("array", @x.x([]))
|
146
|
-
assert_equal("array", @x.x(SubArray.new))
|
147
|
-
assert_equal("array", @x.x(SubSubArray.new))
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_raise
|
151
|
-
assert_raise ArgumentError do
|
152
|
-
X.module_eval do
|
153
|
-
overload :x, 42 do end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
|
160
|
-
|
data/test/more/test_paramix.rb
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
require 'facets/paramix.rb'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class TC_Paramix_01 < Test::Unit::TestCase
|
5
|
-
|
6
|
-
module M
|
7
|
-
include Paramix
|
8
|
-
|
9
|
-
def f
|
10
|
-
mixin_params[M][:p]
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.included(base)
|
14
|
-
params = base.mixin_params[self]
|
15
|
-
base.class_eval do
|
16
|
-
define_method :check do
|
17
|
-
params
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class C
|
24
|
-
include M[:p => "check"]
|
25
|
-
end
|
26
|
-
|
27
|
-
class D
|
28
|
-
include M[:p => "steak"]
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_01_001
|
32
|
-
c = C.new
|
33
|
-
assert_equal( "check", c.mixin_params[M][:p] )
|
34
|
-
assert_equal( "check", c.f )
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_01_002
|
38
|
-
d = D.new
|
39
|
-
assert_equal( "steak", d.mixin_params[M][:p] )
|
40
|
-
assert_equal( "steak", d.f )
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_01_003
|
44
|
-
assert_equal( {M=>{:p => "check"}}, C.mixin_parameters )
|
45
|
-
assert_equal( {M=>{:p => "steak"}}, D.mixin_parameters )
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_01_004
|
49
|
-
c = C.new
|
50
|
-
assert_equal( {:p => "check"}, c.check )
|
51
|
-
d = D.new
|
52
|
-
assert_equal( {:p => "steak"}, d.check )
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
class TC_Paramix_02 < Test::Unit::TestCase
|
58
|
-
|
59
|
-
module M
|
60
|
-
# Manually define Paramix method.
|
61
|
-
def self.[](parameters)
|
62
|
-
Paramix.new(self, parameters) do
|
63
|
-
define_method :check do
|
64
|
-
mixin_params[M] # or parameters
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def f
|
70
|
-
mixin_params[M][:p]
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class C
|
75
|
-
include M[:p => "check"]
|
76
|
-
end
|
77
|
-
|
78
|
-
class D
|
79
|
-
include M[:p => "steak"]
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_02_001
|
83
|
-
c = C.new
|
84
|
-
assert_equal( "check", c.mixin_params[M][:p] )
|
85
|
-
assert_equal( "check", c.f )
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_02_002
|
89
|
-
d = D.new
|
90
|
-
assert_equal( "steak", d.mixin_params[M][:p] )
|
91
|
-
assert_equal( "steak", d.f )
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_02_003
|
95
|
-
assert_equal( {M=>{:p => "check"}}, C.mixin_parameters )
|
96
|
-
assert_equal( {M=>{:p => "steak"}}, D.mixin_parameters )
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_02_004
|
100
|
-
c = C.new
|
101
|
-
assert_equal( {:p => "check"}, c.check )
|
102
|
-
d = D.new
|
103
|
-
assert_equal( {:p => "steak"}, d.check )
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
class TC_Paramix_03 < Test::Unit::TestCase
|
109
|
-
|
110
|
-
module M
|
111
|
-
include Paramix
|
112
|
-
|
113
|
-
def f
|
114
|
-
mixin_params[M][:p]
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
class C
|
119
|
-
extend M[:p => "mosh"]
|
120
|
-
end
|
121
|
-
|
122
|
-
class D
|
123
|
-
extend M[:p => "many"]
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_03_001
|
127
|
-
assert_equal( "mosh", C.f )
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_03_002
|
131
|
-
assert_equal( "many", D.f )
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_03_003
|
135
|
-
assert_equal( {M=>{:p => "mosh"}}, (class << C; self; end).mixin_parameters )
|
136
|
-
assert_equal( {M=>{:p => "many"}}, (class << D; self; end).mixin_parameters )
|
137
|
-
end
|
138
|
-
|
139
|
-
end
|
140
|
-
|
141
|
-
|
142
|
-
class TC_Paramix_04 < Test::Unit::TestCase
|
143
|
-
|
144
|
-
module O
|
145
|
-
def self.[](parameters)
|
146
|
-
Paramix.new(self, parameters) do
|
147
|
-
attr_accessor mixin_parameters[O][:name]
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
class X
|
153
|
-
include O[:name=>"x"]
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_attribute
|
157
|
-
o = X.new
|
158
|
-
assert_nothing_raised{ o.x = 10 }
|
159
|
-
assert_equal(10, o.x)
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_ancestors
|
163
|
-
assert(X.ancestors.include?(X))
|
164
|
-
assert(X.ancestors.include?(O))
|
165
|
-
assert(X.ancestors.include?(Object))
|
166
|
-
assert(X.ancestors.include?(Kernel))
|
167
|
-
end
|
168
|
-
|
169
|
-
end
|
170
|
-
|
data/test/more/test_prototype.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Test facets/prototype.rb
|
2
|
-
|
3
|
-
require 'facets/prototype.rb'
|
4
|
-
|
5
|
-
require 'test/unit'
|
6
|
-
|
7
|
-
class TestPrototypeKernel < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def test_new
|
10
|
-
q = nil
|
11
|
-
s = "Testing"
|
12
|
-
assert_nothing_raised { q = s.new }
|
13
|
-
assert_equal( s, q )
|
14
|
-
assert_not_equal( s.object_id, q.object_id )
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class TestPrototype < Test::Unit::TestCase
|
19
|
-
|
20
|
-
def setup
|
21
|
-
@person = prototype do
|
22
|
-
@name = ''
|
23
|
-
@age = 0
|
24
|
-
@announce = fn { |x| "#{x}, #{name} is #{age}" }
|
25
|
-
end
|
26
|
-
|
27
|
-
@person.name = 'Tom'
|
28
|
-
@person.age = 35
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_simple_case
|
32
|
-
assert_equal( "Peter, Tom is 35", @person.announce['Peter'])
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
data/test/more/test_snapshot.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# Test lib/facets/snapshot.rb
|
2
|
-
|
3
|
-
require 'facets/snapshot.rb'
|
4
|
-
require 'test/unit'
|
5
|
-
|
6
|
-
class TC_Snapshot < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
customer = Struct.new(:name, :address, :zip)
|
10
|
-
joe = customer.new( "Joe Pitare", "1115 Lila Ln.", 47634 )
|
11
|
-
@joe_snap = joe.take_snapshot
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_storage
|
15
|
-
assert_equal( "Joe Pitare", @joe_snap[:name] )
|
16
|
-
assert_equal( "1115 Lila Ln.", @joe_snap[:address] )
|
17
|
-
assert_equal( 47634, @joe_snap[:zip] )
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
@@ -1,279 +0,0 @@
|
|
1
|
-
# This is a mostly complete testcase for SparseArray.
|
2
|
-
# SparseArray is tested by comparison to standard Array.
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'facets/sparse_array'
|
6
|
-
|
7
|
-
class TC_SparseArray < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def aha(a)
|
10
|
-
return a, SparseArray[*a]
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_conversions
|
14
|
-
a, ha = aha [1,3,'a',8,nil,[1]]
|
15
|
-
assert_equal(ha, ha.to_ary) # these need to be opposite
|
16
|
-
assert_equal(a, ha.to_a) #
|
17
|
-
assert_equal(a.to_s, ha.to_s)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_set_operations
|
21
|
-
a, ha = aha [1,3,5,8,9]
|
22
|
-
b, hb = aha [2,3,6,8,9]
|
23
|
-
assert_equal(a | b, (ha | hb).to_a)
|
24
|
-
assert_equal(a & b, (ha & hb).to_a)
|
25
|
-
assert_equal(a + b, (ha + hb).to_a)
|
26
|
-
assert_equal(a - b, (ha - hb).to_a)
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_multiple
|
30
|
-
a, ha = aha [1,3]
|
31
|
-
assert_equal(a*3,(ha*3).to_a)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_assign
|
35
|
-
a, ha = aha [1,2,3,4]
|
36
|
-
a[1..2] = [8,9]
|
37
|
-
ha[1..2] = [8,9]
|
38
|
-
assert_equal(a, ha.to_a)
|
39
|
-
end
|
40
|
-
def test_assoc
|
41
|
-
a, ha = aha [[1,2],[3,4],[3,6]]
|
42
|
-
assert_equal(a.assoc(3), ha.assoc(3).to_a)
|
43
|
-
end
|
44
|
-
def test_at
|
45
|
-
a, ha = aha [4,5,6,6]
|
46
|
-
assert_equal(a.at(0), ha.at(0))
|
47
|
-
assert_equal(a.at(2), ha.at(2))
|
48
|
-
assert_equal(a.at(4), ha.at(4))
|
49
|
-
assert_equal(a.at(9), ha.at(9))
|
50
|
-
assert_equal(a.at(-1), ha.at(-1))
|
51
|
-
assert_equal(a.at(-3), ha.at(-3))
|
52
|
-
assert_equal(a.at(-4), ha.at(-4))
|
53
|
-
assert_equal(a.at(-5), ha.at(-5))
|
54
|
-
end
|
55
|
-
def test_collect
|
56
|
-
a, ha = aha [4,5,6,6]
|
57
|
-
assert_equal(a.collect{|e|e}, ha.collect{|e|e}.to_a)
|
58
|
-
assert_equal(a.collect!{|e|e}, ha.collect!{|e|e}.to_a)
|
59
|
-
assert_equal(a,ha.to_a)
|
60
|
-
end
|
61
|
-
def test_compact
|
62
|
-
a, ha = aha [4,nil,5,nil,6]
|
63
|
-
assert_equal(a.compact, ha.compact.to_a)
|
64
|
-
end
|
65
|
-
def test_concat
|
66
|
-
a, ha = aha [1,3,5,8,9]
|
67
|
-
b, hb = aha [2,3,6,8,9]
|
68
|
-
assert_equal(a.concat(b),ha.concat(hb).to_a)
|
69
|
-
end
|
70
|
-
def test_count
|
71
|
-
ha = SparseArray[9,3,9,5,nil,nil,9,3]
|
72
|
-
assert_equal(2,ha.count)
|
73
|
-
assert_equal(2,ha.count(3))
|
74
|
-
assert_equal(3,ha.count{|e|e==9})
|
75
|
-
end
|
76
|
-
def test_delete
|
77
|
-
a, ha = aha [1,3,5,8,9,'a','b','c','c','d']
|
78
|
-
# test delete
|
79
|
-
assert_equal(a.delete(1),ha.delete(1))
|
80
|
-
assert_equal(a,ha.to_a)
|
81
|
-
assert_equal(a.delete('a'),ha.delete('a'))
|
82
|
-
assert_equal(a,ha.to_a)
|
83
|
-
# test delete_at
|
84
|
-
assert_equal(a.delete_at(0),ha.delete_at(0))
|
85
|
-
assert_equal(a,ha.to_a)
|
86
|
-
# test delete_if
|
87
|
-
assert_equal(a.delete_if{|v|v=='c'},ha.delete_if{|v|v=='c'}.to_a)
|
88
|
-
assert_equal(a,ha.to_a)
|
89
|
-
end
|
90
|
-
def test_each
|
91
|
-
a, ha = aha [4,'a',nil,'b']
|
92
|
-
# test each
|
93
|
-
ca, cha = '', ''
|
94
|
-
a.each{|e| ca += e.to_s}
|
95
|
-
ha.each{|e| cha += e.to_s}
|
96
|
-
assert_equal(ca,cha)
|
97
|
-
assert_equal(a,ha.to_a)
|
98
|
-
# test each_index
|
99
|
-
ca, cha = '', ''
|
100
|
-
a.each_index{|i| ca += i.to_s}
|
101
|
-
ha.each_index{|i| cha += i.to_s}
|
102
|
-
assert_equal(ca,cha)
|
103
|
-
assert_equal(a,ha.to_a)
|
104
|
-
end
|
105
|
-
def test_eql?
|
106
|
-
a, ha = aha [4,'a',nil,'b']
|
107
|
-
b, hb = aha [4,'a',nil,'b']
|
108
|
-
assert_equal(a,b)
|
109
|
-
assert_equal(ha,hb)
|
110
|
-
assert_equal(a.eql?(b),ha.eql?(hb))
|
111
|
-
assert_equal(b.eql?(a),hb.eql?(ha))
|
112
|
-
assert(ha.eql?(hb))
|
113
|
-
assert(hb.eql?(ha))
|
114
|
-
end
|
115
|
-
def test_empty?
|
116
|
-
a, ha = aha []
|
117
|
-
assert_equal(a.empty?,ha.empty?)
|
118
|
-
a, ha = aha [1,2,3]
|
119
|
-
assert_equal(a.empty?,ha.empty?)
|
120
|
-
end
|
121
|
-
def test_fill
|
122
|
-
a, ha = aha ['a','b','c','d']
|
123
|
-
assert_equal(a.fill('x'),ha.fill('x').to_a)
|
124
|
-
assert_equal(a,ha.to_a)
|
125
|
-
assert_equal(a.fill('y',2,2),ha.fill('y',2,2).to_a)
|
126
|
-
assert_equal(a,ha.to_a)
|
127
|
-
assert_equal(a.fill('z',0..1),ha.fill('z',0..1).to_a)
|
128
|
-
assert_equal(a,ha.to_a)
|
129
|
-
end
|
130
|
-
def test_first
|
131
|
-
a, ha = aha [2,3,4]
|
132
|
-
assert_equal(a.first,ha.first)
|
133
|
-
end
|
134
|
-
def test_flatten
|
135
|
-
a, ha = aha [2,[3],'a',[[1,2],4],nil,5]
|
136
|
-
assert_equal(a.flatten,ha.flatten.to_a)
|
137
|
-
a, ha = aha [2,[3],'a',[[1,2],4],nil,5]
|
138
|
-
assert_equal(a.flatten!,ha.flatten!.to_a)
|
139
|
-
assert_equal(a,ha.to_a)
|
140
|
-
a, ha = aha [2,3,'a',nil,5]
|
141
|
-
assert_equal(a.flatten!,ha.flatten!)
|
142
|
-
end
|
143
|
-
def test_include?
|
144
|
-
a, ha = aha ['a','b','c','d']
|
145
|
-
assert_equal(a.include?('b'),ha.include?('b'))
|
146
|
-
assert_equal(a.include?('x'),ha.include?('x'))
|
147
|
-
end
|
148
|
-
def test_index
|
149
|
-
a, ha = aha ['a','b','b','c','d']
|
150
|
-
assert_equal(a.index('b'),ha.index('b'))
|
151
|
-
assert_equal(a.index('x'),ha.index('x'))
|
152
|
-
end
|
153
|
-
def test_join
|
154
|
-
a, ha = aha [2,3,4]
|
155
|
-
assert_equal(a.join,ha.join)
|
156
|
-
assert_equal(a.join(','),ha.join(','))
|
157
|
-
end
|
158
|
-
def test_last
|
159
|
-
a, ha = aha [2,3,4]
|
160
|
-
assert_equal(a.last,ha.last)
|
161
|
-
end
|
162
|
-
def test_length
|
163
|
-
a, ha = aha [2,3,4]
|
164
|
-
assert_equal(a.length,ha.length)
|
165
|
-
end
|
166
|
-
def test_map!
|
167
|
-
a, ha = aha [4,5,6,6]
|
168
|
-
assert_equal(a.map!{|e|e}, ha.map!{|e|e}.to_a)
|
169
|
-
assert_equal(a,ha.to_a)
|
170
|
-
end
|
171
|
-
def test_nitems
|
172
|
-
a, ha = aha [4,5,nil,6,nil]
|
173
|
-
assert_equal(a.nitems, ha.nitems)
|
174
|
-
end
|
175
|
-
def test_pop
|
176
|
-
a, ha = aha [4,5,nil,6,nil]
|
177
|
-
assert_equal(a.pop, ha.pop)
|
178
|
-
assert_equal(a, ha.to_a)
|
179
|
-
assert_equal(a.pop, ha.pop)
|
180
|
-
assert_equal(a, ha.to_a)
|
181
|
-
end
|
182
|
-
def test_push
|
183
|
-
a, ha = aha [4,5,nil,6,nil]
|
184
|
-
args = [1,2,3]
|
185
|
-
assert_equal(a.push(*args), ha.push(*args).to_a)
|
186
|
-
assert_equal(a, ha.to_a)
|
187
|
-
end
|
188
|
-
def test_rassoc
|
189
|
-
a, ha = aha [[1,2],[1,3],[1,3]]
|
190
|
-
assert_equal(a.rassoc(3), ha.rassoc(3).to_a)
|
191
|
-
end
|
192
|
-
def test_reject!
|
193
|
-
a, ha = aha ['a','b','c','c','d']
|
194
|
-
assert_equal(a.reject!{|v|v=='c'},ha.reject!{|v|v=='c'}.to_a)
|
195
|
-
assert_equal(a,ha.to_a)
|
196
|
-
assert_equal(a.reject!{|v|v=='x'},ha.reject!{|v|v=='x'})
|
197
|
-
assert_equal(a,ha.to_a)
|
198
|
-
end
|
199
|
-
def test_reverse
|
200
|
-
a, ha = aha ['a','b','c','c','d']
|
201
|
-
assert_equal(a.reverse,ha.reverse.to_a)
|
202
|
-
assert_equal(a.reverse!,ha.reverse!.to_a)
|
203
|
-
assert_equal(a,ha.to_a)
|
204
|
-
a, ha = aha [1,2,3,'a','b','c']
|
205
|
-
assert_equal(a.reverse!,ha.reverse!.to_a)
|
206
|
-
assert_equal(a,ha.to_a)
|
207
|
-
end
|
208
|
-
def test_reverse_each
|
209
|
-
a, ha = aha [4,'a',nil,'b']
|
210
|
-
# test each
|
211
|
-
ca, cha = '', ''
|
212
|
-
a.reverse_each{|e| ca += e.to_s}
|
213
|
-
ha.reverse_each{|e| cha += e.to_s}
|
214
|
-
assert_equal(ca,cha)
|
215
|
-
assert_equal(a,ha.to_a)
|
216
|
-
end
|
217
|
-
def test_rindex
|
218
|
-
a, ha = aha ['a','b','c','c','d']
|
219
|
-
assert_equal(a.rindex('c'),ha.rindex('c'))
|
220
|
-
assert_equal(a.rindex('x'),ha.rindex('x'))
|
221
|
-
end
|
222
|
-
def test_shift
|
223
|
-
a, ha = aha ['a','b','c','c','d']
|
224
|
-
assert_equal(a.shift,ha.shift)
|
225
|
-
assert_equal(a,ha.to_a)
|
226
|
-
end
|
227
|
-
|
228
|
-
def test_slice
|
229
|
-
a, ha = aha [1,2,3,4]
|
230
|
-
# test []
|
231
|
-
assert_equal(a[1], ha[1])
|
232
|
-
assert_equal(a[1..2], ha[1..2].to_a)
|
233
|
-
assert_equal(a[1...2], ha[1...2].to_a)
|
234
|
-
assert_equal(a[1..7], ha[1..7].to_a)
|
235
|
-
assert_equal(a[1,2], ha[1,2].to_a)
|
236
|
-
# test slice
|
237
|
-
assert_equal(a.slice(1), ha.slice(1))
|
238
|
-
assert_equal(a.slice(1..2), ha.slice(1..2).to_a)
|
239
|
-
assert_equal(a.slice(1...2), ha.slice(1...2).to_a)
|
240
|
-
assert_equal(a.slice(1...2), ha.slice(1...2).to_a)
|
241
|
-
assert_equal(a.slice(1,2), ha.slice(1,2).to_a)
|
242
|
-
# test slice!
|
243
|
-
assert_equal(a.slice!(1..2), ha.slice!(1..2).to_a)
|
244
|
-
assert_equal(a, ha.to_a)
|
245
|
-
end
|
246
|
-
|
247
|
-
def test_sort
|
248
|
-
a, ha = aha [1,2,3,4]
|
249
|
-
# test sort
|
250
|
-
assert_equal(a.sort, ha.sort.to_a)
|
251
|
-
#assert_equal(a.sort{|x,y| y<=>x}, ha.sort{|x,y| y<=>x}.to_a)
|
252
|
-
# test sort!
|
253
|
-
assert_equal(a.sort!, ha.sort!.to_a)
|
254
|
-
assert_equal(a, ha.to_a)
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_uniq
|
258
|
-
a, ha = aha [1,1,2,3,3,4,5,6,6]
|
259
|
-
assert_equal(a.uniq, ha.uniq.to_a)
|
260
|
-
end
|
261
|
-
|
262
|
-
def test_uniq!
|
263
|
-
a, ha = aha [1,1,2,3,3,4,5,6,6]
|
264
|
-
a.uniq!; ha.uniq!
|
265
|
-
assert_equal(a, ha.to_a)
|
266
|
-
end
|
267
|
-
|
268
|
-
def test_values_at
|
269
|
-
a, ha = aha ['a','b','c','d']
|
270
|
-
assert_equal(a.values_at(1,3),ha.values_at(1,3).to_a)
|
271
|
-
end
|
272
|
-
|
273
|
-
def test_unshift
|
274
|
-
a, ha = aha ['a','b','c','c','d']
|
275
|
-
assert_equal(a.unshift('x'),ha.unshift('x').to_a)
|
276
|
-
assert_equal(a,ha.to_a)
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|