immutable-ruby 0.0.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immutable/_core.rb +3067 -0
- data/lib/immutable/core_ext/enumerable.rb +1 -1
- data/lib/immutable/core_ext/io.rb +1 -1
- data/lib/immutable/core_ext.rb +2 -2
- data/lib/immutable/deque.rb +17 -17
- data/lib/immutable/enumerable.rb +10 -10
- data/lib/immutable/hash.rb +4 -941
- data/lib/immutable/list.rb +36 -36
- data/lib/immutable/nested.rb +8 -8
- data/lib/immutable/set.rb +3 -583
- data/lib/immutable/sorted_set.rb +29 -27
- data/lib/immutable/trie.rb +2 -2
- data/lib/immutable/vector.rb +3 -1549
- data/lib/immutable/version.rb +1 -1
- data/lib/immutable.rb +9 -9
- metadata +34 -696
- data/lib/immutable/core_ext/struct.rb +0 -9
- data/spec/fixtures/io_spec.txt +0 -3
- data/spec/lib/immutable/core_ext/array_spec.rb +0 -13
- data/spec/lib/immutable/core_ext/enumerable_spec.rb +0 -29
- data/spec/lib/immutable/core_ext/io_spec.rb +0 -28
- data/spec/lib/immutable/deque/clear_spec.rb +0 -33
- data/spec/lib/immutable/deque/construction_spec.rb +0 -29
- data/spec/lib/immutable/deque/copying_spec.rb +0 -19
- data/spec/lib/immutable/deque/dequeue_spec.rb +0 -34
- data/spec/lib/immutable/deque/empty_spec.rb +0 -39
- data/spec/lib/immutable/deque/enqueue_spec.rb +0 -27
- data/spec/lib/immutable/deque/first_spec.rb +0 -17
- data/spec/lib/immutable/deque/inspect_spec.rb +0 -23
- data/spec/lib/immutable/deque/last_spec.rb +0 -17
- data/spec/lib/immutable/deque/marshal_spec.rb +0 -33
- data/spec/lib/immutable/deque/new_spec.rb +0 -43
- data/spec/lib/immutable/deque/pop_spec.rb +0 -36
- data/spec/lib/immutable/deque/pretty_print_spec.rb +0 -23
- data/spec/lib/immutable/deque/push_spec.rb +0 -36
- data/spec/lib/immutable/deque/random_modification_spec.rb +0 -33
- data/spec/lib/immutable/deque/rotate_spec.rb +0 -68
- data/spec/lib/immutable/deque/shift_spec.rb +0 -29
- data/spec/lib/immutable/deque/size_spec.rb +0 -19
- data/spec/lib/immutable/deque/to_a_spec.rb +0 -26
- data/spec/lib/immutable/deque/to_ary_spec.rb +0 -35
- data/spec/lib/immutable/deque/to_list_spec.rb +0 -24
- data/spec/lib/immutable/deque/unshift_spec.rb +0 -30
- data/spec/lib/immutable/hash/all_spec.rb +0 -53
- data/spec/lib/immutable/hash/any_spec.rb +0 -53
- data/spec/lib/immutable/hash/assoc_spec.rb +0 -51
- data/spec/lib/immutable/hash/clear_spec.rb +0 -42
- data/spec/lib/immutable/hash/construction_spec.rb +0 -38
- data/spec/lib/immutable/hash/copying_spec.rb +0 -13
- data/spec/lib/immutable/hash/default_proc_spec.rb +0 -72
- data/spec/lib/immutable/hash/delete_spec.rb +0 -39
- data/spec/lib/immutable/hash/dig_spec.rb +0 -34
- data/spec/lib/immutable/hash/each_spec.rb +0 -77
- data/spec/lib/immutable/hash/each_with_index_spec.rb +0 -29
- data/spec/lib/immutable/hash/empty_spec.rb +0 -43
- data/spec/lib/immutable/hash/eql_spec.rb +0 -75
- data/spec/lib/immutable/hash/except_spec.rb +0 -42
- data/spec/lib/immutable/hash/fetch_spec.rb +0 -57
- data/spec/lib/immutable/hash/fetch_values_spec.rb +0 -22
- data/spec/lib/immutable/hash/find_spec.rb +0 -43
- data/spec/lib/immutable/hash/flat_map_spec.rb +0 -35
- data/spec/lib/immutable/hash/flatten_spec.rb +0 -98
- data/spec/lib/immutable/hash/get_spec.rb +0 -79
- data/spec/lib/immutable/hash/has_key_spec.rb +0 -31
- data/spec/lib/immutable/hash/has_value_spec.rb +0 -27
- data/spec/lib/immutable/hash/hash_spec.rb +0 -29
- data/spec/lib/immutable/hash/inspect_spec.rb +0 -30
- data/spec/lib/immutable/hash/invert_spec.rb +0 -30
- data/spec/lib/immutable/hash/key_spec.rb +0 -27
- data/spec/lib/immutable/hash/keys_spec.rb +0 -15
- data/spec/lib/immutable/hash/map_spec.rb +0 -45
- data/spec/lib/immutable/hash/marshal_spec.rb +0 -28
- data/spec/lib/immutable/hash/merge_spec.rb +0 -82
- data/spec/lib/immutable/hash/min_max_spec.rb +0 -45
- data/spec/lib/immutable/hash/new_spec.rb +0 -70
- data/spec/lib/immutable/hash/none_spec.rb +0 -48
- data/spec/lib/immutable/hash/partition_spec.rb +0 -35
- data/spec/lib/immutable/hash/pretty_print_spec.rb +0 -34
- data/spec/lib/immutable/hash/put_spec.rb +0 -111
- data/spec/lib/immutable/hash/reduce_spec.rb +0 -35
- data/spec/lib/immutable/hash/reject_spec.rb +0 -61
- data/spec/lib/immutable/hash/reverse_each_spec.rb +0 -27
- data/spec/lib/immutable/hash/sample_spec.rb +0 -13
- data/spec/lib/immutable/hash/select_spec.rb +0 -57
- data/spec/lib/immutable/hash/size_spec.rb +0 -51
- data/spec/lib/immutable/hash/slice_spec.rb +0 -44
- data/spec/lib/immutable/hash/sort_spec.rb +0 -26
- data/spec/lib/immutable/hash/store_spec.rb +0 -75
- data/spec/lib/immutable/hash/subset_spec.rb +0 -42
- data/spec/lib/immutable/hash/superset_spec.rb +0 -42
- data/spec/lib/immutable/hash/take_spec.rb +0 -35
- data/spec/lib/immutable/hash/to_a_spec.rb +0 -13
- data/spec/lib/immutable/hash/to_hash_spec.rb +0 -21
- data/spec/lib/immutable/hash/to_proc_spec.rb +0 -39
- data/spec/lib/immutable/hash/update_in_spec.rb +0 -79
- data/spec/lib/immutable/hash/values_at_spec.rb +0 -33
- data/spec/lib/immutable/hash/values_spec.rb +0 -23
- data/spec/lib/immutable/list/add_spec.rb +0 -25
- data/spec/lib/immutable/list/all_spec.rb +0 -57
- data/spec/lib/immutable/list/any_spec.rb +0 -49
- data/spec/lib/immutable/list/append_spec.rb +0 -38
- data/spec/lib/immutable/list/at_spec.rb +0 -29
- data/spec/lib/immutable/list/break_spec.rb +0 -69
- data/spec/lib/immutable/list/cadr_spec.rb +0 -38
- data/spec/lib/immutable/list/chunk_spec.rb +0 -28
- data/spec/lib/immutable/list/clear_spec.rb +0 -24
- data/spec/lib/immutable/list/combination_spec.rb +0 -33
- data/spec/lib/immutable/list/compact_spec.rb +0 -34
- data/spec/lib/immutable/list/compare_spec.rb +0 -30
- data/spec/lib/immutable/list/cons_spec.rb +0 -25
- data/spec/lib/immutable/list/construction_spec.rb +0 -110
- data/spec/lib/immutable/list/copying_spec.rb +0 -19
- data/spec/lib/immutable/list/count_spec.rb +0 -36
- data/spec/lib/immutable/list/cycle_spec.rb +0 -28
- data/spec/lib/immutable/list/delete_at_spec.rb +0 -18
- data/spec/lib/immutable/list/delete_spec.rb +0 -16
- data/spec/lib/immutable/list/drop_spec.rb +0 -30
- data/spec/lib/immutable/list/drop_while_spec.rb +0 -38
- data/spec/lib/immutable/list/each_slice_spec.rb +0 -51
- data/spec/lib/immutable/list/each_spec.rb +0 -40
- data/spec/lib/immutable/list/each_with_index_spec.rb +0 -28
- data/spec/lib/immutable/list/empty_spec.rb +0 -23
- data/spec/lib/immutable/list/eql_spec.rb +0 -61
- data/spec/lib/immutable/list/fill_spec.rb +0 -49
- data/spec/lib/immutable/list/find_all_spec.rb +0 -70
- data/spec/lib/immutable/list/find_index_spec.rb +0 -35
- data/spec/lib/immutable/list/find_spec.rb +0 -42
- data/spec/lib/immutable/list/flat_map_spec.rb +0 -51
- data/spec/lib/immutable/list/flatten_spec.rb +0 -30
- data/spec/lib/immutable/list/grep_spec.rb +0 -46
- data/spec/lib/immutable/list/group_by_spec.rb +0 -41
- data/spec/lib/immutable/list/hash_spec.rb +0 -21
- data/spec/lib/immutable/list/head_spec.rb +0 -19
- data/spec/lib/immutable/list/include_spec.rb +0 -35
- data/spec/lib/immutable/list/index_spec.rb +0 -37
- data/spec/lib/immutable/list/indices_spec.rb +0 -61
- data/spec/lib/immutable/list/init_spec.rb +0 -28
- data/spec/lib/immutable/list/inits_spec.rb +0 -28
- data/spec/lib/immutable/list/insert_spec.rb +0 -46
- data/spec/lib/immutable/list/inspect_spec.rb +0 -29
- data/spec/lib/immutable/list/intersperse_spec.rb +0 -28
- data/spec/lib/immutable/list/join_spec.rb +0 -63
- data/spec/lib/immutable/list/last_spec.rb +0 -23
- data/spec/lib/immutable/list/ltlt_spec.rb +0 -19
- data/spec/lib/immutable/list/map_spec.rb +0 -45
- data/spec/lib/immutable/list/maximum_spec.rb +0 -39
- data/spec/lib/immutable/list/merge_by_spec.rb +0 -51
- data/spec/lib/immutable/list/merge_spec.rb +0 -59
- data/spec/lib/immutable/list/minimum_spec.rb +0 -39
- data/spec/lib/immutable/list/multithreading_spec.rb +0 -47
- data/spec/lib/immutable/list/none_spec.rb +0 -47
- data/spec/lib/immutable/list/one_spec.rb +0 -49
- data/spec/lib/immutable/list/partition_spec.rb +0 -115
- data/spec/lib/immutable/list/permutation_spec.rb +0 -55
- data/spec/lib/immutable/list/pop_spec.rb +0 -25
- data/spec/lib/immutable/list/product_spec.rb +0 -23
- data/spec/lib/immutable/list/reduce_spec.rb +0 -53
- data/spec/lib/immutable/list/reject_spec.rb +0 -45
- data/spec/lib/immutable/list/reverse_spec.rb +0 -34
- data/spec/lib/immutable/list/rotate_spec.rb +0 -36
- data/spec/lib/immutable/list/sample_spec.rb +0 -13
- data/spec/lib/immutable/list/select_spec.rb +0 -70
- data/spec/lib/immutable/list/size_spec.rb +0 -25
- data/spec/lib/immutable/list/slice_spec.rb +0 -229
- data/spec/lib/immutable/list/sorting_spec.rb +0 -46
- data/spec/lib/immutable/list/span_spec.rb +0 -76
- data/spec/lib/immutable/list/split_at_spec.rb +0 -43
- data/spec/lib/immutable/list/subsequences_spec.rb +0 -23
- data/spec/lib/immutable/list/sum_spec.rb +0 -23
- data/spec/lib/immutable/list/tail_spec.rb +0 -30
- data/spec/lib/immutable/list/tails_spec.rb +0 -28
- data/spec/lib/immutable/list/take_spec.rb +0 -30
- data/spec/lib/immutable/list/take_while_spec.rb +0 -46
- data/spec/lib/immutable/list/to_a_spec.rb +0 -39
- data/spec/lib/immutable/list/to_ary_spec.rb +0 -41
- data/spec/lib/immutable/list/to_list_spec.rb +0 -19
- data/spec/lib/immutable/list/to_set_spec.rb +0 -17
- data/spec/lib/immutable/list/transpose_spec.rb +0 -19
- data/spec/lib/immutable/list/union_spec.rb +0 -31
- data/spec/lib/immutable/list/uniq_spec.rb +0 -35
- data/spec/lib/immutable/list/zip_spec.rb +0 -23
- data/spec/lib/immutable/nested/construction_spec.rb +0 -101
- data/spec/lib/immutable/set/add_spec.rb +0 -77
- data/spec/lib/immutable/set/all_spec.rb +0 -51
- data/spec/lib/immutable/set/any_spec.rb +0 -51
- data/spec/lib/immutable/set/clear_spec.rb +0 -33
- data/spec/lib/immutable/set/compact_spec.rb +0 -30
- data/spec/lib/immutable/set/construction_spec.rb +0 -18
- data/spec/lib/immutable/set/copying_spec.rb +0 -13
- data/spec/lib/immutable/set/count_spec.rb +0 -36
- data/spec/lib/immutable/set/delete_spec.rb +0 -71
- data/spec/lib/immutable/set/difference_spec.rb +0 -49
- data/spec/lib/immutable/set/disjoint_spec.rb +0 -25
- data/spec/lib/immutable/set/each_spec.rb +0 -45
- data/spec/lib/immutable/set/empty_spec.rb +0 -44
- data/spec/lib/immutable/set/eqeq_spec.rb +0 -103
- data/spec/lib/immutable/set/eql_spec.rb +0 -109
- data/spec/lib/immutable/set/exclusion_spec.rb +0 -47
- data/spec/lib/immutable/set/find_spec.rb +0 -35
- data/spec/lib/immutable/set/first_spec.rb +0 -28
- data/spec/lib/immutable/set/flatten_spec.rb +0 -46
- data/spec/lib/immutable/set/grep_spec.rb +0 -57
- data/spec/lib/immutable/set/grep_v_spec.rb +0 -59
- data/spec/lib/immutable/set/group_by_spec.rb +0 -59
- data/spec/lib/immutable/set/hash_spec.rb +0 -22
- data/spec/lib/immutable/set/include_spec.rb +0 -60
- data/spec/lib/immutable/set/inspect_spec.rb +0 -47
- data/spec/lib/immutable/set/intersect_spec.rb +0 -25
- data/spec/lib/immutable/set/intersection_spec.rb +0 -52
- data/spec/lib/immutable/set/join_spec.rb +0 -64
- data/spec/lib/immutable/set/map_spec.rb +0 -59
- data/spec/lib/immutable/set/marshal_spec.rb +0 -28
- data/spec/lib/immutable/set/maximum_spec.rb +0 -36
- data/spec/lib/immutable/set/minimum_spec.rb +0 -36
- data/spec/lib/immutable/set/new_spec.rb +0 -53
- data/spec/lib/immutable/set/none_spec.rb +0 -47
- data/spec/lib/immutable/set/one_spec.rb +0 -47
- data/spec/lib/immutable/set/partition_spec.rb +0 -52
- data/spec/lib/immutable/set/product_spec.rb +0 -23
- data/spec/lib/immutable/set/reduce_spec.rb +0 -55
- data/spec/lib/immutable/set/reject_spec.rb +0 -50
- data/spec/lib/immutable/set/reverse_each_spec.rb +0 -38
- data/spec/lib/immutable/set/sample_spec.rb +0 -13
- data/spec/lib/immutable/set/select_spec.rb +0 -73
- data/spec/lib/immutable/set/size_spec.rb +0 -17
- data/spec/lib/immutable/set/sorting_spec.rb +0 -65
- data/spec/lib/immutable/set/subset_spec.rb +0 -51
- data/spec/lib/immutable/set/sum_spec.rb +0 -23
- data/spec/lib/immutable/set/superset_spec.rb +0 -51
- data/spec/lib/immutable/set/to_a_spec.rb +0 -30
- data/spec/lib/immutable/set/to_list_spec.rb +0 -35
- data/spec/lib/immutable/set/to_set_spec.rb +0 -19
- data/spec/lib/immutable/set/union_spec.rb +0 -63
- data/spec/lib/immutable/sorted_set/above_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/add_spec.rb +0 -62
- data/spec/lib/immutable/sorted_set/at_spec.rb +0 -24
- data/spec/lib/immutable/sorted_set/below_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/between_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/clear_spec.rb +0 -43
- data/spec/lib/immutable/sorted_set/copying_spec.rb +0 -20
- data/spec/lib/immutable/sorted_set/delete_at_spec.rb +0 -18
- data/spec/lib/immutable/sorted_set/delete_spec.rb +0 -89
- data/spec/lib/immutable/sorted_set/difference_spec.rb +0 -22
- data/spec/lib/immutable/sorted_set/disjoint_spec.rb +0 -25
- data/spec/lib/immutable/sorted_set/drop_spec.rb +0 -55
- data/spec/lib/immutable/sorted_set/drop_while_spec.rb +0 -34
- data/spec/lib/immutable/sorted_set/each_spec.rb +0 -28
- data/spec/lib/immutable/sorted_set/empty_spec.rb +0 -34
- data/spec/lib/immutable/sorted_set/eql_spec.rb +0 -120
- data/spec/lib/immutable/sorted_set/exclusion_spec.rb +0 -22
- data/spec/lib/immutable/sorted_set/fetch_spec.rb +0 -64
- data/spec/lib/immutable/sorted_set/find_index_spec.rb +0 -40
- data/spec/lib/immutable/sorted_set/first_spec.rb +0 -18
- data/spec/lib/immutable/sorted_set/from_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/group_by_spec.rb +0 -57
- data/spec/lib/immutable/sorted_set/include_spec.rb +0 -23
- data/spec/lib/immutable/sorted_set/inspect_spec.rb +0 -37
- data/spec/lib/immutable/sorted_set/intersect_spec.rb +0 -25
- data/spec/lib/immutable/sorted_set/intersection_spec.rb +0 -28
- data/spec/lib/immutable/sorted_set/last_spec.rb +0 -36
- data/spec/lib/immutable/sorted_set/map_spec.rb +0 -51
- data/spec/lib/immutable/sorted_set/marshal_spec.rb +0 -36
- data/spec/lib/immutable/sorted_set/maximum_spec.rb +0 -36
- data/spec/lib/immutable/sorted_set/minimum_spec.rb +0 -19
- data/spec/lib/immutable/sorted_set/new_spec.rb +0 -137
- data/spec/lib/immutable/sorted_set/reverse_each_spec.rb +0 -28
- data/spec/lib/immutable/sorted_set/sample_spec.rb +0 -13
- data/spec/lib/immutable/sorted_set/select_spec.rb +0 -61
- data/spec/lib/immutable/sorted_set/size_spec.rb +0 -17
- data/spec/lib/immutable/sorted_set/slice_spec.rb +0 -256
- data/spec/lib/immutable/sorted_set/sorting_spec.rb +0 -56
- data/spec/lib/immutable/sorted_set/subset_spec.rb +0 -47
- data/spec/lib/immutable/sorted_set/superset_spec.rb +0 -47
- data/spec/lib/immutable/sorted_set/take_spec.rb +0 -54
- data/spec/lib/immutable/sorted_set/take_while_spec.rb +0 -33
- data/spec/lib/immutable/sorted_set/to_set_spec.rb +0 -17
- data/spec/lib/immutable/sorted_set/union_spec.rb +0 -58
- data/spec/lib/immutable/sorted_set/up_to_spec.rb +0 -52
- data/spec/lib/immutable/sorted_set/util_spec.rb +0 -48
- data/spec/lib/immutable/sorted_set/values_at_spec.rb +0 -33
- data/spec/lib/immutable/vector/add_spec.rb +0 -67
- data/spec/lib/immutable/vector/any_spec.rb +0 -69
- data/spec/lib/immutable/vector/assoc_spec.rb +0 -45
- data/spec/lib/immutable/vector/bsearch_spec.rb +0 -65
- data/spec/lib/immutable/vector/clear_spec.rb +0 -33
- data/spec/lib/immutable/vector/combination_spec.rb +0 -81
- data/spec/lib/immutable/vector/compact_spec.rb +0 -29
- data/spec/lib/immutable/vector/compare_spec.rb +0 -31
- data/spec/lib/immutable/vector/concat_spec.rb +0 -34
- data/spec/lib/immutable/vector/copying_spec.rb +0 -20
- data/spec/lib/immutable/vector/count_spec.rb +0 -17
- data/spec/lib/immutable/vector/delete_at_spec.rb +0 -53
- data/spec/lib/immutable/vector/delete_spec.rb +0 -30
- data/spec/lib/immutable/vector/dig_spec.rb +0 -30
- data/spec/lib/immutable/vector/drop_spec.rb +0 -41
- data/spec/lib/immutable/vector/drop_while_spec.rb +0 -54
- data/spec/lib/immutable/vector/each_index_spec.rb +0 -40
- data/spec/lib/immutable/vector/each_spec.rb +0 -44
- data/spec/lib/immutable/vector/each_with_index_spec.rb +0 -39
- data/spec/lib/immutable/vector/empty_spec.rb +0 -41
- data/spec/lib/immutable/vector/eql_spec.rb +0 -76
- data/spec/lib/immutable/vector/fetch_spec.rb +0 -64
- data/spec/lib/immutable/vector/fill_spec.rb +0 -88
- data/spec/lib/immutable/vector/first_spec.rb +0 -18
- data/spec/lib/immutable/vector/flat_map_spec.rb +0 -50
- data/spec/lib/immutable/vector/flatten_spec.rb +0 -58
- data/spec/lib/immutable/vector/get_spec.rb +0 -74
- data/spec/lib/immutable/vector/group_by_spec.rb +0 -57
- data/spec/lib/immutable/vector/include_spec.rb +0 -30
- data/spec/lib/immutable/vector/insert_spec.rb +0 -68
- data/spec/lib/immutable/vector/inspect_spec.rb +0 -49
- data/spec/lib/immutable/vector/join_spec.rb +0 -58
- data/spec/lib/immutable/vector/last_spec.rb +0 -45
- data/spec/lib/immutable/vector/length_spec.rb +0 -45
- data/spec/lib/immutable/vector/ltlt_spec.rb +0 -65
- data/spec/lib/immutable/vector/map_spec.rb +0 -51
- data/spec/lib/immutable/vector/marshal_spec.rb +0 -31
- data/spec/lib/immutable/vector/maximum_spec.rb +0 -33
- data/spec/lib/immutable/vector/minimum_spec.rb +0 -33
- data/spec/lib/immutable/vector/multiply_spec.rb +0 -47
- data/spec/lib/immutable/vector/new_spec.rb +0 -50
- data/spec/lib/immutable/vector/partition_spec.rb +0 -52
- data/spec/lib/immutable/vector/permutation_spec.rb +0 -91
- data/spec/lib/immutable/vector/pop_spec.rb +0 -26
- data/spec/lib/immutable/vector/product_spec.rb +0 -70
- data/spec/lib/immutable/vector/reduce_spec.rb +0 -55
- data/spec/lib/immutable/vector/reject_spec.rb +0 -43
- data/spec/lib/immutable/vector/repeated_combination_spec.rb +0 -77
- data/spec/lib/immutable/vector/repeated_permutation_spec.rb +0 -93
- data/spec/lib/immutable/vector/reverse_each_spec.rb +0 -31
- data/spec/lib/immutable/vector/reverse_spec.rb +0 -21
- data/spec/lib/immutable/vector/rindex_spec.rb +0 -36
- data/spec/lib/immutable/vector/rotate_spec.rb +0 -73
- data/spec/lib/immutable/vector/sample_spec.rb +0 -13
- data/spec/lib/immutable/vector/select_spec.rb +0 -63
- data/spec/lib/immutable/vector/set_spec.rb +0 -174
- data/spec/lib/immutable/vector/shift_spec.rb +0 -27
- data/spec/lib/immutable/vector/shuffle_spec.rb +0 -43
- data/spec/lib/immutable/vector/slice_spec.rb +0 -240
- data/spec/lib/immutable/vector/sorting_spec.rb +0 -56
- data/spec/lib/immutable/vector/sum_spec.rb +0 -17
- data/spec/lib/immutable/vector/take_spec.rb +0 -42
- data/spec/lib/immutable/vector/take_while_spec.rb +0 -34
- data/spec/lib/immutable/vector/to_a_spec.rb +0 -41
- data/spec/lib/immutable/vector/to_ary_spec.rb +0 -34
- data/spec/lib/immutable/vector/to_list_spec.rb +0 -30
- data/spec/lib/immutable/vector/to_set_spec.rb +0 -21
- data/spec/lib/immutable/vector/transpose_spec.rb +0 -48
- data/spec/lib/immutable/vector/uniq_spec.rb +0 -76
- data/spec/lib/immutable/vector/unshift_spec.rb +0 -28
- data/spec/lib/immutable/vector/update_in_spec.rb +0 -82
- data/spec/lib/immutable/vector/values_at_spec.rb +0 -33
- data/spec/lib/immutable/vector/zip_spec.rb +0 -57
- data/spec/lib/load_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -96
@@ -1,25 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::Set do
|
4
|
-
describe "#disjoint?" do
|
5
|
-
[
|
6
|
-
[[], [], true],
|
7
|
-
[["A"], [], true],
|
8
|
-
[[], ["A"], true],
|
9
|
-
[["A"], ["A"], false],
|
10
|
-
[%w[A B C], ["B"], false],
|
11
|
-
[["B"], %w[A B C], false],
|
12
|
-
[%w[A B C], %w[D E], true],
|
13
|
-
[%w[F G H I], %w[A B C], true],
|
14
|
-
[%w[A B C], %w[A B C], false],
|
15
|
-
[%w[A B C], %w[A B C D], false],
|
16
|
-
[%w[D E F G], %w[A B C], true],
|
17
|
-
].each do |a, b, expected|
|
18
|
-
describe "for #{a.inspect} and #{b.inspect}" do
|
19
|
-
it "returns #{expected}" do
|
20
|
-
S[*a].disjoint?(S[*b]).should be(expected)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "set"
|
3
|
-
|
4
|
-
describe Immutable::Set do
|
5
|
-
let(:set) { S["A", "B", "C"] }
|
6
|
-
|
7
|
-
describe "#each" do
|
8
|
-
let(:each) { set.each(&block) }
|
9
|
-
|
10
|
-
context "without a block" do
|
11
|
-
let(:block) { nil }
|
12
|
-
|
13
|
-
it "returns an Enumerator" do
|
14
|
-
expect(each.class).to be(Enumerator)
|
15
|
-
expect(each.to_a).to eq(set.to_a)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context "with an empty block" do
|
20
|
-
let(:block) { ->(item) {} }
|
21
|
-
|
22
|
-
it "returns self" do
|
23
|
-
expect(each).to be(set)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "with a block" do
|
28
|
-
let(:items) { ::Set.new }
|
29
|
-
let(:values) { ::Set.new(%w[A B C]) }
|
30
|
-
let(:block) { ->(item) { items << item } }
|
31
|
-
before(:each) { each }
|
32
|
-
|
33
|
-
it "yields all values" do
|
34
|
-
expect(items).to eq(values)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it "yields both of a pair of colliding keys" do
|
39
|
-
set = S[DeterministicHash.new('a', 1010), DeterministicHash.new('b', 1010)]
|
40
|
-
yielded = []
|
41
|
-
set.each { |obj| yielded << obj }
|
42
|
-
yielded.map(&:value).sort.should == ['a', 'b']
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::Set do
|
4
|
-
describe "#empty?" do
|
5
|
-
[
|
6
|
-
[[], true],
|
7
|
-
[["A"], false],
|
8
|
-
[%w[A B C], false],
|
9
|
-
[[nil], false],
|
10
|
-
[[false], false]
|
11
|
-
].each do |values, expected|
|
12
|
-
describe "on #{values.inspect}" do
|
13
|
-
it "returns #{expected.inspect}" do
|
14
|
-
S[*values].empty?.should == expected
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe ".empty" do
|
21
|
-
it "returns the canonical empty set" do
|
22
|
-
S.empty.should be_empty
|
23
|
-
S.empty.object_id.should be(S[].object_id)
|
24
|
-
S.empty.should be(Immutable::EmptySet)
|
25
|
-
end
|
26
|
-
|
27
|
-
context "from a subclass" do
|
28
|
-
it "returns an empty instance of the subclass" do
|
29
|
-
subclass = Class.new(Immutable::Set)
|
30
|
-
subclass.empty.class.should be(subclass)
|
31
|
-
subclass.empty.should be_empty
|
32
|
-
end
|
33
|
-
|
34
|
-
it "calls overridden #initialize when creating empty Set" do
|
35
|
-
subclass = Class.new(Immutable::Set) do
|
36
|
-
def initialize
|
37
|
-
@variable = 'value'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
subclass.empty.instance_variable_get(:@variable).should == 'value'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "set"
|
3
|
-
|
4
|
-
describe Immutable::Set do
|
5
|
-
let(:set) { S[*values] }
|
6
|
-
let(:comparison) { S[*comparison_values] }
|
7
|
-
|
8
|
-
describe "#==" do
|
9
|
-
let(:eqeq) { set == comparison }
|
10
|
-
|
11
|
-
shared_examples "comparing non-sets" do
|
12
|
-
let(:values) { %w[A B C] }
|
13
|
-
|
14
|
-
it "returns false" do
|
15
|
-
expect(eqeq).to eq(false)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context "when comparing to a standard set" do
|
20
|
-
let(:comparison) { ::Set.new(%w[A B C]) }
|
21
|
-
|
22
|
-
include_examples "comparing non-sets"
|
23
|
-
end
|
24
|
-
|
25
|
-
context "when comparing to a arbitrary object" do
|
26
|
-
let(:comparison) { Object.new }
|
27
|
-
|
28
|
-
include_examples "comparing non-sets"
|
29
|
-
end
|
30
|
-
|
31
|
-
context "with an empty set for each comparison" do
|
32
|
-
let(:values) { [] }
|
33
|
-
let(:comparison_values) { [] }
|
34
|
-
|
35
|
-
it "returns true" do
|
36
|
-
expect(eqeq).to eq(true)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with an empty set and a set with nil" do
|
41
|
-
let(:values) { [] }
|
42
|
-
let(:comparison_values) { [nil] }
|
43
|
-
|
44
|
-
it "returns false" do
|
45
|
-
expect(eqeq).to eq(false)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "with a single item array and empty array" do
|
50
|
-
let(:values) { ["A"] }
|
51
|
-
let(:comparison_values) { [] }
|
52
|
-
|
53
|
-
it "returns false" do
|
54
|
-
expect(eqeq).to eq(false)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context "with matching single item array" do
|
59
|
-
let(:values) { ["A"] }
|
60
|
-
let(:comparison_values) { ["A"] }
|
61
|
-
|
62
|
-
it "returns true" do
|
63
|
-
expect(eqeq).to eq(true)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context "with mismatching single item array" do
|
68
|
-
let(:values) { ["A"] }
|
69
|
-
let(:comparison_values) { ["B"] }
|
70
|
-
|
71
|
-
it "returns false" do
|
72
|
-
expect(eqeq).to eq(false)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context "with a multi-item array and single item array" do
|
77
|
-
let(:values) { %w[A B] }
|
78
|
-
let(:comparison_values) { ["A"] }
|
79
|
-
|
80
|
-
it "returns false" do
|
81
|
-
expect(eqeq).to eq(false)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "with matching multi-item array" do
|
86
|
-
let(:values) { %w[A B] }
|
87
|
-
let(:comparison_values) { %w[A B] }
|
88
|
-
|
89
|
-
it "returns true" do
|
90
|
-
expect(eqeq).to eq(true)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "with a mismatching multi-item array" do
|
95
|
-
let(:values) { %w[A B] }
|
96
|
-
let(:comparison_values) { %w[B A] }
|
97
|
-
|
98
|
-
it "returns true" do
|
99
|
-
expect(eqeq).to eq(true)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "set"
|
3
|
-
|
4
|
-
describe Immutable::Set do
|
5
|
-
let(:set) { S[*values] }
|
6
|
-
let(:comparison) { S[*comparison_values] }
|
7
|
-
|
8
|
-
describe "#eql?" do
|
9
|
-
let(:eql?) { set.eql?(comparison) }
|
10
|
-
|
11
|
-
shared_examples "comparing non-sets" do
|
12
|
-
let(:values) { %w[A B C] }
|
13
|
-
|
14
|
-
it "returns false" do
|
15
|
-
expect(eql?).to eq(false)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context "when comparing to a standard set" do
|
20
|
-
let(:comparison) { ::Set.new(%w[A B C]) }
|
21
|
-
|
22
|
-
include_examples "comparing non-sets"
|
23
|
-
end
|
24
|
-
|
25
|
-
context "when comparing to a arbitrary object" do
|
26
|
-
let(:comparison) { Object.new }
|
27
|
-
|
28
|
-
include_examples "comparing non-sets"
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when comparing with a subclass of Immutable::Set" do
|
32
|
-
let(:comparison) { Class.new(Immutable::Set).new(%w[A B C]) }
|
33
|
-
|
34
|
-
include_examples "comparing non-sets"
|
35
|
-
end
|
36
|
-
|
37
|
-
context "with an empty set for each comparison" do
|
38
|
-
let(:values) { [] }
|
39
|
-
let(:comparison_values) { [] }
|
40
|
-
|
41
|
-
it "returns true" do
|
42
|
-
expect(eql?).to eq(true)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "with an empty set and a set with nil" do
|
47
|
-
let(:values) { [] }
|
48
|
-
let(:comparison_values) { [nil] }
|
49
|
-
|
50
|
-
it "returns false" do
|
51
|
-
expect(eql?).to eq(false)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "with a single item array and empty array" do
|
56
|
-
let(:values) { ["A"] }
|
57
|
-
let(:comparison_values) { [] }
|
58
|
-
|
59
|
-
it "returns false" do
|
60
|
-
expect(eql?).to eq(false)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context "with matching single item array" do
|
65
|
-
let(:values) { ["A"] }
|
66
|
-
let(:comparison_values) { ["A"] }
|
67
|
-
|
68
|
-
it "returns true" do
|
69
|
-
expect(eql?).to eq(true)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context "with mismatching single item array" do
|
74
|
-
let(:values) { ["A"] }
|
75
|
-
let(:comparison_values) { ["B"] }
|
76
|
-
|
77
|
-
it "returns false" do
|
78
|
-
expect(eql?).to eq(false)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context "with a multi-item array and single item array" do
|
83
|
-
let(:values) { %w[A B] }
|
84
|
-
let(:comparison_values) { ["A"] }
|
85
|
-
|
86
|
-
it "returns false" do
|
87
|
-
expect(eql?).to eq(false)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context "with matching multi-item array" do
|
92
|
-
let(:values) { %w[A B] }
|
93
|
-
let(:comparison_values) { %w[A B] }
|
94
|
-
|
95
|
-
it "returns true" do
|
96
|
-
expect(eql?).to eq(true)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context "with a mismatching multi-item array" do
|
101
|
-
let(:values) { %w[A B] }
|
102
|
-
let(:comparison_values) { %w[B A] }
|
103
|
-
|
104
|
-
it "returns true" do
|
105
|
-
expect(eql?).to eq(true)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::Set do
|
4
|
-
[:exclusion, :^].each do |method|
|
5
|
-
describe "##{method}" do
|
6
|
-
[
|
7
|
-
[[], [], []],
|
8
|
-
[["A"], [], ["A"]],
|
9
|
-
[["A"], ["A"], []],
|
10
|
-
[%w[A B C], ["B"], %w[A C]],
|
11
|
-
[%w[A B C], %w[B C D], %w[A D]],
|
12
|
-
[%w[A B C], %w[D E F], %w[A B C D E F]],
|
13
|
-
].each do |a, b, expected|
|
14
|
-
context "for #{a.inspect} and #{b.inspect}" do
|
15
|
-
let(:set_a) { S[*a] }
|
16
|
-
let(:set_b) { S[*b] }
|
17
|
-
let(:result) { set_a.send(method, set_b) }
|
18
|
-
|
19
|
-
it "doesn't modify the original Sets" do
|
20
|
-
result
|
21
|
-
set_a.should eql(S.new(a))
|
22
|
-
set_b.should eql(S.new(b))
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns #{expected.inspect}" do
|
26
|
-
result.should eql(S[*expected])
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "when passed a Ruby Array" do
|
31
|
-
it "returns the expected Set" do
|
32
|
-
S[*a].exclusion(b.freeze).should eql(S[*expected])
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
it "works for a wide variety of inputs" do
|
38
|
-
50.times do
|
39
|
-
array1 = (1..400).to_a.sample(100)
|
40
|
-
array2 = (1..400).to_a.sample(100)
|
41
|
-
result = S.new(array1) ^ S.new(array2)
|
42
|
-
result.to_a.sort.should eql(((array1 | array2) - (array1 & array2)).sort)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::Set do
|
4
|
-
[:find, :detect].each do |method|
|
5
|
-
describe "##{method}" do
|
6
|
-
[
|
7
|
-
[[], "A", nil],
|
8
|
-
[[], nil, nil],
|
9
|
-
[["A"], "A", "A"],
|
10
|
-
[["A"], "B", nil],
|
11
|
-
[["A"], nil, nil],
|
12
|
-
[["A", "B", nil], "A", "A"],
|
13
|
-
[["A", "B", nil], "B", "B"],
|
14
|
-
[["A", "B", nil], nil, nil],
|
15
|
-
[["A", "B", nil], "C", nil],
|
16
|
-
].each do |values, item, expected|
|
17
|
-
describe "on #{values.inspect}" do
|
18
|
-
context "with a block" do
|
19
|
-
it "returns #{expected.inspect}" do
|
20
|
-
S[*values].send(method) { |x| x == item }.should == expected
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "without a block" do
|
25
|
-
it "returns an Enumerator" do
|
26
|
-
result = S[*values].send(method)
|
27
|
-
result.class.should be(Enumerator)
|
28
|
-
result.each { |x| x == item}.should == expected
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::Set do
|
4
|
-
describe "#first" do
|
5
|
-
context "on an empty set" do
|
6
|
-
it "returns nil" do
|
7
|
-
S.empty.first.should be_nil
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
context "on a non-empty set" do
|
12
|
-
it "returns an arbitrary value from the set" do
|
13
|
-
%w[A B C].include?(S["A", "B", "C"].first).should == true
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
it "returns nil if only member of set is nil" do
|
18
|
-
S[nil].first.should be(nil)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns the first item yielded by #each" do
|
22
|
-
10.times do
|
23
|
-
set = S.new((rand(10)+1).times.collect { rand(10000 )})
|
24
|
-
set.each { |item| break item }.should be(set.first)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable do
|
4
|
-
describe "#flatten" do
|
5
|
-
[
|
6
|
-
[["A"], ["A"]],
|
7
|
-
[%w[A B C], %w[A B C]],
|
8
|
-
[["A", S["B"], "C"], %w[A B C]],
|
9
|
-
[[S["A"], S["B"], S["C"]], %w[A B C]],
|
10
|
-
].each do |values, expected|
|
11
|
-
describe "on #{values}" do
|
12
|
-
let(:set) { S[*values] }
|
13
|
-
|
14
|
-
it "preserves the original" do
|
15
|
-
set.flatten
|
16
|
-
set.should eql(S[*values])
|
17
|
-
end
|
18
|
-
|
19
|
-
it "returns the inlined values" do
|
20
|
-
set.flatten.should eql(S[*expected])
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "on an empty set" do
|
26
|
-
it "returns an empty set" do
|
27
|
-
S.empty.flatten.should equal(S.empty)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "on a set with multiple levels of nesting" do
|
32
|
-
it "inlines lower levels of nesting" do
|
33
|
-
set = S[S[S[1]], S[S[2]]]
|
34
|
-
set.flatten.should eql(S[1, 2])
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "from a subclass" do
|
39
|
-
it "returns an instance of the subclass" do
|
40
|
-
subclass = Class.new(Immutable::Set)
|
41
|
-
subclass.new.flatten.class.should be(subclass)
|
42
|
-
subclass.new([S[1], S[2]]).flatten.class.should be(subclass)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::Set do
|
4
|
-
let(:set) { S[*values] }
|
5
|
-
|
6
|
-
describe "#grep" do
|
7
|
-
let(:grep) { set.grep(String, &block) }
|
8
|
-
|
9
|
-
shared_examples "check filtered values" do
|
10
|
-
it "returns the filtered values" do
|
11
|
-
expect(grep).to eq(S[*filtered])
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
shared_examples "check different types of inputs" do
|
16
|
-
context "with an empty set" do
|
17
|
-
let(:values) { [] }
|
18
|
-
let(:filtered) { [] }
|
19
|
-
|
20
|
-
include_examples "check filtered values"
|
21
|
-
end
|
22
|
-
|
23
|
-
context "with a single item set" do
|
24
|
-
let(:values) { ["A"] }
|
25
|
-
let(:filtered) { ["A"] }
|
26
|
-
|
27
|
-
include_examples "check filtered values"
|
28
|
-
end
|
29
|
-
|
30
|
-
context "with a single item set that doesn't contain match" do
|
31
|
-
let(:values) { [1] }
|
32
|
-
let(:filtered) { [] }
|
33
|
-
|
34
|
-
include_examples "check filtered values"
|
35
|
-
end
|
36
|
-
|
37
|
-
context "with a multi-item set where one isn't a match" do
|
38
|
-
let(:values) { ["A", 2, "C"] }
|
39
|
-
let(:filtered) { %w[A C] }
|
40
|
-
|
41
|
-
include_examples "check filtered values"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "without a block" do
|
46
|
-
let(:block) { nil }
|
47
|
-
|
48
|
-
include_examples "check different types of inputs"
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "with a block" do
|
52
|
-
let(:block) { ->(item) { item }}
|
53
|
-
|
54
|
-
include_examples "check different types of inputs"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "immutable/set"
|
3
|
-
|
4
|
-
describe Immutable::Set do
|
5
|
-
let(:set) { S[*values] }
|
6
|
-
|
7
|
-
describe "#grep_v" do
|
8
|
-
let(:grep_v) { set.grep_v(String, &block) }
|
9
|
-
|
10
|
-
shared_examples "check filtered values" do
|
11
|
-
it "returns the filtered values" do
|
12
|
-
expect(grep_v).to eq(S[*filtered])
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "without a block" do
|
17
|
-
let(:block) { nil }
|
18
|
-
|
19
|
-
context "with an empty set" do
|
20
|
-
let(:values) { [] }
|
21
|
-
let(:filtered) { [] }
|
22
|
-
|
23
|
-
include_examples "check filtered values"
|
24
|
-
end
|
25
|
-
|
26
|
-
context "with a single item set" do
|
27
|
-
let(:values) { ["A"] }
|
28
|
-
let(:filtered) { [] }
|
29
|
-
|
30
|
-
include_examples "check filtered values"
|
31
|
-
end
|
32
|
-
|
33
|
-
context "with a single item set that doesn't contain match" do
|
34
|
-
let(:values) { [1] }
|
35
|
-
let(:filtered) { [1] }
|
36
|
-
|
37
|
-
include_examples "check filtered values"
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with a multi-item set where one isn't a match" do
|
41
|
-
let(:values) { [2, "C", 4] }
|
42
|
-
let(:filtered) { [2, 4] }
|
43
|
-
|
44
|
-
include_examples "check filtered values"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "with a block" do
|
49
|
-
let(:block) { ->(item) { item + 100 }}
|
50
|
-
|
51
|
-
context "resulting items are processed with the block" do
|
52
|
-
let(:values) { [2, "C", 4] }
|
53
|
-
let(:filtered) { [102, 104] }
|
54
|
-
|
55
|
-
include_examples "check filtered values"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::Set do
|
4
|
-
[:group_by, :group, :classify].each do |method|
|
5
|
-
describe "##{method}" do
|
6
|
-
context "with a block" do
|
7
|
-
[
|
8
|
-
[[], []],
|
9
|
-
[[1], [true => S[1]]],
|
10
|
-
[[1, 2, 3, 4], [true => S[3, 1], false => S[4, 2]]],
|
11
|
-
].each do |values, expected|
|
12
|
-
context "on #{values.inspect}" do
|
13
|
-
let(:set) { S[*values] }
|
14
|
-
|
15
|
-
it "returns #{expected.inspect}" do
|
16
|
-
set.send(method, &:odd?).should eql(H[*expected])
|
17
|
-
set.should eql(S.new(values)) # make sure it hasn't changed
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "without a block" do
|
24
|
-
[
|
25
|
-
[[], []],
|
26
|
-
[[1], [1 => S[1]]],
|
27
|
-
[[1, 2, 3, 4], [1 => S[1], 2 => S[2], 3 => S[3], 4 => S[4]]],
|
28
|
-
].each do |values, expected|
|
29
|
-
context "on #{values.inspect}" do
|
30
|
-
let(:set) { S[*values] }
|
31
|
-
|
32
|
-
it "returns #{expected.inspect}" do
|
33
|
-
set.group_by.should eql(H[*expected])
|
34
|
-
set.should eql(S.new(values)) # make sure it hasn't changed
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "on an empty set" do
|
41
|
-
it "returns an empty hash" do
|
42
|
-
S.empty.group_by { |x| x }.should eql(H.empty)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "returns a hash without default proc" do
|
47
|
-
S[1,2,3].group_by { |x| x }.default_proc.should be_nil
|
48
|
-
end
|
49
|
-
|
50
|
-
context "from a subclass" do
|
51
|
-
it "returns an Hash whose values are instances of the subclass" do
|
52
|
-
subclass = Class.new(Immutable::Set)
|
53
|
-
instance = subclass.new([1, 'string', :symbol])
|
54
|
-
instance.group_by { |x| x.class }.values.each { |v| v.class.should be(subclass) }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::Set do
|
4
|
-
describe "#hash" do
|
5
|
-
context "on an empty set" do
|
6
|
-
it "returns 0" do
|
7
|
-
S.empty.hash.should == 0
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it "generates the same hash value for a set regardless of the order things were added to it" do
|
12
|
-
item1 = DeterministicHash.new('a', 121)
|
13
|
-
item2 = DeterministicHash.new('b', 474)
|
14
|
-
item3 = DeterministicHash.new('c', 121)
|
15
|
-
S.empty.add(item1).add(item2).add(item3).hash.should == S.empty.add(item3).add(item2).add(item1).hash
|
16
|
-
end
|
17
|
-
|
18
|
-
it "values are sufficiently distributed" do
|
19
|
-
(1..4000).each_slice(4).map { |a, b, c, d| S[a, b, c, d].hash }.uniq.size.should == 1000
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|