├── .codoopts ├── .gitignore ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── Cakefile ├── Gemfile ├── Gemfile.lock ├── Guardfile ├── LICENSE ├── README.md ├── Rakefile ├── index.js ├── lib ├── base │ ├── arr.coffee │ ├── chain.coffee │ ├── err.coffee │ ├── hsh.coffee │ ├── itr.coffee │ ├── match_data.coffee │ ├── num.coffee │ ├── rgx.coffee │ ├── str.coffee │ └── time.coffee ├── boot.coffee ├── core │ ├── .DS_Store │ ├── aliases.coffee │ ├── base_private.coffee │ ├── base_public.coffee │ ├── block.coffee │ ├── breaker.coffee │ ├── coerce.coffee │ ├── errors.coffee │ └── kernel.coffee ├── oo │ ├── .DS_Store │ ├── array.coffee │ ├── coerce.coffee │ ├── comparable.coffee │ ├── enumerable.coffee │ ├── enumerator.coffee │ ├── fixnum.coffee │ ├── float.coffee │ ├── hash.coffee │ ├── integer.coffee │ ├── match_data.coffee │ ├── math.coffee │ ├── numeric.coffee │ ├── object.coffee │ ├── range.coffee │ ├── regexp.coffee │ ├── string.coffee │ └── time.coffee └── ruby.coffee ├── package.json ├── ruby.coffee ├── ruby.js ├── ruby.min.js ├── ruby.min.js.gz └── spec ├── README.md ├── javascripts ├── .gitignore └── support │ └── jasmine.yml └── lib ├── corelib ├── README.md ├── array │ ├── append_spec.coffee │ ├── at_spec.coffee │ ├── clear_spec.coffee │ ├── clone_spec.coffee │ ├── collect_spec.coffee │ ├── combination_spec.coffee │ ├── compact_spec.coffee │ ├── comparison_spec.coffee │ ├── concat_spec.coffee │ ├── count_spec.coffee │ ├── cycle_spec.coffee │ ├── delete_at_spec.coffee │ ├── delete_if_spec.coffee │ ├── delete_spec.coffee │ ├── drop_spec.coffee │ ├── drop_while_spec.coffee │ ├── dup_spec.coffee │ ├── each_index_spec.coffee │ ├── each_spec.coffee │ ├── element_reference_spec.coffee │ ├── element_set_spec.coffee │ ├── empty_spec.coffee │ ├── eql_spec.coffee │ ├── equal_value_spec.coffee │ ├── fetch_spec.coffee │ ├── fill_spec.coffee │ ├── find_index_spec.coffee │ ├── first_spec.coffee │ ├── fixtures │ │ ├── classes.rb │ │ └── encoded_strings.rb │ ├── flatten_spec.coffee │ ├── include_spec.coffee │ ├── index_spec.coffee │ ├── insert_spec.coffee │ ├── inspect_spec.coffee │ ├── intersection_spec.coffee │ ├── join_spec.coffee │ ├── keep_if_spec.coffee │ ├── last_spec.coffee │ ├── length_spec.coffee │ ├── map_spec.coffee │ ├── minus_spec.coffee │ ├── multiply_spec.coffee │ ├── new_spec.coffee │ ├── pack │ │ ├── a_spec.rb │ │ ├── at_spec.rb │ │ ├── b_spec.rb │ │ ├── c_spec.rb │ │ ├── comment_spec.rb │ │ ├── d_spec.rb │ │ ├── e_spec.rb │ │ ├── empty_spec.rb │ │ ├── f_spec.rb │ │ ├── g_spec.rb │ │ ├── h_spec.rb │ │ ├── i_spec.rb │ │ ├── l_spec.rb │ │ ├── m_spec.rb │ │ ├── n_spec.rb │ │ ├── p_spec.rb │ │ ├── percent_spec.rb │ │ ├── q_spec.rb │ │ ├── s_spec.rb │ │ ├── shared │ │ │ ├── basic.rb │ │ │ ├── encodings.rb │ │ │ ├── float.rb │ │ │ ├── integer.rb │ │ │ ├── numeric_basic.rb │ │ │ ├── string.rb │ │ │ └── unicode.rb │ │ ├── u_spec.rb │ │ ├── v_spec.rb │ │ ├── w_spec.rb │ │ ├── x_spec.rb │ │ └── z_spec.rb │ ├── partition_spec.coffee │ ├── plus_spec.coffee │ ├── pop_spec.coffee │ ├── product_spec.coffee │ ├── push_spec.coffee │ ├── rassoc_spec.coffee │ ├── reject_spec.coffee │ ├── replace_spec.coffee │ ├── reverse_each_spec.coffee │ ├── reverse_spec.coffee │ ├── rindex_spec.coffee │ ├── rotate_spec.coffee │ ├── sample_spec.coffee │ ├── select_spec.coffee │ ├── shared │ │ ├── clone.rb │ │ ├── collect.rb │ │ ├── enumeratorize.rb │ │ ├── eql.rb │ │ ├── index.rb │ │ ├── indexes.rb │ │ ├── inspect.rb │ │ ├── join.rb │ │ ├── keep_if.rb │ │ ├── length.rb │ │ ├── replace.rb │ │ └── slice.rb │ ├── shift_spec.coffee │ ├── shuffle_spec.coffee │ ├── size_spec.coffee │ ├── slice_spec.coffee │ ├── sort_by_spec.coffee │ ├── sort_spec.coffee │ ├── take_spec.coffee │ ├── take_while_spec.coffee │ ├── to_a_spec.coffee │ ├── to_ary_spec.coffee │ ├── to_s_spec.coffee │ ├── transpose_spec.coffee │ ├── try_convert_spec.coffee │ ├── union_spec.coffee │ ├── uniq_spec.coffee │ ├── unshift_spec.coffee │ ├── unsupported │ │ ├── allocate_spec.rb │ │ ├── array_spec.rb │ │ ├── assoc_spec.rb │ │ ├── choice_spec.rb │ │ ├── constructor_spec.rb │ │ ├── frozen_spec.rb │ │ ├── hash_spec.rb │ │ ├── initialize_copy_spec.rb │ │ ├── initialize_spec.rb │ │ ├── permutation_spec.rb │ │ ├── repeated_combination_spec.rb │ │ └── repeated_permutation_spec.rb │ ├── values_at_spec.coffee │ └── zip_spec.coffee ├── comparable │ └── between_spec.coffee ├── enumerable │ ├── all_spec.coffee │ ├── any_spec.coffee │ ├── chunk_spec.coffee │ ├── collect_concat_spec.coffee │ ├── collect_spec.coffee │ ├── count_spec.coffee │ ├── cycle_spec.coffee │ ├── detect_spec.coffee │ ├── drop_spec.coffee │ ├── drop_while_spec.coffee │ ├── each_cons_spec.coffee │ ├── each_entry_spec.coffee │ ├── each_slice_spec.coffee │ ├── each_with_index_spec.coffee │ ├── each_with_object_spec.coffee │ ├── entries_spec.coffee │ ├── find_all_spec.coffee │ ├── find_index_spec.coffee │ ├── find_spec.coffee │ ├── first_spec.coffee │ ├── fixtures │ │ └── classes.coffee │ ├── flat_map_spec.coffee │ ├── grep_spec.coffee │ ├── group_by_spec.coffee │ ├── include_spec.coffee │ ├── inject_spec.coffee │ ├── map_spec.coffee │ ├── max_by_spec.coffee │ ├── max_spec.coffee │ ├── member_spec.coffee │ ├── min_by_spec.coffee │ ├── min_spec.coffee │ ├── minmax_by_spec.coffee │ ├── minmax_spec.coffee │ ├── none_spec.coffee │ ├── one_spec.coffee │ ├── partition_spec.coffee │ ├── reduce_spec.coffee │ ├── reject_spec.coffee │ ├── reverse_each_spec.coffee │ ├── select_spec.coffee │ ├── slice_before_spec.coffee │ ├── sort_by_spec.coffee │ ├── sort_spec.coffee │ ├── take_spec.coffee │ ├── take_while_spec.coffee │ ├── to_a_spec.coffee │ └── zip_spec.coffee ├── enumerator │ ├── each_spec.rb │ ├── each_with_index_spec.rb │ ├── each_with_object_spec.rb │ ├── enum_for_spec.rb │ ├── feed_spec.rb │ ├── inject_spec.rb │ ├── inspect_spec.rb │ ├── new_spec.coffee │ ├── next_spec.rb │ ├── next_values_spec.rb │ ├── peek_spec.rb │ ├── peek_values_spec.rb │ ├── rewind_spec.rb │ ├── to_enum_spec.rb │ ├── with_index_spec.rb │ └── with_object_spec.rb ├── fixnum │ ├── abs_spec.coffee │ ├── case_compare_spec.coffee │ ├── coerce_spec.coffee │ ├── comparison_spec.coffee │ ├── deprecated │ │ ├── id2name_spec.rb │ │ └── induced_from_spec.rb │ ├── div_spec.coffee │ ├── divide_spec.coffee │ ├── divmod_spec.coffee │ ├── equal_value_spec.coffee │ ├── even_spec.coffee │ ├── exponent_spec.coffee │ ├── fdiv_spec.coffee │ ├── gt_spec.coffee │ ├── gte_spec.coffee │ ├── lt_spec.coffee │ ├── lte_spec.coffee │ ├── magnitude_spec.coffee │ ├── minus_spec.coffee │ ├── modulo_spec.coffee │ ├── multiply_spec.coffee │ ├── odd_spec.coffee │ ├── plus_spec.coffee │ ├── quo_spec.coffee │ ├── succ_spec.coffee │ ├── to_f_spec.coffee │ ├── to_s_spec.coffee │ ├── uminus_spec.coffee │ ├── unsupported │ │ ├── bit_methods │ │ │ ├── bit_and_spec.rb │ │ │ ├── bit_or_spec.rb │ │ │ ├── bit_xor_spec.rb │ │ │ ├── complement_spec.rb │ │ │ ├── element_reference_spec.rb │ │ │ ├── left_shift_spec.rb │ │ │ ├── right_shift_spec.rb │ │ │ └── size_spec.rb │ │ ├── hash_spec.rb │ │ └── to_sym_spec.rb │ └── zero_spec.coffee ├── float │ ├── abs_spec.coffee │ ├── angle_spec.coffee │ ├── case_compare_spec.coffee │ ├── ceil_spec.coffee │ ├── coerce_spec.coffee │ ├── comparison_spec.coffee │ ├── constants_spec.coffee │ ├── divide_spec.coffee │ ├── divmod_spec.coffee │ ├── eql_spec.coffee │ ├── equal_value_spec.coffee │ ├── exponent_spec.coffee │ ├── fdiv_spec.coffee │ ├── finite_spec.coffee │ ├── fixtures │ │ └── coerce.rb │ ├── floor_spec.coffee │ ├── gt_spec.coffee │ ├── gte_spec.coffee │ ├── infinite_spec.coffee │ ├── lt_spec.coffee │ ├── lte_spec.coffee │ ├── magnitude_spec.coffee │ ├── minus_spec.coffee │ ├── modulo_spec.coffee │ ├── multiply_spec.coffee │ ├── nan_spec.coffee │ ├── plus_spec.coffee │ ├── quo_spec.coffee │ ├── round_spec.coffee │ ├── shared │ │ ├── abs.rb │ │ ├── equal.rb │ │ ├── modulo.rb │ │ ├── quo.rb │ │ └── to_i.rb │ ├── to_f_spec.coffee │ ├── to_i_spec.coffee │ ├── to_int_spec.coffee │ ├── to_s_spec.coffee │ ├── truncate_spec.coffee │ ├── unsupported │ │ ├── arg_spec.rb │ │ ├── denominator_spec.rb │ │ ├── hash_spec.rb │ │ ├── induced_from_spec.rb │ │ ├── numerator_spec.rb │ │ ├── phase_spec.rb │ │ ├── rationalize_spec.rb │ │ ├── to_r_spec.rb │ │ ├── uminus_spec.rb │ │ └── uplus_spec.rb │ └── zero_spec.coffee ├── hash │ ├── assoc_spec.coffee │ ├── clear_spec.coffee │ ├── clone_spec.rb │ ├── compare_by_identity_spec.rb │ ├── constructor_spec.rb │ ├── default_proc_spec.coffee │ ├── default_spec.coffee │ ├── delete_if_spec.coffee │ ├── delete_spec.coffee │ ├── each_key_spec.coffee │ ├── each_pair_spec.coffee │ ├── each_spec.coffee │ ├── each_value_spec.coffee │ ├── element_reference_spec.coffee │ ├── element_set_spec.coffee │ ├── empty_spec.coffee │ ├── eql_spec.coffee │ ├── equal_value_spec.rb │ ├── fetch_spec.coffee │ ├── fixtures │ │ └── classes.rb │ ├── flatten_spec.coffee │ ├── has_key_spec.coffee │ ├── has_value_spec.coffee │ ├── include_spec.coffee │ ├── index_spec.coffee │ ├── indexes_spec.coffee │ ├── indices_spec.coffee │ ├── initialize_spec.rb │ ├── inspect_spec.rb │ ├── invert_spec.coffee │ ├── keep_if_spec.coffee │ ├── key_spec.coffee │ ├── keys_spec.coffee │ ├── length_spec.rb │ ├── member_spec.coffee │ ├── merge_spec.coffee │ ├── new_spec.rb │ ├── rassoc_spec.coffee │ ├── reject_spec.coffee │ ├── replace_spec.rb │ ├── select_spec.coffee │ ├── shared │ │ ├── each.rb │ │ ├── eql.rb │ │ ├── equal.rb │ │ ├── index.rb │ │ ├── iteration.rb │ │ ├── key.rb │ │ ├── length.rb │ │ ├── replace.rb │ │ ├── store.rb │ │ ├── to_s.rb │ │ ├── update.rb │ │ ├── value.rb │ │ └── values_at.rb │ ├── shift_spec.rb │ ├── size_spec.coffee │ ├── sort_spec.coffee │ ├── store_spec.coffee │ ├── to_a_spec.coffee │ ├── to_h_spec.coffee │ ├── to_hash_spec.coffee │ ├── to_s_spec.rb │ ├── try_convert_spec.rb │ ├── unsupported │ │ ├── allocate_spec.rb │ │ ├── hash_spec.rb │ │ ├── initialize_copy_spec.rb │ │ └── rehash_spec.rb │ ├── update_spec.coffee │ ├── value_spec.coffee │ ├── values_at_spec.coffee │ └── values_spec.coffee ├── integer │ ├── ceil_spec.coffee │ ├── chr_spec.coffee │ ├── deprecated │ │ └── induced_from_spec.rb │ ├── downto_spec.coffee │ ├── even_spec.coffee │ ├── floor_spec.coffee │ ├── gcd_spec.coffee │ ├── gcdlcm_spec.coffee │ ├── integer_spec.coffee │ ├── lcm_spec.coffee │ ├── next_spec.coffee │ ├── odd_spec.coffee │ ├── ord_spec.coffee │ ├── pred_spec.coffee │ ├── round_spec.coffee │ ├── shared │ │ ├── next.rb │ │ └── to_i.rb │ ├── succ_spec.coffee │ ├── times_spec.coffee │ ├── to_i_spec.coffee │ ├── to_int_spec.coffee │ ├── truncate_spec.coffee │ ├── unsupported │ │ ├── denominator_spec.rb │ │ ├── numerator_spec.rb │ │ ├── rationalize_spec.rb │ │ └── to_r_spec.rb │ └── upto_spec.coffee ├── kernel │ ├── Float_spec.coffee │ ├── Integer_spec.coffee │ ├── rand_spec.coffee │ └── typecast_spec.coffee ├── matchdata │ ├── begin_spec.coffee │ ├── captures_spec.coffee │ ├── element_reference_spec.coffee │ ├── end_spec.coffee │ ├── eql_spec.coffee │ ├── equal_value_spec.coffee │ ├── hash_spec.coffee │ ├── initialize_copy_spec.coffee │ ├── inspect_spec.coffee │ ├── length_spec.coffee │ ├── names_spec.coffee │ ├── offset_spec.coffee │ ├── post_match_spec.coffee │ ├── pre_match_spec.coffee │ ├── regexp_spec.coffee │ ├── select_spec.coffee │ ├── shared │ │ ├── eql.rb │ │ └── length.rb │ ├── size_spec.coffee │ ├── string_spec.coffee │ ├── to_a_spec.coffee │ ├── to_s_spec.coffee │ └── values_at_spec.coffee ├── numeric │ ├── abs2_spec.coffee │ ├── abs_spec.coffee │ ├── ceil_spec.coffee │ ├── coerce_spec.coffee │ ├── comparison_spec.coffee │ ├── div_spec.coffee │ ├── divmod_spec.coffee │ ├── eql_spec.coffee │ ├── fdiv_spec.coffee │ ├── fixtures │ │ └── classes.coffee │ ├── floor_spec.coffee │ ├── integer_spec.coffee │ ├── magnitude_spec.coffee │ ├── modulo_spec.coffee │ ├── nonzero_spec.coffee │ ├── quo_spec.coffee │ ├── rect_spec.coffee │ ├── rectangular_spec.coffee │ ├── remainder_spec.coffee │ ├── round_spec.coffee │ ├── shared │ │ ├── abs.rb │ │ ├── quo.rb │ │ └── rect.rb │ ├── step_spec.coffee │ ├── to_int_spec.coffee │ ├── truncate_spec.coffee │ ├── unsupported │ │ ├── angle_spec.rb │ │ ├── arg_spec.rb │ │ ├── conj_spec.rb │ │ ├── conjugate_spec.rb │ │ ├── denominator_spec.rb │ │ ├── i_spec.rb │ │ ├── imag_spec.rb │ │ ├── imaginary_spec.rb │ │ ├── initialize_copy_spec.rb │ │ ├── numerator_spec.rb │ │ ├── phase_spec.rb │ │ ├── polar_spec.rb │ │ ├── real_spec.rb │ │ ├── singleton_method_added_spec.rb │ │ ├── to_c_spec.rb │ │ ├── uminus_spec.rb │ │ └── uplus_spec.rb │ └── zero_spec.coffee ├── object │ ├── __id__spec.rb │ ├── clone_spec.rb │ ├── dup_spec.rb │ ├── fixtures │ │ └── classes.rb │ ├── id_spec.rb │ ├── initialize_spec.rb │ ├── instance_exec_spec.rb │ ├── instance_of_spec.rb │ ├── is_a_spec.rb │ ├── kind_of_spec.rb │ ├── match_spec.rb │ ├── metaclass_spec.rb │ ├── new_spec.rb │ ├── object_id_spec.rb │ └── shared │ │ ├── dup_clone.rb │ │ └── kind_of.rb ├── range │ ├── begin_spec.coffee │ ├── case_compare_spec.coffee │ ├── cover_spec.coffee │ ├── each_spec.coffee │ ├── end_spec.coffee │ ├── eql_spec.coffee │ ├── equal_value_spec.coffee │ ├── exclude_end_spec.coffee │ ├── first_spec.coffee │ ├── hash_spec.coffee │ ├── include_spec.coffee │ ├── initialize_spec.coffee │ ├── inspect_spec.coffee │ ├── jsruby_spec.coffee │ ├── last_spec.coffee │ ├── max_spec.coffee │ ├── member_spec.coffee │ ├── min_spec.coffee │ ├── new_spec.coffee │ ├── step_spec.coffee │ ├── to_a_spec.coffee │ └── to_s_spec.coffee ├── regexp │ ├── case_compare_spec.coffee │ ├── casefold_spec.coffee │ ├── compile_spec.coffee │ ├── encoding_spec.coffee │ ├── eql_spec.coffee │ ├── equal_value_spec.coffee │ ├── escape_spec.coffee │ ├── fixed_encoding_spec.coffee │ ├── hash_spec.coffee │ ├── initialize_copy_spec.coffee │ ├── initialize_spec.coffee │ ├── inspect_spec.coffee │ ├── kcode_spec.coffee │ ├── last_match_spec.coffee │ ├── match_spec.coffee │ ├── named_captures.coffee │ ├── names_spec.coffee │ ├── new_spec.coffee │ ├── options_spec.coffee │ ├── quote_spec.coffee │ ├── shared │ │ ├── equal_value.rb │ │ ├── new.rb │ │ └── quote.rb │ ├── source_spec.coffee │ ├── to_s_spec.coffee │ ├── try_convert_spec.coffee │ ├── union_spec.coffee │ └── versions │ │ ├── named_captures_1.9.rb │ │ └── names_1.9.rb ├── string │ ├── append_spec.coffee │ ├── ascii_only_spec.coffee │ ├── capitalize_spec.coffee │ ├── case_compare_spec.coffee │ ├── casecmp_spec.coffee │ ├── center_spec.coffee │ ├── chars_spec.coffee │ ├── chomp_spec.coffee │ ├── chop_spec.coffee │ ├── chr_spec.coffee │ ├── clear_spec.coffee │ ├── comparison_spec.coffee │ ├── concat_spec.coffee │ ├── count_spec.coffee │ ├── delete_spec.coffee │ ├── downcase_spec.coffee │ ├── dump_spec.coffee │ ├── dup_spec.coffee │ ├── each_char_spec.coffee │ ├── each_line_spec.coffee │ ├── each_spec.coffee │ ├── element_reference_spec.coffee │ ├── element_set_spec.coffee │ ├── empty_spec.coffee │ ├── end_with_spec.coffee │ ├── eql_spec.coffee │ ├── equal_spec.coffee │ ├── equal_value_spec.coffee │ ├── fixtures │ │ ├── classes.coffee │ │ ├── classes.rb │ │ ├── iso-8859-9-encoding.rb │ │ └── utf-8-encoding.rb │ ├── gsub_spec.coffee │ ├── include_spec.coffee │ ├── index_spec.coffee │ ├── initialize_spec.coffee │ ├── insert_spec.coffee │ ├── inspect_spec.coffee │ ├── length_spec.coffee │ ├── lines_spec.coffee │ ├── ljust_spec.coffee │ ├── lstrip_spec.coffee │ ├── match_spec.coffee │ ├── modulo_spec.rb │ ├── multiply_spec.coffee │ ├── new_spec.coffee │ ├── next_spec.coffee │ ├── partition_spec.coffee │ ├── plus_spec.coffee │ ├── prepend_spec.coffee │ ├── replace_spec.coffee │ ├── reverse_spec.coffee │ ├── rindex_spec.coffee │ ├── rjust_spec.coffee │ ├── rpartition_spec.coffee │ ├── rstrip_spec.coffee │ ├── scan_spec.coffee │ ├── shared │ │ ├── chars.rb │ │ ├── codepoints.rb │ │ ├── concat.rb │ │ ├── each_line.rb │ │ ├── encode.rb │ │ ├── equal_value.rb │ │ ├── length.rb │ │ ├── replace.rb │ │ ├── slice.rb │ │ ├── succ.rb │ │ ├── to_a.rb │ │ ├── to_s.rb │ │ ├── to_sym.rb │ │ └── versions │ │ │ ├── slice_1.9.rb │ │ │ └── slice_2.0.rb │ ├── size_spec.coffee │ ├── slice_spec.coffee │ ├── split_spec.coffee │ ├── squeeze_spec.coffee │ ├── start_with_spec.coffee │ ├── string_spec.coffee │ ├── strip_spec.coffee │ ├── sub_spec.coffee │ ├── succ_spec.coffee │ ├── swapcase_spec.coffee │ ├── to_a_spec.coffee │ ├── to_f_spec.coffee │ ├── to_i_spec.coffee │ ├── to_s_spec.coffee │ ├── to_str_spec.coffee │ ├── tr_s_spec.coffee │ ├── tr_spec.coffee │ ├── try_convert_spec.coffee │ ├── unpack │ │ ├── a_spec.rb │ │ ├── at_spec.rb │ │ ├── b_spec.rb │ │ ├── c_spec.rb │ │ ├── comment_spec.rb │ │ ├── d_spec.rb │ │ ├── e_spec.rb │ │ ├── f_spec.rb │ │ ├── g_spec.rb │ │ ├── h_spec.rb │ │ ├── i_spec.rb │ │ ├── l_spec.rb │ │ ├── m_spec.rb │ │ ├── n_spec.rb │ │ ├── p_spec.rb │ │ ├── percent_spec.rb │ │ ├── q_spec.rb │ │ ├── s_spec.rb │ │ ├── shared │ │ │ ├── basic.rb │ │ │ ├── float.rb │ │ │ ├── integer.rb │ │ │ ├── string.rb │ │ │ └── unicode.rb │ │ ├── u_spec.rb │ │ ├── v_spec.rb │ │ ├── w_spec.rb │ │ ├── x_spec.rb │ │ └── z_spec.rb │ ├── unsupported │ │ ├── allocate_spec.rb │ │ ├── bytes_spec.rb │ │ ├── bytesize_spec.rb │ │ ├── byteslice_spec.rb │ │ ├── codepoints_spec.rb │ │ ├── crypt_spec.rb │ │ ├── each_byte_spec.rb │ │ ├── each_codepoint_spec.rb │ │ ├── encode_spec.rb │ │ ├── encoding_spec.rb │ │ ├── entries_spec.rb │ │ ├── force_encoding_spec.rb │ │ ├── getbyte_spec.rb │ │ ├── hash_spec.rb │ │ ├── hex_spec.rb │ │ ├── intern_spec.rb │ │ ├── oct_spec.rb │ │ ├── ord_spec.rb │ │ ├── setbyte_spec.rb │ │ ├── sum_spec.rb │ │ ├── to_c_spec.rb │ │ ├── to_r_spec.rb │ │ ├── to_sym_spec.rb │ │ └── valid_encoding_spec.rb │ ├── upcase_spec.coffee │ └── upto_spec.coffee ├── time │ ├── asctime_spec.coffee │ ├── at_spec.coffee │ ├── comparison_spec.coffee │ ├── ctime_spec.coffee │ ├── day_spec.coffee │ ├── dst_spec.rb │ ├── dup_spec.coffee │ ├── eql_spec.coffee │ ├── fixtures │ │ ├── classes.coffee │ │ └── methods.rb │ ├── friday_spec.coffee │ ├── getgm_spec.coffee │ ├── getlocal_spec.rb │ ├── getutc_spec.coffee │ ├── gm_spec.coffee │ ├── gmt_offset_spec.rb │ ├── gmt_spec.coffee │ ├── gmtime_spec.coffee │ ├── gmtoff_spec.coffee │ ├── hour_spec.coffee │ ├── initialize_copy_spec.coffee │ ├── inspect_spec.coffee │ ├── isdst_spec.rb │ ├── local_spec.coffee │ ├── localtime_spec.rb │ ├── mday_spec.coffee │ ├── min_spec.coffee │ ├── minus_spec.coffee │ ├── mktime_spec.rb │ ├── mon_spec.coffee │ ├── monday_spec.coffee │ ├── month_spec.coffee │ ├── new_spec.coffee │ ├── now_spec.coffee │ ├── plus_spec.coffee │ ├── round_spec.rb │ ├── saturday_spec.coffee │ ├── sec_spec.coffee │ ├── shared │ │ ├── asctime.rb │ │ ├── day.rb │ │ ├── getgm.rb │ │ ├── gm.rb │ │ ├── gmt_offset.rb │ │ ├── gmtime.rb │ │ ├── inspect.rb │ │ ├── isdst.rb │ │ ├── local.rb │ │ ├── month.rb │ │ ├── now.rb │ │ ├── time_params.rb │ │ └── to_i.rb │ ├── strftime_spec.coffee │ ├── succ_spec.coffee │ ├── sunday_spec.coffee │ ├── thursday_spec.coffee │ ├── times_spec.rb │ ├── to_a_spec.rb │ ├── to_f_spec.coffee │ ├── to_i_spec.coffee │ ├── to_r_spec.rb │ ├── to_s_spec.coffee │ ├── tuesday_spec.coffee │ ├── tv_sec_spec.coffee │ ├── tv_usec_spec.coffee │ ├── unsupported │ │ ├── _dump_spec.rb │ │ ├── _load_spec.rb │ │ ├── hash_spec.rb │ │ ├── nsec_spec.rb │ │ ├── subsec_spec.rb │ │ └── tv_nsec_spec.rb │ ├── usec_spec.coffee │ ├── utc_offset_spec.rb │ ├── utc_spec.rb │ ├── wday_spec.coffee │ ├── wednesday_spec.coffee │ ├── yday_spec.coffee │ ├── year_spec.coffee │ └── zone_spec.rb └── versions │ ├── element_reference_1.9.rb │ └── names_1.9.rb ├── helpers └── SpecHelper.coffee ├── lite ├── arr_spec.coffee ├── coerce_spec.coffee ├── hsh_spec.coffee ├── num_spec.coffee └── str_spec.coffee ├── playground ├── README.md ├── boxing_unboxing_spec.coffee ├── examples_spec.coffee ├── jsruby_differences_spec.coffee ├── jsruby_spec.coffee ├── loops_spec.coffee └── single_block_arg_spec.coffee ├── rubyjs ├── README.md ├── array_spec.coffee ├── block_spec.coffee ├── coerce_spec.coffee ├── enumerable │ ├── single_block_argument_arity_2_spec.coffee │ └── single_block_argument_spec.coffee ├── enumerable_spec.coffee ├── enumerator_spec.coffee ├── hash_spec.coffee ├── numeric_spec.coffee ├── object_spec.coffee ├── ruby_spec.coffee ├── string_spec.coffee └── time_spec.coffee ├── spec_helper.coffee └── support └── support.yml /.codoopts: -------------------------------------------------------------------------------- 1 | --name "RubyJS" 2 | --readme README.md 3 | --title "RubyJS API Documentation" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /tmp/* 2 | /playground/* 3 | /benchmark/* 4 | /doc/* 5 | npm-debug.log 6 | node_modules/* 7 | .rbenv-version -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | lib/ 4 | spec/ 5 | tmp/ 6 | Gemfile 7 | Gemfile.lock 8 | Guardfile 9 | *.log 10 | .git/ 11 | Rakefile 12 | 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.11" 4 | - "0.10" 5 | - "0.8" 6 | before_script: 7 | - "npm i -g jasmine-node" -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 2012-12-14 2 | 3 | - rails asset pipeline gem: github.com/rubyjs/rubyjs-rails thanks to github.com/PikachuEXE 4 | - Block.supportMultipleArgs 5 | 6 | ### 2012-12-13 7 | 8 | - Add Block classes to handle different block arities 9 | 10 | ### 2012-12-10 11 | 12 | - Created npm module 13 | 14 | # 0.7.2 bugfix release for Enumerable 15 | 16 | ### 2012-12-05 17 | 18 | - Bugfix: Enumerable#min, #max do not return wrapped value. 19 | - Improvements for Enumerable#min_by, #max_by, #min, #max 20 | - Bugfix: Make Enumerable#sort throw ArgumentError for mixed elements. 21 | 22 | ### 2012-12-04 23 | 24 | - Array cleanup, replacing R([]) with new R.Array([]) (optimization) 25 | 26 | ### 2012-12-03. 0.7.1 27 | 28 | - new R.Array() accepts recursive flag 29 | - Perf: less argument splatting in new R.Enumerator() and #to_enum 30 | - Bug: String#upto includes last element when not passing a block. 31 | - R.pollute_global() adds convenience methods to global namespace: puts, proc, truthy, falsey, inspect -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rake' 4 | gem 'guard' 5 | gem 'guard-coffeescript' 6 | gem 'guard-shell' 7 | gem 'guard-uglify' 8 | gem 'guard-livereload' 9 | gem 'jasmine', '~> 1.3.0' 10 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | require 'guard/guard' 2 | 3 | # Output compiled JS classes for debugging 4 | # 5 | guard 'coffeescript', :output => 'tmp', :bare => true do 6 | watch('^lib/**/(.*)\.coffee') 7 | end 8 | 9 | # Creates ~/ruby.js, and spec/javascripts/ruby-full.js for jasmine 10 | guard :shell do 11 | watch('^lib/**/(.*)\.coffee') { `cake build` } 12 | end 13 | 14 | # Compiles spec/ files 15 | guard 'coffeescript', :output => 'spec/javascripts' do 16 | watch('^spec/lib/(.*)\.coffee') 17 | end 18 | 19 | guard 'livereload' do 20 | watch('^spec/javascripts/.+\.js$') 21 | watch('^javascripts/lib/.+\.js$') 22 | end 23 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./ruby.js') 2 | -------------------------------------------------------------------------------- /lib/base/err.coffee: -------------------------------------------------------------------------------- 1 | _err = 2 | throw_argument: (msg) -> 3 | throw RArgumentError.new(msg) 4 | 5 | throw_type: (msg) -> 6 | throw RTypeError.new(msg) 7 | 8 | throw_index: (msg) -> 9 | throw RIndexError.new(msg) 10 | 11 | throw_not_implemented: (msg) -> 12 | throw RNotImplementedError.new(msg) 13 | 14 | throw_key: (msg) -> 15 | throw RKeyError.new(msg) 16 | 17 | -------------------------------------------------------------------------------- /lib/boot.coffee: -------------------------------------------------------------------------------- 1 | # This file is included at the end of the compiled javascript and 2 | # setups the RubyJS environment 3 | 4 | RubyJS.pollute_global_with_shortcuts() 5 | RubyJS.pollute_global_with_kernel() 6 | root.puts = _puts 7 | -------------------------------------------------------------------------------- /lib/core/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hasclass/core-lib/5fc22406621699f158f78fef94a979ba68c52318/lib/core/.DS_Store -------------------------------------------------------------------------------- /lib/core/aliases.coffee: -------------------------------------------------------------------------------- 1 | # Native classes, to avoid naming conflicts inside RubyJS classes. 2 | nativeArray = Array 3 | nativeNumber = Number 4 | nativeObject = Object 5 | nativeRegExp = RegExp 6 | nativeString = String 7 | 8 | ObjProto = Object.prototype 9 | StrProto = String.prototype 10 | ArrProto = Array.prototype 11 | 12 | nativeToString = ObjProto.toString 13 | nativeStrSlice = StrProto.slice 14 | nativeStrMatch = StrProto.match 15 | nativeJoin = ArrProto.join 16 | nativeSort = ArrProto.sort 17 | nativeSlice = ArrProto.slice 18 | nativeUnshift = ArrProto.unshift 19 | nativePush = ArrProto.push -------------------------------------------------------------------------------- /lib/core/errors.coffee: -------------------------------------------------------------------------------- 1 | errors = [ 2 | 'ArgumentError' 3 | 'RegexpError' 4 | 'TypeError' 5 | 'KeyError' 6 | 'IndexError' 7 | 'FloatDomainError' 8 | 'RangeError' 9 | 'StandardError' 10 | 'ZeroDivisionError' 11 | 'NotSupportedError' 12 | 'NotImplementedError' 13 | ] 14 | 15 | for error in errors 16 | do (error) -> 17 | errorClass = class extends Error 18 | errorClass.new = -> new RubyJS[error](error) 19 | RubyJS[error] = this["R"+error] = errorClass 20 | -------------------------------------------------------------------------------- /lib/oo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hasclass/core-lib/5fc22406621699f158f78fef94a979ba68c52318/lib/oo/.DS_Store -------------------------------------------------------------------------------- /lib/oo/math.coffee: -------------------------------------------------------------------------------- 1 | # Not yet implemented 2 | class RubyJS.Math 3 | 4 | 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rubyjs", 3 | "version": "0.7.2", 4 | "description": "JavaScript standard library (String, Array, etc) based on Ruby core-lib.", 5 | "keywords": [], 6 | "author": "Sebastian Burkhard ", 7 | "repository": "git://github.com/rubyjs/core-lib.git", 8 | "main": "index", 9 | "homepage": "http://rubyjs.org", 10 | "contributors": [ 11 | { 12 | "name": "Sebastian Burkhard" 13 | } 14 | ], 15 | "bugs": { 16 | "url": "https://github.com/rubyjs/core-lib/issues", 17 | "email": "info@rubyjs.org" 18 | }, 19 | "dependencies": { 20 | }, 21 | "devDependencies": { 22 | }, 23 | "licenses": [ 24 | { 25 | "type": "MIT", 26 | "url": "http://github.com/rubyjs/core-lib/raw/master/LICENSE" 27 | } 28 | ], 29 | "scripts": { 30 | "test": "jasmine-node --coffee spec" 31 | } 32 | } -------------------------------------------------------------------------------- /ruby.min.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hasclass/core-lib/5fc22406621699f158f78fef94a979ba68c52318/ruby.min.js.gz -------------------------------------------------------------------------------- /spec/README.md: -------------------------------------------------------------------------------- 1 | CoffeeScript 1.3.3 needed. 2 | 3 | Generate specs and core javascript files by running 4 | 5 | $ cake build_tests 6 | $ rake jasmine 7 | $ open http://localhost:8888 8 | 9 | Use Guard for automatic compiling. 10 | 11 | $ bundle install 12 | $ bundle exec guard 13 | -------------------------------------------------------------------------------- /spec/javascripts/.gitignore: -------------------------------------------------------------------------------- 1 | *.js -------------------------------------------------------------------------------- /spec/javascripts/support/jasmine.yml: -------------------------------------------------------------------------------- 1 | src_dir: spec/javascripts 2 | 3 | src_files: 4 | - helpers/SpecHelper.js 5 | - ruby.js 6 | - corelib/string/fixtures/classes.js 7 | - corelib/numeric/fixtures/classes.js 8 | - corelib/enumerable/fixtures/classes.js 9 | - corelib/time/fixtures/classes.js 10 | 11 | spec_dir: spec/javascripts 12 | 13 | spec_files: 14 | - '**/*_spec.js' -------------------------------------------------------------------------------- /spec/lib/corelib/README.md: -------------------------------------------------------------------------------- 1 | spec/lib/corelib contains rubyspec specs. 2 | 3 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/count_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'ruby_version_is "1.8.7"', -> 2 | describe "Array#count", -> 3 | it "returns the number of elements", -> 4 | expect( R(['a', 'b', 'c']).count() ).toEqual R(3) 5 | 6 | it "returns the number of elements that equal the argument", -> 7 | expect( R(['a', 'b', 'b', 'c']).count('b') ).toEqual R(2) 8 | 9 | it "returns the number of element for which the block evaluates to true", -> 10 | expect( R(['a', 'b', 'c']).count (s) -> !(s == 'b') ).toEqual R(2) 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/drop_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'ruby_version_is "1.8.7"', -> 2 | describe "Array#drop", -> 3 | it "removes the specified number of elements from the start of the array", -> 4 | expect( R([1, 2, 3, 4, 5]).drop(2) ).toEqual R([3, 4, 5]) 5 | 6 | it "raises an ArgumentError if the number of elements specified is negative", -> 7 | expect( -> R([1, 2]).drop(-3) ).toThrow('ArgumentError') 8 | 9 | it "returns an empty Array if all elements are dropped", -> 10 | expect( R([1, 2]).drop(2) ).toEqual R([]) 11 | 12 | it "returns an empty Array when called on an empty Array", -> 13 | expect( R([]).drop(0) ).toEqual R([]) 14 | 15 | it "does not remove any elements when passed zero", -> 16 | expect( R([1, 2]).drop(0) ).toEqual R([1, 2]) 17 | 18 | it "returns an empty Array if more elements than exist are dropped", -> 19 | expect( R([1, 2]).drop(3) ).toEqual R([]) 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/drop_while_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'ruby_version_is "1.8.7"', -> 2 | describe "Array#drop_while", -> 3 | it "removes elements from the start of the array while the block evaluates to true", -> 4 | expect( R([1, 2, 3, 4]).drop_while((n) -> n < 4 ) ).toEqual R([4]) 5 | 6 | it "removes elements from the start of the array until the block returns nil", -> 7 | expect( R([1, 2, 3, null, 5]).drop_while((n) -> n ) ).toEqual R([null, 5]) 8 | 9 | it "removes elements from the start of the array until the block returns false", -> 10 | expect( R([1, 2, 3, false, 5]).drop_while((n) -> n ) ).toEqual R([false, 5]) 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/each_index_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Array#each_index", -> 2 | it "passes the index of each element to the block", -> 3 | a = R(['a', 'b', 'c', 'd']) 4 | acc = [] 5 | a.each_index (i) -> acc.push i 6 | expect( acc ).toEqual [0, 1, 2, 3] 7 | 8 | it "returns self", -> 9 | a = R(['a', 'b', 'c']) 10 | acc = [] 11 | expect( a.each_index( (i) -> acc.push) is a).toEqual true 12 | 13 | it "is not confused by removing elements from the front", -> 14 | a = R([1, 2, 3]) 15 | 16 | a.shift() 17 | acc = [] 18 | a.each_index (i) -> acc.push i 19 | expect( acc ).toEqual [0, 1] 20 | 21 | a.shift() 22 | acc = [] 23 | a.each_index (i) -> acc.push i 24 | expect( acc ).toEqual [0] 25 | 26 | # it_behaves_like :enumeratorize, :each_index -------------------------------------------------------------------------------- /spec/lib/corelib/array/empty_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Array#empty?", -> 2 | it "returns true if the array has no elements", -> 3 | expect( R([] ).empty() ).toEqual true 4 | expect( R([1] ).empty() ).toEqual false 5 | expect( R([1, 2]).empty() ).toEqual false -------------------------------------------------------------------------------- /spec/lib/corelib/array/index_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Array#index", -> 2 | # it_behaves_like(:array_index, :index) 3 | it "returns the index of the first element == to object", -> 4 | x = 5 | equals: (obj) -> R(3).equals(obj) 6 | 7 | expect( R([2, x, 3, 1, 3, 1]).index(3) ).toEqual R(1) 8 | expect( R([2, 3.0, 3, x, 1, 3, 1]).index(x) ).toEqual R(1) 9 | 10 | it "returns 0 if first element == to object", -> 11 | expect( R([2, 1, 3, 2, 5]).index(2) ).toEqual R(0) 12 | 13 | it "returns size-1 if only last element == to object", -> 14 | expect( R([2, 1, 3, 1, 5]).index(5) ).toEqual R(4) 15 | 16 | it "returns nil if no element == to object", -> 17 | expect( R([2, 1, 1, 1, 1]).index(3) ).toEqual null 18 | 19 | describe 'ruby_version_is "1.8.7"', -> 20 | it "accepts a block instead of an argument", -> 21 | expect( R([4, 2, 1, 5, 1, 3]).index((x) -> x < 2) ).toEqual R(2) 22 | 23 | it "ignore the block if there is an argument", -> 24 | expect( R([4, 2, 1, 5, 1, 3]).index(5, (x) -> x < 2) ).toEqual R(3) 25 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/keep_if_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Array#keep_if", -> 2 | it "returns the same array if no changes were made", -> 3 | ary = R [1, 2, 3] 4 | expect( ary.keep_if( -> true ) is ary ).toEqual true 5 | expect( ary.keep_if( -> true ) ).toEqual ary 6 | # check for falsey values 7 | expect( ary.keep_if( -> false) ).toEqual R([]) 8 | expect( ary.keep_if( -> 0 ) ).toEqual R([]) 9 | expect( ary.keep_if( -> 1 ) ).toEqual R([]) 10 | expect( ary.keep_if( -> null ) ).toEqual R([]) 11 | expect( ary.keep_if( -> undefined ) ).toEqual R([]) 12 | 13 | it "deletes elements for which the block returns a false value", -> 14 | ary = R [1, 2, 3, 4, 5] 15 | expect( ary.keep_if((item) -> item > 3) is ary ).toEqual true 16 | expect( ary ).toEqual R([4, 5]) 17 | 18 | it "returns an enumerator if no block is given", -> 19 | expect( R([1, 2, 3]).keep_if() ).toBeInstanceOf R.Enumerator 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/length_spec.coffee: -------------------------------------------------------------------------------- 1 | xdescribe "Array#length", -> 2 | 3 | it "returns the number of elements", -> 4 | expect( R([]).length).toEqual R(0) 5 | expect( R([1, 2, 3]).length).toEqual R(3) 6 | 7 | it "properly handles recursive arrays", -> 8 | empty = R([]) 9 | empty.push(empty) 10 | expect( empty.length ).toEqual R(1) 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/pack/comment_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding: ascii-8bit -*- 2 | require File.expand_path('../../../../spec_helper', __FILE__) 3 | require File.expand_path('../../fixtures/classes', __FILE__) 4 | 5 | describe "Array#pack", -> 6 | it "ignores directives text from '#' to the first newline", -> 7 | [1, 2, 3].pack("c#this is a comment\nc").should == "\x01\x02" 8 | 9 | it "ignores directives text from '#' to the end if no newline is present", -> 10 | [1, 2, 3].pack("c#this is a comment c").should == "\x01" 11 | 12 | it "ignores comments at the start of the directives string", -> 13 | [1, 2, 3].pack("#this is a comment\nc").should == "\x01" 14 | 15 | it "ignores the entire directive string if it is a comment", -> 16 | [1, 2, 3].pack("#this is a comment").should == "" 17 | 18 | it "ignores multiple comments", -> 19 | [1, 2, 3].pack("c#comment\nc#comment\nc#c").should == "\x01\x02\x03" 20 | end 21 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/pack/empty_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | 3 | describe "Array#pack with empty format", -> 4 | it "returns an empty String", -> 5 | [1, 2, 3].pack("").should == "" 6 | 7 | ruby_version_is "1.9", -> 8 | it "returns a String with US-ASCII encoding", -> 9 | [1, 2, 3].pack("").encoding.should == Encoding::US_ASCII 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/pack/p_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | require File.expand_path('../../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/basic', __FILE__) 4 | 5 | describe "Array#pack with format 'P'", -> 6 | it_behaves_like :array_pack_basic_non_float, 'P' 7 | 8 | it "returns a String whose size is the number of bytes in a machine word", -> 9 | [nil].pack("P").size.should == 1.size 10 | end 11 | 12 | describe "Array#pack with format 'p'", -> 13 | it_behaves_like :array_pack_basic_non_float, 'p' 14 | 15 | it "returns a String whose size is the number of bytes in a machine word", -> 16 | [nil].pack("p").size.should == 1.size 17 | end 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/pack/percent_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | 3 | describe "Array#pack with format '%'", -> 4 | it "raises an Argument Error", -> 5 | expect( -> [1].pack("%") ).toThrow(ArgumentError) 6 | end 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/pack/shared/encodings.rb: -------------------------------------------------------------------------------- 1 | describe :array_pack_hex, :shared => true do 2 | it "encodes no bytes when passed zero as the count modifier", -> 3 | ["abc"].pack(pack_format(0)).should == "" 4 | 5 | it "raises a TypeError if the object does not respond to #to_str", -> 6 | obj = mock("pack hex non-string") 7 | expect( -> [obj].pack(pack_format) ).toThrow(TypeError) 8 | 9 | it "raises a TypeError if #to_str does not return a String", -> 10 | obj = mock("pack hex non-string") 11 | obj.should_receive(:to_str).and_return(1) 12 | expect( -> [obj].pack(pack_format) ).toThrow(TypeError) 13 | end 14 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/reverse_each_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Array#reverse_each", -> 2 | it "traverses array in reverse order and pass each element to block", -> 3 | acc = [] 4 | R([1, 3, 4, 6]).reverse_each (i) -> acc.push i 5 | expect( acc ).toEqual [6, 4, 3, 1] 6 | 7 | it "returns self", -> 8 | a = R ['a', 'b', 'c'] 9 | expect( a.reverse_each(->) is a ).toEqual true 10 | 11 | it "returns Enumerator without Block", -> 12 | a = R ['a', 'b', 'c'] 13 | expect( a.reverse_each() ).toBeInstanceOf(R.Enumerator) 14 | 15 | xit "yields only the top level element of an empty recursive arrays", -> 16 | # empty = ArraySpecs.empty_recursive_array 17 | # empty.reverse_each { |i| ScratchPad << i } 18 | # ScratchPad.recorded.should == [empty] 19 | 20 | xit "yields only the top level element of a recursive array", -> 21 | # array = ArraySpecs.recursive_array 22 | # array.reverse_each { |i| ScratchPad << i } 23 | # ScratchPad.recorded.should == [array, array, array, array, array, 3.0, 'two', 1] 24 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/select_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Array#select", -> 2 | # it_behaves_like :enumeratorize, :select 3 | 4 | it "returns a new array of elements for which block is true", -> 5 | expect( R([1, 3, 4, 5, 6, 9]).select (i) -> i >= 5 ).toEqual R([5,6,9]) 6 | 7 | xit "does not return subclass instance on Array subclasses", -> 8 | # ArraySpecs.MyArray[1, 2, 3].select { true }.should be_kind_of(Array) 9 | 10 | it "properly handles recursive arrays", -> 11 | empty = R [] 12 | empty.push(empty) 13 | expect( empty.select( -> true ) ).toEqual empty 14 | expect( empty.select( -> false ) ).toEqual R([]) 15 | 16 | # array = ArraySpecs.recursive_array 17 | # array.select { true }.should == [1, 'two', 3.0, array, array, array, array, array] 18 | # array.select { false }.should == [] 19 | 20 | describe "Array#select!", -> 21 | it "returns nil if no changes were made in the array", -> 22 | expect( R([1, 2, 3]).select_bang -> true ).toEqual null 23 | 24 | # it_behaves_like :keep_if, :select! 25 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/shared/enumeratorize.rb: -------------------------------------------------------------------------------- 1 | describe :enumeratorize, :shared => true do 2 | ruby_version_is '' ... '1.8.7' do 3 | it "raises a LocalJumpError if no block given", -> 4 | lambda{ [1,2].send(@method) ).toThrow(LocalJumpError) 5 | ruby_version_is '1.8.7' do 6 | it "returns an Enumerator if no block given", -> 7 | [1,2].send(@method).should be_an_instance_of(enumerator_class) 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/shared/index.rb: -------------------------------------------------------------------------------- 1 | describe :array_index, :shared => true do 2 | it "returns the index of the first element == to object", -> 3 | x = mock('3') 4 | def x.==(obj) 3 == obj; end 5 | 6 | [2, x, 3, 1, 3, 1].send(@method, 3).should == 1 7 | [2, 3.0, 3, x, 1, 3, 1].send(@method, x).should == 1 8 | 9 | it "returns 0 if first element == to object", -> 10 | [2, 1, 3, 2, 5].send(@method, 2).should == 0 11 | 12 | it "returns size-1 if only last element == to object", -> 13 | [2, 1, 3, 1, 5].send(@method, 5).should == 4 14 | 15 | it "returns nil if no element == to object", -> 16 | [2, 1, 1, 1, 1].send(@method, 3).should == nil 17 | ruby_version_is "1.8.7", -> 18 | it "accepts a block instead of an argument", -> 19 | [4, 2, 1, 5, 1, 3].send(@method) {|x| x < 2}.should == 2 20 | 21 | it "ignore the block if there is an argument", -> 22 | [4, 2, 1, 5, 1, 3].send(@method, 5) {|x| x < 2}.should == 3 23 | end -------------------------------------------------------------------------------- /spec/lib/corelib/array/shared/indexes.rb: -------------------------------------------------------------------------------- 1 | describe :array_indexes, :shared => true do 2 | it "returns elements at integer argument indexes (DEPRECATED)", -> 3 | array = [1, 2, 3, 4, 5] 4 | 5 | x = mock('4') 6 | def x.to_int() 4 end 7 | 8 | params = [1, 0, 5, -1, -8, 10, x] 9 | array.send(@method, *params).should == array.values_at(*params) 10 | 11 | it "tries to convert the passed arguments to Integers using #to_int", -> 12 | obj = mock('to_int') 13 | obj.should_receive(:to_int).and_return(1, 3) 14 | [1, 2, 3, 4, 5].send(@method, obj, obj).should == [2, 4] 15 | 16 | it "returns elements in range arguments as nested arrays (DEPRECATED)", -> 17 | array = [1, 2, 3, 4, 5] 18 | params = [0..2, 1...3, 4..6] 19 | array.indexes(*params).should == [[1, 2, 3], [2, 3], [5]] 20 | array.indices(*params).should == [[1, 2, 3], [2, 3], [5]] 21 | end 22 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/shared/keep_if.rb: -------------------------------------------------------------------------------- 1 | describe :keep_if, :shared => true do 2 | it "deletes elements for which the block returns a false value", -> 3 | array = [1, 2, 3, 4, 5] 4 | array.send(@method) {|item| item > 3 }.should equal(array) 5 | array.should == [4, 5] 6 | 7 | it "returns an enumerator if no block is given", -> 8 | [1, 2, 3].send(@method).should be_an_instance_of(enumerator_class) 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/shared/length.rb: -------------------------------------------------------------------------------- 1 | describe :array_length, :shared => true do 2 | it "returns the number of elements", -> 3 | [].send(@method).should == 0 4 | [1, 2, 3].send(@method).should == 3 5 | 6 | it "properly handles recursive arrays", -> 7 | ArraySpecs.empty_recursive_array.send(@method).should == 1 8 | ArraySpecs.recursive_array.send(@method).should == 8 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/size_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Array#size", -> 2 | 3 | it "returns the number of elements", -> 4 | expect( R([]).size()).toEqual R(0) 5 | expect( R([1, 2, 3]).size()).toEqual R(3) 6 | 7 | it "properly handles recursive arrays", -> 8 | empty = R([]) 9 | empty.push(empty) 10 | expect( empty.size() ).toEqual R(1) 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/take_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'ruby_version_is "1.8.7"', -> 2 | describe "Array#take", -> 3 | it "returns the first specified number of elements", -> 4 | expect( R([1, 2, 3]).take(2) ).toEqual R([1, 2]) 5 | 6 | it "returns all elements when the argument is greater than the Array size", -> 7 | expect( R([1, 2]).take(99) ).toEqual R([1, 2]) 8 | 9 | it "returns all elements when the argument is less than the Array size", -> 10 | expect( R([1, 2]).take(4) ).toEqual R([1, 2]) 11 | 12 | it "returns an empty Array when passed zero", -> 13 | expect( R([1]).take(0) ).toEqual R([]) 14 | 15 | it "returns an empty Array when called on an empty Array", -> 16 | expect( R([]).take(3) ).toEqual R([]) 17 | 18 | it "raises an ArgumentError when the argument is negative", -> 19 | expect( -> R([1]).take(-3) ).toThrow('ArgumentError') 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/take_while_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'ruby_version_is "1.8.7"', -> 2 | describe "Array#take_while", -> 3 | it "returns all elements until the block returns false", -> 4 | expect( R([1, 2, 3]).take_while( (element) -> element < 3 )).toEqual R([1, 2]) 5 | 6 | it "returns all elements until the block returns nil", -> 7 | expect( R([1, 2, null, 4]).take_while( (element) -> element )).toEqual R([1, 2]) 8 | 9 | it "returns all elements until the block returns false", -> 10 | expect( R([1, 2, false, 4]).take_while( (element) -> element )).toEqual R([1, 2]) 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/to_a_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Array#to_a", -> 2 | it "returns self", -> 3 | a = R([1, 2, 3]) 4 | expect( a.to_a() ).toEqual R([1, 2, 3]) 5 | expect( a ).toEqual a.to_a() 6 | 7 | xit "does not return subclass instance on Array subclasses", -> 8 | # e = ArraySpecs.MyArray.new(1, 2) 9 | # e.to_a.should be_an_instance_of(Array) 10 | # e.to_a.should == [1, 2] 11 | 12 | it "properly handles recursive arrays", -> 13 | empty = R([]) 14 | empty.push(empty) 15 | expect(empty.to_a()).toEqual empty 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/to_ary_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Array#to_ary", -> 2 | it "returns self", -> 3 | a = R([1, 2, 3]) 4 | expect( a.to_ary() ).toEqual R([1, 2, 3]) 5 | expect( a ).toEqual a.to_ary() 6 | 7 | xit "does not return subclass instance on Array subclasses", -> 8 | # e = ArraySpecs.MyArray.new(1, 2) 9 | # e.to_ary.should be_an_instance_of(Array) 10 | # e.to_ary.should == [1, 2] 11 | 12 | it "properly handles recursive arrays", -> 13 | empty = R([]) 14 | empty.push(empty) 15 | expect(empty.to_ary()).toEqual empty 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/unsupported/allocate_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Array.allocate", -> 4 | it "returns an instance of Array", -> 5 | ary = Array.allocate 6 | ary.should be_kind_of(Array) 7 | 8 | it "returns a fully-formed instance of Array", -> 9 | ary = Array.allocate 10 | ary.size.should == 0 11 | ary << 1 12 | ary.should == [1] 13 | 14 | it "does not accept any arguments", -> 15 | expect( -> Array.allocate(1) ).toThrow(ArgumentError) 16 | end 17 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/unsupported/array_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Array", -> 4 | it "includes Enumerable", -> 5 | Array.ancestors.include?(Enumerable).should == true 6 | end 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/unsupported/choice_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | 4 | describe "Array#choice", -> 5 | ruby_version_is "1.8.7"..."1.9", -> 6 | it "selects a random value from the array", -> 7 | a = [1,2,3,4] 8 | 10.times { a.include?(a.choice).should be_true } 9 | 10 | it "returns nil for empty arrays", -> 11 | [].choice.should be_nil 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/unsupported/constructor_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | 4 | describe "Array.[]", -> 5 | it "returns a new array populated with the given elements", -> 6 | obj = Object.new 7 | Array.[](5, true, nil, 'a', "Ruby", obj).should == [5, true, nil, "a", "Ruby", obj] 8 | 9 | a = ArraySpecs.MyArray.[](5, true, nil, 'a', "Ruby", obj) 10 | a.should be_kind_of(ArraySpecs.MyArray) 11 | a.inspect.should == [5, true, nil, "a", "Ruby", obj].inspect 12 | end 13 | 14 | describe "Array[]", -> 15 | it "is a synonym for .[]", -> 16 | obj = Object.new 17 | Array[5, true, nil, 'a', "Ruby", obj].should == Array.[](5, true, nil, "a", "Ruby", obj) 18 | 19 | a = ArraySpecs.MyArray[5, true, nil, 'a', "Ruby", obj] 20 | a.should be_kind_of(ArraySpecs.MyArray) 21 | a.inspect.should == [5, true, nil, "a", "Ruby", obj].inspect 22 | end 23 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/unsupported/frozen_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | 4 | describe "Array#frozen?", -> 5 | it "returns true if array is frozen", -> 6 | a = [1, 2, 3] 7 | a.frozen?.should == false 8 | a.freeze 9 | a.frozen?.should == true 10 | 11 | not_compliant_on :rubinius do 12 | ruby_version_is "" .. "1.9", -> 13 | it "returns true for an array being sorted by #sort!", -> 14 | a = [1, 2, 3] 15 | a.sort! { |x,y| a.frozen?.should == true; x <=> y } 16 | 17 | ruby_version_is "1.9", -> 18 | it "returns false for an array being sorted by #sort!", -> 19 | a = [1, 2, 3] 20 | a.sort! { |x,y| a.frozen?.should == false; x <=> y } 21 | 22 | it "returns false for an array being sorted by #sort", -> 23 | a = [1, 2, 3] 24 | a.sort { |x,y| a.frozen?.should == false; x <=> y } 25 | -------------------------------------------------------------------------------- /spec/lib/corelib/array/unsupported/initialize_copy_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/replace', __FILE__) 4 | 5 | describe "Array#initialize_copy", -> 6 | it "is private", -> 7 | Array.should have_private_instance_method("initialize_copy") 8 | 9 | it_behaves_like(:array_replace, :initialize_copy) 10 | end 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/comparable/between_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Comparable#between?", -> 2 | it "returns true if self is greater than or equal to the first and less than or equal to the second argument", -> 3 | # a = ComparableSpecs::Weird.new(-1) 4 | # b = ComparableSpecs::Weird.new(0) 5 | # c = ComparableSpecs::Weird.new(1) 6 | # d = ComparableSpecs::Weird.new(2) 7 | 8 | a = R(-1) 9 | b = R(0) 10 | c = R(1) 11 | d = R(2) 12 | 13 | expect( a.between(a, a) ).toEqual true 14 | expect( a.between(a, b) ).toEqual true 15 | expect( a.between(a, c) ).toEqual true 16 | expect( a.between(a, d) ).toEqual true 17 | expect( c.between(c, d) ).toEqual true 18 | expect( d.between(d, d) ).toEqual true 19 | expect( c.between(a, d) ).toEqual true 20 | 21 | expect( a.between(b, b) ).toEqual false 22 | expect( a.between(b, c) ).toEqual false 23 | expect( a.between(b, d) ).toEqual false 24 | expect( c.between(a, a) ).toEqual false 25 | expect( c.between(a, b) ).toEqual false 26 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerable/detect_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Enumerable#detect", -> 2 | it "aliases to #find", -> 3 | numerous = EnumerableSpecs.Numerous.new() 4 | expect( numerous.detect ).toBeDefined() 5 | expect( numerous.detect ).toEqual(numerous.find) 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerable/entries_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Enumerable#entries", -> 2 | it "aliases to #to_a", -> 3 | numerous = EnumerableSpecs.Numerous.new() 4 | expect( numerous.entries ).toBeDefined() 5 | expect( numerous.entries ).toEqual(numerous.to_a) 6 | 7 | # describe :enumerable_entries, :shared => true do 8 | # it "returns an array containing the elements" do 9 | # numerous = EnumerableSpecs::Numerous.new(1, nil, 'a', 2, false, true) 10 | # numerous.send(@method).should == [1, nil, "a", 2, false, true] 11 | # end 12 | 13 | # ruby_version_is "1.8.7" do 14 | # it "passes through the values yielded by #each_with_index" do 15 | # [:a, :b].each_with_index.send(@method).should == [[:a, 0], [:b, 1]] 16 | # end 17 | 18 | # it "passes arguments to each" do 19 | # count = EnumerableSpecs::EachCounter.new(1, 2, 3) 20 | # count.to_a(:hello, "world").should == [1, 2, 3] 21 | # count.arguments_passed.should == [:hello, "world"] 22 | # end 23 | # end 24 | # end 25 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerable/first_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'ruby_version_is "1.8.7"', -> 2 | describe "Enumerable#first", -> 3 | it "returns the first element", -> 4 | expect( EnumerableSpecs.Numerous.new().first() ).toEqual R(2) 5 | expect( EnumerableSpecs.Empty.new().first() ).toEqual null 6 | 7 | it "returns nil if self is empty", -> 8 | expect( EnumerableSpecs.Empty.new().first() ).toEqual null 9 | 10 | # describe "when passed an argument", -> 11 | # it_behaves_like :enumerable_take, :first 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerable/partition_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Enumerable#partition", -> 2 | it "returns two arrays, the first containing elements for which the block is true, the second containing the rest", -> 3 | expect( 4 | EnumerableSpecs.NumerousLiteral.new().partition((i) -> i % 2 is 0 ).valueOf() 5 | ).toEqual [[2, 6, 4], [5, 3, 1]] 6 | 7 | 8 | # ruby_version_is "" ... "1.8.7", -> 9 | # it "throws LocalJumpError if called without a block", -> 10 | # expect( -> EnumerableSpecs.Numerous.new().partition ).toThrow(LocalJumpError) 11 | 12 | describe 'ruby_version_is "1.8.7"', -> 13 | it "returns an Enumerator if called without a block", -> 14 | expect( EnumerableSpecs.NumerousLiteral.new().partition() ).toBeInstanceOf R.Enumerator 15 | 16 | it "gathers whole arrays as elements when each yields multiple", -> 17 | multi = new EnumerableSpecs.YieldsMulti() 18 | expect( 19 | multi.partition( (e) -> R(e).size().equals(3) ).valueOf() 20 | ).toEqual [[[3,4,5]], [[1,2], [6,7,8,9]]] 21 | 22 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerable/reduce_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Enumerable#reduce", -> 2 | # it_behaves_like :enumerable_inject, :reduce 3 | it "aliases to inject", -> 4 | expect( R.Enumerable.reduce ).toEqual R.Enumerable.inject 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerable/reverse_each_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'ruby_version_is "1.8.7"', -> 2 | describe "Enumerable#reverse_each", -> 3 | it "traverses enum in reverse order and pass each element to block", -> 4 | acc = [] 5 | EnumerableSpecs.NumerousLiteral.new().reverse_each (i) -> acc.push i 6 | expect( acc ).toEqual [4, 1, 6, 3, 5, 2] 7 | 8 | it "returns an Enumerator if no block given", -> 9 | en = EnumerableSpecs.NumerousLiteral.new().reverse_each() 10 | expect( en ).toBeInstanceOf R.Enumerator 11 | expect( en.to_a().to_native() ).toEqual [4, 1, 6, 3, 5, 2] 12 | 13 | it "gathers whole arrays as elements when each yields multiple", -> 14 | multi = new EnumerableSpecs.YieldsMulti() 15 | yielded = [] 16 | multi.reverse_each (e) -> yielded.push e 17 | expect( yielded ).toEqual [[6, 7, 8, 9], [3, 4, 5], [1, 2]] 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerable/select_spec.coffee: -------------------------------------------------------------------------------- 1 | # alias to find_all -------------------------------------------------------------------------------- /spec/lib/corelib/enumerable/to_a_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Enumerable#to_a", -> 2 | # it_behaves_like(:enumerable_entries , :to_a) 3 | 4 | it "returns an array containing the elements", -> 5 | numerous = EnumerableSpecs.Numerous.new(1, null, 'a', 2, false, true) 6 | expect( numerous.to_a() ).toEqual R.$Array_r([1, null, "a", 2, false, true]) 7 | 8 | it "passes through the values yielded by #each_with_index", -> 9 | expect( R(["a", 'b']).each_with_index().to_a() ).toEqual R([['a', 0], ['b', 1]]) 10 | 11 | # it "passes arguments to each" do 12 | # count = EnumerableSpecs::EachCounter.new(1, 2, 3) 13 | # count.to_a(:hello, "world").should == [1, 2, 3] 14 | # count.arguments_passed.should == [:hello, "world"] 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/each_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../shared/enumerator/each', __FILE__) 2 | 3 | ruby_version_is "1.8.7" do 4 | describe "Enumerator#each" do 5 | it_behaves_like(:enum_each, :each) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/each_with_object_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/enumerator/with_object', __FILE__) 3 | 4 | ruby_version_is "1.9" do 5 | describe "Enumerator#each_with_object" do 6 | it_behaves_like :enum_with_object, :each_with_object 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/enum_for_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.8.7" do 4 | require File.expand_path('../../../shared/enumerator/enum_for', __FILE__) 5 | 6 | describe "#enum_for" do 7 | it_behaves_like :enum_for, :enum_for 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/feed_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.9" do 4 | describe "Enumerator#feed" do 5 | it "needs to be reviewed for spec completeness" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/inject_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../shared/enumerator/each', __FILE__) 2 | 3 | describe "Enumerator#inject" do 4 | it_behaves_like(:enum_each, :each) 5 | 6 | it "works when chained against each_with_index" do 7 | passed_values = [] 8 | [:a].each_with_index.inject(0) do |accumulator,value| 9 | passed_values << value 10 | accumulator + 1 11 | end.should == 1 12 | passed_values.should == [[:a,0]] 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/inspect_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.9" do 4 | describe "Enumerator#inspect" do 5 | it "needs to be reviewed for spec completeness" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/next_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.8.7" do 4 | require File.expand_path('../../../shared/enumerator/next', __FILE__) 5 | 6 | describe "Enumerator#next" do 7 | it_behaves_like(:enum_next,:next) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/next_values_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.9" do 4 | describe "Enumerator#next_values" do 5 | it "needs to be reviewed for spec completeness" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/rewind_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.8.7" do 4 | require File.expand_path('../../../shared/enumerator/rewind', __FILE__) 5 | 6 | describe "Enumerator#rewind" do 7 | it_behaves_like(:enum_rewind, :rewind) 8 | 9 | ruby_version_is "1.8.8" do 10 | it "calls the enclosed object's rewind method if one exists" do 11 | obj = mock('rewinder') 12 | enum = enumerator_class.new(obj) 13 | obj.should_receive(:each).at_most(1) 14 | obj.should_receive(:rewind) 15 | enum.rewind 16 | end 17 | 18 | it "does nothing if the object doesn't have a #rewind method" do 19 | obj = mock('rewinder') 20 | enum = enumerator_class.new(obj) 21 | obj.should_receive(:each).at_most(1) 22 | lambda { enum.rewind.should == enum }.should_not raise_error 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/to_enum_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.8.7" do 4 | require File.expand_path('../../../shared/enumerator/enum_for', __FILE__) 5 | 6 | describe "#to_enum" do 7 | it_behaves_like :enum_for, :enum_for 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/enumerator/with_object_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/enumerator/with_object', __FILE__) 3 | 4 | ruby_version_is "1.8.8" do 5 | describe "Enumerator#with_object" do 6 | it_behaves_like :enum_with_object, :with_object 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/abs_spec.coffee: -------------------------------------------------------------------------------- 1 | # describe :fixnum_abs, :shared => true do 2 | # it "returns self's absolute value" do 3 | # { 0 => [0, -0, +0], 2 => [2, -2, +2], 100 => [100, -100, +100] }.each do |key, values| 4 | # values.each do |value| 5 | # value.send(@method).should == key 6 | # end 7 | # end 8 | # end 9 | # end 10 | 11 | describe "Fixnum#abs", -> 12 | it "returns self's absolute value", -> 13 | expect( R(0).abs().valueOf() ).toEqual 0 14 | expect( R(-0).abs().valueOf() ).toEqual 0 15 | expect( R(+0).abs().valueOf() ).toEqual 0 16 | 17 | expect( R( 2).abs().valueOf() ).toEqual 2 18 | expect( R(-2).abs().valueOf() ).toEqual 2 19 | expect( R(+2).abs().valueOf() ).toEqual 2 20 | 21 | expect( R( 100).abs().valueOf() ).toEqual 100 22 | expect( R(-100).abs().valueOf() ).toEqual 100 23 | expect( R(+100).abs().valueOf() ).toEqual 100 -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/case_compare_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#===", -> 2 | it "is an alias for Fixnum#==", -> 3 | FixnumProto = RubyJS.Fixnum.prototype 4 | expect( FixnumProto['==='] ).toEqual FixnumProto.equals -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/comparison_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#cmp", -> 2 | it "returns -1 when self is less than the given argument", -> 3 | expect( R(-3).cmp(-1) ).toEqual -1 4 | expect( R(-5).cmp(10) ).toEqual -1 5 | expect( R(-5).cmp(-4.5) ).toEqual -1 6 | 7 | it "returns 0 when self is equal to the given argument", -> 8 | expect( R(0).cmp(0) ).toEqual 0 9 | expect( R(954).cmp(954) ).toEqual 0 10 | expect( R(954).cmp(954.0)).toEqual 0 11 | 12 | it "returns 1 when self is greater than the given argument", -> 13 | expect( R(496).cmp(5) ).toEqual 1 14 | expect( R(200).cmp(100) ).toEqual 1 15 | expect( R(51).cmp(50.5) ).toEqual 1 16 | 17 | it "returns nil when the given argument is not an Integer", -> 18 | expect( R(3).cmp('mock') ).toEqual null 19 | expect( R(3).cmp([]) ).toEqual null 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/deprecated/id2name_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is ""..."1.9.1" do 4 | describe "Fixnum#id2name" do 5 | 6 | not_compliant_on :rubinius do 7 | it "returns the string name of the object whose symbol ID is self" do 8 | a = :@sym 9 | b = :@ruby 10 | c = :@rubinius 11 | a.to_i.id2name.should == '@sym' 12 | b.to_i.id2name.should == '@ruby' 13 | c.to_i.id2name.should == '@rubinius' 14 | end 15 | 16 | it "returns nil if there is no symbol in the symbol table with this value" do 17 | 100000000.id2name.should == nil 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/equal_value_spec.coffee: -------------------------------------------------------------------------------- 1 | #describe "Fixnum#==", -> 2 | # it_behaves_like :fixnum_equal, :== 3 | #end 4 | 5 | describe "Fixnum#==", -> 6 | it "returns true if self has the same value as other", -> 7 | expect( R(1).equals(1)).toEqual true 8 | expect( R(9).equals(5)).toEqual false 9 | 10 | # Actually, these call Float#==, Bignum#== etc. 11 | expect( R(9).equals(R.$Float(9.0)) ).toEqual true 12 | expect( R(9).equals(R.$Float(9.01)) ).toEqual false 13 | 14 | #expect(R(10).equals bignum_value)).toEqual false 15 | 16 | 17 | it "calls 'other == self' if the given argument is not a Fixnum", -> 18 | obj = 19 | equals: (other) -> false 20 | expect( R(1).equals(obj) ).toEqual false 21 | 22 | obj.equals = -> true 23 | expect( R(2).equals(obj)).toEqual true 24 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/even_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#even?", -> 2 | it "is true for zero", -> 3 | expect( R(0).even() ).toEqual true 4 | 5 | it "is true for even positive Fixnums", -> 6 | expect( R(4).even() ).toEqual true 7 | 8 | it "is true for even negative Fixnums", -> 9 | expect( R(-4).even()).toEqual true 10 | 11 | it "is false for odd positive Fixnums", -> 12 | expect( R(5).even() ).toEqual false 13 | 14 | it "is false for odd negative Fixnums", -> 15 | expect( R(-5).even()).toEqual false 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/gt_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#>", -> 2 | it "returns true if self is greater than the given argument", -> 3 | expect( R(13).gt(2) ).toEqual true 4 | expect( R(-500).gt(-600) ).toEqual true 5 | expect( R(1).gt(5) ).toEqual false 6 | expect( R(5).gt(5) ).toEqual false 7 | expect( R(5).gt(4.999) ).toEqual true 8 | xit 'bignum_value', -> 9 | (900 > bignum_value).should == false 10 | 11 | it "raises an ArgumentError when given a non-Integer", -> 12 | expect( -> R(13).gt("10") ).toThrow("TypeError") 13 | expect( -> R(13).gt([]) ).toThrow("TypeError") 14 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/gte_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#>=", -> 2 | it "returns true if self is greater than the given argument", -> 3 | expect( R(13).gteq(2) ).toEqual true 4 | expect( R(-500).gt(-600) ).toEqual true 5 | expect( R(1).gteq(5) ).toEqual false 6 | expect( R(5).gteq(5) ).toEqual true 7 | expect( R(5).gteq(4.999) ).toEqual true 8 | 9 | xit 'bignum_value', -> 10 | (900 > bignum_value).should == false 11 | 12 | it "raises an ArgumentError when given a non-Integer", -> 13 | expect( -> R(13).gteq("10") ).toThrow("TypeError") 14 | expect( -> R(13).gteq([]) ).toThrow("TypeError") 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/lt_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#<", -> 2 | it "returns true if self is greater than the given argument", -> 3 | expect( R(2)['lt'](13) ).toEqual true 4 | expect( R(-600)['lt'](-500) ).toEqual true 5 | expect( R(5)['lt'](1) ).toEqual false 6 | expect( R(5)['lt'](5) ).toEqual false 7 | expect( R(5)['lt'](4.999) ).toEqual false 8 | 9 | xit 'bignum_value', -> 10 | (900 < bignum_value).should == truee 11 | 12 | it "raises an ArgumentError when given a non-Integer", -> 13 | expect( -> R(13)['lt']("10") ).toThrow("TypeError") 14 | expect( -> R(13)['lt']([]) ).toThrow("TypeError") 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/lte_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#<=", -> 2 | it "returns true if self is greater than the given argument", -> 3 | expect( R(2).lteq(13) ).toEqual true 4 | expect( R(-600).lteq(-500) ).toEqual true 5 | expect( R(5).lteq(1) ).toEqual false 6 | expect( R(5).lteq(5) ).toEqual true 7 | expect( R(-2).lteq(-2) ).toEqual true 8 | expect( R(5).lteq(4.999) ).toEqual false 9 | 10 | xit 'bignum_value', -> 11 | (900 <= bignum_value).should == truee 12 | 13 | it "raises an ArgumentError when given a non-Integer", -> 14 | expect( -> R(13).lteq("10") ).toThrow("TypeError") 15 | expect( -> R(13).lteq([]) ).toThrow("TypeError") 16 | 17 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/magnitude_spec.coffee: -------------------------------------------------------------------------------- 1 | # ruby_version_is '1.9' do 2 | # describe "Fixnum#magnitude" do 3 | # it_behaves_like :fixnum_abs, :magnitude 4 | # end 5 | # end 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/minus_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#-", -> 2 | it "returns self minus the given Integer", -> 3 | expect( R(5).minus(10) ).toEqual R(-5) 4 | expect( R(9237212).minus(5280) ).toEqual R(9231932) 5 | expect( R(781).minus(0.5) ).toEqual R(780.5) 6 | 7 | xit "bignum_value", -> 8 | (2560496 - bignum_value).toEqual R(-9223372036852215312) 9 | 10 | it "raises a TypeError when given a non-Integer", -> 11 | obj = 12 | to_int: 10 13 | expect( -> R(13).minus(obj) ).toThrow("TypeError") 14 | expect( -> R(13).minus("10") ).toThrow("TypeError") 15 | expect( -> R(13).minus([]) ).toThrow("TypeError") 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/odd_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#odd?", -> 2 | it "is false for zero", -> 3 | expect( R(0).odd() ).toEqual false 4 | 5 | it "is false for even positive Fixnums", -> 6 | expect( R(4).odd() ).toEqual false 7 | 8 | it "is false for even negative Fixnums", -> 9 | expect( R(-4).odd() ).toEqual false 10 | 11 | it "is true for odd positive Fixnums", -> 12 | expect( R(5).odd() ).toEqual true 13 | 14 | it "is true for odd negative Fixnums", -> 15 | expect( R(-5).odd() ).toEqual true 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/plus_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#+", -> 2 | it "returns self plus the given Integer", -> 3 | expect( R(491).plus(2) ).toEqual R(493) 4 | expect( R(90210).plus(10) ).toEqual R(90220) 5 | expect( R(1001).plus(5.219) ).toEqual R(1006.219) 6 | 7 | xit "bignum_value", -> 8 | (9 + bignum_value).should == 9223372036854775817 9 | 10 | it "raises a TypeError when given a non-Integer", -> 11 | obj = 12 | to_int: 10 13 | expect( -> R(13)['*'](obj) ).toThrow("TypeError") 14 | expect( -> R(13).minus("10") ).toThrow("TypeError") 15 | expect( -> R(13).minus([]) ).toThrow("TypeError") 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/succ_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#succ", -> 2 | it "returns the next larger positive Fixnum", -> 3 | expect(R(2).succ()).toEqual R(3) 4 | 5 | it "returns the next larger negative Fixnum", -> 6 | expect(R(-2).succ()).toEqual R(-1) 7 | 8 | xit "overflows a Fixnum to a Bignum", -> 9 | expect(R(fixnum_max).succ()).toEqual (fixnum_max + 1) 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/to_f_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#to_f", -> 2 | it "returns self converted to a Float", -> 3 | expect( R(0).to_f() ).toEqual R.$Float(0.0) 4 | expect( R(-500).to_f() ).toEqual R.$Float(-500.0) 5 | expect( R(9641278).to_f()).toEqual R.$Float(9641278.0) 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/uminus_spec.coffee: -------------------------------------------------------------------------------- 1 | # describe "Fixnum#-@" do 2 | # it "returns self as a negative value" do 3 | # 2.send(:-@).should == -2 4 | # -2.should == -2 5 | # -268435455.should == -268435455 6 | # (--5).should == 5 7 | # -8.send(:-@).should == 8 8 | # end 9 | 10 | # it "negates self at Fixnum/Bignum boundaries" do 11 | # fixnum_max.send(:-@).should == (0 - fixnum_max) 12 | # fixnum_min.send(:-@).should == (0 - fixnum_min) 13 | # end 14 | # end 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/unsupported/bit_methods/complement_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Fixnum#~" do 4 | it "returns self with each bit flipped" do 5 | (~0).should == -1 6 | (~1221).should == -1222 7 | (~-2).should == 1 8 | (~-599).should == 598 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/unsupported/bit_methods/size_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Fixnum#size" do 4 | platform_is :wordsize => 32 do 5 | it "returns the number of bytes in the machine representation of self" do 6 | -1.size.should == 4 7 | 0.size.should == 4 8 | 4091.size.should == 4 9 | end 10 | end 11 | 12 | platform_is :wordsize => 64 do 13 | it "returns the number of bytes in the machine representation of self" do 14 | -1.size.should == 8 15 | 0.size.should == 8 16 | 4091.size.should == 8 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/unsupported/hash_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Fixnum#hash" do 4 | it "is provided" do 5 | 1.respond_to?(:hash).should == true 6 | end 7 | 8 | it "is stable" do 9 | 1.hash.should == 1.hash 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/unsupported/to_sym_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is ""..."1.9.1" do 4 | describe "Fixnum#to_sym" do 5 | not_compliant_on :rubinius do 6 | it "returns the symbol whose integer value is self" do 7 | a = :@sym 8 | b = :@ruby 9 | c = :@rubinius 10 | 11 | a.to_i.to_sym.should == :@sym 12 | b.to_i.to_sym.should == :@ruby 13 | c.to_i.to_sym.should == :@rubinius 14 | end 15 | 16 | it "returns nil if there is no symbol in the symbol table with this value" do 17 | 100000000.to_sym.should == nil 18 | end 19 | 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/lib/corelib/fixnum/zero_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Fixnum#zero?", -> 2 | it "returns true if self is 0", -> 3 | expect( R( 0).zero() ).toEqual true 4 | expect( R(-1).zero() ).toEqual false 5 | expect( R( 1).zero() ).toEqual false 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/abs_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#abs", -> 2 | #it_behaves_like(:float_abs, :abs) 3 | it "returns the absolute value", -> 4 | expect( R(-99.1).abs() ).toEqual R(99.1).to_f() 5 | expect( R(4.5).abs() ).toEqual R(4.5).to_f() 6 | expect( R(0.0).to_f().abs() ).toEqual R(0.0).to_f() 7 | 8 | it "returns 0.0 if -0.0", -> 9 | expect( R(-0.0).to_f().abs() ).toEqual R(+0.0).to_f() 10 | 11 | it "returns Infinity if -Infinity", -> 12 | expect( R(-R.Float.INFINITY).abs().infinite() ).toEqual 1 13 | 14 | # TODO NaN.abs == NaN 15 | xit "returns NaN if NaN", -> 16 | expect( R.$Float(R.Float.NAN).abs().nan() ).toEqual true 17 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/angle_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#angle", -> 2 | it "is alias to #arg", -> 3 | proto = R.Float.prototype 4 | expect( proto.angle ).toEqual proto.arg 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/case_compare_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#===", -> 2 | it "is alias to #==", -> 3 | proto = R.Float.prototype 4 | expect( proto['==='] ).toEqual proto.equals 5 | expect( proto.equal_case ).toEqual proto.equals 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/ceil_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#ceil", -> 2 | it "returns the smallest Integer greater than or equal to self", -> 3 | expect( R(-1.2 ).to_f().ceil() ).toEqual(R -1) 4 | expect( R(-1.0 ).to_f().ceil() ).toEqual(R -1) 5 | expect( R(0.0 ).to_f().ceil() ).toEqual(R 0 ) 6 | expect( R(1.3 ).to_f().ceil() ).toEqual(R 2 ) 7 | expect( R(3.0 ).to_f().ceil() ).toEqual(R 3 ) 8 | expect( R(-9223372036854775808.1).ceil() ).toEqual(R -9223372036854775808) 9 | expect( R(+9223372036854775808.1).ceil() ).toEqual(R +9223372036854775808) 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/coerce_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#coerce", -> 2 | it "returns [other, self] both as Floats", -> 3 | expect( new R.Float( 1.2 ).coerce(1 ).valueOf(true) ).toEqual [1.0, 1.2] 4 | expect( new R.Float( 5.28 ).coerce(1.0 ).valueOf(true) ).toEqual [1.0, 5.28] 5 | expect( new R.Float( 1.0 ).coerce(1 ).valueOf(true) ).toEqual [1.0, 1.0] 6 | expect( new R.Float( 1.0 ).coerce("2.5").valueOf(true) ).toEqual [2.5, 1.0] 7 | expect( new R.Float( 1.0 ).coerce(3.14 ).valueOf(true) ).toEqual [3.14, 1.0] 8 | 9 | xit 'bignum unsupported', -> 10 | # a, b = -0.0.coerce(bignum_value) 11 | # a.should be_close(9223372036854775808.0, TOLERANCE) 12 | # b.should be_close(-0.0, TOLERANCE) 13 | # a, b = 1.0.coerce(bignum_value) 14 | # a.should be_close(9223372036854775808.0, TOLERANCE) 15 | # b.should be_close(1.0, TOLERANCE) 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/constants_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#CONSTANTS", -> 2 | it "constants", -> 3 | expect( R.Float.DIG ).toEqual 15 4 | expect( R.Float.EPSILON ).toEqual eval("0.0000000000000002220446049250313080847263336181640625") 5 | expect( R.Float.MANT_DIG ).toEqual 53 6 | expect( R.Float.MAX_10_EXP ).toEqual 308 7 | expect( R.Float.MIN_10_EXP ).toEqual -307 8 | expect( R.Float.MAX_EXP ).toEqual 1024 9 | expect( R.Float.MIN_EXP ).toEqual -1021 10 | expect( R.Float.MAX ).toEqual eval("179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0") 11 | expect( R.Float.RADIX ).toEqual 2 12 | 13 | # expect( R.Float.INFINITY ).toEqualshould == 1 14 | # expect( R.Float.NAN ).toEqualshould be_true 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/eql_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#eql?", -> 2 | it "returns true if other is a Float equal to self", -> 3 | expect( R.$Float(0.0).eql(R.$Float(0.0)) ).toEqual true 4 | 5 | it "returns false if other is a Float not equal to self", -> 6 | expect( R.$Float(1.0).eql(1.1) ).toEqual false 7 | 8 | it "returns false if other is not a Float", -> 9 | expect( R.$Float(1.0).eql(1) ).toEqual false 10 | expect( R.$Float(1.0).eql([]) ).toEqual false 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/equal_value_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#==", -> 2 | # it_behaves_like :float_equal, :== 3 | 4 | it "returns true if self has the same value as other", -> 5 | expect( R(1.0).to_f().equals 1).toEqual true 6 | expect( R(2.71828).equals 1.428).toEqual false 7 | expect( R(-4.2).equals 4.2).toEqual false 8 | 9 | xit "calls 'other == self' if coercion fails", -> 10 | # class X; def ==(other); 2.0 == other; end; end 11 | 12 | # 1.0.send(@method, X.new).should == false 13 | # 2.0.send(@method, X.new).should == true 14 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/exponent_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#**", -> 2 | it "returns self raise to the other power", -> 3 | expect( R(2.3).exp(3 ).valueOf() ).toBeCloseTo(12.167,0.00001) 4 | expect( R(5.2).exp(-1 ).valueOf() ).toBeCloseTo(0.192307692307692,0.00001) 5 | expect( R(9.5).exp(0.5).valueOf() ).toBeCloseTo(3.08220700148449, 0.00001) 6 | expect( R(9.5).exp(0xffffffff).to_s().valueOf() ).toEqual 'Infinity' 7 | 8 | xdescribe 'ruby_version_is "1.9"', -> 9 | xit "returns a complex number when negative and raised to a fractional power", -> 10 | # ((-8.0) ** (1.0/3)) .should be_close(Complex(1, 1.73205), TOLERANCE) 11 | # ((-8.0) ** Rational(1,3)).should be_close(Complex(1, 1.73205), TOLERANCE) 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/fdiv_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#fdiv", -> 2 | it "is alias to #quo", -> 3 | proto = R.Float.prototype 4 | expect( proto.fdiv ).toEqual proto.quo 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/finite_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#finite?", -> 2 | it "returns true for finite values", -> 3 | expect( R.$Float( 3.14159).finite() ).toEqual true 4 | 5 | it "returns false for positive infinity", -> 6 | expect( R.$Float( R.Float.INFINITY).finite() ).toEqual false 7 | 8 | it "returns false for negative infinity", -> 9 | expect( R.$Float( -R.Float.INFINITY).finite() ).toEqual false 10 | 11 | it "returns false for NaN", -> 12 | expect( R.$Float( R.Float.NAN).finite() ).toEqual false 13 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/fixtures/coerce.rb: -------------------------------------------------------------------------------- 1 | module FloatSpecs 2 | class CanCoerce 3 | def initialize(a) 4 | @a = a 5 | end 6 | 7 | def coerce(b) 8 | [self.class.new(b), @a] 9 | end 10 | 11 | def /(b) 12 | @a.to_i % b.to_i 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/floor_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#floor", -> 2 | it "returns the largest Integer less than or equal to self", -> 3 | expect( R( -1.2 ).to_f().floor() ).toEqual(R -2) 4 | expect( R( -1.0 ).to_f().floor() ).toEqual(R -1) 5 | expect( R( 0.0 ).to_f().floor() ).toEqual(R 0 ) 6 | expect( R( 1.0 ).to_f().floor() ).toEqual(R 1 ) 7 | expect( R( 5.9 ).to_f().floor() ).toEqual(R 5 ) 8 | expect( R(-9223372036854775808.1).floor() ).toEqual(R -9223372036854775808) 9 | expect( R(+9223372036854775808.1).floor() ).toEqual(R +9223372036854775808) 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/gt_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#>", -> 2 | it "returns true if self is greater than other", -> 3 | expect( R(1.5).gt 1).toEqual true 4 | expect( R(2.5).gt 3).toEqual false 5 | expect( R(45.91).gt 99999999999999).toEqual false 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/gte_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#>=", -> 2 | it "returns true if self is greater than or equal to other", -> 3 | expect( R(5.2).gteq 5.2).toEqual true 4 | expect( R(9.71).gteq 1).toEqual true 5 | expect( R(5.55382).gteq 0xfabdafbafcab).toEqual false 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/infinite_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#infinite?", -> 2 | it "returns nil for finite values", -> 3 | expect( R.$Float(1.0).infinite() ).toEqual null 4 | 5 | it "returns 1 for positive infinity", -> 6 | expect( R.$Float(R.Float.INFINITY).infinite() ).toEqual 1 7 | 8 | it "returns -1 for negative infinity", -> 9 | expect( R.$Float(-R.Float.INFINITY).infinite() ).toEqual -1 10 | 11 | it "returns nil for NaN", -> 12 | expect( R.$Float(R.Float.NAN).infinite() ).toEqual null 13 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/lt_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#<", -> 2 | it "returns true if self is less than other", -> 3 | expect( R(71.3).lt 91.8).toEqual true 4 | expect( R(192.6).lt -500).toEqual false 5 | expect( R(-0.12).lt 0x4fffffff).toEqual true 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/lte_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#<=", -> 2 | it "returns true if self is less than or equal to other", -> 3 | expect( R(2.0).lteq 3.14159).toEqual true 4 | expect( R(-2.7183).lteq -24).toEqual false 5 | expect( R(0.0).lteq 0.0).toEqual true 6 | expect( R(9235.9).lteq 9999234234423).toEqual true 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/magnitude_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#magnitude", -> 2 | it "is alias to #abs", -> 3 | proto = R.Float.prototype 4 | expect( proto.magnitude ).toEqual proto.abs 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/minus_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#-", -> 2 | it "returns self minus other", -> 3 | expect( R(9237212.5280).minus(5280).valueOf() ).toBeCloseTo 9231932.528, 0.0001 4 | expect( R(5.5).minus(5.5).valueOf() ).toBeCloseTo 0.0, 0.0001 5 | 6 | xit 'unsupported', -> 7 | #(2_560_496.1691 - bignum_value).should be_close(-9223372036852215808.000, TOLERANCE) 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/multiply_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#*", -> 2 | it "returns self plus other", -> 3 | expect( R(4923.98221).multiply(2).valueOf() ).toBeCloseTo 9847.96442, 0.0001 4 | expect( R(6712.5).multiply(0.25).valueOf() ).toBeCloseTo 1678.125, 0.0001 5 | 6 | xit 'unsupported', -> 7 | # (256.4096 * bignum_value).should be_close(2364961134621118431232.000, TOLERANCE) 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/nan_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#nan?", -> 2 | it "returns true if self is not a valid IEEE floating-point number", -> 3 | expect( R.$Float(0.0).nan() ).toEqual false 4 | expect( R.$Float(-1.5).nan() ).toEqual false 5 | expect( R.$Float(R.Float.NAN).nan() ).toEqual true 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/plus_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#+", -> 2 | it "returns self plus other", -> 3 | expect( R(491.213).plus(2).valueOf() ).toBeCloseTo 493.213, 0.0001 4 | expect( R(1001.99).plus(5.219).valueOf() ).toBeCloseTo 1007.209, 0.0001 5 | 6 | xit 'unsupported', -> 7 | #expect( R(9.99).plus bignum_value).toEqual R(9223372036854775808.000) 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/shared/abs.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | 3 | describe :float_abs, :shared => true do 4 | it "returns the absolute value" do 5 | -99.1.send(@method).should be_close(99.1, TOLERANCE) 6 | 4.5.send(@method).should be_close(4.5, TOLERANCE) 7 | 0.0.send(@method).should be_close(0.0, TOLERANCE) 8 | end 9 | 10 | it "returns 0.0 if -0.0" do 11 | (-0.0).send(@method).should be_positive_zero 12 | end 13 | 14 | it "returns Infinity if -Infinity" do 15 | (-infinity_value).send(@method).infinite?.should == 1 16 | end 17 | 18 | it "returns NaN if NaN" do 19 | nan_value.send(@method).nan?.should be_true 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/shared/equal.rb: -------------------------------------------------------------------------------- 1 | describe :float_equal, :shared => true do 2 | it "returns true if self has the same value as other" do 3 | 1.0.send(@method, 1).should == true 4 | 2.71828.send(@method, 1.428).should == false 5 | -4.2.send(@method, 4.2).should == false 6 | end 7 | 8 | it "calls 'other == self' if coercion fails" do 9 | class X; def ==(other); 2.0 == other; end; end 10 | 11 | 1.0.send(@method, X.new).should == false 12 | 2.0.send(@method, X.new).should == true 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/shared/to_i.rb: -------------------------------------------------------------------------------- 1 | describe :float_to_i, :shared => true do 2 | it "returns self truncated to an Integer" do 3 | 899.2.send(@method).should eql(899) 4 | -1.122256e-45.send(@method).should eql(0) 5 | 5_213_451.9201.send(@method).should eql(5213451) 6 | 1.233450999123389e+12.send(@method).should eql(1233450999123) 7 | -9223372036854775808.1.send(@method).should eql(-9223372036854775808) 8 | 9223372036854775808.1.send(@method).should eql(9223372036854775808) 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/to_f_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#to_f", -> 2 | it "returns self", -> 3 | expect( R(-500.3).to_f() ).toEqual R( -500.3) 4 | expect( R(267.51).to_f() ).toEqual R( 267.51) 5 | expect( R(1.1412).to_f() ).toEqual R( 1.1412) 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/to_i_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#to_i", -> 2 | #it_behaves_like(:float_to_i, :to_i) 3 | it "returns self truncated to an Integer", -> 4 | expect( R(899.2).to_i() ).toEqual(R 899) 5 | expect( R(5213451.9201).to_i() ).toEqual(R 5213451) 6 | expect( R(1.233450999123389e+12).to_i() ).toEqual(R 1233450999123) 7 | expect( R(-9223372036854775808.1).to_i() ).toEqual(R -9223372036854775808) 8 | expect( R(9223372036854775808.1).to_i() ).toEqual(R 9223372036854775808) 9 | expect( R(-2.333).to_i() ).toEqual(R -2) 10 | 11 | # TODO solve: 12 | xit 'BUG', -> 13 | expect( R(-1.122256e-45).to_i() ).toEqual(R 0) 14 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/to_int_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#to_int", -> 2 | it "is alias to #to_i", -> 3 | proto = R.Float.prototype 4 | expect( proto.to_int ).toEqual proto.to_i 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/truncate_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#truncate", -> 2 | it "is alias to #to_i", -> 3 | proto = R.Float.prototype 4 | expect( proto.truncate ).toEqual proto.to_i 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/unsupported/denominator_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.9" do 4 | describe "Float#denominator" do 5 | before(:each) do 6 | @numbers = [ 7 | 0.0, 8 | 29871.22736282, 9 | 7772222663.0, 10 | 1.4592, 11 | ].map {|n| [0-n, n]}.flatten 12 | end 13 | 14 | it "returns an Integer" do 15 | @numbers.each do |number| 16 | number.denominator.should be_kind_of(Integer) 17 | end 18 | end 19 | 20 | it "converts self to a Rational and returns the denominator" do 21 | @numbers.each do |number| 22 | number.denominator.should == Rational(number).denominator 23 | end 24 | end 25 | 26 | it "returns 1 for NaN and Infinity" do 27 | nan_value.denominator.should == 1 28 | infinity_value.denominator.should == 1 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/unsupported/hash_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Float#hash" do 4 | it "is provided" do 5 | 0.0.respond_to?(:hash).should == true 6 | end 7 | 8 | it "is stable" do 9 | 1.0.hash.should == 1.0.hash 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/unsupported/phase_spec.rb: -------------------------------------------------------------------------------- 1 | describe "Float#phase", -> 2 | it "is alias to #arg", -> 3 | proto = R.Float.prototype 4 | expect( proto.phase ).toEqual proto.arg 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/unsupported/to_r_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.9" do 4 | describe "Float#to_r" do 5 | it "needs to be reviewed for spec completeness" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/unsupported/uminus_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Float#-@" do 4 | it "negates self" do 5 | (2.221.send(:-@)).should be_close(-2.221, TOLERANCE) 6 | -2.01.should be_close(-2.01,TOLERANCE) 7 | -2_455_999_221.5512.should be_close(-2455999221.5512, TOLERANCE) 8 | (--5.5).should be_close(5.5, TOLERANCE) 9 | -8.551.send(:-@).should be_close(8.551, TOLERANCE) 10 | end 11 | 12 | it "negates self at Float boundaries" do 13 | Float::MAX.send(:-@).should be_close(0.0 - Float::MAX, TOLERANCE) 14 | Float::MIN.send(:-@).should be_close(0.0 - Float::MIN, TOLERANCE) 15 | end 16 | 17 | it "returns negative infinity for positive infinity" do 18 | infinity_value.send(:-@).infinite?.should == -1 19 | end 20 | 21 | it "returns positive infinity for negative infinity" do 22 | (-infinity_value).send(:-@).infinite?.should == 1 23 | end 24 | 25 | it "returns NaN for NaN" do 26 | nan_value.send(:-@).nan?.should == true 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/unsupported/uplus_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Float#+@" do 4 | it "returns the same value with same sign (twos complement)" do 5 | 34.56.send(:+@).should == 34.56 6 | -34.56.send(:+@).should == -34.56 7 | 0.0.send(:+@).should eql(0.0) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/float/zero_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Float#zero?", -> 2 | it "returns true if self is 0.0", -> 3 | expect( R(0.0).to_f().zero() ).toEqual true 4 | expect( R(1.0).to_f().zero() ).toEqual false 5 | expect( R(-1.0).to_f().zero() ).toEqual false 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/clear_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#clear", -> 2 | it "removes all key, value pairs", -> 3 | h = R.hashify(1: 2, 3: 4) 4 | expect( h.clear() == h).toEqual true 5 | expect( h ).toEqual R.hashify({}) 6 | 7 | it "does not remove default values", -> 8 | h = R.hashify({}, 5) 9 | h.clear() 10 | expect( h.default()).toEqual 5 11 | 12 | h = R.hashify({a: 100, b: 200}, "Go fish") 13 | h.clear() 14 | expect( h.get("z") ).toEqual "Go fish" 15 | 16 | it "does not remove default procs", -> 17 | h = R.hashify {}, -> 5 18 | h.clear() 19 | expect( h.default_proc() ).toNotEqual null 20 | 21 | describe "1.9", -> 22 | xit "raises a RuntimeError if called on a frozen instance", -> 23 | # lambda { HashSpecs.frozen_hash.clear }.should raise_error(RuntimeError) 24 | # lambda { HashSpecs.empty_frozen_hash.clear }.should raise_error(RuntimeError) 25 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/clone_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Hash#clone", -> 4 | it "copies instance variable but not the objects they refer to", -> 5 | hash = new_hash('key' => 'value') 6 | 7 | clone = hash.clone 8 | 9 | clone.should == hash 10 | clone.object_id.should_not == hash.object_id 11 | end 12 | 13 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/empty_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#empty?", -> 2 | it "returns true if the hash has no entries", -> 3 | expect( R.hashify({}) .empty() ).toEqual true 4 | expect( R.hashify(1: 1).empty() ).toEqual false 5 | 6 | it "returns true if the hash has no entries and has a default value", -> 7 | expect( R.hashify({}, 5).empty() ).toEqual true 8 | expect( R.hashify({}, -> 5).empty() ).toEqual true 9 | expect( R.hashify({}, (h,k) -> h.set(k,k) ).empty() ).toEqual true 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/equal_value_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/eql', __FILE__) 4 | 5 | describe "Hash#==", -> 6 | it_behaves_like :hash_eql, :== 7 | it_behaves_like :hash_eql_additional, :== 8 | it_behaves_like :hash_eql_additional_more, :== 9 | 10 | it "compares values with == semantics", -> 11 | l_val = mock("left") 12 | r_val = mock("right") 13 | 14 | l_val.should_receive(:==).with(r_val).and_return(true) 15 | 16 | (new_hash(1 => l_val) == new_hash(1 => r_val)).should be_true 17 | end 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/fixtures/classes.rb: -------------------------------------------------------------------------------- 1 | module HashSpecs 2 | class MyHash < hash_class; end 3 | 4 | class MyInitializerHash < hash_class 5 | 6 | def initialize 7 | raise "Constructor called" 8 | 9 | 10 | class NewHash < hash_class 11 | def initialize(*args) 12 | args.each_with_index do |val, index| 13 | self[index] = val 14 | 15 | class DefaultHash < hash_class 16 | def default(key) 17 | 100 18 | 19 | class ToHashHash < hash_class 20 | def to_hash 21 | new_hash "to_hash" => "was", "called!" => "duh." 22 | 23 | def self.empty_frozen_hash 24 | @empty ||= new_hash 25 | @empty.freeze 26 | @empty 27 | 28 | def self.frozen_hash 29 | @hash ||= new_hash(1 => 2, 3 => 4) 30 | @hash.freeze 31 | @hash 32 | end 33 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/has_value_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#has_value?", -> 2 | 3 | it "returns true if the value exists in the hash", -> 4 | expect( R.hashify(a: 'b').has_value('a') ).toEqual false 5 | expect( R.hashify(1: 2).has_value(2) ).toEqual true 6 | h = R.hashify {}, 5 7 | expect( h.has_value(5) ).toEqual false 8 | h = R.hashify {}, -> 5 9 | expect( h.has_value(5) ).toEqual false 10 | 11 | it "uses == semantics for comparing values", -> 12 | expect( R.hashify(5: 2.0).has_value(2) ).toEqual true 13 | expect( R.hashify(5: 2.0).has_value('2') ).toEqual false 14 | 15 | # DEBT test for rubyjs typecasted objects -------------------------------------------------------------------------------- /spec/lib/corelib/hash/index_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#index", -> 2 | it "returns the corresponding key for value", -> 3 | expect( R.hashify(2: 'a', 1: 'b').index('b') ).toEqual '1' 4 | 5 | it "returns nil if the value is not found", -> 6 | expect( R.hashify(a: -1, b: 3.14, c: 2.718).index('1') ).toEqual null 7 | 8 | it "doesn't return default value if the value is not found", -> 9 | expect( R.hashify({}, 5).index(5) ).toEqual null 10 | 11 | it "compares values using ==", -> 12 | expect( R.hashify(1: 0).index(0.0) ).toEqual '1' 13 | expect( R.hashify(1: 0.0).index(0) ).toEqual '1' 14 | 15 | # TODO: 16 | # inhash = {equals: -> true} 17 | # expect( R.hashify(1: inhash).key("foo") ).toEqual '1' 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/indexes_spec.coffee: -------------------------------------------------------------------------------- 1 | # ruby_version_is ""..."1.9", -> 2 | # describe "Hash#indexes", -> 3 | # it_behaves_like(:hash_values_at, :indexes) 4 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/indices_spec.coffee: -------------------------------------------------------------------------------- 1 | # ruby_version_is ""..."1.9", -> 2 | # describe "Hash#indices", -> 3 | # it_behaves_like(:hash_values_at, :indices) 4 | # end 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/inspect_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/to_s', __FILE__) 4 | 5 | describe "Hash#inspect", -> 6 | it_behaves_like :to_s, :inspect 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/invert_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#invert", -> 2 | it "returns a new hash where keys are values and vice versa", -> 3 | h = R.hashify(1: 'a', 2: 'b', 3: 'c') 4 | expect( h.invert() ).toEqual R.hashify(a: '1', b: '2', c: '3') 5 | 6 | it "handles collisions by overriding with the key coming later in keys()", -> 7 | h = R.hashify(a: 1, b: 1) 8 | override_key = h.keys().last() 9 | expect( h.invert().get(1) ).toEqual override_key 10 | 11 | xit "compares new keys with eql? semantics", -> 12 | # h = R.hashify(a: 1.0, b: 1) 13 | # i = h.invert() 14 | # i[1.0].should == :a 15 | # i[1].should == :b 16 | 17 | xit "does not return subclass instances for subclasses", -> 18 | # HashSpecs::MyHash[1 => 2, 3 => 4].invert.class.should == hash_class 19 | # HashSpecs::MyHash[].invert.class.should == hash_class 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/keep_if_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#keep_if", -> 2 | it "yields two arguments: key and value", -> 3 | all_args = [] 4 | R.hashify(1: 2, 3: 4).keep_if (args...) -> all_args.push(args) 5 | expect( all_args ).toEqual [['1', 2], ['3', 4]] 6 | 7 | it "keeps every entry for which block is true and returns self", -> 8 | h = R.hashify(a: 1, b: 2, c: 3, d: 4) 9 | h2 = h.keep_if (k,v) -> v % 2 == 0 10 | expect( h2 == h).toEqual true 11 | expect( h ).toEqual R.hashify(b: 2, d: 4) 12 | 13 | it "returns self even if unmodified", -> 14 | h = R.hashify(1: 2, 3: 4) 15 | h2 = h.keep_if(-> true) 16 | expect( h2 == h ).toEqual true 17 | 18 | xit "raises an RuntimeError if called on a frozen instance", -> 19 | # lambda { HashSpecs.frozen_hash.keep_if { true } }.should raise_error(RuntimeError) 20 | # lambda { HashSpecs.empty_frozen_hash.keep_if { false } }.should raise_error(RuntimeError) 21 | 22 | # it_behaves_like(:hash_iteration_no_block, :keep_if) 23 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/key_spec.coffee: -------------------------------------------------------------------------------- 1 | # describe "Hash#key?", -> 2 | # it_behaves_like(:hash_key_p, :key?) 3 | # end 4 | 5 | describe "Hash#key", -> 6 | it "returns the corresponding key for value", -> 7 | expect( R.hashify(2: 'a', 1: 'b').key('b') ).toEqual '1' 8 | 9 | it "returns nil if the value is not found", -> 10 | expect( R.hashify(a: -1, b: 3.14, c: 2.718).key('1') ).toEqual null 11 | 12 | it "doesn't return default value if the value is not found", -> 13 | expect( R.hashify({}, 5).key(5) ).toEqual null 14 | 15 | it "compares values using ==", -> 16 | expect( R.hashify(1: 0).key(0.0) ).toEqual '1' 17 | expect( R.hashify(1: 0.0).key(0) ).toEqual '1' 18 | 19 | # TODO: 20 | # inhash = {equals: -> true} 21 | # expect( R.hashify(1: inhash).key("foo") ).toEqual '1' 22 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/keys_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#keys", -> 2 | xit "returns an array with the keys in the order they were inserted", -> 3 | # safari does not uspport this. 4 | 5 | it "returns an array with the keys in random order they were inserted", -> 6 | new_hash = R.hashify({}) 7 | expect( new_hash.keys() ).toEqual R([]) 8 | expect( new_hash.keys() ).toBeInstanceOf R.Array 9 | 10 | expect( R.hashify({}, 5).keys() ).toEqual R([]) 11 | expect( R.hashify({}, -> 5 ).keys() ).toEqual R([]) 12 | 13 | # HASH unordered keys 14 | expect( R.hashify(1: 2, 4: 8, 2: 4).keys().sort() ).toEqual R(['1', '2', '4']) 15 | expect( R.hashify(1: 2, 2: 4, 4: 8).keys() ).toBeInstanceOf R.Array 16 | 17 | expect( R.hashify(null: null).keys() ).toEqual R(['null']) 18 | 19 | 20 | it "it uses the same order as #values", -> 21 | h = R.hashify(1: "1", 2: "2", 4: "4", 3: "3") 22 | 23 | h.size().times (i) -> 24 | expect( h.get(h.keys().get(i)) ).toEqual h.values().get(i) 25 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/length_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/length', __FILE__) 4 | 5 | describe "Hash#length", -> 6 | it_behaves_like(:hash_length, :length) 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/replace_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/replace', __FILE__) 4 | 5 | describe "Hash#replace", -> 6 | it_behaves_like(:hash_replace, :replace) 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/shared/index.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | require File.expand_path('../../fixtures/classes', __FILE__) 3 | 4 | describe :hash_index, :shared => true do 5 | it "returns the corresponding key for value", -> 6 | new_hash(2 => 'a', 1 => 'b').send(@method, 'b').should == 1 7 | 8 | it "returns nil if the value is not found", -> 9 | new_hash(:a => -1, :b => 3.14, :c => 2.718).send(@method, 1).should be_nil 10 | 11 | it "doesn't return default value if the value is not found", -> 12 | new_hash(5).send(@method, 5).should be_nil 13 | 14 | it "compares values using ==", -> 15 | new_hash(1 => 0).send(@method, 0.0).should == 1 16 | new_hash(1 => 0.0).send(@method, 0).should == 1 17 | 18 | needle = mock('needle') 19 | inhash = mock('inhash') 20 | inhash.should_receive(:==).with(needle).and_return(true) 21 | 22 | new_hash(1 => inhash).send(@method, needle).should == 1 23 | end 24 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/shared/length.rb: -------------------------------------------------------------------------------- 1 | describe :hash_length, :shared => true do 2 | it "returns the number of entries", -> 3 | new_hash(:a => 1, :b => 'c').send(@method).should == 2 4 | new_hash(:a => 1, :b => 2, :a => 2).send(@method).should == 2 5 | new_hash(:a => 1, :b => 1, :c => 1).send(@method).should == 3 6 | new_hash().send(@method).should == 0 7 | new_hash(5).send(@method).should == 0 8 | new_hash { 5 }.send(@method).should == 0 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/shared/value.rb: -------------------------------------------------------------------------------- 1 | describe :hash_value_p, :shared => true do 2 | it "returns true if the value exists in the hash", -> 3 | new_hash(:a => :b).send(@method, :a).should == false 4 | new_hash(1 => 2).send(@method, 2).should == true 5 | h = new_hash 5 6 | h.send(@method, 5).should == false 7 | h = new_hash { 5 } 8 | h.send(@method, 5).should == false 9 | 10 | it "uses == semantics for comparing values", -> 11 | new_hash(5 => 2.0).send(@method, 2).should == true 12 | end 13 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/shared/values_at.rb: -------------------------------------------------------------------------------- 1 | describe :hash_values_at, :shared => true do 2 | it "returns an array of values for the given keys", -> 3 | h = new_hash(:a => 9, :b => 'a', :c => -10, :d => nil) 4 | h.send(@method).should be_kind_of(Array) 5 | h.send(@method).should == [] 6 | h.send(@method, :a, :d, :b).should be_kind_of(Array) 7 | h.send(@method, :a, :d, :b).should == [9, nil, 'a'] 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/size_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#size", -> 2 | it "returns the number of entries", -> 3 | expect( R.hashify(a: 1, b: 'c').size() ).toEqual R(2) 4 | # expect( R.hashify(a: 1, b: 2, a: 2).size() ).toEqual R(2) # not valid coffee 5 | expect( R.hashify(a: 1, b: 1, c: 1).size() ).toEqual R(3) 6 | expect( R.hashify({}).size() ).toEqual R(0) 7 | expect( R.hashify({}, 5).size() ).toEqual R(0) 8 | expect( R.hashify({}, -> 5 ).size() ).toEqual R(0) 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/sort_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#sort", -> 2 | it "converts self to a nested array of [key, value] arrays and sort with Array#sort", -> 3 | hsh = R.h(a: 'b', 1: '2', b: 'a') 4 | expect( hsh.sort() ).toEqual R([["1", "2"], ["a", "b"], ["b", "a"]]) 5 | 6 | xit "works when some of the keys are themselves arrays", -> 7 | # R.h([1,2]: 5, [1,1]: 5).sort.should == [[[1,1],5], [[1,2],5]] 8 | 9 | it "uses block to sort array if passed a block", -> 10 | expect( R.h(1: 2, 2: 9, 3: 4).sort( (a,b) -> R(b).cmp(a) ) ).toEqual R([['3', 4], ['2', 9], ['1', 2]]) 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/to_a_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#to_a", -> 2 | it "returns a list of [key, value] pairs with same order as each()", -> 3 | h = R.hashify(a: 1, 1: 'a', 3: 'b', b: 5) 4 | pairs = [] 5 | 6 | h.each_pair (key, value) -> pairs.push([key, value]) 7 | 8 | expect( h.to_a() ).toBeInstanceOf(R.Array) 9 | expect( h.to_a() ).toEqual R(pairs) 10 | 11 | it "is called for Enumerable#entries", -> 12 | h = R.hashify(a: 1, 1: 'a', 3: 'b', b: 5) 13 | pairs = [] 14 | 15 | h.each_pair (key, value) -> pairs.push([key, value]) 16 | 17 | expect( h.entries() ).toBeInstanceOf(R.Array) 18 | expect( h.entries() ).toEqual R(pairs) 19 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/to_h_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#to_h", -> 2 | it "returns self for Hash instances", -> 3 | h = R.hashify({}) 4 | expect( h.to_hash() == h).toEqual true 5 | 6 | describe "when called on a subclass of Hash", -> 7 | # before :each do 8 | # @h = HashSpecs::MyHash.new 9 | # @h[:foo] = :bar 10 | 11 | # it "returns a new Hash instance", -> 12 | # @h.to_h.should be_an_instance_of(Hash) 13 | # @h.to_h.should == @h 14 | # @h[:foo].should == :bar 15 | 16 | # it "copies the default", -> 17 | # @h.default = 42 18 | # @h.to_h.default.should == 42 19 | # @h[:hello].should == 42 20 | 21 | # it "copies the default_proc", -> 22 | # @h.default_proc = prc = Proc.new{ |h, k| h[k] = 2 * k } 23 | # @h.to_h.default_proc.should == prc 24 | # @h[42].should == 84 25 | # end 26 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/to_hash_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#to_hash", -> 2 | it "returns self for Hash instances", -> 3 | h = R.hashify({}) 4 | expect( h.to_hash() == h).toEqual true 5 | 6 | xit "returns self for instances of subclasses of Hash", -> 7 | # h = HashSpecs::MyHash.new 8 | # h.to_hash.should equal(h) 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/to_s_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/to_s', __FILE__) 4 | 5 | describe "Hash#to_s", -> 6 | 7 | ruby_version_is "1.9", -> 8 | it_behaves_like :to_s, :to_s 9 | 10 | ruby_version_is ""..."1.9", -> 11 | it "returns a string by calling Hash#to_a and using Array#join with default separator", -> 12 | h = new_hash(:fun => 'x', 1 => 3, nil => "ok", [] => :y) 13 | h.to_a.to_s.should == h.to_s 14 | old, $, = $,, ':' 15 | h.to_a.to_s.should == h.to_s 16 | $, = old 17 | end 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/unsupported/allocate_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Hash.allocate", -> 4 | it "returns an instance of Hash", -> 5 | hsh = hash_class.allocate 6 | hsh.should be_kind_of(Hash) 7 | 8 | it "returns a fully-formed instance of Hash", -> 9 | hsh = hash_class.allocate 10 | hsh.size.should == 0 11 | hsh[:a] = 1 12 | hsh.should == { :a => 1 } 13 | end 14 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/unsupported/initialize_copy_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/replace', __FILE__) 4 | 5 | describe "Hash#initialize_copy", -> 6 | it "is private", -> 7 | hash_class.should have_private_instance_method("initialize_copy") 8 | 9 | it_behaves_like(:hash_replace, :initialize_copy) 10 | end 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/value_spec.coffee: -------------------------------------------------------------------------------- 1 | # not supported 2 | # 3 | # require File.expand_path('../../../spec_helper', __FILE__) 4 | # require File.expand_path('../fixtures/classes', __FILE__) 5 | # require File.expand_path('../shared/value', __FILE__) 6 | 7 | # describe "Hash#value?", -> 8 | # it_behaves_like(:hash_value_p, :value?) 9 | # end 10 | 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/values_at_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#values_at", -> 2 | it "returns an array of values for the given keys", -> 3 | h = R.hashify(a: 9, b: 'a', c: -10, d: null) 4 | expect( h.values_at() ).toBeInstanceOf(R.Array) 5 | expect( h.values_at() ).toEqual R([]) 6 | expect( h.values_at('a', 'd', 'b') ).toBeInstanceOf(R.Array) 7 | expect( h.values_at('a', 'd', 'b') ).toEqual R([9, null, 'a']) 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/hash/values_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Hash#values", -> 2 | it "returns an array of values", -> 3 | h = R.hashify({1: 'a', 'a': 'a', 'the': 'lang'}) 4 | expect( h.values() ).toBeInstanceOf(R.Array) 5 | expect( h.values().sort() ).toEqual R(['a', 'a', 'lang']) 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/ceil_spec.coffee: -------------------------------------------------------------------------------- 1 | # describe "Integer#ceil", -> 2 | # it "is an alias to #to_i", -> 3 | # Proto = RubyJS.Integer.prototype 4 | # expect( Proto.ceil ).toEqual Proto.to_i 5 | 6 | describe "Integer#ceil", -> 7 | #it_behaves_like(:integer_to_i, :ceil) 8 | 9 | it "returns self", -> 10 | expect( R( 10 ).ceil() ).toEqual R(10) 11 | expect( R(-15 ).ceil() ).toEqual R(-15) 12 | 13 | xit 'returns self for bignums', -> 14 | # expect( R(bignum_value.ceil() ).toEqual (bignum_value) 15 | # expect( R((-bignum_value).ceil() ).toEqual (-bignum_value) 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/even_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Integer#even?", -> 2 | it "returns true when self is an even number", -> 3 | expect( R(-2).even() ).toEqual true 4 | expect( R(-1).even() ).toEqual false 5 | 6 | expect( R(0).even() ).toEqual true 7 | expect( R(1).even() ).toEqual false 8 | expect( R(2).even() ).toEqual true 9 | 10 | xit 'unsupported', -> 11 | # bignum_value(0).even?.should be_true 12 | # bignum_value(1).even?.should be_false 13 | 14 | # (-bignum_value(0)).even?.should be_true 15 | # (-bignum_value(1)).even?.should be_false 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/floor_spec.coffee: -------------------------------------------------------------------------------- 1 | 2 | # describe "Integer#floor", -> 3 | # # it_behaves_like(:integer_to_i, :floor) 4 | # it "is an alias to #to_i", -> 5 | # Proto = RubyJS.Integer.prototype 6 | # expect( Proto.floor ).toEqual Proto.to_i 7 | 8 | 9 | describe "Integer#floor", -> 10 | #it_behaves_like(:integer_to_i, :floor) 11 | 12 | it "returns self", -> 13 | expect( R( 10 ).floor() ).toEqual R(10) 14 | expect( R(-15 ).floor() ).toEqual R(-15) 15 | 16 | xit 'returns self for bignums', -> 17 | # expect( R(bignum_value.floor() ).toEqual (bignum_value) 18 | # expect( R((-bignum_value).floor() ).toEqual (-bignum_value) 19 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/integer_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Integer#integer? / is_integer", -> 2 | # use is_integer? instead 3 | # wacky implementation... 4 | it "returns true", -> 5 | expect( R(0).is_integer? ).toEqual true 6 | expect( R(-1).is_integer? ).toEqual true 7 | expect( R(1.23).is_integer? ).toNotEqual true 8 | 9 | # it "returns true" do 10 | # 0.integer?.should == true 11 | # -1.integer?.should == true 12 | # bignum_value.integer?.should == true 13 | # end 14 | # end 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/next_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Integer#next", -> 2 | #it_behaves_like(:integer_next, :succ) 3 | 4 | it "returns the next larger positive Fixnum", -> 5 | expect( R( 2).next() ) .toEqual R(3) 6 | 7 | it "returns the next larger negative Fixnum", -> 8 | expect( R(-2).next() ).toEqual R(-1) 9 | 10 | xit "returns the next larger positive Bignum", -> 11 | # bignum_value.next().toEqual R(bignum_value(1)) 12 | 13 | xit "returns the next larger negative Bignum", -> 14 | # (-bignum_value(1)).next().toEqual R(-bignum_value) 15 | 16 | xit "overflows a Fixnum to a Bignum", -> 17 | # fixnum_max.next().toEqual R(fixnum_max + 1) 18 | 19 | xit "underflows a Bignum to a Fixnum", -> 20 | # (fixnum_min - 1).next().toEqual R(fixnum_min) 21 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/odd_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Integer#odd?", -> 2 | it "returns true when self is an odd number", -> 3 | expect( R(-2).odd() ).toEqual false 4 | expect( R(-1).odd() ).toEqual true 5 | 6 | expect( R(0).odd() ).toEqual false 7 | expect( R(1).odd() ).toEqual true 8 | expect( R(2).odd() ).toEqual false 9 | 10 | xit 'unsupported', -> 11 | # bignum_value(0).odd?.should be_false 12 | # bignum_value(1).odd?.should be_true 13 | 14 | # (-bignum_value(0)).odd?.should be_false 15 | # (-bignum_value(1)).odd?.should be_true 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/ord_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Integer#ord", -> 2 | describe 'ruby_version_is "1.8.7"', -> 3 | it "returns self", -> 4 | expect( R(20).ord() ).toEqual R(20) 5 | expect( R(40).ord() ).toEqual R(40) 6 | 7 | expect( R(0).ord() ).toEqual R(0) 8 | expect( R(-10).ord() ).toEqual R(-10) 9 | 10 | #expect( R(?a).ord() ).toEqual R(97) 11 | #expect( R(?Z).ord() ).toEqual R(90) 12 | 13 | xit 'unsupported', -> 14 | #bignum_value.ord.should eql(bignum_value) 15 | #(-bignum_value).ord.should eql(-bignum_value) 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/pred_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Integer#pred", -> 2 | it "returns the Integer equal to self - 1", -> 3 | expect( R(0 ).pred() ).toEqual R(-1) 4 | expect( R(-1 ).pred() ).toEqual R(-2) 5 | expect( R(20 ).pred() ).toEqual R(19) 6 | 7 | xit 'unsupported', -> 8 | expect( R(bignum_value ).pred() ).toEqual R(bignum_value(-1)) 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/shared/next.rb: -------------------------------------------------------------------------------- 1 | describe :integer_next, :shared => true do 2 | it "returns the next larger positive Fixnum" do 3 | 2.send(@method).should == 3 4 | end 5 | 6 | it "returns the next larger negative Fixnum" do 7 | (-2).send(@method).should == -1 8 | end 9 | 10 | it "returns the next larger positive Bignum" do 11 | bignum_value.send(@method).should == bignum_value(1) 12 | end 13 | 14 | it "returns the next larger negative Bignum" do 15 | (-bignum_value(1)).send(@method).should == -bignum_value 16 | end 17 | 18 | it "overflows a Fixnum to a Bignum" do 19 | fixnum_max.send(@method).should == fixnum_max + 1 20 | end 21 | 22 | it "underflows a Bignum to a Fixnum" do 23 | (fixnum_min - 1).send(@method).should == fixnum_min 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/shared/to_i.rb: -------------------------------------------------------------------------------- 1 | describe :integer_to_i, :shared => true do 2 | it "returns self" do 3 | 10.send(@method).should eql(10) 4 | (-15).send(@method).should eql(-15) 5 | bignum_value.send(@method).should eql(bignum_value) 6 | (-bignum_value).send(@method).should eql(-bignum_value) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/succ_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Integer#succ", -> 2 | # it_behaves_like(:integer_to_i, :floor) 3 | it "is an alias to #next", -> 4 | Proto = RubyJS.Integer.prototype 5 | expect( Proto.succ ).toEqual Proto.next -------------------------------------------------------------------------------- /spec/lib/corelib/integer/to_i_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Integer#ceil", -> 2 | #it_behaves_like(:integer_to_i, :ceil) 3 | 4 | it "returns self", -> 5 | expect( R( 10 ).to_i() ).toEqual R(10) 6 | expect( R(-15 ).to_i() ).toEqual R(-15) 7 | 8 | xit 'returns self for bignums', -> 9 | # expect( R(bignum_value.ceil() ).toEqual (bignum_value) 10 | # expect( R((-bignum_value).ceil() ).toEqual (-bignum_value) 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/to_int_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Integer#to_int", -> 2 | # it_behaves_like(:integer_to_i, :floor) 3 | it "is an alias to #to_i", -> 4 | Proto = RubyJS.Integer.prototype 5 | expect( Proto.to_int ).toEqual Proto.to_i -------------------------------------------------------------------------------- /spec/lib/corelib/integer/truncate_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Integer#truncate", -> 2 | # it_behaves_like(:integer_to_i, :floor) 3 | it "is an alias to #to_i", -> 4 | Proto = RubyJS.Integer.prototype 5 | expect( Proto.truncate ).toEqual Proto.to_i -------------------------------------------------------------------------------- /spec/lib/corelib/integer/unsupported/denominator_spec.rb: -------------------------------------------------------------------------------- 1 | describe "Integer#denominator", -> 2 | describe 'ruby_version_is "1.9"', -> 3 | # The Numeric child classes override this method, so their behaviour is 4 | # specified in the appropriate place 5 | it "returns 1", -> 6 | expect( R(20).denominator() ).toEqual R(1) 7 | expect( R(-20).denominator() ).toEqual R(1) 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/unsupported/numerator_spec.rb: -------------------------------------------------------------------------------- 1 | describe "Integer#numerator", -> 2 | describe 'ruby_version_is "1.9"', -> 3 | it "returns self", -> 4 | expect( R(- 0).numerator() ).toEqual R( 0) 5 | expect( R(-29871).numerator() ).toEqual R(29871) 6 | expect( R(-99999999999999*99).numerator() ).toEqual R(99999999999999*99) 7 | expect( R(-72628191273).numerator() ).toEqual R(72628191273) 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/integer/unsupported/to_r_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Integer#to_r" do 4 | ruby_version_is "1.9" do 5 | it "returns a Rational object" do 6 | 309.to_r.should be_an_instance_of(Rational) 7 | end 8 | 9 | it "constructs a rational number with self as the numerator" do 10 | 34.to_r.numerator.should == 34 11 | end 12 | 13 | it "constructs a rational number with 1 as the denominator" do 14 | 298.to_r.denominator.should == 1 15 | end 16 | 17 | it "works even if self is a Bignum" do 18 | bignum = 99999**999 19 | bignum.should be_an_instance_of(Bignum) 20 | bignum.to_r.should == Rational(bignum, 1) 21 | end 22 | 23 | it "raises an ArgumentError if given any arguments" do 24 | lambda { 287.to_r(2) }.should raise_error(ArgumentError) 25 | lambda { 9102826.to_r(309, [], 71) }.should raise_error(ArgumentError) 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /spec/lib/corelib/kernel/rand_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Kernel#rand", -> 2 | # implement tests -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/begin_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#begin", -> 2 | xit "returns the offset of the start of the nth element", -> 3 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").begin(0) ).toEqual R(1) 4 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").begin(2) ).toEqual R(2) 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/captures_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#captures", -> 2 | it "returns an array of the match captures", -> 3 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").captures() ).toEqual R(["H","X","113","8"]) 4 | 5 | it "docs", -> 6 | expect( R(/foo/).match("foo").captures() ).toEqual R([]) 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/element_reference_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#[]", -> 2 | it "acts as normal array indexing [index]", -> 3 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").get(0) ).toEqual 'HX1138' 4 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").get(1) ).toEqual 'H' 5 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").get(2) ).toEqual 'X' 6 | 7 | it "supports accessors [start, length]", -> 8 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").get(1, 2) ).toEqual R(['H', 'X']) 9 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").get(-3, 2) ).toEqual R(['X', '113']) 10 | 11 | xit "supports ranges [start..end]", -> 12 | # expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").get(1..3) ).toEqual R(['H', 'X', '113']) 13 | 14 | # language_version __FILE__, "element_reference" 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/end_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#end", -> 2 | it "returns the offset of the end of the nth element", -> 3 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").end(0) ).toEqual R(7) 4 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").end(2) ).toEqual R(3) 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/hash_spec.coffee: -------------------------------------------------------------------------------- 1 | # require File.expand_path('../../../spec_helper', __FILE__) 2 | # ruby_version_is "1.9" do 3 | # describe "MatchData#hash" do 4 | # it "needs to be reviewed for spec completeness" 5 | # end 6 | # end 7 | 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/initialize_copy_spec.coffee: -------------------------------------------------------------------------------- 1 | # require File.expand_path('../../../spec_helper', __FILE__) 2 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/length_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#length", -> 2 | # it_behaves_like(:matchdata_length, :length) 3 | it "length should return the number of elements in the match array", -> 4 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").length() ).toEqual R(5) 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/names_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#names", -> 2 | it "returns an Array", -> 3 | expect( -> R(/foo/).match("foo").names() ).toThrow('NotSupportedError') 4 | 5 | 6 | # require File.expand_path('../../../spec_helper', __FILE__) 7 | 8 | # language_version __FILE__, "names" 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/offset_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#offset", -> 2 | it "returns a two element array with the begin and end of the nth match", -> 3 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").offset(0) ).toEqual R([1, 7]) 4 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").offset(4) ).toEqual R([6, 7]) 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/post_match_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#post_match", -> 2 | it "returns the string after the match equiv. special var $'", -> 3 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138: The Movie").post_match() ).toEqual ': The Movie' 4 | 5 | # TODO: add $' 6 | # expect( R["$'"] ).toEqual ': The Movie' 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/pre_match_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#pre_match", -> 2 | it "returns the string before the match, equiv. special var $`", -> 3 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138: The Movie").pre_match() ).toEqual 'T' 4 | # TODO: add $` 5 | # expect( R['$`'] ).toEqual 'T' 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/regexp_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'ruby_version_is "1.8.8"', -> 2 | describe "MatchData#regexp from String#match", -> 3 | xit "returns a Regexp object", -> 4 | m = R('haystack').match(/hay/) 5 | expect( m.regexp() ).toBeInstanceOf(R.Regexp) 6 | 7 | xit "returns the pattern used in the match", -> 8 | m = R('haystack').match(/hay/) 9 | expect( m.regexp().equals(/hay/) ).toEqual true 10 | 11 | describe "MatchData#regexp", -> 12 | it "returns a Regexp object", -> 13 | m = R(/hay/).match('haystack') 14 | expect( m.regexp() ).toBeInstanceOf(R.Regexp) 15 | 16 | it "returns the pattern used in the match", -> 17 | m = R(/hay/).match('haystack') 18 | expect( m.regexp().equals(/hay/) ).toEqual true 19 | 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/select_spec.coffee: -------------------------------------------------------------------------------- 1 | # describe 'ruby_version_is ""..."1.9"', -> 2 | # describe "MatchData#select", -> 3 | # it "yields the contents of the match array to a block", -> 4 | # m = R(/(.)(.)(\d+)(\d)/).match("THX1138: The Movie") 5 | # expect( m.select (x) -> x ).toEqual R(["HX1138", "H", "X", "113", "8"]) 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/shared/eql.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | 3 | describe :matchdata_eql, :shared => true do 4 | it "returns true if both operands have equal target strings, patterns, and match positions" do 5 | a = 'haystack'.match(/hay/) 6 | b = 'haystack'.match(/hay/) 7 | a.send(@method, b).should be_true 8 | end 9 | 10 | it "returns false if the operands have different target strings" do 11 | a = 'hay'.match(/hay/) 12 | b = 'haystack'.match(/hay/) 13 | a.send(@method, b).should be_false 14 | end 15 | 16 | it "returns false if the operands have different patterns" do 17 | a = 'haystack'.match(/h.y/) 18 | b = 'haystack'.match(/hay/) 19 | a.send(@method, b).should be_false 20 | end 21 | 22 | it "returns false if the argument is not a MatchData object" do 23 | a = 'haystack'.match(/hay/) 24 | a.send(@method, Object.new).should be_false 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/shared/length.rb: -------------------------------------------------------------------------------- 1 | describe :matchdata_length, :shared => true do 2 | it "length should return the number of elements in the match array" do 3 | /(.)(.)(\d+)(\d)/.match("THX1138.").send(@method).should == 5 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/size_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#size", -> 2 | # it_behaves_like(:matchdata_length, :size) 3 | it "length should return the number of elements in the match array", -> 4 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").size() ).toEqual R(5) 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/string_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#string", -> 2 | it "returns a copy of the match string", -> 3 | str = R(/(.)(.)(\d+)(\d)/).match("THX1138.").string() 4 | expect( str ).toEqual R("THX1138.") 5 | 6 | xit "returns a frozen copy of the match string", -> 7 | # str = /(.)(.)(\d+)(\d)/.match("THX1138.").string 8 | # str.should == "THX1138." 9 | # str.frozen?.should == true 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/to_a_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#to_a", -> 2 | it "returns an array of matches", -> 3 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").to_a().equals(["HX1138", "H", "X", "113", "8"]) ).toEqual(true) 4 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/to_s_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#to_s", -> 2 | it "returns the entire matched string", -> 3 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138.").to_s() ).toEqual R("HX1138") 4 | -------------------------------------------------------------------------------- /spec/lib/corelib/matchdata/values_at_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "MatchData#values_at", -> 2 | it "returns an array of the matching value", -> 3 | expect( R(/(.)(.)(\d+)(\d)/).match("THX1138: The Movie").values_at(0, 2, -2) ).toEqual R(["HX1138", "X", "113"]) 4 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/abs2_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'ruby_version_is "1.9"', -> 2 | describe "Numeric#abs2", -> 3 | beforeEach -> 4 | @numbers = R.$Array_r([ 5 | 0, 6 | R.$Float(0.0), 7 | 1, 8 | 20, 9 | # bignum_value, 10 | 278202.292871, 11 | 72829, 12 | 3.333333333333, 13 | 0.1, 14 | # infinity_value 15 | ]).map((n) -> [n.uminus(), n]).flatten() 16 | 17 | it "returns the square of the absolute value of self", -> 18 | @numbers.each (number) -> 19 | expect( number.abs2().equals(number.abs().multiply(number.abs())) ).toEqual true 20 | 21 | it "calls #* on self", -> 22 | # number = mock_numeric('numeric') 23 | # number.should_receive(:*).and_return(:result) 24 | # number.abs2.should == :result 25 | 26 | it "returns NaN when self is NaN", -> 27 | expect( R.$Float( 0.0/0.0).abs2().nan()).toEqual true 28 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/abs_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Numeric#abs", -> 2 | beforeEach -> 3 | @obj = NumericSpecs.Subclass.new() 4 | @obj['lt'] = -> 5 | @obj.uminus = -> 6 | 7 | it "returns self when self is greater than 0", -> 8 | spy = spyOn(@obj, 'lt').andReturn(false) 9 | expect( @obj.abs() is @obj).toEqual true 10 | expect( spy ).wasCalled() 11 | expect( spy.mostRecentCall.args[0] ).toEqual 0 12 | 13 | it "returns self\#@- when self is less than 0", -> 14 | spy = spyOn(@obj, 'lt').andReturn(true) 15 | spy2 = spyOn(@obj, 'uminus').andReturn(R(123)) 16 | expect( @obj.abs() ).toEqual R(123) 17 | 18 | expect( spy ).wasCalled() 19 | expect( spy.mostRecentCall.args[0] ).toEqual 0 20 | expect( spy2 ).wasCalled() 21 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/ceil_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Numeric#ceil", -> 2 | beforeEach -> 3 | @obj = new NumericSpecs.Subclass() 4 | @obj.to_f = () -> null 5 | 6 | it "converts self to a Float (using #to_f) and returns the #ceil'ed result", -> 7 | spy = spyOn(@obj, 'to_f').andReturn(R(1 + 0.000001)) 8 | expect( @obj.ceil() ).toEqual R(2) 9 | expect( spy ).wasCalled() 10 | 11 | it "converts self to a Float (using #to_f) and returns the #ceil'ed result", -> 12 | spy = spyOn(@obj, 'to_f').andReturn(R(-1 - 0.000001)) 13 | expect( @obj.ceil() ).toEqual R(-1) 14 | expect( spy ).wasCalled() 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/eql_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Numeric#eql?", -> 2 | beforeEach -> 3 | @obj = NumericSpecs.Subclass.new() 4 | 5 | # TODO: follow the protocol: 6 | xit "returns false if self's and other's types don't match", -> 7 | expect( @obj.eql(1) ).toEqual false 8 | expect( @obj.eql(-1.5) ).toEqual false 9 | # expect( @obj.eql(bignum_value) ).toEqual false 10 | expect( @obj.eql('sym') ).toEqual false 11 | 12 | it "returns the result of calling self#== with other when self's and other's types match", -> 13 | other = NumericSpecs.Subclass.new() 14 | @obj.equals = -> 'result' 15 | # @obj.should_receive(:==).with(other).and_return("result", nil) 16 | expect( @obj.eql(other) ).toEqual true 17 | 18 | @obj.equals = -> null 19 | expect( @obj.eql(other) ).toEqual false 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/fixtures/classes.coffee: -------------------------------------------------------------------------------- 1 | root = global ? window 2 | root.NumericSpecs = {} 3 | 4 | class NumericSpecs.Comparison extends RubyJS.Numeric 5 | # This method is used because we cannot define 6 | # singleton methods on subclasses of Numeric, 7 | # which is needed for a.should_receive to work. 8 | cmp: (other) -> 9 | #ScratchPad.record :numeric_comparison 10 | 1 11 | 12 | class NumericSpecs.Subclass extends RubyJS.Numeric 13 | @new: -> new NumericSpecs.Subclass() 14 | 15 | 16 | singleton_method_added: (val) -> 17 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/floor_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Numeric#floor", -> 2 | beforeEach -> 3 | @obj = new NumericSpecs.Subclass() 4 | @obj.to_f = () -> null 5 | 6 | it "converts self to a Float (using #to_f) and returns the #floor'ed result", -> 7 | spy = spyOn(@obj, 'to_f').andReturn(R(2 - 0.000001)) 8 | expect( @obj.floor() ).toEqual R(1) 9 | expect( spy ).wasCalled() 10 | 11 | it "converts self to a Float (using #to_f) and returns the #floor'ed result", -> 12 | spy = spyOn(@obj, 'to_f').andReturn(R(0.000001 - 2)) 13 | expect( @obj.floor() ).toEqual R(-2) 14 | expect( spy ).wasCalled() -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/integer_spec.coffee: -------------------------------------------------------------------------------- 1 | # NOTE integer? becomes is_integer? 2 | describe "Numeric#integer? => is_integer?", -> 3 | it "returns false", -> 4 | expect( NumericSpecs.Subclass.new().integer? ).toEqual false 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/magnitude_spec.coffee: -------------------------------------------------------------------------------- 1 | # it_behaves_like(:numeric_abs, :magnitude) 2 | describe "Numeric#magnitude", -> 3 | beforeEach -> 4 | @obj = NumericSpecs.Subclass.new() 5 | @obj.lt = -> 6 | @obj.uminus = -> 7 | 8 | it "returns self when self is greater than 0", -> 9 | spy = spyOn(@obj, 'lt').andReturn(false) 10 | expect( @obj.magnitude() is @obj).toEqual true 11 | expect( spy ).wasCalled() 12 | expect( spy.mostRecentCall.args[0] ).toEqual 0 13 | 14 | it "returns self\#@- when self is less than 0", -> 15 | spy = spyOn(@obj, 'lt').andReturn(true) 16 | spy2 = spyOn(@obj, 'uminus').andReturn(R(123)) 17 | expect( @obj.magnitude() ).toEqual R(123) 18 | 19 | expect( spy ).wasCalled() 20 | expect( spy.mostRecentCall.args[0] ).toEqual 0 21 | expect( spy2 ).wasCalled() 22 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/nonzero_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Numeric#nonzero?", -> 2 | beforeEach -> 3 | @obj = new NumericSpecs.Subclass() 4 | 5 | it "returns self if self#zero? is false", -> 6 | @obj.zero = -> false 7 | expect( @obj.nonzero() == @obj ).toEqual true 8 | 9 | it "returns nil if self#zero? is true", -> 10 | @obj.zero = -> true 11 | expect( @obj.nonzero() == null).toEqual true 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/round_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Numeric#round", -> 2 | it "converts self to a Float (using #to_f) and returns the #round'ed result", -> 3 | obj = new R.Numeric 4 | obj.to_f = -> R(2.3) 5 | expect( obj.round() ).toEqual R(2) 6 | obj.to_f = -> R(-2.3) 7 | expect( obj.round() ).toEqual R(-2) 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/shared/abs.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | require File.expand_path('../../fixtures/classes', __FILE__) 3 | 4 | describe :numeric_abs, :shared => true do 5 | before(:each) do 6 | @obj = NumericSpecs::Subclass.new 7 | end 8 | 9 | it "returns self when self is greater than 0" do 10 | @obj.should_receive(:<).with(0).and_return(false) 11 | @obj.send(@method).should == @obj 12 | end 13 | 14 | it "returns self\#@- when self is less than 0" do 15 | @obj.should_receive(:<).with(0).and_return(true) 16 | @obj.should_receive(:-@).and_return(:absolute_value) 17 | @obj.send(@method).should == :absolute_value 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/shared/quo.rb: -------------------------------------------------------------------------------- 1 | describe :numeric_quo_18, :shared => true do 2 | it "returns the result of calling self#/ with other" do 3 | obj = mock_numeric('numeric') 4 | obj.should_receive(:/).with(19).and_return(:result) 5 | obj.send(@method, 19).should == :result 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/to_int_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Numeric#to_int", -> 2 | it "returns self#to_i", -> 3 | obj = NumericSpecs.Subclass.new() 4 | obj.to_i = -> 5 | spy = spyOn(obj, 'to_i').andReturn(5) 6 | expect( obj.to_int() ).toEqual 5 7 | expect( spy ).wasCalled() 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/truncate_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Numeric#truncate", -> 2 | beforeEach -> 3 | @obj = NumericSpecs.Subclass.new() 4 | @obj.to_f = -> 5 | 6 | it "converts self to a Float (using #to_f) and returns the #truncate'd result", -> 7 | spy = spyOn( @obj, 'to_f').andReturn(R 2.5555) 8 | expect( @obj.truncate() ).toEqual R.$Integer(2) 9 | expect( spy ).wasCalled() 10 | 11 | it "converts self to a negative Float (using #to_f) and returns the #truncate'd result", -> 12 | spy = spyOn( @obj, 'to_f').andReturn(R -2.3333) 13 | expect( @obj.truncate() ).toEqual R.$Integer(-2) 14 | expect( spy ).wasCalled() 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/angle_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/complex/numeric/arg', __FILE__) 3 | 4 | ruby_version_is "1.9" do 5 | describe "Numeric#angle" do 6 | it_behaves_like(:numeric_arg, :angle) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/arg_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/complex/numeric/arg', __FILE__) 3 | 4 | ruby_version_is "1.9" do 5 | describe "Numeric#arg" do 6 | it_behaves_like(:numeric_arg, :arg) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/conj_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/complex/numeric/conj', __FILE__) 3 | 4 | ruby_version_is "1.9" do 5 | describe "Numeric#conj" do 6 | it_behaves_like(:numeric_conj, :conj) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/conjugate_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/complex/numeric/conj', __FILE__) 3 | 4 | ruby_version_is "1.9" do 5 | describe "Numeric#conjugate" do 6 | it_behaves_like(:numeric_conj, :conjugate) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/denominator_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.9" do 4 | describe "Numeric#denominator" do 5 | # The Numeric child classes override this method, so their behaviour is 6 | # specified in the appropriate place 7 | before(:each) do 8 | @numbers = [ 9 | 20, # Integer 10 | 99999999**99, # Bignum 11 | ] 12 | end 13 | 14 | it "returns 1" do 15 | @numbers.each {|number| number.denominator.should == 1} 16 | end 17 | 18 | it "works with Numeric subclasses" do 19 | rational = mock_numeric('rational') 20 | rational.should_receive(:denominator).and_return(:denominator) 21 | numeric = mock_numeric('numeric') 22 | numeric.should_receive(:to_r).and_return(rational) 23 | numeric.denominator.should == :denominator 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/i_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | ruby_version_is "1.9" do 4 | describe "Numeric#i" do 5 | it "returns a Complex object" do 6 | 34.i.should be_an_instance_of(Complex) 7 | end 8 | 9 | it "sets the real part to 0" do 10 | 7342.i.real.should == 0 11 | end 12 | 13 | it "sets the imaginary part to self" do 14 | 62.81.i.imag.should == 62.81 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/imag_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/complex/numeric/imag', __FILE__) 3 | 4 | ruby_version_is "1.9" do 5 | describe "Numeric#imag" do 6 | it_behaves_like(:numeric_imag, :imag) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/imaginary_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/complex/numeric/imag', __FILE__) 3 | 4 | ruby_version_is "1.9" do 5 | describe "Numeric#imaginary" do 6 | it_behaves_like(:numeric_imag, :imaginary) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/initialize_copy_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | 4 | describe "Numeric#singleton_method_added" do 5 | it "raises a TypeError when trying to #dup a Numeric" do 6 | lambda do 7 | a = NumericSpecs::Subclass.new 8 | a.dup 9 | end.should raise_error(TypeError) 10 | 11 | lambda do 12 | a = 1 13 | a.dup 14 | end.should raise_error(TypeError) 15 | 16 | lambda do 17 | a = 1.5 18 | a.dup 19 | end.should raise_error(TypeError) 20 | 21 | lambda do 22 | a = bignum_value 23 | a.dup 24 | end.should raise_error(TypeError) 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/phase_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/complex/numeric/arg', __FILE__) 3 | 4 | ruby_version_is "1.9" do 5 | describe "Numeric#phase" do 6 | it_behaves_like(:numeric_arg, :phase) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/polar_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/complex/numeric/polar', __FILE__) 3 | 4 | ruby_version_is "1.9" do 5 | describe "Numeric#polar" do 6 | it_behaves_like(:numeric_polar, :polar) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/real_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/complex/numeric/real', __FILE__) 3 | require File.expand_path('../fixtures/classes', __FILE__) 4 | 5 | ruby_version_is "1.9" do 6 | describe "Numeric#real" do 7 | it_behaves_like(:numeric_real, :real) 8 | end 9 | end 10 | 11 | ruby_version_is "1.9" do 12 | describe "Numeric#real?" do 13 | it "returns true" do 14 | NumericSpecs::Subclass.new.real?.should == true 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/unsupported/uplus_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes', __FILE__) 3 | 4 | describe "Numeric#+@" do 5 | it "returns self" do 6 | obj = NumericSpecs::Subclass.new 7 | obj.send(:+@).should == obj 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/numeric/zero_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Numeric#zero?", -> 2 | beforeEach -> 3 | # FIXME: move to proper subclass 4 | @obj = NumericSpecs.Subclass.new() 5 | @obj.equals = -> 6 | 7 | it "returns true if self is 0", -> 8 | spy = spyOn(@obj, 'equals').andReturn(true) 9 | expect( @obj.zero() ).toEqual true 10 | expect( spy ).wasCalled() 11 | 12 | it "returns false if self is not 0", -> 13 | spy = spyOn(@obj, 'equals').andReturn(false) 14 | expect( @obj.zero() ).toEqual false 15 | expect( spy ).wasCalled() 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/__id__spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/object/object_id', __FILE__) 3 | 4 | ruby_version_is "".."1.9" do 5 | describe "Object#__id__" do 6 | it_behaves_like :basic_object_id, :__id__, Object 7 | it_behaves_like :object_id, :__id__, Object 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/clone_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../shared/dup_clone', __FILE__) 3 | 4 | describe "Object#clone" do 5 | it_behaves_like :object_dup_clone, :clone 6 | 7 | it "preserves frozen state from the original" do 8 | o = ObjectSpecDupInitCopy.new 9 | o2 = o.clone 10 | o.freeze 11 | o3 = o.clone 12 | 13 | o2.frozen?.should == false 14 | o3.frozen?.should == true 15 | end 16 | end 17 | 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/dup_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../shared/dup_clone', __FILE__) 3 | 4 | describe "Object#dup" do 5 | it_behaves_like :object_dup_clone, :dup 6 | 7 | it "does not preserve frozen state from the original" do 8 | o = ObjectSpecDupInitCopy.new 9 | o.freeze 10 | o2 = o.dup 11 | 12 | o2.frozen?.should == false 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/fixtures/classes.rb: -------------------------------------------------------------------------------- 1 | module ObjectSpecs 2 | class IVars 3 | def initialize 4 | @secret = 99 5 | end 6 | end 7 | 8 | module InstExec 9 | def self.included(base) 10 | base.instance_exec { @@count = 2 } 11 | end 12 | end 13 | 14 | module InstExecIncluded 15 | include InstExec 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/id_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/object/object_id', __FILE__) 3 | 4 | ruby_version_is "".."1.9" do 5 | describe "Object#id" do 6 | it_behaves_like :basic_object_id, :id, Object 7 | it_behaves_like :object_id, :id, Object 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/initialize_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/is_a_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../shared/kind_of', __FILE__) 3 | 4 | describe "Object#is_a?" do 5 | it_behaves_like(:object_kind_of , :is_a?) 6 | end 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/kind_of_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../shared/kind_of', __FILE__) 3 | 4 | describe "Object#kind_of?" do 5 | it_behaves_like(:object_kind_of , :kind_of?) 6 | end 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/match_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe Object, '=~' do 4 | ruby_version_is ""..."1.9" do 5 | it "returns false matching any object" do 6 | o = Object.new 7 | 8 | (o =~ /Object/).should == false 9 | (o =~ 'Object').should == false 10 | (o =~ Object).should == false 11 | (o =~ Object.new).should == false 12 | (o =~ nil).should == false 13 | (o =~ true).should == false 14 | end 15 | end 16 | 17 | ruby_version_is "1.9" do 18 | it "returns nil matching any object" do 19 | o = Object.new 20 | 21 | (o =~ /Object/).should be_nil 22 | (o =~ 'Object').should be_nil 23 | (o =~ Object).should be_nil 24 | (o =~ Object.new).should be_nil 25 | (o =~ nil).should be_nil 26 | (o =~ true).should be_nil 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/metaclass_spec.rb: -------------------------------------------------------------------------------- 1 | 2 | describe "Object#metaclass" do 3 | it "returns the object's metaclass" do 4 | foo = "foo" 5 | foo.instance_eval "class << self; def meta_test_method; 5; end; end" 6 | foo.respond_to?(:meta_test_method).should == true 7 | lambda { "hello".metaclass.method(:meta_test_method) }.should raise_error(NameError) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/new_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Object.new" do 4 | it "creates a new Object" do 5 | Object.new.should be_kind_of(Object) 6 | end 7 | 8 | ruby_version_is "1.9.1".."1.9.2" do # Ref: [redmine:2451] 9 | it "accepts any number of arguments" do 10 | lambda { 11 | Object.new("This", "makes it easier", "to call super", "from other constructors") 12 | }.should_not raise_error 13 | end 14 | end 15 | 16 | ruby_version_is "1.9.3" do # Ref: [redmine:2451] 17 | it "doesn't accept arguments" do 18 | lambda { 19 | Object.new("This", "makes it easier", "to call super", "from other constructors") 20 | }.should raise_error 21 | end 22 | end 23 | end 24 | 25 | -------------------------------------------------------------------------------- /spec/lib/corelib/object/object_id_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/object/object_id', __FILE__) 3 | 4 | describe "Object#object_id" do 5 | it_behaves_like :basic_object_id, :object_id, Object 6 | it_behaves_like :object_id, :object_id, Object 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/range/begin_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'Range#begin', -> 2 | it "returns the first element of self", -> 3 | r = RubyJS.Range.new 4 | expect( r(-1,1).begin() ).toEqual R(-1) 5 | expect( r(0,1).begin() ).toEqual R(0) 6 | expect( r(0xffff,0xfffff).begin() ).toEqual R(65535) 7 | expect( r('Q','T').begin() ).toEqual R('Q') 8 | expect( r('Q','T').begin() ).toEqual R('Q') 9 | expect( r(0.5,2.4).begin() ).toEqual R(0.5) 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/range/end_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Range#end", -> 2 | it "end returns the last element of self", -> 3 | r = RubyJS.Range.new 4 | expect( r(-1,1).end() ).toEqual R(1) 5 | expect( r(0,1).end() ).toEqual R(1) 6 | expect( r("A","Q").end() ).toEqual R("Q") 7 | expect( r("A","Q").end() ).toEqual R("Q") 8 | expect( r(0xffff,0xfffff).end() ).toEqual R(1048575) 9 | expect( r(0.5,2.4).end() ).toEqual R(2.4) 10 | 11 | expect( r(-1,1, true).end() ).toEqual R(1) 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/range/eql_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Range#equal?", -> 2 | it "is an alias to #==", -> 3 | RangeProto = RubyJS.Range.prototype 4 | expect( RangeProto.eql ).toEqual RangeProto.equals -------------------------------------------------------------------------------- /spec/lib/corelib/range/exclude_end_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Range#exclude_end()", -> 2 | it "returns true if the range exludes the end value", -> 3 | expect( RubyJS.Range.new(-2, 2).exclude_end() ).toEqual false 4 | expect( RubyJS.Range.new('A', 'B').exclude_end() ).toEqual false 5 | expect( RubyJS.Range.new(0.5, 2.4).exclude_end() ).toEqual false 6 | expect( RubyJS.Range.new(0xfffd, 0xffff).exclude_end() ).toEqual false 7 | 8 | expect( RubyJS.Range.new(0,5, true).exclude_end() ).toEqual true 9 | expect( RubyJS.Range.new('A','B', true).exclude_end() ).toEqual true 10 | expect( RubyJS.Range.new(0.5,2.4, true).exclude_end() ).toEqual true 11 | expect( RubyJS.Range.new(0xfffd,0xffff, true).exclude_end() ).toEqual true 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/range/first_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Range#first", -> 2 | it "is an alias to begin", -> 3 | r = RubyJS.Range.new(1,2) 4 | expect( r.first() ).toEqual r.begin() 5 | expect( r.first() ).toEqual R(1) 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/range/hash_spec.coffee: -------------------------------------------------------------------------------- 1 | xdescribe "Range#hash", -> 2 | it "is provided", -> 3 | # (0..1).respond_to?(:hash).toEqual true 4 | # ('A'..'Z').respond_to?(:hash).toEqual true 5 | # (0xfffd..0xffff).respond_to?(:hash).toEqual true 6 | # (0.5..2.4).respond_to?(:hash).toEqual true 7 | 8 | it "generates the same hash values for Ranges with the same start, end and exclude_end? values", -> 9 | # (0..1).hash.toEqual (0..1).hash 10 | # (0...10).hash.toEqual (0...10).hash 11 | # (0..10).hash.should_not == (0...10).hash 12 | 13 | it "generates a Fixnum for the hash value", -> 14 | # (0..0).hash.toEqual an_instance_of(Fixnum) 15 | # (0..1).hash.toEqual an_instance_of(Fixnum) 16 | # (0...10).hash.toEqual an_instance_of(Fixnum) 17 | # (0..10).hash.toEqual an_instance_of(Fixnum) 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/range/include_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Range#include?", -> 2 | it "is an alias to #===", -> 3 | RangeProto = RubyJS.Range.prototype 4 | expect( RangeProto.include ).toEqual RangeProto['==='] -------------------------------------------------------------------------------- /spec/lib/corelib/range/initialize_spec.coffee: -------------------------------------------------------------------------------- 1 | # describe "Range#initialize", -> 2 | # it "is private", -> 3 | # Range.should have_private_instance_method("initialize") 4 | 5 | # it "raises an ArgumentError if passed without or with only an argument", -> 6 | # lambda { (1..3).__send__(:initialize) }. 7 | # should raise_error(ArgumentError) 8 | # lambda { (1..3).__send__(:initialize, 1) }. 9 | # should raise_error(ArgumentError) 10 | 11 | # it "raises a NameError if passed with two or three arguments", -> 12 | # lambda { (1..3).__send__(:initialize, 1, 3) }. 13 | # should raise_error(NameError) 14 | # lambda { (1..3).__send__(:initialize, 1, 3, 5) }. 15 | # should raise_error(NameError) 16 | 17 | # it "raises an ArgumentError if passed with four or more arguments", -> 18 | # lambda { (1..3).__send__(:initialize, 1, 3, 5, 7) }. 19 | # should raise_error(ArgumentError) 20 | # lambda { (1..3).__send__(:initialize, 1, 3, 5, 7, 9) }. 21 | # should raise_error(ArgumentError) 22 | -------------------------------------------------------------------------------- /spec/lib/corelib/range/inspect_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Range#inspect", -> 2 | it "provides a printable form, using #inspect to convert the start and end objects", -> 3 | r = RubyJS.Range.new 4 | expect( r('A','Z').inspect() ).toEqual '"A".."Z"' 5 | expect( r('A','Z', true).inspect() ).toEqual '"A"..."Z"' 6 | expect( r( 0,21).inspect() ).toEqual "0..21" 7 | expect( r(-8,0).inspect() ).toEqual "-8..0" 8 | expect( r(-411,959).inspect() ).toEqual "-411..959" 9 | expect( r(0xfff,0xfffff).inspect() ).toEqual "4095..1048575" 10 | expect( r(0.5,2.4).inspect() ).toEqual "0.5..2.4" 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/range/jsruby_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'Range', -> 2 | it "should create range", -> 3 | range = RubyJS.Range.new(1,5) 4 | expect( range.to_a().valueOf() ).toEqual([1,2,3,4,5]) 5 | 6 | range = RubyJS.Range.new('a', 'e') 7 | expect( range.to_a().valueOf() ).toEqual(['a', 'b', 'c', 'd', 'e']) 8 | 9 | expect( (i.valueOf() for i in RubyJS.Range.new(1,3).iterator()) ).toEqual [1,2,3] -------------------------------------------------------------------------------- /spec/lib/corelib/range/last_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Range#last", -> 2 | it "is an alias to end", -> 3 | r = RubyJS.Range.new(1,2) 4 | expect( r.last() ).toEqual r.end() 5 | expect( r.last() ).toEqual R(2) 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/range/member_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Range#member?", -> 2 | it "is an alias to #member", -> 3 | RangeProto = RubyJS.Range.prototype 4 | expect( RangeProto.include ).toEqual RangeProto.member -------------------------------------------------------------------------------- /spec/lib/corelib/range/to_s_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Range#to_s", -> 2 | it "is an alias to #inspect", -> 3 | expect( R.Range.prototype.to_s ).toEqual R.Range.prototype.inspect -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/case_compare_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Regexp#===", -> 2 | it "is true if there is a match", -> 3 | expect(R(/abc/)['==='] "aabcc").toEqual true 4 | 5 | it "is false if there is no match", -> 6 | expect(R(/abc/)['==='] "xyz").toEqual false 7 | 8 | xdescribe 'ruby_version_is "1.9"', -> 9 | it "returns true if it matches a Symbol", -> 10 | # expect(R(/a/)['==='] :a).toEqual true 11 | 12 | it "returns false if it does not match a Symbol", -> 13 | # expect(R(/a/)['==='] :b).toEqual false 14 | -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/casefold_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Regexp#casefold?", -> 2 | it "returns the value of the case-insensitive flag", -> 3 | expect( R(/abc/i).casefold() ).toEqual true 4 | expect( R(/xyz/).casefold() ).toEqual false 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/escape_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Regexp.escape", -> 2 | # it_behaves_like :regexp_quote, :escape 3 | # -*- encoding: ascii-8bit -*- 4 | 5 | it "escapes any characters with special meaning in a regular expression", -> 6 | expect( R.Regexp.escape("\*?{}.+^[]()- ") ).toEqual '\\*\\?\\{\\}\\.\\+\\^\\[\\]\\(\\)\\-\\ ' 7 | expect( R.Regexp.escape("\n\r\f\t") ).toEqual '\\n\\r\\f\\t' 8 | # DOCUMENT: single and double quotes act the same in JS 9 | # expect( R.Regexp.quote('\*?{}.+^[]()- ') ).toEqual '\\\\\*\?\{\}\.\+\^\[\]\(\)\-\\ ' 10 | # expect( R.Regexp.quote('\n\r\f\t') ).toEqual '\\\\n\\\\r\\\\f\\\\t' 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/hash_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Regexp#hash", -> 2 | it "unsupported", -> 3 | expect( -> R(/foo/).hash() ).toThrow('NotSupportedError') 4 | 5 | 6 | # require File.expand_path('../../../spec_helper', __FILE__) 7 | 8 | # describe "Regexp#hash" do 9 | # it "is provided" do 10 | # Regexp.new('').respond_to?(:hash).should == true 11 | # end 12 | 13 | # it "is based on the text and options of Regexp" do 14 | # (/cat/ix.hash == /cat/ixn.hash).should == true 15 | # (/dog/m.hash == /dog/m.hash).should == true 16 | # (/cat/.hash == /cat/ix.hash).should == false 17 | # (/cat/.hash == /dog/.hash).should == false 18 | # end 19 | 20 | # it "returns the same value for two Regexps differing only in the /n option" do 21 | # (//.hash == //n.hash).should == true 22 | # end 23 | # end 24 | -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/initialize_copy_spec.coffee: -------------------------------------------------------------------------------- 1 | # require File.expand_path('../../../spec_helper', __FILE__) 2 | -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/initialize_spec.coffee: -------------------------------------------------------------------------------- 1 | # TODO: document this spec. although private methods not supported 2 | # 3 | 4 | # require File.expand_path('../../../spec_helper', __FILE__) 5 | 6 | # describe "Regexp#initialize" do 7 | # it "is a private method" do 8 | # Regexp.should have_private_method(:initialize) 9 | # end 10 | 11 | # it "raises a SecurityError on a Regexp primitive" do 12 | # lambda { //.send(:initialize, "") }.should raise_error(SecurityError) 13 | # end 14 | 15 | # ruby_version_is ""..."1.9" do 16 | # it "reinitializes an initialized non-primitive Regexp" do 17 | # r = Regexp.new("a") 18 | # r.send(:initialize, "b") 19 | # r.should == /b/ 20 | # end 21 | # end 22 | 23 | # ruby_version_is "1.9" do 24 | # it "raises a TypeError on an initialized non-primitive Regexp" do 25 | # lambda { Regexp.new("").send(:initialize, "") }.should raise_error(TypeError) 26 | # end 27 | # end 28 | # end 29 | -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/kcode_spec.coffee: -------------------------------------------------------------------------------- 1 | # DEPRECATED 2 | 3 | # ruby_version_is ""..."1.9" do 4 | # describe "Regexp#kcode" do 5 | # it "returns the character set code" do 6 | # default = /f.(o)/.kcode 7 | # default.should_not == 'sjis' 8 | # default.should_not == 'euc' 9 | # default.should_not == 'utf8' 10 | 11 | # /ab+c/s.kcode.should == "sjis" 12 | # /a(.)+s/n.kcode.should == "none" 13 | # /xyz/e.kcode.should == "euc" 14 | # /cars/u.kcode.should == "utf8" 15 | # end 16 | # end 17 | # end 18 | -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/last_match_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Regexp.last_match", -> 2 | it "returns MatchData instance when not passed arguments", -> 3 | R(/c(.)t/)['=~']('cat') 4 | 5 | expect( R.Regexp.last_match() ).toBeInstanceOf(R.MatchData) 6 | 7 | it "returns the nth field in this MatchData when passed a Fixnum", -> 8 | R(/c(.)t/)['=~']('cat') 9 | expect( R.Regexp.last_match(1) ).toEqual 'a' 10 | 11 | it "returns null if $~ is null when passed a Fixnum", -> 12 | R['$~'] = null 13 | expect( R.Regexp.last_match(1) ).toEqual null 14 | -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/source_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Regexp#source", -> 2 | it "returns the original string of the pattern", -> 3 | expect( R(/ab+c/i).source() ).toEqual R("ab+c") 4 | expect( R(/x(.)xz/).source() ).toEqual R("x(.)xz") 5 | 6 | it "has working rdocs", -> 7 | expect( R(/\x20\+/).source() ).toEqual R("\\x20\\+") 8 | expect( R(/ab+c/i).source() ).toEqual R("ab+c") -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/try_convert_spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'ruby_version_is "1.9"', -> 2 | describe "Regexp.try_convert", -> 3 | it "returns the argument if given a Regexp", -> 4 | expect( R.Regexp.try_convert(/foo/i) ).toEqual R(/foo/i) 5 | 6 | it "returns nil if given an argument that can't be converted to a Regexp", -> 7 | expect( R.Regexp.try_convert('') ).toEqual null 8 | expect( R.Regexp.try_convert('glark') ).toEqual null 9 | expect( R.Regexp.try_convert([]) ).toEqual null 10 | expect( R.Regexp.try_convert({}) ).toEqual null 11 | expect( R.Regexp.try_convert(null) ).toEqual null 12 | 13 | it "tries to coerce the argument by calling #to_regexp", -> 14 | rex = 15 | to_regexp: -> R(/(p(a)t[e]rn)/) 16 | expect( R.Regexp.try_convert(rex) ).toEqual R(/(p(a)t[e]rn)/) 17 | 18 | # TODO: test for R.Regexp.try_convert() throws error -------------------------------------------------------------------------------- /spec/lib/corelib/regexp/versions/names_1.9.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | 3 | describe "Regexp#names" do 4 | it "returns an Array" do 5 | /foo/.names.should be_an_instance_of(Array) 6 | end 7 | 8 | it "returns an empty Array if there are no named captures" do 9 | /needle/.names.should == [] 10 | end 11 | 12 | it "returns each named capture as a String" do 13 | /n(?ee)d(?le)/.names.each do |name| 14 | name.should be_an_instance_of(String) 15 | end 16 | end 17 | 18 | it "returns all of the named captures" do 19 | /n(?ee)d(?le)/.names.should == ['cap', 'ture'] 20 | end 21 | 22 | it "works with nested named captures" do 23 | /n(?eed(?le))/.names.should == ['cap', 'ture'] 24 | end 25 | 26 | it "returns each capture name only once" do 27 | /n(?ee)d(?le)/.names.should == ['cap'] 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/append_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String#<<", -> 2 | it "is alias to concat", -> 3 | a = R('str') 4 | expect( a['<<'] ).toEqual a.concat -------------------------------------------------------------------------------- /spec/lib/corelib/string/case_compare_spec.coffee: -------------------------------------------------------------------------------- 1 | # TODO: figure out difference 2 | 3 | # require File.expand_path('../../../spec_helper', __FILE__) 4 | 5 | # ruby_version_is "1.9" do 6 | # describe "String#===" do 7 | # it "needs to be reviewed for spec completeness" 8 | # end 9 | # end 10 | 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/clear_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String#clear", -> 2 | beforeEach -> 3 | @s = R("Jolene") 4 | 5 | it "sets self equal to the empty String", -> 6 | @s.clear() 7 | expect( @s ).toEqual R("") 8 | 9 | it "returns self after emptying it", -> 10 | cleared = @s.clear() 11 | expect( cleared ).toEqual R("") 12 | expect( cleared is @s).toEqual true 13 | 14 | xit "preserves its encoding", -> 15 | # @s.encode!(Encoding::SHIFT_JIS) 16 | # @s.encoding.should == Encoding::SHIFT_JIS 17 | # @s.clear.encoding.should == Encoding::SHIFT_JIS 18 | # @s.encoding.should == Encoding::SHIFT_JIS 19 | 20 | # does not work in node 21 | xit "works with multibyte Strings", -> 22 | # s = R("\u{9765}\u{876}") 23 | # s.clear() 24 | # expect( s ).toEqual R("") 25 | 26 | xit "raises a RuntimeError if self is frozen", -> 27 | # @s.freeze 28 | # lambda { @s.clear }.should raise_error(RuntimeError) 29 | # lambda { "".freeze.clear }.should raise_error(RuntimeError) 30 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/dup_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String#dup", -> 2 | beforeEach -> 3 | @obj = new StringSpecs.InitializeString "string" 4 | 5 | it "calls #initialize_copy on the new instance", -> 6 | dup = @obj.dup() 7 | expect( dup.recorded ).toEqual(@obj.object_id) 8 | 9 | it "copies instance variables", -> 10 | dup = @obj.dup() 11 | expect( dup.ivar ).toEqual 1 12 | 13 | it "does not copy singleton methods", -> 14 | @obj.special = () -> 'the_one' 15 | dup = @obj.dup() 16 | expect( dup.special ).toEqual undefined 17 | 18 | # it "does not copy modules included in the singleton class", -> 19 | # class << @obj 20 | # include StringSpecs::StringModule 21 | 22 | # dup = @obj.dup 23 | # lambda { dup.repr }.should raise_error(NameError) 24 | 25 | # it "does not copy constants defined in the singleton class", -> 26 | # class << @obj 27 | # CLONE = :clone 28 | 29 | # dup = @obj.dup 30 | # lambda { class << dup; CLONE; end }.should raise_error(NameError) 31 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/each_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String#each", -> 2 | # removed 3 | # ruby_version_is ''...'1.9' do 4 | # it_behaves_like(:string_each_line, :each) 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/empty_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String#empty?", -> 2 | it "returns true if the string has a length of zero", -> 3 | expect( R("hello").empty() ).toEqual false 4 | expect( R(" ").empty() ).toEqual false 5 | expect( R("\x00").empty() ).toEqual false 6 | expect( R("").empty() ).toEqual true 7 | # StringSpecs::MyString.new("").empty?.should == true 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/fixtures/classes.coffee: -------------------------------------------------------------------------------- 1 | root = global ? window 2 | root.StringSpecs = {} 3 | 4 | class StringSpecs.MyString extends RubyJS.String 5 | 6 | class StringSpecs.SubString extends RubyJS.String 7 | constructor: (str) -> 8 | super 9 | @special = str || null 10 | 11 | class StringSpecs.InitializeString extends RubyJS.String 12 | @object_ids: 0 13 | 14 | constructor: (other) -> 15 | super 16 | @object_id = InitializeString.object_ids++ 17 | @ivar = 1 18 | 19 | initialize_copy: (other) -> 20 | @recorded = other.object_id 21 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/fixtures/iso-8859-9-encoding.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding: iso-8859-9 -*- 2 | module StringSpecs 3 | class ISO88599Encoding 4 | def source_encoding; __ENCODING__; end 5 | def x_escape; "\xDF"; end 6 | def ascii_only; "glark"; end 7 | def cedilla; "Ş"; end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/fixtures/utf-8-encoding.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | module StringSpecs 3 | class UTF8Encoding 4 | def self.source_encoding; __ENCODING__; end 5 | def self.egrave; "é"; end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/initialize_spec.coffee: -------------------------------------------------------------------------------- 1 | 2 | 3 | # require File.expand_path('../../../spec_helper', __FILE__) 4 | # require File.expand_path('../fixtures/classes', __FILE__) 5 | # require File.expand_path('../shared/replace', __FILE__) 6 | 7 | # describe "String#initialize" do 8 | # it "is a private method" do 9 | # String.should have_private_instance_method(:initialize) 10 | # end 11 | 12 | # describe "with no arguments" do 13 | # it "does not change self" do 14 | # s = "some string" 15 | # s.send :initialize 16 | # s.should == "some string" 17 | # end 18 | 19 | # it "does not raise an exception when frozen" do 20 | # a = "hello".freeze 21 | # a.send(:initialize).should equal(a) 22 | # end 23 | # end 24 | 25 | # describe "with an argument" do 26 | # it_behaves_like :string_replace, :initialize 27 | # end 28 | # end 29 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/length_spec.coffee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hasclass/core-lib/5fc22406621699f158f78fef94a979ba68c52318/spec/lib/corelib/string/length_spec.coffee -------------------------------------------------------------------------------- /spec/lib/corelib/string/next_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String#next", -> 2 | it "is alias to #succ", -> 3 | proto = R.String.prototype 4 | expect( proto.next ).toEqual proto.succ 5 | 6 | describe "String#next!", -> 7 | it "is alias to #succ", -> 8 | proto = R.String.prototype 9 | expect( proto.next_bang ).toEqual proto.succ_bang 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/shared/equal_value.rb: -------------------------------------------------------------------------------- 1 | describe :string_equal_value, :shared => true do 2 | it "returns true if self <=> string returns 0" do 3 | 'hello'.send(@method, 'hello').should == true 4 | end 5 | 6 | it "returns false if self <=> string does not return 0" do 7 | "more".send(@method, "MORE").should == false 8 | "less".send(@method, "greater").should == false 9 | end 10 | 11 | it "ignores subclass differences" do 12 | a = "hello" 13 | b = StringSpecs::MyString.new("hello") 14 | 15 | a.send(@method, b).should == true 16 | b.send(@method, a).should == true 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/shared/length.rb: -------------------------------------------------------------------------------- 1 | describe :string_length, :shared => true do 2 | it "returns the length of self" do 3 | "".send(@method).should == 0 4 | "\x00".send(@method).should == 1 5 | "one".send(@method).should == 3 6 | "two".send(@method).should == 3 7 | "three".send(@method).should == 5 8 | "four".send(@method).should == 4 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/shared/to_a.rb: -------------------------------------------------------------------------------- 1 | describe :string_to_a, :shared => true do 2 | it "returns an empty array for empty strings" do 3 | "".send(@method).should == [] 4 | end 5 | 6 | it "returns an array containing the string for non-empty strings" do 7 | "hello".send(@method).should == ["hello"] 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/shared/to_s.rb: -------------------------------------------------------------------------------- 1 | describe :string_to_s, :shared => true do 2 | it "returns self when self.class == String" do 3 | a = "a string" 4 | a.should equal(a.send(@method)) 5 | end 6 | 7 | it "returns a new instance of String when called on a subclass" do 8 | a = StringSpecs::MyString.new("a string") 9 | s = a.send(@method) 10 | s.should == "a string" 11 | s.should be_kind_of(String) 12 | end 13 | 14 | it "taints the result when self is tainted" do 15 | "x".taint.send(@method).tainted?.should == true 16 | StringSpecs::MyString.new("x").taint.send(@method).tainted?.should == true 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/size_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String#size", -> 2 | # it_behaves_like(:string_length, :size) 3 | it "returns the length of self", -> 4 | expect( R("" ).size().equals 0).toEqual true 5 | expect( R("\x00" ).size().equals 1).toEqual true 6 | expect( R("one" ).size().equals 3).toEqual true 7 | expect( R("two" ).size().equals 3).toEqual true 8 | expect( R("three").size().equals 5).toEqual true 9 | expect( R("four" ).size().equals 4).toEqual true 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/string_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String#multiply", -> 2 | it "multiply", -> 3 | expect(R("-").multiply(2).valueOf()).toEqual("--") 4 | 5 | it "returns a new string containing count copies of self", -> 6 | expect(R("cool").multiply(0).valueOf()).toEqual("") 7 | expect(R("cool").multiply(1).valueOf()).toEqual("cool") 8 | expect(R("cool").multiply(3).valueOf()).toEqual("coolcoolcool") 9 | 10 | it "tries to convert the given argument to an integer using to_int", -> 11 | expect(R("cool").multiply(3.1).valueOf()).toEqual("coolcoolcool") 12 | expect(R("a").multiply(3.999).valueOf() ).toEqual("aaa") 13 | 14 | it "raises an ArgumentError when given integer is negative", -> 15 | expect(-> R("cool").multiply -3 ).toThrow("ArgumentError") 16 | expect(-> R("cool").multiply -3.14 ).toThrow("ArgumentError") 17 | 18 | # it "raises a RangeError when given integer is a Bignum", -> 19 | # lambda { "cool" * 999999999999999999999 }.should raise_error(RangeError) 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/to_a_spec.coffee: -------------------------------------------------------------------------------- 1 | # DEPRECATED! 2 | describe "String#to_a", -> 3 | xit "returns an empty array for empty strings", -> 4 | expect(R("").to_a().valueOf()).toEqual [] 5 | 6 | xit "returns an array containing the string for non-empty strings", -> 7 | expect(R("hello").to_a().valueOf()).toNotEqual ["hello"] 8 | expect(R("hello").to_a().valueOf()).toEqual ["hello"] 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/to_s_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String#to_s", -> 2 | it "returns self when self.class == String", -> 3 | a = R "a string" 4 | expect( a.to_s() is a).toEqual true 5 | 6 | xit "returns a new instance of String when called on a subclass", -> 7 | # a = StringSpecs::MyString.new("a string") 8 | # s = a.send(@method) 9 | # s.should == "a string" 10 | # s.should be_kind_of(String) 11 | 12 | xit "taints the result when self is tainted", -> 13 | # "x".taint.send(@method).tainted?.should == true 14 | # StringSpecs::MyString.new("x").taint.send(@method).tainted?.should == true 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/to_str_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String#<<", -> 2 | it "is alias to concat", -> 3 | a = R('str') 4 | expect( a.to_str ).toEqual a.to_s -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/comment_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding: ascii-8bit -*- 2 | require File.expand_path('../../../../spec_helper', __FILE__) 3 | require File.expand_path('../../fixtures/classes', __FILE__) 4 | 5 | describe "String#unpack" do 6 | it "ignores directives text from '#' to the first newline" do 7 | "\x01\x02\x03".unpack("c#this is a comment\nc").should == [1, 2] 8 | end 9 | 10 | it "ignores directives text from '#' to the end if no newline is present" do 11 | "\x01\x02\x03".unpack("c#this is a comment c").should == [1] 12 | end 13 | 14 | it "ignores comments at the start of the directives string" do 15 | "\x01\x02\x03".unpack("#this is a comment\nc").should == [1] 16 | end 17 | 18 | it "ignores the entire directive string if it is a comment" do 19 | "\x01\x02\x03".unpack("#this is a comment c").should == [] 20 | end 21 | 22 | it "ignores multiple comments" do 23 | "\x01\x02\x03".unpack("c#comment\nc#comment\nc#c").should == [1, 2, 3] 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/d_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | require File.expand_path('../../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/basic', __FILE__) 4 | require File.expand_path('../shared/float', __FILE__) 5 | 6 | little_endian do 7 | describe "String#unpack with format 'D'" do 8 | it_behaves_like :string_unpack_basic, 'D' 9 | it_behaves_like :string_unpack_double_le, 'D' 10 | end 11 | 12 | describe "String#unpack with format 'd'" do 13 | it_behaves_like :string_unpack_basic, 'd' 14 | it_behaves_like :string_unpack_double_le, 'd' 15 | end 16 | end 17 | 18 | big_endian do 19 | describe "String#unpack with format 'D'" do 20 | it_behaves_like :string_unpack_basic, 'D' 21 | it_behaves_like :string_unpack_double_be, 'D' 22 | end 23 | 24 | describe "String#unpack with format 'd'" do 25 | it_behaves_like :string_unpack_basic, 'd' 26 | it_behaves_like :string_unpack_double_be, 'd' 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/e_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | require File.expand_path('../../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/basic', __FILE__) 4 | require File.expand_path('../shared/float', __FILE__) 5 | 6 | describe "String#unpack with format 'E'" do 7 | it_behaves_like :string_unpack_basic, 'E' 8 | it_behaves_like :string_unpack_double_le, 'E' 9 | end 10 | 11 | describe "String#unpack with format 'e'" do 12 | it_behaves_like :string_unpack_basic, 'e' 13 | it_behaves_like :string_unpack_float_le, 'e' 14 | end 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/f_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | require File.expand_path('../../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/basic', __FILE__) 4 | require File.expand_path('../shared/float', __FILE__) 5 | 6 | little_endian do 7 | describe "String#unpack with format 'F'" do 8 | it_behaves_like :string_unpack_basic, 'F' 9 | it_behaves_like :string_unpack_float_le, 'F' 10 | end 11 | 12 | describe "String#unpack with format 'f'" do 13 | it_behaves_like :string_unpack_basic, 'f' 14 | it_behaves_like :string_unpack_float_le, 'f' 15 | end 16 | end 17 | 18 | big_endian do 19 | describe "String#unpack with format 'F'" do 20 | it_behaves_like :string_unpack_basic, 'F' 21 | it_behaves_like :string_unpack_float_be, 'F' 22 | end 23 | 24 | describe "String#unpack with format 'f'" do 25 | it_behaves_like :string_unpack_basic, 'f' 26 | it_behaves_like :string_unpack_float_be, 'f' 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/g_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | require File.expand_path('../../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/basic', __FILE__) 4 | require File.expand_path('../shared/float', __FILE__) 5 | 6 | describe "String#unpack with format 'G'" do 7 | it_behaves_like :string_unpack_basic, 'G' 8 | it_behaves_like :string_unpack_double_be, 'G' 9 | end 10 | 11 | describe "String#unpack with format 'g'" do 12 | it_behaves_like :string_unpack_basic, 'g' 13 | it_behaves_like :string_unpack_float_be, 'g' 14 | end 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/n_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | require File.expand_path('../../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/basic', __FILE__) 4 | require File.expand_path('../shared/integer', __FILE__) 5 | 6 | describe "String#unpack with format 'N'" do 7 | it_behaves_like :string_unpack_basic, 'N' 8 | it_behaves_like :string_unpack_32bit_be, 'N' 9 | it_behaves_like :string_unpack_32bit_be_unsigned, 'N' 10 | it_behaves_like :string_unpack_no_platform, 'N' 11 | end 12 | 13 | describe "String#unpack with format 'n'" do 14 | it_behaves_like :string_unpack_basic, 'n' 15 | it_behaves_like :string_unpack_16bit_be, 'n' 16 | it_behaves_like :string_unpack_16bit_be_unsigned, 'n' 17 | it_behaves_like :string_unpack_no_platform, 'n' 18 | end 19 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/p_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | require File.expand_path('../../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/basic', __FILE__) 4 | 5 | describe "String#unpack with format 'P'" do 6 | it_behaves_like :string_unpack_basic, 'P' 7 | 8 | it "returns a random object after consuming a size-of a machine word bytes" do 9 | str = "\0" * 1.size 10 | str.unpack("P").should be_kind_of(Object) 11 | end 12 | end 13 | 14 | describe "String#unpack with format 'p'" do 15 | it_behaves_like :string_unpack_basic, 'p' 16 | 17 | it "returns a random object after consuming a size-of a machine word bytes" do 18 | str = "\0" * 1.size 19 | str.unpack("p").should be_kind_of(Object) 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/percent_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | 3 | describe "String#unpack with format '%'" do 4 | it "raises an Argument Error" do 5 | lambda { "abc".unpack("%") }.should raise_error(ArgumentError) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/v_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../../spec_helper', __FILE__) 2 | require File.expand_path('../../fixtures/classes', __FILE__) 3 | require File.expand_path('../shared/basic', __FILE__) 4 | require File.expand_path('../shared/integer', __FILE__) 5 | 6 | describe "String#unpack with format 'V'" do 7 | it_behaves_like :string_unpack_basic, 'V' 8 | it_behaves_like :string_unpack_32bit_le, 'V' 9 | it_behaves_like :string_unpack_32bit_le_unsigned, 'V' 10 | it_behaves_like :string_unpack_no_platform, 'V' 11 | end 12 | 13 | describe "String#unpack with format 'v'" do 14 | it_behaves_like :string_unpack_basic, 'v' 15 | it_behaves_like :string_unpack_16bit_le, 'v' 16 | it_behaves_like :string_unpack_16bit_le_unsigned, 'v' 17 | it_behaves_like :string_unpack_no_platform, 'v' 18 | end 19 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/w_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding: ascii-8bit -*- 2 | require File.expand_path('../../../../spec_helper', __FILE__) 3 | require File.expand_path('../../fixtures/classes', __FILE__) 4 | require File.expand_path('../shared/basic', __FILE__) 5 | 6 | describe "String#unpack with directive 'w'" do 7 | it_behaves_like :string_unpack_basic, 'w' 8 | it_behaves_like :string_unpack_no_platform, 'w' 9 | 10 | it "decodes a BER-compressed integer" do 11 | [ ["\x00", [0]], 12 | ["\x01", [1]], 13 | ["\xce\x0f", [9999]], 14 | ["\x84\x80\x80\x80\x80\x80\x80\x80\x80\x00", [2**65]] 15 | ].should be_computed_by(:unpack, "w") 16 | end 17 | 18 | it "ignores NULL bytes between directives" do 19 | "\x01\x02\x03".unpack("w\x00w").should == [1, 2] 20 | end 21 | 22 | it "ignores spaces between directives" do 23 | "\x01\x02\x03".unpack("w w").should == [1, 2] 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unpack/z_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding: ascii-8bit -*- 2 | require File.expand_path('../../../../spec_helper', __FILE__) 3 | require File.expand_path('../../fixtures/classes', __FILE__) 4 | require File.expand_path('../shared/basic', __FILE__) 5 | require File.expand_path('../shared/string', __FILE__) 6 | 7 | describe "String#unpack with format 'Z'" do 8 | it_behaves_like :string_unpack_basic, 'Z' 9 | it_behaves_like :string_unpack_no_platform, 'Z' 10 | it_behaves_like :string_unpack_string, 'Z' 11 | 12 | it "stops decoding at NULL bytes when passed the '*' modifier" do 13 | "a\x00\x00 b \x00c".unpack('Z*Z*Z*Z*').should == ["a", "", " b ", "c"] 14 | end 15 | 16 | it "decodes the number of bytes specified by the count modifier and truncates the decoded string at the first NULL byte" do 17 | [ ["a\x00 \x00b c", ["a", " "]], 18 | ["\x00a\x00 bc \x00", ["", "c"]] 19 | ].should be_computed_by(:unpack, "Z5Z") 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unsupported/allocate_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "String.allocate" do 4 | it "returns an instance of String" do 5 | str = String.allocate 6 | str.should be_kind_of(String) 7 | end 8 | 9 | it "returns a fully-formed String" do 10 | str = String.allocate 11 | str.size.should == 0 12 | str << "more" 13 | str.should == "more" 14 | end 15 | 16 | ruby_version_is "1.9" do 17 | it "returns a binary String" do 18 | String.new.encoding.should == Encoding::BINARY 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unsupported/codepoints_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../shared/codepoints', __FILE__) 3 | 4 | with_feature :encoding do 5 | describe "String#codepoints" do 6 | it_behaves_like(:string_codepoints, :codepoints) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unsupported/each_codepoint_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../shared/codepoints', __FILE__) 3 | 4 | with_feature :encoding do 5 | describe "String#each_codepoint" do 6 | it_behaves_like(:string_codepoints, :each_codepoint) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unsupported/entries_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../shared/to_a', __FILE__) 3 | 4 | ruby_version_is ""..."1.9" do 5 | describe "String#entries" do 6 | it_behaves_like :string_to_a, :entries 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unsupported/hash_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes.rb', __FILE__) 3 | 4 | describe "String#hash" do 5 | it "returns a hash based on a string's length and content" do 6 | "abc".hash.should == "abc".hash 7 | "abc".hash.should_not == "cba".hash 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unsupported/intern_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes.rb', __FILE__) 3 | require File.expand_path('../shared/to_sym.rb', __FILE__) 4 | 5 | describe "String#intern" do 6 | it_behaves_like(:string_to_sym, :intern) 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unsupported/ord_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | with_feature :encoding do 4 | describe "String#ord" do 5 | it "returns a Fixnum" do 6 | 'a'.ord.should be_an_instance_of(Fixnum) 7 | end 8 | 9 | it "returns the codepoint of the first character in the String" do 10 | 'a'.ord.should == 97 11 | end 12 | 13 | 14 | it "ignores subsequent characters" do 15 | "\u{287}a".ord.should == "\u{287}".ord 16 | end 17 | 18 | ruby_version_is "1.9" do 19 | it "understands multibyte characters" do 20 | "\u{9879}".ord.should == 39033 21 | end 22 | 23 | it "is equivalent to #codepoints.first" do 24 | "\u{981}\u{982}".ord.should == "\u{981}\u{982}".codepoints.first 25 | end 26 | end 27 | 28 | it "raises an ArgumentError if called on an empty String" do 29 | lambda { ''.ord }.should raise_error(ArgumentError) 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unsupported/sum_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes.rb', __FILE__) 3 | 4 | describe "String#sum" do 5 | it "returns a basic n-bit checksum of the characters in self" do 6 | "ruby".sum.should == 450 7 | "ruby".sum(8).should == 194 8 | "rubinius".sum(23).should == 881 9 | end 10 | 11 | it "tries to convert n to an integer using to_int" do 12 | obj = mock('8') 13 | obj.should_receive(:to_int).and_return(8) 14 | 15 | "hello".sum(obj).should == "hello".sum(8) 16 | end 17 | 18 | it "returns sum of the bytes in self if n less or equal to zero" do 19 | "xyz".sum(0).should == 363 20 | "xyz".sum(-10).should == 363 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/lib/corelib/string/unsupported/to_sym_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/classes.rb', __FILE__) 3 | require File.expand_path('../shared/to_sym.rb', __FILE__) 4 | 5 | describe "String#to_sym" do 6 | it_behaves_like(:string_to_sym, :to_sym) 7 | end 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/asctime_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#asctime", -> 2 | # it_behaves_like(:time_asctime, :asctime) 3 | it "returns a canonical string representation of time", -> 4 | t = R.Time.now() 5 | expect( t.asctime() ).toEqual t.strftime("%a %b %e %H:%M:%S %Y") 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/ctime_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#ctime", -> 2 | # it_behaves_like(:time_asctime, :ctime) 3 | 4 | it "returns a canonical string representation of time", -> 5 | t = R.Time.now() 6 | expect( t.ctime() ).toEqual t.strftime("%a %b %e %H:%M:%S %Y") 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/day_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#day", -> 2 | # it_behaves_like(:time_day, :day) 3 | 4 | it "returns the day of the month (1..n) for a local Time", -> 5 | with_timezone "CET", 1, -> 6 | expect( R.Time.local(1970, 1, 1).day() ).toEqual R(1) 7 | 8 | it "returns the day of the month for a UTC Time", -> 9 | expect( R.Time.utc(1970, 1, 1).day() ).toEqual R(1) 10 | 11 | describe "1.9", -> 12 | it "returns the day of the month for a Time with a fixed offset", -> 13 | expect( R.Time.new(2012, 1, 1, 0, 0, 0, -3600).day() ).toEqual R(1) 14 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/dst_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/methods', __FILE__) 3 | require File.expand_path('../shared/isdst', __FILE__) 4 | 5 | describe "Time#dst?", -> 6 | it_behaves_like(:time_isdst, :dst?) 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/dup_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#dup", -> 2 | it "returns a Time object that represents the same time", -> 3 | t = R.Time.at(100) 4 | expect( t.dup().tv_sec() ).toEqual t.tv_sec() 5 | 6 | xit "copies the gmt state flag", -> 7 | expect( R.Time.now().gmtime().dup().gmt() ).toEqual true 8 | 9 | xit "returns an independent Time object", -> 10 | t = R.Time.now() 11 | t2 = t.dup() 12 | t.gmtime() 13 | expect( t2.gmt() ).toEqual false 14 | 15 | xit "returns a subclass instance", -> 16 | # c = Class.new(Time) 17 | # t = c.now 18 | 19 | # t.should be_kind_of(c) 20 | # t.dup.should be_kind_of(c) 21 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/fixtures/classes.coffee: -------------------------------------------------------------------------------- 1 | # module TimeSpecs 2 | 3 | # class SubTime < Time; 4 | 5 | root = global ? window 6 | 7 | root.with_timezone = (txt, offset = 0, block) -> 8 | fn = R.Time._local_timezone 9 | R.Time._local_timezone = -> 10 | (offset * -3600) 11 | 12 | block() 13 | 14 | R.Time._local_timezone = fn 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/fixtures/methods.rb: -------------------------------------------------------------------------------- 1 | def with_timezone(name, offset = nil, daylight_saving_zone = "") 2 | zone = name.dup 3 | 4 | if offset 5 | # TZ convention is backwards 6 | offset = -offset 7 | 8 | zone << offset.to_s 9 | zone << ":00:00" 10 | zone << daylight_saving_zone 11 | 12 | old = ENV["TZ"] 13 | ENV["TZ"] = zone 14 | 15 | begin 16 | yield 17 | ensure 18 | ENV["TZ"] = old 19 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/friday_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "1.9", -> 2 | describe "Time#friday?", -> 3 | it "returns true if time represents Friday", -> 4 | expect( R.Time.local(2000, 1, 7).friday() ).toEqual true 5 | 6 | it "returns false if time doesn't represent Friday", -> 7 | expect( R.Time.local(2000, 1, 1).friday() ).toEqual false 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/getgm_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#getgm", -> 2 | it "returns a new time which is the utc representation of time", -> 3 | # Testing with America/Regina here because it doesn't have DST. 4 | t = R.Time.new(2007, 1, 9, 6, 0, 0, -6 * 3600) 5 | expect( t.getgm().equals(R.Time.gm(2007, 1, 9, 12, 0, 0)) ).toEqual true 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/getutc_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#getutc", -> 2 | it "returns a new time which is the utc representation of time", -> 3 | # Testing with America/Regina here because it doesn't have DST. 4 | t = R.Time.new(2007, 1, 9, 6, 0, 0, -6 * 3600) 5 | expect( t.getutc().equals(R.Time.gm(2007, 1, 9, 12, 0, 0)) ).toEqual true 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/gm_spec.coffee: -------------------------------------------------------------------------------- 1 | 2 | describe "Time.gm", -> 3 | # it_behaves_like(:time_gm, :gm) 4 | # it_behaves_like(:time_params, :gm) 5 | # it_behaves_like(:time_params_10_arg, :gm) 6 | # it_behaves_like(:time_params_microseconds, :gm) 7 | 8 | describe "1.9", -> 9 | it "creates a time based on given values, interpreted as UTC (GMT)", -> 10 | expect( R.Time.gm(2000,1,1,20,15,1).inspect() ).toEqual R("2000-01-01 20:15:01 UTC") 11 | 12 | # TODO: not supported 13 | xit "creates a time based on given C-style gmtime arguments, interpreted as UTC (GMT)", -> 14 | time = R.Time.gm(1, 15, 20, 1, 1, 2000, 'ignored', 'ignored', 'ignored', 'ignored') 15 | expect( time.inspect() ).toEqual R("2000-01-01 20:15:01 UTC") 16 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/gmt_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#gmt?", -> 2 | it "returns true if time represents a time in UTC (GMT)", -> 3 | R.Time.__local_timezone__ = 3600 4 | expect( R.Time.now().gmt() ).toEqual false 5 | expect( R.Time.now().gmtime().gmt() ).toEqual true 6 | R.Time.__reset_local_timezone__() -------------------------------------------------------------------------------- /spec/lib/corelib/time/gmtime_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#gmtime", -> 2 | # it_behaves_like(:time_gmtime, :gmtime) 3 | 4 | it "returns the utc representation of time", -> 5 | # Testing with America/Regina here because it doesn't have DST. 6 | t = R.Time.new(2007, 1, 9, 6, 0, 0, -6 * 3600) 7 | t.gmtime() 8 | expect( t.to_i() ).toEqual R.Time.gm(2007, 1, 9, 12, 0, 0).to_i() 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/initialize_copy_spec.coffee: -------------------------------------------------------------------------------- 1 | # require File.expand_path('../../../spec_helper', __FILE__) 2 | # require File.expand_path('../fixtures/methods', __FILE__) 3 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/isdst_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/methods', __FILE__) 3 | require File.expand_path('../shared/isdst', __FILE__) 4 | 5 | describe "Time#isdst", -> 6 | it_behaves_like(:time_isdst, :isdst) 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/mday_spec.coffee: -------------------------------------------------------------------------------- 1 | 2 | describe "Time#mday", -> 3 | # it_behaves_like(:time_day, :mday) 4 | 5 | it "returns the day of the month (1..n) for a local Time", -> 6 | with_timezone "CET", 1, -> 7 | expect( R.Time.local(1970, 1, 1).mday() ).toEqual R(1) 8 | 9 | it "returns the day of the month for a UTC Time", -> 10 | expect( R.Time.utc(1970, 1, 1).mday() ).toEqual R(1) 11 | 12 | describe "1.9", -> 13 | it "returns the day of the month for a Time with a fixed offset", -> 14 | expect( R.Time.new(2012, 1, 1, 0, 0, 0, -3600).mday() ).toEqual R(1) 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/min_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#min", -> 2 | it "returns the minute of the hour (0..59) for a local Time", -> 3 | with_timezone "CET", 1, -> 4 | expect( R.Time.local(1970, 1, 1, 0, 0).min() ).toEqual R(0) 5 | 6 | it "returns the minute of the hour for a UTC Time", -> 7 | expect( R.Time.utc(1970, 1, 1, 0, 0).min() ).toEqual R(0) 8 | 9 | describe "1.9", -> 10 | it "returns the minute of the hour for a Time with a fixed offset", -> 11 | expect( R.Time.new(2012, 1, 1, 0, 0, 0, -3600).min() ).toEqual R(0) 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/mktime_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/methods', __FILE__) 3 | require File.expand_path('../shared/local', __FILE__) 4 | require File.expand_path('../shared/time_params', __FILE__) 5 | 6 | describe "Time.mktime", -> 7 | it_behaves_like(:time_local, :mktime) 8 | it_behaves_like(:time_local_10_arg, :mktime) 9 | it_behaves_like(:time_params, :mktime) 10 | it_behaves_like(:time_params_10_arg, :mktime) 11 | it_behaves_like(:time_params_microseconds, :mktime) 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/mon_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#mon", -> 2 | # it_behaves_like(:time_month, :mon) 3 | it "returns the month of the year for a local Time", -> 4 | expect( R.Time.local(1970, 1).mon() ).toEqual R(1) 5 | with_timezone "CET", 1, -> 6 | expect( R.Time.local(1970, 1).mon() ).toEqual R(1) 7 | 8 | it "returns the month of the year for a UTC Time", -> 9 | expect( R.Time.utc(1970, 1).mon() ).toEqual R(1) 10 | 11 | describe "1.9", -> 12 | it "returns the four digit year for a Time with a fixed offset", -> 13 | expect( R.Time.new(2012, 1, 1, 0, 0, 0, -3600).mon() ).toEqual R(1) 14 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/monday_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "1.9", -> 2 | describe "Time#monday?", -> 3 | it "returns true if time represents Monday", -> 4 | expect( R.Time.local(2000, 1, 3).monday() ).toEqual true 5 | 6 | it "returns false if time doesn't represent Monday", -> 7 | expect( R.Time.local(2000, 1, 1).monday() ).toEqual false 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/month_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#month", -> 2 | # it_behaves_like(:time_month, :month) 3 | it "returns the month of the year for a local Time", -> 4 | with_timezone "CET", 1, -> 5 | expect( R.Time.local(1970, 1).month() ).toEqual R(1) 6 | 7 | it "returns the month of the year for a UTC Time", -> 8 | expect( R.Time.utc(1970, 1).month() ).toEqual R(1) 9 | 10 | describe "1.9", -> 11 | it "returns the four digit year for a Time with a fixed offset", -> 12 | expect( R.Time.new(2012, 1, 1, 0, 0, 0, -3600).month() ).toEqual R(1) 13 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/now_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "R.Time.now", -> 2 | it "returns a date close to now", -> 3 | d = new Date() 4 | expect( R.Time.now() - d < 1000 ).toEqual true -------------------------------------------------------------------------------- /spec/lib/corelib/time/round_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "1.9", -> 4 | describe "Time#round", -> 5 | before do 6 | @time = R.Time.utc(2010, 3, 30, 5, 43, "25.123456789".to_r) 7 | @subclass = Class.new(Time).now 8 | 9 | it "defaults to rounding to 0 places", -> 10 | @time.round.should == R.Time.utc(2010, 3, 30, 5, 43, 25.to_r) 11 | 12 | it "rounds to 0 decimal places with an explicit argument", -> 13 | @time.round(0).should == R.Time.utc(2010, 3, 30, 5, 43, 25.to_r) 14 | 15 | it "rounds to 7 decimal places with an explicit argument", -> 16 | @time.round(7).should == R.Time.utc(2010, 3, 30, 5, 43, "25.1234568".to_r) 17 | 18 | it "returns an instance of Time, even if #round is called on a subclass", -> 19 | @subclass.round.should be_kind_of Time 20 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/saturday_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "1.9", -> 2 | describe "Time#saturday?", -> 3 | it "returns true if time represents Saturday", -> 4 | expect( R.Time.local(2000, 1, 1).saturday() ).toEqual true 5 | 6 | it "returns false if time doesn't represent Saturday", -> 7 | expect( R.Time.local(2000, 1, 2).saturday() ).toEqual false 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/sec_spec.coffee: -------------------------------------------------------------------------------- 1 | 2 | describe "Time#sec", -> 3 | it "returns the second of the minute(0..60) for time", -> 4 | expect( R.Time.at(0).sec() ).toEqual R(0) 5 | expect( R.Time.new(2012,12,1,12,30,45).sec() ).toEqual R(45) 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/shared/asctime.rb: -------------------------------------------------------------------------------- 1 | describe :time_asctime, :shared => true do 2 | it "returns a canonical string representation of time", -> 3 | t = R.Time.now 4 | t.send(@method).should == t.strftime("%a %b %e %H:%M:%S %Y") 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/shared/day.rb: -------------------------------------------------------------------------------- 1 | describe :time_day, :shared => true do 2 | it "returns the day of the month (1..n) for a local Time", -> 3 | with_timezone("CET", 1) do 4 | R.Time.local(1970, 1, 1).send(@method).should == 1 5 | 6 | it "returns the day of the month for a UTC Time", -> 7 | R.Time.utc(1970, 1, 1).send(@method).should == 1 8 | 9 | describe "1.9", -> 10 | it "returns the day of the month for a Time with a fixed offset", -> 11 | R.Time.new(2012, 1, 1, 0, 0, 0, -3600).send(@method).should == 1 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/shared/getgm.rb: -------------------------------------------------------------------------------- 1 | describe :time_getgm, :shared => true do 2 | it "returns a new time which is the utc representation of time", -> 3 | # Testing with America/Regina here because it doesn't have DST. 4 | with_timezone("CST", -6) do 5 | t = R.Time.local(2007, 1, 9, 6, 0, 0) 6 | t.send(@method).should == Time.gm(2007, 1, 9, 12, 0, 0) 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/shared/gm.rb: -------------------------------------------------------------------------------- 1 | describe :time_gm, :shared => true do 2 | describe ""..."1.9", -> 3 | it "creates a time based on given values, interpreted as UTC (GMT)", -> 4 | Time.send(@method, 2000,"jan",1,20,15,1).inspect.should == "Sat Jan 01 20:15:01 UTC 2000" 5 | 6 | it "creates a time based on given C-style gmtime arguments, interpreted as UTC (GMT)", -> 7 | time = Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored) 8 | time.inspect.should == "Sat Jan 01 20:15:01 UTC 2000" 9 | 10 | describe "1.9", -> 11 | it "creates a time based on given values, interpreted as UTC (GMT)", -> 12 | Time.send(@method, 2000,"jan",1,20,15,1).inspect.should == "2000-01-01 20:15:01 UTC" 13 | 14 | it "creates a time based on given C-style gmtime arguments, interpreted as UTC (GMT)", -> 15 | time = Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored) 16 | time.inspect.should == "2000-01-01 20:15:01 UTC" 17 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/shared/gmtime.rb: -------------------------------------------------------------------------------- 1 | describe :time_gmtime, :shared => true do 2 | it "returns the utc representation of time", -> 3 | # Testing with America/Regina here because it doesn't have DST. 4 | with_timezone("CST", -6) do 5 | t = R.Time.local(2007, 1, 9, 6, 0, 0) 6 | t.send(@method) 7 | t.should == Time.gm(2007, 1, 9, 12, 0, 0) 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/shared/isdst.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../fixtures/methods', __FILE__) 2 | 3 | describe :time_isdst, :shared => true do 4 | it "dst? returns whether time is during daylight saving time", -> 5 | with_timezone("America/Los_Angeles") do 6 | R.Time.local(2007, 9, 9, 0, 0, 0).send(@method).should == true 7 | R.Time.local(2007, 1, 9, 0, 0, 0).send(@method).should == false 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/shared/local.rb: -------------------------------------------------------------------------------- 1 | describe :time_local, :shared => true do 2 | it "creates a time based on given values, interpreted in the local time zone", -> 3 | with_timezone("PST", -8) do 4 | Time.send(@method, 2000, "jan", 1, 20, 15, 1).to_a.should == 5 | [1, 15, 20, 1, 1, 2000, 6, 1, false, "PST"] 6 | 7 | it "respects rare old timezones", -> 8 | with_timezone("Europe/Amsterdam") do 9 | Time.send(@method, 1910, 1, 1).to_a.should == 10 | [0, 0, 0, 1, 1, 1910, 6, 1, false, "AMT"] 11 | 12 | describe :time_local_10_arg, :shared => true do 13 | it "creates a time based on given C-style gmtime arguments, interpreted in the local time zone", -> 14 | with_timezone("PST", -8) do 15 | Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored).to_a.should == 16 | [1, 15, 20, 1, 1, 2000, 6, 1, false, "PST"] 17 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/shared/month.rb: -------------------------------------------------------------------------------- 1 | describe :time_month, :shared => true do 2 | it "returns the month of the year for a local Time", -> 3 | with_timezone("CET", 1) do 4 | R.Time.local(1970, 1).send(@method).should == 1 5 | 6 | it "returns the month of the year for a UTC Time", -> 7 | R.Time.utc(1970, 1).send(@method).should == 1 8 | 9 | describe "1.9", -> 10 | it "returns the four digit year for a Time with a fixed offset", -> 11 | R.Time.new(2012, 1, 1, 0, 0, 0, -3600).send(@method).should == 1 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/shared/now.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../fixtures/classes', __FILE__) 2 | 3 | describe :time_now, :shared => true do 4 | platform_is_not :windows do 5 | it "creates a time based on the current system time", -> 6 | unless `which date` == "" 7 | Time.__send__(@method).to_i.should be_close(`date +%s`.to_i, 2) 8 | 9 | it "creates a subclass instance if called on a subclass", -> 10 | TimeSpecs::SubR.Time.now.should be_kind_of(TimeSpecs::SubTime) 11 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/shared/to_i.rb: -------------------------------------------------------------------------------- 1 | describe :time_to_i, :shared => true do 2 | it "returns the value of time as an integer number of seconds since epoch", -> 3 | R.Time.at(0).send(@method).should == 0 4 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/succ_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#succ", -> 2 | it "returns a new time one second later than time", -> 3 | expect( R.Time.at(100).succ().eql(R.Time.at(101)) ).toEqual true 4 | 5 | it "returns a new instance", -> 6 | t1 = R.Time.at(100) 7 | t2 = t1.succ() 8 | expect( t1 ).toNotEqual t2 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/sunday_spec.coffee: -------------------------------------------------------------------------------- 1 | 2 | describe "1.9", -> 3 | describe "Time#sunday?", -> 4 | it "returns true if time represents Sunday", -> 5 | expect( R.Time.local(2000, 1, 2).sunday() ).toEqual true 6 | 7 | it "returns false if time doesn't represent Sunday", -> 8 | expect( R.Time.local(2000, 1, 1).sunday() ).toEqual false 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/thursday_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "1.9", -> 2 | describe "Time#thursday?", -> 3 | it "returns true if time represents Thursday", -> 4 | expect( R.Time.local(2000, 1, 6).thursday() ).toEqual true 5 | 6 | it "returns false if time doesn't represent Thursday", -> 7 | expect( R.Time.local(2000, 1, 1).thursday() ).toEqual false 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/times_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../../../shared/process/times', __FILE__) 3 | 4 | describe "Time.times", -> 5 | describe "" ... "1.9", -> 6 | it_behaves_like :process_times, :times, Time 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/to_a_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/methods', __FILE__) 3 | 4 | describe "Time#to_a", -> 5 | it "returns a 10 element array representing the deconstructed time", -> 6 | # Testing with America/Regina here because it doesn't have DST. 7 | with_timezone("America/Regina") do 8 | R.Time.at(0).to_a.should == [0, 0, 18, 31, 12, 1969, 3, 365, false, "CST"] 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/to_f_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#to_f", -> 2 | it "returns the float number of seconds + usecs since the epoch", -> 3 | expect( R.Time.at(100, 1000).to_f() ).toEqual R(100.001) 4 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/to_i_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#to_i", -> 2 | it "returns the value of time as an integer number of seconds since epoch", -> 3 | expect( R.Time.at(0).to_i() ).toEqual R(0) 4 | with_timezone "UTC", 0, -> 5 | expect( R.Time.at(9999999).to_i() ).toEqual R(9999999) -------------------------------------------------------------------------------- /spec/lib/corelib/time/to_r_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "Time#to_r", -> 4 | describe "1.9", -> 5 | it "returns the a Rational representing seconds and subseconds since the epoch", -> 6 | R.Time.at(Rational(11, 10)).to_r.should eql(Rational(11, 10)) 7 | 8 | it "returns a Rational even for a whole number of seconds", -> 9 | R.Time.at(2).to_r.should eql(Rational(2)) 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/tuesday_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "1.9", -> 2 | describe "Time#tuesday?", -> 3 | it "returns true if time represents Tuesday", -> 4 | expect( R.Time.local(2000, 1, 4).tuesday() ).toEqual true 5 | 6 | it "returns false if time doesn't represent Tuesday", -> 7 | expect( R.Time.local(2000, 1, 1).tuesday() ).toEqual false 8 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/tv_sec_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#tv_sec", -> 2 | # it_behaves_like(:time_to_i, :tv_sec) 3 | it "returns the value of time as an integer number of seconds since epoch", -> 4 | expect( R.Time.at(0).tv_sec() ).toEqual R(0) 5 | with_timezone "UTC", 0, -> 6 | expect( R.Time.at(9999999).tv_sec() ).toEqual R(9999999) -------------------------------------------------------------------------------- /spec/lib/corelib/time/unsupported/hash_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/methods', __FILE__) 3 | 4 | describe "Time#hash", -> 5 | it "returns a Fixnum", -> 6 | R.Time.at(100).hash.should be_kind_of(R.Fixnum) 7 | 8 | it "is stable", -> 9 | R.Time.at(1234).hash.should == R.Time.at(1234).hash 10 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/unsupported/tv_nsec_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe "1.9", -> 4 | describe "Time#tv_nsec", -> 5 | it "needs to be reviewed for spec completeness" 6 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/utc_offset_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/methods', __FILE__) 3 | require File.expand_path('../shared/gmt_offset', __FILE__) 4 | 5 | describe "Time#utc_offset", -> 6 | it_behaves_like(:time_gmt_offset, :utc_offset) 7 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/utc_spec.rb: -------------------------------------------------------------------------------- 1 | describe "Time#utc?", -> 2 | it "returns true if time represents a time in UTC (GMT)", -> 3 | expect( R.Time.now().is_utc() ).toEqual false 4 | 5 | describe "Time.utc", -> 6 | it_behaves_like(:time_gm, :utc) 7 | it_behaves_like(:time_params, :utc) 8 | it_behaves_like(:time_params_10_arg, :utc) 9 | it_behaves_like(:time_params_microseconds, :utc) 10 | 11 | describe "Time#utc", -> 12 | it_behaves_like(:time_gmtime, :utc) 13 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/wday_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#wday", -> 2 | xit "returns an integer representing the day of the week, 0..6, with Sunday being 0", -> 3 | # with_timezone("GMT", 0) do 4 | # R.Time.at(0).wday.should == 4 5 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/wednesday_spec.coffee: -------------------------------------------------------------------------------- 1 | 2 | describe "1.9", -> 3 | describe "Time#wednesday?", -> 4 | it "returns true if time represents Wednesday", -> 5 | expect( R.Time.local(2000, 1, 5).wednesday() ).toEqual true 6 | 7 | it "returns false if time doesn't represent Wednesday", -> 8 | expect( R.Time.local(2000, 1, 1).wednesday() ).toEqual false 9 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/yday_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#yday", -> 2 | 3 | it "returns an integer representing the day of the year, 1..366", -> 4 | R.Time.__local_timezone__ = 3600 5 | expect( R.Time.at(9999999).yday() ).toEqual R(117) 6 | R.Time.__reset_local_timezone__() 7 | # with_timezone "UTC", 0, -> 8 | # expect( R.Time.at(9999999).yday() ).toEqual R(116) 9 | # expect( R.Time.at(9999999).utc_offset() ).toEqual R(0) 10 | expect( R.Time.new(2012,1,1,0,0,0,'-08:00').yday() ).toEqual R(1) 11 | expect( R.Time.new(2012,1,1,0,0,0,'+08:00').yday() ).toEqual R(1) 12 | expect( R.Time.new(2012,1,1,0,0,0).yday() ).toEqual R(1) 13 | expect( R.Time.new(2012,1,1).yday() ).toEqual R(1) 14 | expect( R.Time.new(2012,12,31).yday() ).toEqual R(366) 15 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/year_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Time#year", -> 2 | it "returns the four digit year for a local Time as an Integer", -> 3 | with_timezone "CET", 1, -> 4 | expect( R.Time.local(1970).year() ).toEqual R(1970) 5 | 6 | it "returns the four digit year for a UTC Time as an Integer", -> 7 | expect( R.Time.utc(1970).year() ).toEqual R(1970) 8 | 9 | describe "1.9", -> 10 | it "returns the four digit year for a Time with a fixed offset", -> 11 | expect( R.Time.new(2012, 1, 1, 0, 0, 0, -3600).year() ).toEqual R(2012) 12 | -------------------------------------------------------------------------------- /spec/lib/corelib/time/zone_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | require File.expand_path('../fixtures/methods', __FILE__) 3 | 4 | describe "Time#zone", -> 5 | it "returns the time zone used for time", -> 6 | # Testing with Asia/Kuwait here because it doesn't have DST. 7 | with_timezone("Asia/Kuwait") do 8 | R.Time.now.zone.should == "AST" 9 | 10 | describe "1.9", -> 11 | it "returns nil for a Time with a fixed offset", -> 12 | R.Time.new(2001, 1, 1, 0, 0, 0, "+05:00").zone.should == nil 13 | -------------------------------------------------------------------------------- /spec/lib/helpers/SpecHelper.coffee: -------------------------------------------------------------------------------- 1 | beforeEach -> 2 | @addMatchers({ 3 | toBeInstanceOf: (klass) -> 4 | @actual instanceof klass; 5 | }) 6 | @addMatchers({ 7 | toBeTrue: (klass) -> 8 | @actual is true; 9 | }) 10 | @addMatchers({ 11 | toBeFalse: (klass) -> 12 | @actual is false; 13 | }) 14 | -------------------------------------------------------------------------------- /spec/lib/playground/README.md: -------------------------------------------------------------------------------- 1 | spec/lib/playground contains various unstructured specs. They should eventually be refactored into proper unit tests. -------------------------------------------------------------------------------- /spec/lib/playground/examples_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Examples", -> 2 | it "_r methods return R Objects to chain things together", -> 3 | arr = R(['foo', 'bar', 'baz']) 4 | new_arr = arr.each_with_index().map((w,i) -> "#{i}: #{w}" ) 5 | expect( new_arr.valueOf() ).toEqual ['0: foo', '1: bar', '2: baz'] 6 | 7 | line1 = R("hello world") 8 | line2 = R("-").multiply(line1.size()) 9 | str = [line1, line2].join("\n") 10 | 11 | expect( str ).toEqual "hello world\n-----------" 12 | 13 | -------------------------------------------------------------------------------- /spec/lib/rubyjs/README.md: -------------------------------------------------------------------------------- 1 | spec/lib/rubyjs contains RubyJS specific specs and additional specs not in rubyspec. -------------------------------------------------------------------------------- /spec/lib/rubyjs/numeric_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "Numeric.isNumeric", -> 2 | it "should be true for 1, Number, and R(1)", -> 3 | expect( R.Numeric.isNumeric( 1 ) ).toEqual true 4 | expect( R.Numeric.isNumeric( new Number(1) ) ).toEqual true 5 | expect( R.Numeric.isNumeric( R(1) ) ).toEqual true 6 | 7 | it "should be false for everything else", -> 8 | for val in [false, true, null, [], "1", new String("1"), {}, undefined] 9 | expect( R.Numeric.isNumeric( val ) ).toEqual false -------------------------------------------------------------------------------- /spec/lib/rubyjs/object_spec.coffee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hasclass/core-lib/5fc22406621699f158f78fef94a979ba68c52318/spec/lib/rubyjs/object_spec.coffee -------------------------------------------------------------------------------- /spec/lib/rubyjs/string_spec.coffee: -------------------------------------------------------------------------------- 1 | describe "String.isString", -> 2 | it "should be true for 1, Number, and R(1)", -> 3 | for val in ["foo", new String("1")] 4 | expect( R.String.isString( val ) ).toEqual true 5 | 6 | it "should be false for everything else", -> 7 | for val in [false, true, null, [], 1, new Number(1), {}, undefined] 8 | expect( R.String.isString( val ) ).toEqual false -------------------------------------------------------------------------------- /spec/lib/rubyjs/time_spec.coffee: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hasclass/core-lib/5fc22406621699f158f78fef94a979ba68c52318/spec/lib/rubyjs/time_spec.coffee -------------------------------------------------------------------------------- /spec/lib/spec_helper.coffee: -------------------------------------------------------------------------------- 1 | require('../../ruby') 2 | require('./helpers/SpecHelper') 3 | require('./corelib/string/fixtures/classes') 4 | require('./corelib/numeric/fixtures/classes') 5 | require('./corelib/enumerable/fixtures/classes') 6 | require('./corelib/time/fixtures/classes') 7 | -------------------------------------------------------------------------------- /spec/lib/support/support.yml: -------------------------------------------------------------------------------- 1 | src_dir: spec/lib 2 | 3 | src_files: 4 | # not needed. defined in spechelper.coffee 5 | # - ruby.coffee 6 | # - corelib/string/fixtures/classes.coffee 7 | # - corelib/numeric/fixtures/classes.coffee 8 | # - corelib/enumerable/fixtures/classes.coffee 9 | # - corelib/time/fixtures/classes.coffee 10 | 11 | spec_dir: spec/lib 12 | 13 | spec_files: 14 | - '**/*_spec.coffee' --------------------------------------------------------------------------------