hamster 0.4.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/hamster.rb +11 -9
- data/lib/hamster/core_ext.rb +2 -3
- data/lib/hamster/core_ext/enumerable.rb +18 -27
- data/lib/hamster/core_ext/io.rb +16 -25
- data/lib/hamster/deque.rb +252 -0
- data/lib/hamster/enumerable.rb +123 -112
- data/lib/hamster/experimental/mutable_queue.rb +5 -14
- data/lib/hamster/experimental/mutable_set.rb +7 -14
- data/lib/hamster/hash.rb +732 -102
- data/lib/hamster/immutable.rb +4 -10
- data/lib/hamster/list.rb +1155 -215
- data/lib/hamster/{experimental/mutable_hash.rb → mutable_hash.rb} +11 -14
- data/lib/hamster/nested.rb +36 -0
- data/lib/hamster/{experimental/read_copy_update.rb → read_copy_update.rb} +10 -8
- data/lib/hamster/set.rb +488 -90
- data/lib/hamster/sorted_set.rb +1397 -0
- data/lib/hamster/trie.rb +210 -65
- data/lib/hamster/undefined.rb +1 -7
- data/lib/hamster/vector.rb +1329 -83
- data/lib/hamster/version.rb +1 -3
- data/spec/{hamster/core_ext → fixtures}/io_spec.txt +0 -0
- data/spec/lib/hamster/core_ext/array_spec.rb +14 -0
- data/spec/lib/hamster/core_ext/enumerable_spec.rb +30 -0
- data/spec/lib/hamster/core_ext/io_spec.rb +29 -0
- data/spec/lib/hamster/deque/clear_spec.rb +34 -0
- data/spec/lib/hamster/deque/construction_spec.rb +30 -0
- data/spec/lib/hamster/deque/copying_spec.rb +20 -0
- data/spec/lib/hamster/deque/dequeue_spec.rb +35 -0
- data/spec/lib/hamster/deque/empty_spec.rb +40 -0
- data/spec/lib/hamster/deque/enqueue_spec.rb +28 -0
- data/spec/lib/hamster/deque/first_spec.rb +18 -0
- data/spec/lib/hamster/deque/inspect_spec.rb +24 -0
- data/spec/lib/hamster/deque/last_spec.rb +18 -0
- data/spec/lib/hamster/deque/marshal_spec.rb +34 -0
- data/spec/lib/hamster/deque/new_spec.rb +44 -0
- data/spec/lib/hamster/deque/pop_spec.rb +33 -0
- data/spec/lib/hamster/deque/pretty_print_spec.rb +24 -0
- data/spec/lib/hamster/deque/random_modification_spec.rb +34 -0
- data/spec/lib/hamster/deque/size_spec.rb +20 -0
- data/spec/lib/hamster/deque/to_a_spec.rb +27 -0
- data/spec/lib/hamster/deque/to_ary_spec.rb +36 -0
- data/spec/lib/hamster/deque/to_list_spec.rb +26 -0
- data/spec/lib/hamster/deque/unshift_spec.rb +26 -0
- data/spec/lib/hamster/experimental/mutable_set/add_qm_spec.rb +39 -0
- data/spec/lib/hamster/experimental/mutable_set/add_spec.rb +37 -0
- data/spec/lib/hamster/experimental/mutable_set/delete_qm_spec.rb +38 -0
- data/spec/lib/hamster/experimental/mutable_set/delete_spec.rb +37 -0
- data/spec/lib/hamster/hash/all_spec.rb +54 -0
- data/spec/lib/hamster/hash/any_spec.rb +54 -0
- data/spec/lib/hamster/hash/assoc_spec.rb +52 -0
- data/spec/lib/hamster/hash/clear_spec.rb +43 -0
- data/spec/lib/hamster/hash/construction_spec.rb +39 -0
- data/spec/lib/hamster/hash/copying_spec.rb +14 -0
- data/spec/lib/hamster/hash/default_proc_spec.rb +73 -0
- data/spec/lib/hamster/hash/delete_spec.rb +40 -0
- data/spec/lib/hamster/hash/each_spec.rb +78 -0
- data/spec/lib/hamster/hash/each_with_index_spec.rb +30 -0
- data/spec/lib/hamster/hash/empty_spec.rb +44 -0
- data/spec/lib/hamster/hash/eql_spec.rb +70 -0
- data/spec/lib/hamster/hash/except_spec.rb +43 -0
- data/spec/lib/hamster/hash/fetch_spec.rb +58 -0
- data/spec/lib/hamster/hash/find_spec.rb +44 -0
- data/spec/lib/hamster/hash/flat_map_spec.rb +36 -0
- data/spec/lib/hamster/hash/flatten_spec.rb +99 -0
- data/spec/lib/hamster/hash/get_spec.rb +80 -0
- data/spec/lib/hamster/hash/has_key_spec.rb +32 -0
- data/spec/lib/hamster/hash/has_value_spec.rb +28 -0
- data/spec/lib/hamster/hash/hash_spec.rb +30 -0
- data/spec/{hamster → lib/hamster}/hash/immutable_spec.rb +3 -6
- data/spec/lib/hamster/hash/inspect_spec.rb +31 -0
- data/spec/lib/hamster/hash/invert_spec.rb +31 -0
- data/spec/lib/hamster/hash/key_spec.rb +28 -0
- data/spec/lib/hamster/hash/keys_spec.rb +17 -0
- data/spec/lib/hamster/hash/map_spec.rb +46 -0
- data/spec/lib/hamster/hash/marshal_spec.rb +29 -0
- data/spec/lib/hamster/hash/merge_spec.rb +83 -0
- data/spec/lib/hamster/hash/min_max_spec.rb +46 -0
- data/spec/lib/hamster/hash/new_spec.rb +71 -0
- data/spec/lib/hamster/hash/none_spec.rb +49 -0
- data/spec/lib/hamster/hash/partition_spec.rb +36 -0
- data/spec/lib/hamster/hash/pretty_print_spec.rb +35 -0
- data/spec/lib/hamster/hash/put_spec.rb +103 -0
- data/spec/lib/hamster/hash/reduce_spec.rb +36 -0
- data/spec/lib/hamster/hash/reject_spec.rb +62 -0
- data/spec/lib/hamster/hash/reverse_each_spec.rb +28 -0
- data/spec/lib/hamster/hash/sample_spec.rb +14 -0
- data/spec/lib/hamster/hash/select_spec.rb +58 -0
- data/spec/{hamster → lib/hamster}/hash/size_spec.rb +9 -18
- data/spec/lib/hamster/hash/slice_spec.rb +45 -0
- data/spec/lib/hamster/hash/sort_spec.rb +27 -0
- data/spec/lib/hamster/hash/store_spec.rb +76 -0
- data/spec/lib/hamster/hash/take_spec.rb +36 -0
- data/spec/lib/hamster/hash/to_a_spec.rb +14 -0
- data/spec/lib/hamster/hash/to_hash_spec.rb +22 -0
- data/spec/lib/hamster/hash/update_in_spec.rb +80 -0
- data/spec/lib/hamster/hash/values_at_spec.rb +14 -0
- data/spec/lib/hamster/hash/values_spec.rb +25 -0
- data/spec/{hamster → lib/hamster}/immutable/copying_spec.rb +3 -10
- data/spec/{hamster → lib/hamster}/immutable/immutable_spec.rb +3 -16
- data/spec/lib/hamster/immutable/memoize_spec.rb +56 -0
- data/spec/lib/hamster/immutable/new_spec.rb +14 -0
- data/spec/lib/hamster/immutable/transform_spec.rb +26 -0
- data/spec/lib/hamster/immutable/transform_unless_spec.rb +44 -0
- data/spec/lib/hamster/list/add_spec.rb +26 -0
- data/spec/lib/hamster/list/all_spec.rb +58 -0
- data/spec/lib/hamster/list/any_spec.rb +50 -0
- data/spec/lib/hamster/list/append_spec.rb +39 -0
- data/spec/lib/hamster/list/at_spec.rb +30 -0
- data/spec/lib/hamster/list/break_spec.rb +70 -0
- data/spec/lib/hamster/list/cadr_spec.rb +39 -0
- data/spec/lib/hamster/list/chunk_spec.rb +29 -0
- data/spec/lib/hamster/list/clear_spec.rb +25 -0
- data/spec/lib/hamster/list/combination_spec.rb +34 -0
- data/spec/lib/hamster/list/compact_spec.rb +35 -0
- data/spec/lib/hamster/list/compare_spec.rb +31 -0
- data/spec/lib/hamster/list/cons_spec.rb +26 -0
- data/spec/lib/hamster/list/construction_spec.rb +111 -0
- data/spec/lib/hamster/list/copying_spec.rb +20 -0
- data/spec/lib/hamster/list/count_spec.rb +37 -0
- data/spec/lib/hamster/list/cycle_spec.rb +29 -0
- data/spec/lib/hamster/list/delete_at_spec.rb +19 -0
- data/spec/lib/hamster/list/delete_spec.rb +17 -0
- data/spec/lib/hamster/list/drop_spec.rb +31 -0
- data/spec/lib/hamster/list/drop_while_spec.rb +39 -0
- data/spec/lib/hamster/list/each_slice_spec.rb +52 -0
- data/spec/lib/hamster/list/each_spec.rb +41 -0
- data/spec/lib/hamster/list/each_with_index_spec.rb +29 -0
- data/spec/lib/hamster/list/empty_spec.rb +24 -0
- data/spec/lib/hamster/list/eql_spec.rb +62 -0
- data/spec/lib/hamster/list/fill_spec.rb +50 -0
- data/spec/lib/hamster/list/find_all_spec.rb +71 -0
- data/spec/{hamster → lib/hamster}/list/find_index_spec.rb +7 -29
- data/spec/{hamster → lib/hamster}/list/find_spec.rb +13 -35
- data/spec/lib/hamster/list/flat_map_spec.rb +52 -0
- data/spec/lib/hamster/list/flatten_spec.rb +31 -0
- data/spec/lib/hamster/list/grep_spec.rb +47 -0
- data/spec/lib/hamster/list/group_by_spec.rb +42 -0
- data/spec/lib/hamster/list/hash_spec.rb +22 -0
- data/spec/{hamster → lib/hamster}/list/head_spec.rb +6 -21
- data/spec/{hamster → lib/hamster}/list/include_spec.rb +8 -29
- data/spec/lib/hamster/list/index_spec.rb +34 -0
- data/spec/lib/hamster/list/indices_spec.rb +62 -0
- data/spec/lib/hamster/list/init_spec.rb +29 -0
- data/spec/lib/hamster/list/inits_spec.rb +29 -0
- data/spec/lib/hamster/list/insert_spec.rb +47 -0
- data/spec/lib/hamster/list/inspect_spec.rb +30 -0
- data/spec/lib/hamster/list/intersperse_spec.rb +29 -0
- data/spec/lib/hamster/list/join_spec.rb +64 -0
- data/spec/lib/hamster/list/last_spec.rb +24 -0
- data/spec/lib/hamster/list/ltlt_spec.rb +20 -0
- data/spec/lib/hamster/list/map_spec.rb +46 -0
- data/spec/lib/hamster/list/maximum_spec.rb +40 -0
- data/spec/{hamster → lib/hamster}/list/merge_by_spec.rb +9 -36
- data/spec/{hamster → lib/hamster}/list/merge_spec.rb +5 -24
- data/spec/lib/hamster/list/minimum_spec.rb +40 -0
- data/spec/lib/hamster/list/multithreading_spec.rb +48 -0
- data/spec/{hamster → lib/hamster}/list/none_spec.rb +14 -41
- data/spec/{hamster → lib/hamster}/list/one_spec.rb +15 -40
- data/spec/lib/hamster/list/partition_spec.rb +116 -0
- data/spec/lib/hamster/list/permutation_spec.rb +56 -0
- data/spec/lib/hamster/list/pop_spec.rb +26 -0
- data/spec/lib/hamster/list/product_spec.rb +24 -0
- data/spec/lib/hamster/list/reduce_spec.rb +54 -0
- data/spec/lib/hamster/list/reject_spec.rb +46 -0
- data/spec/lib/hamster/list/reverse_spec.rb +35 -0
- data/spec/lib/hamster/list/rotate_spec.rb +37 -0
- data/spec/lib/hamster/list/sample_spec.rb +14 -0
- data/spec/lib/hamster/list/select_spec.rb +71 -0
- data/spec/lib/hamster/list/size_spec.rb +26 -0
- data/spec/lib/hamster/list/slice_spec.rb +230 -0
- data/spec/lib/hamster/list/sorting_spec.rb +47 -0
- data/spec/lib/hamster/list/span_spec.rb +77 -0
- data/spec/lib/hamster/list/split_at_spec.rb +44 -0
- data/spec/lib/hamster/list/subsequences_spec.rb +24 -0
- data/spec/lib/hamster/list/sum_spec.rb +24 -0
- data/spec/lib/hamster/list/tail_spec.rb +31 -0
- data/spec/lib/hamster/list/tails_spec.rb +29 -0
- data/spec/lib/hamster/list/take_spec.rb +31 -0
- data/spec/lib/hamster/list/take_while_spec.rb +47 -0
- data/spec/lib/hamster/list/to_a_spec.rb +40 -0
- data/spec/lib/hamster/list/to_ary_spec.rb +42 -0
- data/spec/lib/hamster/list/to_list_spec.rb +20 -0
- data/spec/lib/hamster/list/to_set_spec.rb +19 -0
- data/spec/lib/hamster/list/transpose_spec.rb +20 -0
- data/spec/lib/hamster/list/union_spec.rb +32 -0
- data/spec/lib/hamster/list/uniq_spec.rb +30 -0
- data/spec/lib/hamster/list/zip_spec.rb +24 -0
- data/spec/lib/hamster/nested/construction_spec.rb +44 -0
- data/spec/lib/hamster/set/add_spec.rb +76 -0
- data/spec/lib/hamster/set/all_spec.rb +52 -0
- data/spec/lib/hamster/set/any_spec.rb +52 -0
- data/spec/lib/hamster/set/clear_spec.rb +34 -0
- data/spec/{hamster → lib/hamster}/set/compact_spec.rb +9 -20
- data/spec/lib/hamster/set/construction_spec.rb +19 -0
- data/spec/lib/hamster/set/copying_spec.rb +14 -0
- data/spec/lib/hamster/set/count_spec.rb +37 -0
- data/spec/lib/hamster/set/delete_spec.rb +72 -0
- data/spec/lib/hamster/set/difference_spec.rb +50 -0
- data/spec/lib/hamster/set/disjoint_spec.rb +26 -0
- data/spec/lib/hamster/set/each_spec.rb +46 -0
- data/spec/lib/hamster/set/empty_spec.rb +45 -0
- data/spec/lib/hamster/set/eqeq_spec.rb +104 -0
- data/spec/lib/hamster/set/eql_spec.rb +110 -0
- data/spec/lib/hamster/set/exclusion_spec.rb +48 -0
- data/spec/{hamster → lib/hamster}/set/find_spec.rb +10 -27
- data/spec/lib/hamster/set/first_spec.rb +29 -0
- data/spec/lib/hamster/set/flatten_spec.rb +47 -0
- data/spec/lib/hamster/set/grep_spec.rb +58 -0
- data/spec/lib/hamster/set/group_by_spec.rb +60 -0
- data/spec/lib/hamster/set/hash_spec.rb +23 -0
- data/spec/{hamster → lib/hamster}/set/immutable_spec.rb +4 -7
- data/spec/lib/hamster/set/include_spec.rb +61 -0
- data/spec/lib/hamster/set/inspect_spec.rb +48 -0
- data/spec/lib/hamster/set/intersect_spec.rb +26 -0
- data/spec/lib/hamster/set/intersection_spec.rb +53 -0
- data/spec/lib/hamster/set/join_spec.rb +65 -0
- data/spec/lib/hamster/set/map_spec.rb +60 -0
- data/spec/lib/hamster/set/marshal_spec.rb +29 -0
- data/spec/lib/hamster/set/maximum_spec.rb +37 -0
- data/spec/lib/hamster/set/minimum_spec.rb +37 -0
- data/spec/lib/hamster/set/new_spec.rb +54 -0
- data/spec/{hamster → lib/hamster}/set/none_spec.rb +17 -32
- data/spec/{hamster → lib/hamster}/set/one_spec.rb +16 -31
- data/spec/lib/hamster/set/partition_spec.rb +53 -0
- data/spec/lib/hamster/set/product_spec.rb +24 -0
- data/spec/lib/hamster/set/reduce_spec.rb +56 -0
- data/spec/lib/hamster/set/reject_spec.rb +51 -0
- data/spec/lib/hamster/set/reverse_each_spec.rb +39 -0
- data/spec/lib/hamster/set/sample_spec.rb +14 -0
- data/spec/lib/hamster/set/select_spec.rb +74 -0
- data/spec/{hamster → lib/hamster}/set/size_spec.rb +4 -13
- data/spec/lib/hamster/set/sorting_spec.rb +49 -0
- data/spec/lib/hamster/set/subset_spec.rb +52 -0
- data/spec/lib/hamster/set/sum_spec.rb +24 -0
- data/spec/lib/hamster/set/superset_spec.rb +52 -0
- data/spec/lib/hamster/set/to_a_spec.rb +31 -0
- data/spec/lib/hamster/set/to_list_spec.rb +37 -0
- data/spec/lib/hamster/set/to_set_spec.rb +20 -0
- data/spec/lib/hamster/set/union_spec.rb +64 -0
- data/spec/lib/hamster/sorted_set/above_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/add_spec.rb +63 -0
- data/spec/lib/hamster/sorted_set/at_spec.rb +25 -0
- data/spec/lib/hamster/sorted_set/below_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/between_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/clear_spec.rb +44 -0
- data/spec/lib/hamster/sorted_set/construction_spec.rb +29 -0
- data/spec/lib/hamster/sorted_set/delete_at_spec.rb +19 -0
- data/spec/lib/hamster/sorted_set/delete_spec.rb +90 -0
- data/spec/lib/hamster/sorted_set/difference_spec.rb +23 -0
- data/spec/lib/hamster/sorted_set/disjoint_spec.rb +26 -0
- data/spec/lib/hamster/sorted_set/drop_spec.rb +56 -0
- data/spec/lib/hamster/sorted_set/drop_while_spec.rb +35 -0
- data/spec/lib/hamster/sorted_set/each_spec.rb +29 -0
- data/spec/lib/hamster/sorted_set/empty_spec.rb +35 -0
- data/spec/lib/hamster/sorted_set/eql_spec.rb +121 -0
- data/spec/lib/hamster/sorted_set/exclusion_spec.rb +23 -0
- data/spec/lib/hamster/sorted_set/fetch_spec.rb +65 -0
- data/spec/lib/hamster/sorted_set/find_index_spec.rb +41 -0
- data/spec/lib/hamster/sorted_set/first_spec.rb +19 -0
- data/spec/lib/hamster/sorted_set/from_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/group_by_spec.rb +58 -0
- data/spec/lib/hamster/sorted_set/include_spec.rb +24 -0
- data/spec/lib/hamster/sorted_set/inspect_spec.rb +38 -0
- data/spec/lib/hamster/sorted_set/intersect_spec.rb +26 -0
- data/spec/lib/hamster/sorted_set/intersection_spec.rb +29 -0
- data/spec/lib/hamster/sorted_set/last_spec.rb +37 -0
- data/spec/lib/hamster/sorted_set/map_spec.rb +36 -0
- data/spec/lib/hamster/sorted_set/marshal_spec.rb +37 -0
- data/spec/lib/hamster/sorted_set/maximum_spec.rb +37 -0
- data/spec/lib/hamster/sorted_set/minimum_spec.rb +20 -0
- data/spec/lib/hamster/sorted_set/new_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/reverse_each_spec.rb +29 -0
- data/spec/lib/hamster/sorted_set/sample_spec.rb +14 -0
- data/spec/lib/hamster/sorted_set/select_spec.rb +62 -0
- data/spec/{hamster/vector → lib/hamster/sorted_set}/size_spec.rb +6 -15
- data/spec/lib/hamster/sorted_set/slice_spec.rb +257 -0
- data/spec/lib/hamster/sorted_set/sorting_spec.rb +45 -0
- data/spec/lib/hamster/sorted_set/subset_spec.rb +48 -0
- data/spec/lib/hamster/sorted_set/superset_spec.rb +48 -0
- data/spec/lib/hamster/sorted_set/take_spec.rb +55 -0
- data/spec/lib/hamster/sorted_set/take_while_spec.rb +34 -0
- data/spec/lib/hamster/sorted_set/to_set_spec.rb +19 -0
- data/spec/lib/hamster/sorted_set/union_spec.rb +28 -0
- data/spec/lib/hamster/sorted_set/up_to_spec.rb +52 -0
- data/spec/lib/hamster/sorted_set/values_at_spec.rb +34 -0
- data/spec/lib/hamster/vector/add_spec.rb +68 -0
- data/spec/lib/hamster/vector/any_spec.rb +70 -0
- data/spec/lib/hamster/vector/assoc_spec.rb +36 -0
- data/spec/lib/hamster/vector/bsearch_spec.rb +58 -0
- data/spec/lib/hamster/vector/clear_spec.rb +34 -0
- data/spec/lib/hamster/vector/combination_spec.rb +82 -0
- data/spec/lib/hamster/vector/compact_spec.rb +30 -0
- data/spec/lib/hamster/vector/compare_spec.rb +32 -0
- data/spec/lib/hamster/vector/concat_spec.rb +35 -0
- data/spec/lib/hamster/vector/copying_spec.rb +21 -0
- data/spec/lib/hamster/vector/count_spec.rb +18 -0
- data/spec/lib/hamster/vector/delete_at_spec.rb +54 -0
- data/spec/lib/hamster/vector/delete_spec.rb +31 -0
- data/spec/lib/hamster/vector/drop_spec.rb +42 -0
- data/spec/lib/hamster/vector/drop_while_spec.rb +55 -0
- data/spec/lib/hamster/vector/each_index_spec.rb +41 -0
- data/spec/lib/hamster/vector/each_spec.rb +45 -0
- data/spec/lib/hamster/vector/each_with_index_spec.rb +40 -0
- data/spec/lib/hamster/vector/empty_spec.rb +42 -0
- data/spec/lib/hamster/vector/eql_spec.rb +77 -0
- data/spec/lib/hamster/vector/fetch_spec.rb +65 -0
- data/spec/lib/hamster/vector/fill_spec.rb +89 -0
- data/spec/lib/hamster/vector/first_spec.rb +19 -0
- data/spec/lib/hamster/vector/flat_map_spec.rb +51 -0
- data/spec/lib/hamster/vector/flatten_spec.rb +44 -0
- data/spec/lib/hamster/vector/get_spec.rb +75 -0
- data/spec/lib/hamster/vector/group_by_spec.rb +58 -0
- data/spec/{hamster → lib/hamster}/vector/include_spec.rb +6 -20
- data/spec/lib/hamster/vector/insert_spec.rb +69 -0
- data/spec/lib/hamster/vector/inspect_spec.rb +50 -0
- data/spec/{hamster/set → lib/hamster/vector}/join_spec.rb +24 -34
- data/spec/lib/hamster/vector/last_spec.rb +46 -0
- data/spec/lib/hamster/vector/length_spec.rb +46 -0
- data/spec/lib/hamster/vector/ltlt_spec.rb +66 -0
- data/spec/lib/hamster/vector/map_spec.rb +52 -0
- data/spec/lib/hamster/vector/marshal_spec.rb +32 -0
- data/spec/lib/hamster/vector/maximum_spec.rb +34 -0
- data/spec/lib/hamster/vector/minimum_spec.rb +34 -0
- data/spec/lib/hamster/vector/multiply_spec.rb +48 -0
- data/spec/lib/hamster/vector/new_spec.rb +51 -0
- data/spec/lib/hamster/vector/partition_spec.rb +53 -0
- data/spec/lib/hamster/vector/permutation_spec.rb +92 -0
- data/spec/lib/hamster/vector/pop_spec.rb +27 -0
- data/spec/lib/hamster/vector/product_spec.rb +71 -0
- data/spec/{hamster → lib/hamster}/vector/reduce_spec.rb +18 -49
- data/spec/lib/hamster/vector/reject_spec.rb +44 -0
- data/spec/lib/hamster/vector/repeated_combination_spec.rb +78 -0
- data/spec/lib/hamster/vector/repeated_permutation_spec.rb +94 -0
- data/spec/lib/hamster/vector/reverse_each_spec.rb +32 -0
- data/spec/lib/hamster/vector/reverse_spec.rb +22 -0
- data/spec/lib/hamster/vector/rindex_spec.rb +37 -0
- data/spec/lib/hamster/vector/rotate_spec.rb +74 -0
- data/spec/lib/hamster/vector/sample_spec.rb +14 -0
- data/spec/lib/hamster/vector/select_spec.rb +64 -0
- data/spec/lib/hamster/vector/set_spec.rb +175 -0
- data/spec/lib/hamster/vector/shift_spec.rb +28 -0
- data/spec/lib/hamster/vector/shuffle_spec.rb +44 -0
- data/spec/lib/hamster/vector/slice_spec.rb +241 -0
- data/spec/lib/hamster/vector/sorting_spec.rb +57 -0
- data/spec/{hamster/set → lib/hamster/vector}/sum_spec.rb +5 -19
- data/spec/lib/hamster/vector/take_spec.rb +43 -0
- data/spec/lib/hamster/vector/take_while_spec.rb +35 -0
- data/spec/lib/hamster/vector/to_a_spec.rb +42 -0
- data/spec/lib/hamster/vector/to_ary_spec.rb +35 -0
- data/spec/lib/hamster/vector/to_list_spec.rb +32 -0
- data/spec/lib/hamster/vector/to_set_spec.rb +23 -0
- data/spec/lib/hamster/vector/transpose_spec.rb +49 -0
- data/spec/lib/hamster/vector/uniq_spec.rb +56 -0
- data/spec/lib/hamster/vector/unshift_spec.rb +29 -0
- data/spec/lib/hamster/vector/update_in_spec.rb +83 -0
- data/spec/lib/hamster/vector/values_at_spec.rb +34 -0
- data/spec/lib/hamster/vector/zip_spec.rb +58 -0
- data/spec/spec_helper.rb +45 -13
- metadata +807 -458
- data/History.rdoc +0 -419
- data/LICENSE +0 -20
- data/README.rdoc +0 -236
- data/Rakefile +0 -5
- data/lib/hamster/core_ext/enumerator.rb +0 -30
- data/lib/hamster/experimental/mutable_stack.rb +0 -35
- data/lib/hamster/queue.rb +0 -93
- data/lib/hamster/sorter.rb +0 -32
- data/lib/hamster/stack.rb +0 -82
- data/lib/hamster/tuple.rb +0 -45
- data/spec/hamster/core_ext/array_spec.rb +0 -20
- data/spec/hamster/core_ext/coverage/assets/0.4.4/app.js +0 -66
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/blank.gif +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_close.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_loading.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_nav_left.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_nav_right.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_e.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_n.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_s.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_se.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_shadow_w.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_title_left.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_title_main.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_title_over.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancy_title_right.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancybox-x.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancybox-y.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/fancybox.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/spec/hamster/core_ext/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/spec/hamster/core_ext/coverage/assets/0.4.4/favicon.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/jquery-1.4.2.min.js +0 -155
- data/spec/hamster/core_ext/coverage/assets/0.4.4/jquery.dataTables.min.js +0 -152
- data/spec/hamster/core_ext/coverage/assets/0.4.4/jquery.timeago.js +0 -141
- data/spec/hamster/core_ext/coverage/assets/0.4.4/jquery.url.js +0 -174
- data/spec/hamster/core_ext/coverage/assets/0.4.4/loading.gif +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/magnify.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/hamster/core_ext/coverage/assets/0.4.4/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/spec/hamster/core_ext/coverage/assets/0.4.4/stylesheet.css +0 -341
- data/spec/hamster/core_ext/coverage/covered_percent +0 -1
- data/spec/hamster/core_ext/coverage/index.html +0 -71
- data/spec/hamster/core_ext/coverage/resultset.yml +0 -10
- data/spec/hamster/core_ext/enumerable_spec.rb +0 -34
- data/spec/hamster/core_ext/enumerator_spec.rb +0 -25
- data/spec/hamster/core_ext/io_spec.rb +0 -29
- data/spec/hamster/experimental/mutable_set/add?_spec.rb +0 -47
- data/spec/hamster/experimental/mutable_set/add_spec.rb +0 -51
- data/spec/hamster/experimental/mutable_set/delete?_spec.rb +0 -47
- data/spec/hamster/experimental/mutable_set/delete_spec.rb +0 -47
- data/spec/hamster/experimental/mutable_stack/pop_spec.rb +0 -41
- data/spec/hamster/experimental/mutable_stack/push_spec.rb +0 -41
- data/spec/hamster/hash/all_spec.rb +0 -59
- data/spec/hamster/hash/any_spec.rb +0 -68
- data/spec/hamster/hash/clear_spec.rb +0 -36
- data/spec/hamster/hash/construction_spec.rb +0 -35
- data/spec/hamster/hash/copying_spec.rb +0 -23
- data/spec/hamster/hash/delete_spec.rb +0 -47
- data/spec/hamster/hash/each_spec.rb +0 -41
- data/spec/hamster/hash/empty_spec.rb +0 -27
- data/spec/hamster/hash/eql_spec.rb +0 -62
- data/spec/hamster/hash/except_spec.rb +0 -31
- data/spec/hamster/hash/fetch_spec.rb +0 -95
- data/spec/hamster/hash/filter_spec.rb +0 -63
- data/spec/hamster/hash/find_spec.rb +0 -58
- data/spec/hamster/hash/get_spec.rb +0 -68
- data/spec/hamster/hash/has_key_spec.rb +0 -35
- data/spec/hamster/hash/hash_spec.rb +0 -54
- data/spec/hamster/hash/inspect_spec.rb +0 -32
- data/spec/hamster/hash/keys_spec.rb +0 -21
- data/spec/hamster/hash/map_spec.rb +0 -64
- data/spec/hamster/hash/merge_spec.rb +0 -36
- data/spec/hamster/hash/none_spec.rb +0 -64
- data/spec/hamster/hash/put_spec.rb +0 -65
- data/spec/hamster/hash/reduce_spec.rb +0 -60
- data/spec/hamster/hash/remove_spec.rb +0 -63
- data/spec/hamster/hash/slice_spec.rb +0 -31
- data/spec/hamster/hash/uniq_spec.rb +0 -23
- data/spec/hamster/hash/values_spec.rb +0 -34
- data/spec/hamster/immutable/memoize_spec.rb +0 -64
- data/spec/hamster/immutable/new_spec.rb +0 -28
- data/spec/hamster/immutable/transform_spec.rb +0 -31
- data/spec/hamster/immutable/transform_unless_spec.rb +0 -55
- data/spec/hamster/list/all_spec.rb +0 -111
- data/spec/hamster/list/any_spec.rb +0 -79
- data/spec/hamster/list/append_spec.rb +0 -50
- data/spec/hamster/list/at_spec.rb +0 -49
- data/spec/hamster/list/break_spec.rb +0 -85
- data/spec/hamster/list/cadr_spec.rb +0 -50
- data/spec/hamster/list/chunk_spec.rb +0 -40
- data/spec/hamster/list/clear_spec.rb +0 -36
- data/spec/hamster/list/combinations_spec.rb +0 -51
- data/spec/hamster/list/compact_spec.rb +0 -46
- data/spec/hamster/list/cons_spec.rb +0 -41
- data/spec/hamster/list/construction_spec.rb +0 -140
- data/spec/hamster/list/copying_spec.rb +0 -32
- data/spec/hamster/list/count_spec.rb +0 -66
- data/spec/hamster/list/coverage/assets/0.4.4/app.js +0 -66
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/blank.gif +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_close.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_loading.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_nav_left.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_nav_right.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_e.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_n.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_s.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_se.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_shadow_w.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_title_left.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_title_main.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_title_over.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancy_title_right.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancybox-x.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancybox-y.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/fancybox.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/spec/hamster/list/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/spec/hamster/list/coverage/assets/0.4.4/favicon.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/jquery-1.4.2.min.js +0 -155
- data/spec/hamster/list/coverage/assets/0.4.4/jquery.dataTables.min.js +0 -152
- data/spec/hamster/list/coverage/assets/0.4.4/jquery.timeago.js +0 -141
- data/spec/hamster/list/coverage/assets/0.4.4/jquery.url.js +0 -174
- data/spec/hamster/list/coverage/assets/0.4.4/loading.gif +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/magnify.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/hamster/list/coverage/assets/0.4.4/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/spec/hamster/list/coverage/assets/0.4.4/stylesheet.css +0 -341
- data/spec/hamster/list/coverage/covered_percent +0 -1
- data/spec/hamster/list/coverage/index.html +0 -71
- data/spec/hamster/list/coverage/resultset.yml +0 -225
- data/spec/hamster/list/cycle_spec.rb +0 -45
- data/spec/hamster/list/drop_spec.rb +0 -42
- data/spec/hamster/list/drop_while_spec.rb +0 -59
- data/spec/hamster/list/each_slice_spec.rb +0 -80
- data/spec/hamster/list/each_spec.rb +0 -72
- data/spec/hamster/list/each_with_index_spec.rb +0 -42
- data/spec/hamster/list/elem_index_spec.rb +0 -58
- data/spec/hamster/list/elem_indices_spec.rb +0 -45
- data/spec/hamster/list/empty_spec.rb +0 -47
- data/spec/hamster/list/eql_spec.rb +0 -78
- data/spec/hamster/list/filter_spec.rb +0 -61
- data/spec/hamster/list/find_indices_spec.rb +0 -45
- data/spec/hamster/list/flatten_spec.rb +0 -42
- data/spec/hamster/list/grep_spec.rb +0 -70
- data/spec/hamster/list/group_by_spec.rb +0 -77
- data/spec/hamster/list/hash_spec.rb +0 -43
- data/spec/hamster/list/init_spec.rb +0 -40
- data/spec/hamster/list/inits_spec.rb +0 -42
- data/spec/hamster/list/inspect_spec.rb +0 -43
- data/spec/hamster/list/intersperse_spec.rb +0 -40
- data/spec/hamster/list/join_spec.rb +0 -81
- data/spec/hamster/list/last_spec.rb +0 -44
- data/spec/hamster/list/map_spec.rb +0 -69
- data/spec/hamster/list/maximum_spec.rb +0 -77
- data/spec/hamster/list/minimum_spec.rb +0 -77
- data/spec/hamster/list/partition_spec.rb +0 -75
- data/spec/hamster/list/product_spec.rb +0 -44
- data/spec/hamster/list/reduce_spec.rb +0 -99
- data/spec/hamster/list/remove_spec.rb +0 -67
- data/spec/hamster/list/reverse_spec.rb +0 -52
- data/spec/hamster/list/size_spec.rb +0 -47
- data/spec/hamster/list/slice_spec.rb +0 -50
- data/spec/hamster/list/sorting_spec.rb +0 -70
- data/spec/hamster/list/span_spec.rb +0 -86
- data/spec/hamster/list/split_at_spec.rb +0 -53
- data/spec/hamster/list/sum_spec.rb +0 -44
- data/spec/hamster/list/tail_spec.rb +0 -48
- data/spec/hamster/list/tails_spec.rb +0 -42
- data/spec/hamster/list/take_spec.rb +0 -42
- data/spec/hamster/list/take_while_spec.rb +0 -62
- data/spec/hamster/list/to_a_spec.rb +0 -54
- data/spec/hamster/list/to_ary_spec.rb +0 -56
- data/spec/hamster/list/to_list_spec.rb +0 -32
- data/spec/hamster/list/to_set_spec.rb +0 -33
- data/spec/hamster/list/union_spec.rb +0 -49
- data/spec/hamster/list/uniq_spec.rb +0 -45
- data/spec/hamster/list/zip_spec.rb +0 -39
- data/spec/hamster/queue/clear_spec.rb +0 -36
- data/spec/hamster/queue/construction_spec.rb +0 -43
- data/spec/hamster/queue/dequeue_spec.rb +0 -40
- data/spec/hamster/queue/empty_spec.rb +0 -47
- data/spec/hamster/queue/enqueue_spec.rb +0 -41
- data/spec/hamster/queue/head_spec.rb +0 -35
- data/spec/hamster/queue/inspect_spec.rb +0 -31
- data/spec/hamster/queue/size_spec.rb +0 -35
- data/spec/hamster/queue/to_a_spec.rb +0 -42
- data/spec/hamster/queue/to_ary_spec.rb +0 -44
- data/spec/hamster/queue/to_list_spec.rb +0 -44
- data/spec/hamster/set/add_spec.rb +0 -51
- data/spec/hamster/set/all_spec.rb +0 -67
- data/spec/hamster/set/any_spec.rb +0 -67
- data/spec/hamster/set/clear_spec.rb +0 -36
- data/spec/hamster/set/construction_spec.rb +0 -31
- data/spec/hamster/set/copying_spec.rb +0 -23
- data/spec/hamster/set/count_spec.rb +0 -54
- data/spec/hamster/set/coverage/assets/0.4.4/app.js +0 -66
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/blank.gif +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_close.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_loading.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_nav_left.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_nav_right.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_e.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_n.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_s.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_se.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_shadow_w.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_title_left.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_title_main.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_title_over.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancy_title_right.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancybox-x.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancybox-y.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/fancybox.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/spec/hamster/set/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/spec/hamster/set/coverage/assets/0.4.4/favicon.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/jquery-1.4.2.min.js +0 -155
- data/spec/hamster/set/coverage/assets/0.4.4/jquery.dataTables.min.js +0 -152
- data/spec/hamster/set/coverage/assets/0.4.4/jquery.timeago.js +0 -141
- data/spec/hamster/set/coverage/assets/0.4.4/jquery.url.js +0 -174
- data/spec/hamster/set/coverage/assets/0.4.4/loading.gif +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/magnify.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/hamster/set/coverage/assets/0.4.4/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/spec/hamster/set/coverage/assets/0.4.4/stylesheet.css +0 -341
- data/spec/hamster/set/coverage/covered_percent +0 -1
- data/spec/hamster/set/coverage/index.html +0 -71
- data/spec/hamster/set/coverage/resultset.yml +0 -13
- data/spec/hamster/set/delete_spec.rb +0 -47
- data/spec/hamster/set/difference_spec.rb +0 -37
- data/spec/hamster/set/each_spec.rb +0 -42
- data/spec/hamster/set/empty_spec.rb +0 -35
- data/spec/hamster/set/eql_spec.rb +0 -62
- data/spec/hamster/set/exclusion_spec.rb +0 -38
- data/spec/hamster/set/filter_spec.rb +0 -79
- data/spec/hamster/set/flatten_spec.rb +0 -49
- data/spec/hamster/set/grep_spec.rb +0 -62
- data/spec/hamster/set/group_by_spec.rb +0 -65
- data/spec/hamster/set/hash_spec.rb +0 -31
- data/spec/hamster/set/head_spec.rb +0 -39
- data/spec/hamster/set/include_spec.rb +0 -35
- data/spec/hamster/set/inspect_spec.rb +0 -32
- data/spec/hamster/set/intersection_spec.rb +0 -46
- data/spec/hamster/set/map_spec.rb +0 -64
- data/spec/hamster/set/maximum_spec.rb +0 -65
- data/spec/hamster/set/minimum_spec.rb +0 -65
- data/spec/hamster/set/partition_spec.rb +0 -71
- data/spec/hamster/set/product_spec.rb +0 -32
- data/spec/hamster/set/reduce_spec.rb +0 -87
- data/spec/hamster/set/remove_spec.rb +0 -63
- data/spec/hamster/set/sorting_spec.rb +0 -58
- data/spec/hamster/set/subset_spec.rb +0 -39
- data/spec/hamster/set/superset_spec.rb +0 -39
- data/spec/hamster/set/to_a_spec.rb +0 -42
- data/spec/hamster/set/to_list_spec.rb +0 -47
- data/spec/hamster/set/to_set_spec.rb +0 -32
- data/spec/hamster/set/union_spec.rb +0 -45
- data/spec/hamster/set/uniq_spec.rb +0 -23
- data/spec/hamster/sorter/coverage/assets/0.4.4/app.js +0 -66
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/blank.gif +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_close.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_loading.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_nav_left.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_nav_right.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_e.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_n.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_s.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_se.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_shadow_w.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_title_left.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_title_main.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_title_over.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancy_title_right.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancybox-x.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancybox-y.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/fancybox.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/spec/hamster/sorter/coverage/assets/0.4.4/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/spec/hamster/sorter/coverage/assets/0.4.4/favicon.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/jquery-1.4.2.min.js +0 -155
- data/spec/hamster/sorter/coverage/assets/0.4.4/jquery.dataTables.min.js +0 -152
- data/spec/hamster/sorter/coverage/assets/0.4.4/jquery.timeago.js +0 -141
- data/spec/hamster/sorter/coverage/assets/0.4.4/jquery.url.js +0 -174
- data/spec/hamster/sorter/coverage/assets/0.4.4/loading.gif +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/magnify.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/hamster/sorter/coverage/assets/0.4.4/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/spec/hamster/sorter/coverage/assets/0.4.4/stylesheet.css +0 -341
- data/spec/hamster/sorter/coverage/covered_percent +0 -1
- data/spec/hamster/sorter/coverage/index.html +0 -71
- data/spec/hamster/sorter/coverage/resultset.yml +0 -22
- data/spec/hamster/sorter/immutable_spec.rb +0 -12
- data/spec/hamster/stack/clear_spec.rb +0 -36
- data/spec/hamster/stack/construction_spec.rb +0 -43
- data/spec/hamster/stack/copying_spec.rb +0 -31
- data/spec/hamster/stack/empty_spec.rb +0 -31
- data/spec/hamster/stack/eql_spec.rb +0 -60
- data/spec/hamster/stack/immutable_spec.rb +0 -12
- data/spec/hamster/stack/inspect_spec.rb +0 -31
- data/spec/hamster/stack/peek_spec.rb +0 -40
- data/spec/hamster/stack/pop_spec.rb +0 -41
- data/spec/hamster/stack/push_spec.rb +0 -41
- data/spec/hamster/stack/size_spec.rb +0 -35
- data/spec/hamster/stack/to_a_spec.rb +0 -42
- data/spec/hamster/stack/to_ary.rb +0 -44
- data/spec/hamster/stack/to_list_spec.rb +0 -33
- data/spec/hamster/trie/remove_spec.rb +0 -117
- data/spec/hamster/tuple/copying_spec.rb +0 -24
- data/spec/hamster/tuple/eql_spec.rb +0 -61
- data/spec/hamster/tuple/first_spec.rb +0 -19
- data/spec/hamster/tuple/immutable_spec.rb +0 -12
- data/spec/hamster/tuple/inspect_spec.rb +0 -19
- data/spec/hamster/tuple/last_spec.rb +0 -19
- data/spec/hamster/tuple/to_a_spec.rb +0 -38
- data/spec/hamster/tuple/to_ary_spec.rb +0 -44
- data/spec/hamster/undefined/erase_spec.rb +0 -47
- data/spec/hamster/vector/add_spec.rb +0 -41
- data/spec/hamster/vector/any_spec.rb +0 -67
- data/spec/hamster/vector/clear_spec.rb +0 -36
- data/spec/hamster/vector/copying_spec.rb +0 -32
- data/spec/hamster/vector/each_spec.rb +0 -46
- data/spec/hamster/vector/each_with_index_spec.rb +0 -42
- data/spec/hamster/vector/empty_spec.rb +0 -35
- data/spec/hamster/vector/eql_spec.rb +0 -65
- data/spec/hamster/vector/filter_spec.rb +0 -63
- data/spec/hamster/vector/first_spec.rb +0 -35
- data/spec/hamster/vector/get_spec.rb +0 -81
- data/spec/hamster/vector/inspect_spec.rb +0 -31
- data/spec/hamster/vector/last_spec.rb +0 -32
- data/spec/hamster/vector/map_spec.rb +0 -64
- data/spec/hamster/vector/set_spec.rb +0 -153
- data/spec/hamster/vector/to_a_spec.rb +0 -42
- data/spec/hamster/vector/to_ary_spec.rb +0 -44
- data/tasks/bundler.rb +0 -2
- data/tasks/publish.rb +0 -12
- data/tasks/spec.rb +0 -13
@@ -0,0 +1,54 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "hamster/list"
|
3
|
+
|
4
|
+
describe Hamster::List do
|
5
|
+
[:reduce, :inject].each do |method|
|
6
|
+
describe "##{method}" do
|
7
|
+
context "on a really big list" do
|
8
|
+
it "doesn't run out of stack" do
|
9
|
+
-> { Hamster.interval(0, STACK_OVERFLOW_DEPTH).send(method, &:+) }.should_not raise_error
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
[
|
14
|
+
[[], 10, 10],
|
15
|
+
[[1], 10, 9],
|
16
|
+
[[1, 2, 3], 10, 4],
|
17
|
+
].each do |values, initial, expected|
|
18
|
+
context "on #{values.inspect}" do
|
19
|
+
context "with an initial value of #{initial} and a block" do
|
20
|
+
it "returns #{expected.inspect}" do
|
21
|
+
Hamster.list(*values).send(method, initial) { |memo, item| memo - item }.should == expected
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
[
|
28
|
+
[[], nil],
|
29
|
+
[[1], 1],
|
30
|
+
[[1, 2, 3], -4],
|
31
|
+
].each do |values, expected|
|
32
|
+
context "on #{values.inspect}" do
|
33
|
+
context "with no initial value and a block" do
|
34
|
+
it "returns #{expected.inspect}" do
|
35
|
+
Hamster.list(*values).send(method) { |memo, item| memo - item }.should == expected
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with no block and a symbol argument" do
|
42
|
+
it "uses the symbol as the name of a method to reduce with" do
|
43
|
+
Hamster.list(1, 2, 3).send(method, :+).should == 6
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with no block and a string argument" do
|
48
|
+
it "uses the string as the name of a method to reduce with" do
|
49
|
+
Hamster.list(1, 2, 3).send(method, '+').should == 6
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "hamster/list"
|
3
|
+
|
4
|
+
describe Hamster::List do
|
5
|
+
[:reject, :delete_if].each do |method|
|
6
|
+
describe "##{method}" do
|
7
|
+
it "is lazy" do
|
8
|
+
-> { Hamster.stream { fail }.send(method) { |item| false } }.should_not raise_error
|
9
|
+
end
|
10
|
+
|
11
|
+
[
|
12
|
+
[[], []],
|
13
|
+
[["A"], ["A"]],
|
14
|
+
[%w[A B C], %w[A B C]],
|
15
|
+
[%w[A b C], %w[A C]],
|
16
|
+
[%w[a b c], []],
|
17
|
+
].each do |values, expected|
|
18
|
+
context "on #{values.inspect}" do
|
19
|
+
let(:list) { Hamster.list(*values) }
|
20
|
+
|
21
|
+
context "with a block" do
|
22
|
+
it "returns #{expected.inspect}" do
|
23
|
+
list.send(method) { |item| item == item.downcase }.should eql(Hamster.list(*expected))
|
24
|
+
end
|
25
|
+
|
26
|
+
it "is lazy" do
|
27
|
+
count = 0
|
28
|
+
list.send(method) do |item|
|
29
|
+
count += 1
|
30
|
+
false
|
31
|
+
end
|
32
|
+
count.should <= 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "without a block" do
|
37
|
+
it "returns an Enumerator" do
|
38
|
+
list.send(method).class.should be(Enumerator)
|
39
|
+
list.send(method).each { |item| item == item.downcase }.should eql(Hamster.list(*expected))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "hamster/list"
|
3
|
+
|
4
|
+
describe Hamster::List do
|
5
|
+
describe "#reverse" do
|
6
|
+
context "on a really big list" do
|
7
|
+
it "doesn't run out of stack" do
|
8
|
+
-> { Hamster.interval(0, STACK_OVERFLOW_DEPTH).reverse }.should_not raise_error
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "is lazy" do
|
13
|
+
-> { Hamster.stream { fail }.reverse }.should_not raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
[
|
17
|
+
[[], []],
|
18
|
+
[["A"], ["A"]],
|
19
|
+
[%w[A B C], %w[C B A]],
|
20
|
+
].each do |values, expected|
|
21
|
+
context "on #{values.inspect}" do
|
22
|
+
let(:list) { Hamster.list(*values) }
|
23
|
+
|
24
|
+
it "preserves the original" do
|
25
|
+
list.reverse { |item| item.downcase }
|
26
|
+
list.should eql(Hamster.list(*values))
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns #{expected.inspect}" do
|
30
|
+
list.reverse { |item| item.downcase }.should == Hamster.list(*expected)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "hamster/list"
|
3
|
+
|
4
|
+
describe Hamster::List do
|
5
|
+
describe "#rotate" do
|
6
|
+
let(:list) { Hamster.list(1,2,3,4,5) }
|
7
|
+
|
8
|
+
context "when passed no argument" do
|
9
|
+
it "returns a new list with the first element moved to the end" do
|
10
|
+
list.rotate.should eql(Hamster.list(2,3,4,5,1))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with an integral argument n" do
|
15
|
+
it "returns a new list with the first (n % size) elements moved to the end" do
|
16
|
+
list.rotate(2).should eql(Hamster.list(3,4,5,1,2))
|
17
|
+
list.rotate(3).should eql(Hamster.list(4,5,1,2,3))
|
18
|
+
list.rotate(4).should eql(Hamster.list(5,1,2,3,4))
|
19
|
+
list.rotate(5).should eql(Hamster.list(1,2,3,4,5))
|
20
|
+
list.rotate(-1).should eql(Hamster.list(5,1,2,3,4))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with a non-numeric argument" do
|
25
|
+
it "raises a TypeError" do
|
26
|
+
-> { list.rotate('hello') }.should raise_error(TypeError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with an argument of zero (or one evenly divisible by list length)" do
|
31
|
+
it "it returns self" do
|
32
|
+
list.rotate(0).should be(list)
|
33
|
+
list.rotate(5).should be(list)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "hamster/list"
|
3
|
+
|
4
|
+
describe Hamster::List do
|
5
|
+
describe "#sample" do
|
6
|
+
let(:list) { Hamster.list(*(1..10)) }
|
7
|
+
|
8
|
+
it "returns a randomly chosen item" do
|
9
|
+
chosen = 100.times.map { list.sample }
|
10
|
+
chosen.each { |item| list.include?(item).should == true }
|
11
|
+
list.each { |item| chosen.include?(item).should == true }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "hamster/list"
|
3
|
+
|
4
|
+
describe Hamster::List do
|
5
|
+
let(:list) { Hamster.list(*values) }
|
6
|
+
let(:selected_list) { Hamster.list(*selected_values) }
|
7
|
+
|
8
|
+
describe "#select" do
|
9
|
+
it "is lazy" do
|
10
|
+
expect { Hamster.stream { fail }.select { |item| false } }.to_not raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
shared_examples "checking values" do
|
14
|
+
context "with a block" do
|
15
|
+
let(:select) { list.select { |item| item == item.upcase } }
|
16
|
+
|
17
|
+
it "preserves the original" do
|
18
|
+
expect(list).to eq(Hamster.list(*values))
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns the selected list" do
|
22
|
+
expect(select).to eq(selected_list)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "without a block" do
|
27
|
+
let(:select) { list.select }
|
28
|
+
|
29
|
+
it "returns an Enumerator" do
|
30
|
+
expect(select.class).to be(Enumerator)
|
31
|
+
expect(select.each { |item| item == item.upcase }).to eq(selected_list)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with an empty array" do
|
37
|
+
let(:values) { [] }
|
38
|
+
let(:selected_values) { [] }
|
39
|
+
|
40
|
+
include_examples "checking values"
|
41
|
+
end
|
42
|
+
|
43
|
+
context "with a single item array" do
|
44
|
+
let(:values) { ["A"] }
|
45
|
+
let(:selected_values) { ["A"] }
|
46
|
+
|
47
|
+
include_examples "checking values"
|
48
|
+
end
|
49
|
+
|
50
|
+
context "with a multi-item array" do
|
51
|
+
let(:values) { %w[A B] }
|
52
|
+
let(:selected_values) { %w[A B] }
|
53
|
+
|
54
|
+
include_examples "checking values"
|
55
|
+
end
|
56
|
+
|
57
|
+
context "with a multi-item single selectable array" do
|
58
|
+
let(:values) { %w[A b] }
|
59
|
+
let(:selected_values) { ["A"] }
|
60
|
+
|
61
|
+
include_examples "checking values"
|
62
|
+
end
|
63
|
+
|
64
|
+
context "with a multi-item multi-selectable array" do
|
65
|
+
let(:values) { %w[a b] }
|
66
|
+
let(:selected_values) { [] }
|
67
|
+
|
68
|
+
include_examples "checking values"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "hamster/list"
|
3
|
+
|
4
|
+
describe Hamster::List do
|
5
|
+
[:size, :length].each do |method|
|
6
|
+
describe "##{method}" do
|
7
|
+
context "on a really big list" do
|
8
|
+
it "doesn't run out of stack" do
|
9
|
+
-> { Hamster.interval(0, STACK_OVERFLOW_DEPTH).size }.should_not raise_error
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
[
|
14
|
+
[[], 0],
|
15
|
+
[["A"], 1],
|
16
|
+
[%w[A B C], 3],
|
17
|
+
].each do |values, expected|
|
18
|
+
context "on #{values.inspect}" do
|
19
|
+
it "returns #{expected.inspect}" do
|
20
|
+
Hamster.list(*values).send(method).should == expected
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "hamster/list"
|
3
|
+
|
4
|
+
describe Hamster::List do
|
5
|
+
let(:list) { Hamster.list(1,2,3,4) }
|
6
|
+
let(:big) { Hamster.list(*1..10000) }
|
7
|
+
|
8
|
+
[:slice, :[]].each do |method|
|
9
|
+
describe "##{method}" do
|
10
|
+
context "when passed a positive integral index" do
|
11
|
+
it "returns the element at that index" do
|
12
|
+
list.send(method, 0).should be(1)
|
13
|
+
list.send(method, 1).should be(2)
|
14
|
+
list.send(method, 2).should be(3)
|
15
|
+
list.send(method, 3).should be(4)
|
16
|
+
list.send(method, 4).should be(nil)
|
17
|
+
list.send(method, 10).should be(nil)
|
18
|
+
|
19
|
+
big.send(method, 0).should be(1)
|
20
|
+
big.send(method, 9999).should be(10000)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "leaves the original unchanged" do
|
24
|
+
list.should eql(Hamster.list(1,2,3,4))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when passed a negative integral index" do
|
29
|
+
it "returns the element which is number (index.abs) counting from the end of the list" do
|
30
|
+
list.send(method, -1).should be(4)
|
31
|
+
list.send(method, -2).should be(3)
|
32
|
+
list.send(method, -3).should be(2)
|
33
|
+
list.send(method, -4).should be(1)
|
34
|
+
list.send(method, -5).should be(nil)
|
35
|
+
list.send(method, -10).should be(nil)
|
36
|
+
|
37
|
+
big.send(method, -1).should be(10000)
|
38
|
+
big.send(method, -10000).should be(1)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when passed a positive integral index and count" do
|
43
|
+
it "returns 'count' elements starting from 'index'" do
|
44
|
+
list.send(method, 0, 0).should eql(Hamster.list)
|
45
|
+
list.send(method, 0, 1).should eql(Hamster.list(1))
|
46
|
+
list.send(method, 0, 2).should eql(Hamster.list(1,2))
|
47
|
+
list.send(method, 0, 4).should eql(Hamster.list(1,2,3,4))
|
48
|
+
list.send(method, 0, 6).should eql(Hamster.list(1,2,3,4))
|
49
|
+
list.send(method, 0, -1).should be_nil
|
50
|
+
list.send(method, 0, -2).should be_nil
|
51
|
+
list.send(method, 0, -4).should be_nil
|
52
|
+
list.send(method, 2, 0).should eql(Hamster.list)
|
53
|
+
list.send(method, 2, 1).should eql(Hamster.list(3))
|
54
|
+
list.send(method, 2, 2).should eql(Hamster.list(3,4))
|
55
|
+
list.send(method, 2, 4).should eql(Hamster.list(3,4))
|
56
|
+
list.send(method, 2, -1).should be_nil
|
57
|
+
list.send(method, 4, 0).should eql(Hamster.list)
|
58
|
+
list.send(method, 4, 2).should eql(Hamster.list)
|
59
|
+
list.send(method, 4, -1).should be_nil
|
60
|
+
list.send(method, 5, 0).should be_nil
|
61
|
+
list.send(method, 5, 2).should be_nil
|
62
|
+
list.send(method, 5, -1).should be_nil
|
63
|
+
list.send(method, 6, 0).should be_nil
|
64
|
+
list.send(method, 6, 2).should be_nil
|
65
|
+
list.send(method, 6, -1).should be_nil
|
66
|
+
|
67
|
+
big.send(method, 0, 3).should eql(Hamster.list(1,2,3))
|
68
|
+
big.send(method, 1023, 4).should eql(Hamster.list(1024,1025,1026,1027))
|
69
|
+
big.send(method, 1024, 4).should eql(Hamster.list(1025,1026,1027,1028))
|
70
|
+
end
|
71
|
+
|
72
|
+
it "leaves the original unchanged" do
|
73
|
+
list.should eql(Hamster.list(1,2,3,4))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when passed a negative integral index and count" do
|
78
|
+
it "returns 'count' elements, starting from index which is number 'index.abs' counting from the end of the array" do
|
79
|
+
list.send(method, -1, 0).should eql(Hamster.list)
|
80
|
+
list.send(method, -1, 1).should eql(Hamster.list(4))
|
81
|
+
list.send(method, -1, 2).should eql(Hamster.list(4))
|
82
|
+
list.send(method, -1, -1).should be_nil
|
83
|
+
list.send(method, -2, 0).should eql(Hamster.list)
|
84
|
+
list.send(method, -2, 1).should eql(Hamster.list(3))
|
85
|
+
list.send(method, -2, 2).should eql(Hamster.list(3,4))
|
86
|
+
list.send(method, -2, 4).should eql(Hamster.list(3,4))
|
87
|
+
list.send(method, -2, -1).should be_nil
|
88
|
+
list.send(method, -4, 0).should eql(Hamster.list)
|
89
|
+
list.send(method, -4, 1).should eql(Hamster.list(1))
|
90
|
+
list.send(method, -4, 2).should eql(Hamster.list(1,2))
|
91
|
+
list.send(method, -4, 4).should eql(Hamster.list(1,2,3,4))
|
92
|
+
list.send(method, -4, 6).should eql(Hamster.list(1,2,3,4))
|
93
|
+
list.send(method, -4, -1).should be_nil
|
94
|
+
list.send(method, -5, 0).should be_nil
|
95
|
+
list.send(method, -5, 1).should be_nil
|
96
|
+
list.send(method, -5, 10).should be_nil
|
97
|
+
list.send(method, -5, -1).should be_nil
|
98
|
+
|
99
|
+
big.send(method, -1, 1).should eql(Hamster.list(10000))
|
100
|
+
big.send(method, -1, 2).should eql(Hamster.list(10000))
|
101
|
+
big.send(method, -6, 2).should eql(Hamster.list(9995,9996))
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context "when passed a Range" do
|
106
|
+
it "returns the elements whose indexes are within the given Range" do
|
107
|
+
list.send(method, 0..-1).should eql(Hamster.list(1,2,3,4))
|
108
|
+
list.send(method, 0..-10).should eql(Hamster.list)
|
109
|
+
list.send(method, 0..0).should eql(Hamster.list(1))
|
110
|
+
list.send(method, 0..1).should eql(Hamster.list(1,2))
|
111
|
+
list.send(method, 0..2).should eql(Hamster.list(1,2,3))
|
112
|
+
list.send(method, 0..3).should eql(Hamster.list(1,2,3,4))
|
113
|
+
list.send(method, 0..4).should eql(Hamster.list(1,2,3,4))
|
114
|
+
list.send(method, 0..10).should eql(Hamster.list(1,2,3,4))
|
115
|
+
list.send(method, 2..-10).should eql(Hamster.list)
|
116
|
+
list.send(method, 2..0).should eql(Hamster.list)
|
117
|
+
list.send(method, 2..2).should eql(Hamster.list(3))
|
118
|
+
list.send(method, 2..3).should eql(Hamster.list(3,4))
|
119
|
+
list.send(method, 2..4).should eql(Hamster.list(3,4))
|
120
|
+
list.send(method, 3..0).should eql(Hamster.list)
|
121
|
+
list.send(method, 3..3).should eql(Hamster.list(4))
|
122
|
+
list.send(method, 3..4).should eql(Hamster.list(4))
|
123
|
+
list.send(method, 4..0).should eql(Hamster.list)
|
124
|
+
list.send(method, 4..4).should eql(Hamster.list)
|
125
|
+
list.send(method, 4..5).should eql(Hamster.list)
|
126
|
+
list.send(method, 5..0).should be_nil
|
127
|
+
list.send(method, 5..5).should be_nil
|
128
|
+
list.send(method, 5..6).should be_nil
|
129
|
+
|
130
|
+
big.send(method, 159..162).should eql(Hamster.list(160,161,162,163))
|
131
|
+
big.send(method, 160..162).should eql(Hamster.list(161,162,163))
|
132
|
+
big.send(method, 161..162).should eql(Hamster.list(162,163))
|
133
|
+
big.send(method, 9999..10100).should eql(Hamster.list(10000))
|
134
|
+
big.send(method, 10000..10100).should eql(Hamster.list)
|
135
|
+
big.send(method, 10001..10100).should be_nil
|
136
|
+
|
137
|
+
list.send(method, 0...-1).should eql(Hamster.list(1,2,3))
|
138
|
+
list.send(method, 0...-10).should eql(Hamster.list)
|
139
|
+
list.send(method, 0...0).should eql(Hamster.list)
|
140
|
+
list.send(method, 0...1).should eql(Hamster.list(1))
|
141
|
+
list.send(method, 0...2).should eql(Hamster.list(1,2))
|
142
|
+
list.send(method, 0...3).should eql(Hamster.list(1,2,3))
|
143
|
+
list.send(method, 0...4).should eql(Hamster.list(1,2,3,4))
|
144
|
+
list.send(method, 0...10).should eql(Hamster.list(1,2,3,4))
|
145
|
+
list.send(method, 2...-10).should eql(Hamster.list)
|
146
|
+
list.send(method, 2...0).should eql(Hamster.list)
|
147
|
+
list.send(method, 2...2).should eql(Hamster.list)
|
148
|
+
list.send(method, 2...3).should eql(Hamster.list(3))
|
149
|
+
list.send(method, 2...4).should eql(Hamster.list(3,4))
|
150
|
+
list.send(method, 3...0).should eql(Hamster.list)
|
151
|
+
list.send(method, 3...3).should eql(Hamster.list)
|
152
|
+
list.send(method, 3...4).should eql(Hamster.list(4))
|
153
|
+
list.send(method, 4...0).should eql(Hamster.list)
|
154
|
+
list.send(method, 4...4).should eql(Hamster.list)
|
155
|
+
list.send(method, 4...5).should eql(Hamster.list)
|
156
|
+
list.send(method, 5...0).should be_nil
|
157
|
+
list.send(method, 5...5).should be_nil
|
158
|
+
list.send(method, 5...6).should be_nil
|
159
|
+
|
160
|
+
big.send(method, 159...162).should eql(Hamster.list(160,161,162))
|
161
|
+
big.send(method, 160...162).should eql(Hamster.list(161,162))
|
162
|
+
big.send(method, 161...162).should eql(Hamster.list(162))
|
163
|
+
big.send(method, 9999...10100).should eql(Hamster.list(10000))
|
164
|
+
big.send(method, 10000...10100).should eql(Hamster.list)
|
165
|
+
big.send(method, 10001...10100).should be_nil
|
166
|
+
|
167
|
+
list.send(method, -1..-1).should eql(Hamster.list(4))
|
168
|
+
list.send(method, -1...-1).should eql(Hamster.list)
|
169
|
+
list.send(method, -1..3).should eql(Hamster.list(4))
|
170
|
+
list.send(method, -1...3).should eql(Hamster.list)
|
171
|
+
list.send(method, -1..4).should eql(Hamster.list(4))
|
172
|
+
list.send(method, -1...4).should eql(Hamster.list(4))
|
173
|
+
list.send(method, -1..10).should eql(Hamster.list(4))
|
174
|
+
list.send(method, -1...10).should eql(Hamster.list(4))
|
175
|
+
list.send(method, -1..0).should eql(Hamster.list)
|
176
|
+
list.send(method, -1..-4).should eql(Hamster.list)
|
177
|
+
list.send(method, -1...-4).should eql(Hamster.list)
|
178
|
+
list.send(method, -1..-6).should eql(Hamster.list)
|
179
|
+
list.send(method, -1...-6).should eql(Hamster.list)
|
180
|
+
list.send(method, -2..-2).should eql(Hamster.list(3))
|
181
|
+
list.send(method, -2...-2).should eql(Hamster.list)
|
182
|
+
list.send(method, -2..-1).should eql(Hamster.list(3,4))
|
183
|
+
list.send(method, -2...-1).should eql(Hamster.list(3))
|
184
|
+
list.send(method, -2..10).should eql(Hamster.list(3,4))
|
185
|
+
list.send(method, -2...10).should eql(Hamster.list(3,4))
|
186
|
+
|
187
|
+
big.send(method, -1..-1).should eql(Hamster.list(10000))
|
188
|
+
big.send(method, -1..9999).should eql(Hamster.list(10000))
|
189
|
+
big.send(method, -1...9999).should eql(Hamster.list)
|
190
|
+
big.send(method, -2...9999).should eql(Hamster.list(9999))
|
191
|
+
big.send(method, -2..-1).should eql(Hamster.list(9999,10000))
|
192
|
+
|
193
|
+
list.send(method, -4..-4).should eql(Hamster.list(1))
|
194
|
+
list.send(method, -4..-2).should eql(Hamster.list(1,2,3))
|
195
|
+
list.send(method, -4...-2).should eql(Hamster.list(1,2))
|
196
|
+
list.send(method, -4..-1).should eql(Hamster.list(1,2,3,4))
|
197
|
+
list.send(method, -4...-1).should eql(Hamster.list(1,2,3))
|
198
|
+
list.send(method, -4..3).should eql(Hamster.list(1,2,3,4))
|
199
|
+
list.send(method, -4...3).should eql(Hamster.list(1,2,3))
|
200
|
+
list.send(method, -4..4).should eql(Hamster.list(1,2,3,4))
|
201
|
+
list.send(method, -4...4).should eql(Hamster.list(1,2,3,4))
|
202
|
+
list.send(method, -4..0).should eql(Hamster.list(1))
|
203
|
+
list.send(method, -4...0).should eql(Hamster.list)
|
204
|
+
list.send(method, -4..1).should eql(Hamster.list(1,2))
|
205
|
+
list.send(method, -4...1).should eql(Hamster.list(1))
|
206
|
+
|
207
|
+
list.send(method, -5..-5).should be_nil
|
208
|
+
list.send(method, -5...-5).should be_nil
|
209
|
+
list.send(method, -5..-4).should be_nil
|
210
|
+
list.send(method, -5..-1).should be_nil
|
211
|
+
list.send(method, -5..10).should be_nil
|
212
|
+
|
213
|
+
big.send(method, -10001..-1).should be_nil
|
214
|
+
end
|
215
|
+
|
216
|
+
it "leaves the original unchanged" do
|
217
|
+
list.should eql(Hamster.list(1,2,3,4))
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
context "when passed a subclass of Range" do
|
223
|
+
it "works the same as with a Range" do
|
224
|
+
subclass = Class.new(Range)
|
225
|
+
list.send(method, subclass.new(1,2)).should eql(Hamster.list(2,3))
|
226
|
+
list.send(method, subclass.new(-3,-1,true)).should eql(Hamster.list(2,3))
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|