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,229 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
let(:list) { L[1,2,3,4] }
|
5
|
-
let(:big) { (1..10000).to_list }
|
6
|
-
|
7
|
-
[:slice, :[]].each do |method|
|
8
|
-
describe "##{method}" do
|
9
|
-
context "when passed a positive integral index" do
|
10
|
-
it "returns the element at that index" do
|
11
|
-
list.send(method, 0).should be(1)
|
12
|
-
list.send(method, 1).should be(2)
|
13
|
-
list.send(method, 2).should be(3)
|
14
|
-
list.send(method, 3).should be(4)
|
15
|
-
list.send(method, 4).should be(nil)
|
16
|
-
list.send(method, 10).should be(nil)
|
17
|
-
|
18
|
-
big.send(method, 0).should be(1)
|
19
|
-
big.send(method, 9999).should be(10000)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "leaves the original unchanged" do
|
23
|
-
list.should eql(L[1,2,3,4])
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "when passed a negative integral index" do
|
28
|
-
it "returns the element which is number (index.abs) counting from the end of the list" do
|
29
|
-
list.send(method, -1).should be(4)
|
30
|
-
list.send(method, -2).should be(3)
|
31
|
-
list.send(method, -3).should be(2)
|
32
|
-
list.send(method, -4).should be(1)
|
33
|
-
list.send(method, -5).should be(nil)
|
34
|
-
list.send(method, -10).should be(nil)
|
35
|
-
|
36
|
-
big.send(method, -1).should be(10000)
|
37
|
-
big.send(method, -10000).should be(1)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when passed a positive integral index and count" do
|
42
|
-
it "returns 'count' elements starting from 'index'" do
|
43
|
-
list.send(method, 0, 0).should eql(L.empty)
|
44
|
-
list.send(method, 0, 1).should eql(L[1])
|
45
|
-
list.send(method, 0, 2).should eql(L[1,2])
|
46
|
-
list.send(method, 0, 4).should eql(L[1,2,3,4])
|
47
|
-
list.send(method, 0, 6).should eql(L[1,2,3,4])
|
48
|
-
list.send(method, 0, -1).should be_nil
|
49
|
-
list.send(method, 0, -2).should be_nil
|
50
|
-
list.send(method, 0, -4).should be_nil
|
51
|
-
list.send(method, 2, 0).should eql(L.empty)
|
52
|
-
list.send(method, 2, 1).should eql(L[3])
|
53
|
-
list.send(method, 2, 2).should eql(L[3,4])
|
54
|
-
list.send(method, 2, 4).should eql(L[3,4])
|
55
|
-
list.send(method, 2, -1).should be_nil
|
56
|
-
list.send(method, 4, 0).should eql(L.empty)
|
57
|
-
list.send(method, 4, 2).should eql(L.empty)
|
58
|
-
list.send(method, 4, -1).should be_nil
|
59
|
-
list.send(method, 5, 0).should be_nil
|
60
|
-
list.send(method, 5, 2).should be_nil
|
61
|
-
list.send(method, 5, -1).should be_nil
|
62
|
-
list.send(method, 6, 0).should be_nil
|
63
|
-
list.send(method, 6, 2).should be_nil
|
64
|
-
list.send(method, 6, -1).should be_nil
|
65
|
-
|
66
|
-
big.send(method, 0, 3).should eql(L[1,2,3])
|
67
|
-
big.send(method, 1023, 4).should eql(L[1024,1025,1026,1027])
|
68
|
-
big.send(method, 1024, 4).should eql(L[1025,1026,1027,1028])
|
69
|
-
end
|
70
|
-
|
71
|
-
it "leaves the original unchanged" do
|
72
|
-
list.should eql(L[1,2,3,4])
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context "when passed a negative integral index and count" do
|
77
|
-
it "returns 'count' elements, starting from index which is number 'index.abs' counting from the end of the array" do
|
78
|
-
list.send(method, -1, 0).should eql(L.empty)
|
79
|
-
list.send(method, -1, 1).should eql(L[4])
|
80
|
-
list.send(method, -1, 2).should eql(L[4])
|
81
|
-
list.send(method, -1, -1).should be_nil
|
82
|
-
list.send(method, -2, 0).should eql(L.empty)
|
83
|
-
list.send(method, -2, 1).should eql(L[3])
|
84
|
-
list.send(method, -2, 2).should eql(L[3,4])
|
85
|
-
list.send(method, -2, 4).should eql(L[3,4])
|
86
|
-
list.send(method, -2, -1).should be_nil
|
87
|
-
list.send(method, -4, 0).should eql(L.empty)
|
88
|
-
list.send(method, -4, 1).should eql(L[1])
|
89
|
-
list.send(method, -4, 2).should eql(L[1,2])
|
90
|
-
list.send(method, -4, 4).should eql(L[1,2,3,4])
|
91
|
-
list.send(method, -4, 6).should eql(L[1,2,3,4])
|
92
|
-
list.send(method, -4, -1).should be_nil
|
93
|
-
list.send(method, -5, 0).should be_nil
|
94
|
-
list.send(method, -5, 1).should be_nil
|
95
|
-
list.send(method, -5, 10).should be_nil
|
96
|
-
list.send(method, -5, -1).should be_nil
|
97
|
-
|
98
|
-
big.send(method, -1, 1).should eql(L[10000])
|
99
|
-
big.send(method, -1, 2).should eql(L[10000])
|
100
|
-
big.send(method, -6, 2).should eql(L[9995,9996])
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "when passed a Range" do
|
105
|
-
it "returns the elements whose indexes are within the given Range" do
|
106
|
-
list.send(method, 0..-1).should eql(L[1,2,3,4])
|
107
|
-
list.send(method, 0..-10).should eql(L.empty)
|
108
|
-
list.send(method, 0..0).should eql(L[1])
|
109
|
-
list.send(method, 0..1).should eql(L[1,2])
|
110
|
-
list.send(method, 0..2).should eql(L[1,2,3])
|
111
|
-
list.send(method, 0..3).should eql(L[1,2,3,4])
|
112
|
-
list.send(method, 0..4).should eql(L[1,2,3,4])
|
113
|
-
list.send(method, 0..10).should eql(L[1,2,3,4])
|
114
|
-
list.send(method, 2..-10).should eql(L.empty)
|
115
|
-
list.send(method, 2..0).should eql(L.empty)
|
116
|
-
list.send(method, 2..2).should eql(L[3])
|
117
|
-
list.send(method, 2..3).should eql(L[3,4])
|
118
|
-
list.send(method, 2..4).should eql(L[3,4])
|
119
|
-
list.send(method, 3..0).should eql(L.empty)
|
120
|
-
list.send(method, 3..3).should eql(L[4])
|
121
|
-
list.send(method, 3..4).should eql(L[4])
|
122
|
-
list.send(method, 4..0).should eql(L.empty)
|
123
|
-
list.send(method, 4..4).should eql(L.empty)
|
124
|
-
list.send(method, 4..5).should eql(L.empty)
|
125
|
-
list.send(method, 5..0).should be_nil
|
126
|
-
list.send(method, 5..5).should be_nil
|
127
|
-
list.send(method, 5..6).should be_nil
|
128
|
-
|
129
|
-
big.send(method, 159..162).should eql(L[160,161,162,163])
|
130
|
-
big.send(method, 160..162).should eql(L[161,162,163])
|
131
|
-
big.send(method, 161..162).should eql(L[162,163])
|
132
|
-
big.send(method, 9999..10100).should eql(L[10000])
|
133
|
-
big.send(method, 10000..10100).should eql(L.empty)
|
134
|
-
big.send(method, 10001..10100).should be_nil
|
135
|
-
|
136
|
-
list.send(method, 0...-1).should eql(L[1,2,3])
|
137
|
-
list.send(method, 0...-10).should eql(L.empty)
|
138
|
-
list.send(method, 0...0).should eql(L.empty)
|
139
|
-
list.send(method, 0...1).should eql(L[1])
|
140
|
-
list.send(method, 0...2).should eql(L[1,2])
|
141
|
-
list.send(method, 0...3).should eql(L[1,2,3])
|
142
|
-
list.send(method, 0...4).should eql(L[1,2,3,4])
|
143
|
-
list.send(method, 0...10).should eql(L[1,2,3,4])
|
144
|
-
list.send(method, 2...-10).should eql(L.empty)
|
145
|
-
list.send(method, 2...0).should eql(L.empty)
|
146
|
-
list.send(method, 2...2).should eql(L.empty)
|
147
|
-
list.send(method, 2...3).should eql(L[3])
|
148
|
-
list.send(method, 2...4).should eql(L[3,4])
|
149
|
-
list.send(method, 3...0).should eql(L.empty)
|
150
|
-
list.send(method, 3...3).should eql(L.empty)
|
151
|
-
list.send(method, 3...4).should eql(L[4])
|
152
|
-
list.send(method, 4...0).should eql(L.empty)
|
153
|
-
list.send(method, 4...4).should eql(L.empty)
|
154
|
-
list.send(method, 4...5).should eql(L.empty)
|
155
|
-
list.send(method, 5...0).should be_nil
|
156
|
-
list.send(method, 5...5).should be_nil
|
157
|
-
list.send(method, 5...6).should be_nil
|
158
|
-
|
159
|
-
big.send(method, 159...162).should eql(L[160,161,162])
|
160
|
-
big.send(method, 160...162).should eql(L[161,162])
|
161
|
-
big.send(method, 161...162).should eql(L[162])
|
162
|
-
big.send(method, 9999...10100).should eql(L[10000])
|
163
|
-
big.send(method, 10000...10100).should eql(L.empty)
|
164
|
-
big.send(method, 10001...10100).should be_nil
|
165
|
-
|
166
|
-
list.send(method, -1..-1).should eql(L[4])
|
167
|
-
list.send(method, -1...-1).should eql(L.empty)
|
168
|
-
list.send(method, -1..3).should eql(L[4])
|
169
|
-
list.send(method, -1...3).should eql(L.empty)
|
170
|
-
list.send(method, -1..4).should eql(L[4])
|
171
|
-
list.send(method, -1...4).should eql(L[4])
|
172
|
-
list.send(method, -1..10).should eql(L[4])
|
173
|
-
list.send(method, -1...10).should eql(L[4])
|
174
|
-
list.send(method, -1..0).should eql(L.empty)
|
175
|
-
list.send(method, -1..-4).should eql(L.empty)
|
176
|
-
list.send(method, -1...-4).should eql(L.empty)
|
177
|
-
list.send(method, -1..-6).should eql(L.empty)
|
178
|
-
list.send(method, -1...-6).should eql(L.empty)
|
179
|
-
list.send(method, -2..-2).should eql(L[3])
|
180
|
-
list.send(method, -2...-2).should eql(L.empty)
|
181
|
-
list.send(method, -2..-1).should eql(L[3,4])
|
182
|
-
list.send(method, -2...-1).should eql(L[3])
|
183
|
-
list.send(method, -2..10).should eql(L[3,4])
|
184
|
-
list.send(method, -2...10).should eql(L[3,4])
|
185
|
-
|
186
|
-
big.send(method, -1..-1).should eql(L[10000])
|
187
|
-
big.send(method, -1..9999).should eql(L[10000])
|
188
|
-
big.send(method, -1...9999).should eql(L.empty)
|
189
|
-
big.send(method, -2...9999).should eql(L[9999])
|
190
|
-
big.send(method, -2..-1).should eql(L[9999,10000])
|
191
|
-
|
192
|
-
list.send(method, -4..-4).should eql(L[1])
|
193
|
-
list.send(method, -4..-2).should eql(L[1,2,3])
|
194
|
-
list.send(method, -4...-2).should eql(L[1,2])
|
195
|
-
list.send(method, -4..-1).should eql(L[1,2,3,4])
|
196
|
-
list.send(method, -4...-1).should eql(L[1,2,3])
|
197
|
-
list.send(method, -4..3).should eql(L[1,2,3,4])
|
198
|
-
list.send(method, -4...3).should eql(L[1,2,3])
|
199
|
-
list.send(method, -4..4).should eql(L[1,2,3,4])
|
200
|
-
list.send(method, -4...4).should eql(L[1,2,3,4])
|
201
|
-
list.send(method, -4..0).should eql(L[1])
|
202
|
-
list.send(method, -4...0).should eql(L.empty)
|
203
|
-
list.send(method, -4..1).should eql(L[1,2])
|
204
|
-
list.send(method, -4...1).should eql(L[1])
|
205
|
-
|
206
|
-
list.send(method, -5..-5).should be_nil
|
207
|
-
list.send(method, -5...-5).should be_nil
|
208
|
-
list.send(method, -5..-4).should be_nil
|
209
|
-
list.send(method, -5..-1).should be_nil
|
210
|
-
list.send(method, -5..10).should be_nil
|
211
|
-
|
212
|
-
big.send(method, -10001..-1).should be_nil
|
213
|
-
end
|
214
|
-
|
215
|
-
it "leaves the original unchanged" do
|
216
|
-
list.should eql(L[1,2,3,4])
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
context "when passed a subclass of Range" do
|
222
|
-
it "works the same as with a Range" do
|
223
|
-
subclass = Class.new(Range)
|
224
|
-
list.send(method, subclass.new(1,2)).should eql(L[2,3])
|
225
|
-
list.send(method, subclass.new(-3,-1,true)).should eql(L[2,3])
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
[
|
5
|
-
[:sort, ->(left, right) { left.length <=> right.length }],
|
6
|
-
[:sort_by, ->(item) { item.length }],
|
7
|
-
].each do |method, comparator|
|
8
|
-
describe "##{method}" do
|
9
|
-
it "is lazy" do
|
10
|
-
-> { Immutable.stream { fail }.send(method, &comparator) }.should_not raise_error
|
11
|
-
end
|
12
|
-
|
13
|
-
[
|
14
|
-
[[], []],
|
15
|
-
[["A"], ["A"]],
|
16
|
-
[%w[Ichi Ni San], %w[Ni San Ichi]],
|
17
|
-
].each do |values, expected|
|
18
|
-
context "on #{values.inspect}" do
|
19
|
-
let(:list) { L[*values] }
|
20
|
-
|
21
|
-
context "with a block" do
|
22
|
-
it "preserves the original" do
|
23
|
-
list.send(method, &comparator)
|
24
|
-
list.should == L[*values]
|
25
|
-
end
|
26
|
-
|
27
|
-
it "returns #{expected.inspect}" do
|
28
|
-
list.send(method, &comparator).should == L[*expected]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "without a block" do
|
33
|
-
it "preserves the original" do
|
34
|
-
list.send(method)
|
35
|
-
list.should eql(L[*values])
|
36
|
-
end
|
37
|
-
|
38
|
-
it "returns #{expected.sort.inspect}" do
|
39
|
-
list.send(method).should == L[*expected.sort]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "List#span" do
|
4
|
-
it "is lazy" do
|
5
|
-
-> { Immutable.stream { |item| fail }.span { true } }.should_not raise_error
|
6
|
-
end
|
7
|
-
|
8
|
-
describe <<-DESC do
|
9
|
-
given a predicate (in the form of a block), splits the list into two lists
|
10
|
-
(returned as an array) such that elements in the first list (the prefix) are
|
11
|
-
taken from the head of the list while the predicate is satisfied, and elements
|
12
|
-
in the second list (the remainder) are the remaining elements from the list
|
13
|
-
once the predicate is not satisfied. For example:
|
14
|
-
DESC
|
15
|
-
|
16
|
-
[
|
17
|
-
[[], [], []],
|
18
|
-
[[1], [1], []],
|
19
|
-
[[1, 2], [1, 2], []],
|
20
|
-
[[1, 2, 3], [1, 2], [3]],
|
21
|
-
[[1, 2, 3, 4], [1, 2], [3, 4]],
|
22
|
-
[[2, 3, 4], [2], [3, 4]],
|
23
|
-
[[3, 4], [], [3, 4]],
|
24
|
-
[[4], [], [4]],
|
25
|
-
].each do |values, expected_prefix, expected_remainder|
|
26
|
-
context "given the list #{values.inspect}" do
|
27
|
-
let(:list) { L[*values] }
|
28
|
-
|
29
|
-
context "and a predicate that returns true for values <= 2" do
|
30
|
-
let(:result) { list.span { |item| item <= 2 }}
|
31
|
-
let(:prefix) { result.first }
|
32
|
-
let(:remainder) { result.last }
|
33
|
-
|
34
|
-
it "preserves the original" do
|
35
|
-
result
|
36
|
-
list.should eql(L[*values])
|
37
|
-
end
|
38
|
-
|
39
|
-
it "returns the prefix as #{expected_prefix.inspect}" do
|
40
|
-
prefix.should eql(L[*expected_prefix])
|
41
|
-
end
|
42
|
-
|
43
|
-
it "returns the remainder as #{expected_remainder.inspect}" do
|
44
|
-
remainder.should eql(L[*expected_remainder])
|
45
|
-
end
|
46
|
-
|
47
|
-
it "calls the block only once for each element" do
|
48
|
-
count = 0
|
49
|
-
result = list.span { |item| count += 1; item <= 2 }
|
50
|
-
# force realization of lazy lists
|
51
|
-
result.first.size.should == expected_prefix.size
|
52
|
-
result.last.size.should == expected_remainder.size
|
53
|
-
# it may not need to call the block on every element, just up to the
|
54
|
-
# point where the block first returns a false value
|
55
|
-
count.should <= values.size
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "without a predicate" do
|
60
|
-
it "returns a frozen array" do
|
61
|
-
list.span.class.should be(Array)
|
62
|
-
list.span.should be_frozen
|
63
|
-
end
|
64
|
-
|
65
|
-
it "returns self as the prefix" do
|
66
|
-
list.span.first.should equal(list)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "returns an empty list as the remainder" do
|
70
|
-
list.span.last.should be_empty
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
describe "#split_at" do
|
5
|
-
it "is lazy" do
|
6
|
-
-> { Immutable.stream { fail }.split_at(1) }.should_not raise_error
|
7
|
-
end
|
8
|
-
|
9
|
-
[
|
10
|
-
[[], [], []],
|
11
|
-
[[1], [1], []],
|
12
|
-
[[1, 2], [1, 2], []],
|
13
|
-
[[1, 2, 3], [1, 2], [3]],
|
14
|
-
[[1, 2, 3, 4], [1, 2], [3, 4]],
|
15
|
-
].each do |values, expected_prefix, expected_remainder|
|
16
|
-
context "on #{values.inspect}" do
|
17
|
-
let(:list) { L[*values] }
|
18
|
-
let(:result) { list.split_at(2) }
|
19
|
-
let(:prefix) { result.first }
|
20
|
-
let(:remainder) { result.last }
|
21
|
-
|
22
|
-
it "preserves the original" do
|
23
|
-
result
|
24
|
-
list.should eql(L[*values])
|
25
|
-
end
|
26
|
-
|
27
|
-
it "returns a frozen array with two items" do
|
28
|
-
result.class.should be(Array)
|
29
|
-
result.should be_frozen
|
30
|
-
result.size.should be(2)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "correctly identifies the matches" do
|
34
|
-
prefix.should eql(L[*expected_prefix])
|
35
|
-
end
|
36
|
-
|
37
|
-
it "correctly identifies the remainder" do
|
38
|
-
remainder.should eql(L[*expected_remainder])
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
describe "#subsequences" do
|
5
|
-
let(:list) { L[1,2,3,4,5] }
|
6
|
-
|
7
|
-
it "yields all sublists with 1 or more consecutive items" do
|
8
|
-
result = []
|
9
|
-
list.subsequences { |l| result << l }
|
10
|
-
result.size.should == (5 + 4 + 3 + 2 + 1)
|
11
|
-
result.sort.should == [[1], [1,2], [1,2,3], [1,2,3,4], [1,2,3,4,5],
|
12
|
-
[2], [2,3], [2,3,4], [2,3,4,5], [3], [3,4], [3,4,5], [4], [4,5], [5]]
|
13
|
-
end
|
14
|
-
|
15
|
-
context "with no block" do
|
16
|
-
it "returns an Enumerator" do
|
17
|
-
list.subsequences.class.should be(Enumerator)
|
18
|
-
list.subsequences.to_a.sort.should == [[1], [1,2], [1,2,3], [1,2,3,4], [1,2,3,4,5],
|
19
|
-
[2], [2,3], [2,3,4], [2,3,4,5], [3], [3,4], [3,4,5], [4], [4,5], [5]]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
describe "#sum" do
|
5
|
-
context "on a really big list" do
|
6
|
-
it "doesn't run out of stack" do
|
7
|
-
-> { BigList.sum }.should_not raise_error
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
[
|
12
|
-
[[], 0],
|
13
|
-
[[2], 2],
|
14
|
-
[[1, 3, 5, 7, 11], 27],
|
15
|
-
].each do |values, expected|
|
16
|
-
context "on #{values.inspect}" do
|
17
|
-
it "returns #{expected.inspect}" do
|
18
|
-
L[*values].sum.should == expected
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
describe "#tail" do
|
5
|
-
context "on a really big list" do
|
6
|
-
it "doesn't run out of stack" do
|
7
|
-
-> { BigList.select(&:nil?).tail }.should_not raise_error
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
[
|
12
|
-
[[], []],
|
13
|
-
[["A"], []],
|
14
|
-
[%w[A B C], %w[B C]],
|
15
|
-
].each do |values, expected|
|
16
|
-
context "on #{values.inspect}" do
|
17
|
-
let(:list) { L[*values] }
|
18
|
-
|
19
|
-
it "preserves the original" do
|
20
|
-
list.tail
|
21
|
-
list.should eql(L[*values])
|
22
|
-
end
|
23
|
-
|
24
|
-
it "returns #{expected.inspect}" do
|
25
|
-
list.tail.should eql(L[*expected])
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
describe "#tails" do
|
5
|
-
it "is lazy" do
|
6
|
-
-> { Immutable.stream { fail }.tails }.should_not raise_error
|
7
|
-
end
|
8
|
-
|
9
|
-
[
|
10
|
-
[[], []],
|
11
|
-
[["A"], [L["A"]]],
|
12
|
-
[%w[A B C], [L["A", "B", "C"], L["B", "C"], L["C"]]],
|
13
|
-
].each do |values, expected|
|
14
|
-
context "on #{values.inspect}" do
|
15
|
-
let(:list) { L[*values] }
|
16
|
-
|
17
|
-
it "preserves the original" do
|
18
|
-
list.tails
|
19
|
-
list.should eql(L[*values])
|
20
|
-
end
|
21
|
-
|
22
|
-
it "returns #{expected.inspect}" do
|
23
|
-
list.tails.should eql(L[*expected])
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
describe "#take" do
|
5
|
-
it "is lazy" do
|
6
|
-
-> { Immutable.stream { fail }.take(1) }.should_not raise_error
|
7
|
-
end
|
8
|
-
|
9
|
-
[
|
10
|
-
[[], 10, []],
|
11
|
-
[["A"], 10, ["A"]],
|
12
|
-
[["A"], -1, []],
|
13
|
-
[%w[A B C], 0, []],
|
14
|
-
[%w[A B C], 2, %w[A B]],
|
15
|
-
].each do |values, number, expected|
|
16
|
-
context "#{number} from #{values.inspect}" do
|
17
|
-
let(:list) { L[*values] }
|
18
|
-
|
19
|
-
it "preserves the original" do
|
20
|
-
list.take(number)
|
21
|
-
list.should eql(L[*values])
|
22
|
-
end
|
23
|
-
|
24
|
-
it "returns #{expected.inspect}" do
|
25
|
-
list.take(number).should eql(L[*expected])
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
describe "#take_while" do
|
5
|
-
it "is lazy" do
|
6
|
-
-> { Immutable.stream { fail }.take_while { false } }.should_not raise_error
|
7
|
-
end
|
8
|
-
|
9
|
-
[
|
10
|
-
[[], []],
|
11
|
-
[["A"], ["A"]],
|
12
|
-
[%w[A B C], %w[A B]],
|
13
|
-
].each do |values, expected|
|
14
|
-
context "on #{values.inspect}" do
|
15
|
-
let(:list) { L[*values] }
|
16
|
-
|
17
|
-
context "with a block" do
|
18
|
-
it "returns #{expected.inspect}" do
|
19
|
-
list.take_while { |item| item < "C" }.should eql(L[*expected])
|
20
|
-
end
|
21
|
-
|
22
|
-
it "preserves the original" do
|
23
|
-
list.take_while { |item| item < "C" }
|
24
|
-
list.should eql(L[*values])
|
25
|
-
end
|
26
|
-
|
27
|
-
it "is lazy" do
|
28
|
-
count = 0
|
29
|
-
list.take_while do |item|
|
30
|
-
count += 1
|
31
|
-
true
|
32
|
-
end
|
33
|
-
count.should <= 1
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "without a block" do
|
38
|
-
it "returns an Enumerator" do
|
39
|
-
list.take_while.class.should be(Enumerator)
|
40
|
-
list.take_while.each { |item| item < "C" }.should eql(L[*expected])
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
[:to_a, :entries].each do |method|
|
5
|
-
describe "##{method}" do
|
6
|
-
context "on a really big list" do
|
7
|
-
it "doesn't run out of stack" do
|
8
|
-
-> { BigList.to_a }.should_not raise_error
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
[
|
13
|
-
[],
|
14
|
-
["A"],
|
15
|
-
%w[A B C],
|
16
|
-
].each do |values|
|
17
|
-
context "on #{values.inspect}" do
|
18
|
-
let(:list) { L[*values] }
|
19
|
-
|
20
|
-
it "returns #{values.inspect}" do
|
21
|
-
list.send(method).should == values
|
22
|
-
end
|
23
|
-
|
24
|
-
it "leaves the original unchanged" do
|
25
|
-
list.send(method)
|
26
|
-
list.should eql(L[*values])
|
27
|
-
end
|
28
|
-
|
29
|
-
it "returns a mutable array" do
|
30
|
-
result = list.send(method)
|
31
|
-
expect(result.last).to_not eq("The End")
|
32
|
-
result << "The End"
|
33
|
-
result.last.should == "The End"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
let(:list) { L["A", "B", "C", "D"] }
|
5
|
-
|
6
|
-
describe "#to_ary" do
|
7
|
-
context "on a really big list" do
|
8
|
-
it "doesn't run out of stack" do
|
9
|
-
-> { BigList.to_ary }.should_not raise_error
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context "enables implicit conversion to" do
|
14
|
-
it "block parameters" do
|
15
|
-
def func(&block)
|
16
|
-
yield(list)
|
17
|
-
end
|
18
|
-
|
19
|
-
func do |a, b, *c|
|
20
|
-
expect(a).to eq("A")
|
21
|
-
expect(b).to eq("B")
|
22
|
-
expect(c).to eq(%w[C D])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it "method arguments" do
|
27
|
-
def func(a, b, *c)
|
28
|
-
expect(a).to eq("A")
|
29
|
-
expect(b).to eq("B")
|
30
|
-
expect(c).to eq(%w[C D])
|
31
|
-
end
|
32
|
-
func(*list)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "works with splat" do
|
36
|
-
array = *list
|
37
|
-
expect(array).to eq(%w[A B C D])
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Immutable::List do
|
4
|
-
describe "#to_list" do
|
5
|
-
[
|
6
|
-
[],
|
7
|
-
["A"],
|
8
|
-
%w[A B C],
|
9
|
-
].each do |values|
|
10
|
-
context "on #{values.inspect}" do
|
11
|
-
let(:list) { L[*values] }
|
12
|
-
|
13
|
-
it "returns self" do
|
14
|
-
list.to_list.should equal(list)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|