summaryrefslogtreecommitdiffstats
path: root/include/ruby/encoding.h
Commit message (Collapse)AuthorAgeFilesLines
* * debug.c, parse.y: fixed types.nobu2009-09-141-0/+1
| | | | | | | * node.h (nd_line): limit to int. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * encoding.c (rb_enc_fast_mbclen): faster mbclen for strings knownmatz2009-05-201-0/+3
| | | | | | | | | | | | | | | to be valid. * string.c (enc_strlen): coderange specified version of rb_enc_strlen(). use rb_enc_fast_mbclen() if coderange is 7bit or valid. * string.c (str_gsub): use rb_enc_fast_mbclen(). * string.c (rb_str_reverse, rb_str_split_m, rb_str_each_char, scan_once): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * encoding.c (rb_enc_codepoint_len): combine rb_enc_codepoint()matz2009-05-191-1/+7
| | | | | | | | | | | | | | | | | | | and rb_enc_codelen() in one function to reduce calls. * encoding.c (rb_enc_codepoint): compatibility function. * sprintf.c (rb_str_format): use rb_enc_codepoint_len(). * string.c (rb_str_inspect, rb_str_upcase_bang, rb_str_downcase_bang, rb_str_capitalize_bang, rb_str_swapcase_bang, trnext, tr_trans, rb_str_delete_bang, rb_str_squeeze_bang, rb_str_count, rb_str_split_m, rb_str_each_line, rb_str_each_codepoint, rb_str_lstrip_bang, sym_printable): ditto. * transcode.c (make_econv_exception): use rb_enc_mbc_to_codepoint() git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c, include/ruby/encoding.h: fixed types.nobu2009-05-071-2/+2
| | | | | | | * include/ruby/encoding.h (rb_enc_nth): long is used for index. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h ({RSTRING,RBIGNUM}_EMBED_LEN_MAX): made int.nobu2009-03-151-4/+4
| | | | | | | | | * include/ruby/ruby.h (OBJ_{TAINTED,UNTRUSTED,FROZEN}): return int. * include/ruby/encoding.h (ENC_CODERANGE): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c, bignum.c, dln.c, error.c, gc.c, io.c, marshal.c,nobu2009-03-121-1/+1
| | | | | | | | | | numeric.c, pack.c, strftime.c, string.c, thread.c, transcode.c, transcode_data.h, util.c, variable.c, vm_dump.c, include/ruby/encoding.h, missing/crypt.c, missing/vsnprintf.c: suppress VC type warnings. [ruby-core:22726] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h: suppress warnings of overflow.akr2009-03-121-2/+2
| | | | git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (enc_initialized_p): ENC_UNINITIALIZEDnobu2009-03-051-3/+0
| | | | | | | | | | is not defined already. * include/ruby/encoding.h (ENC_FROM_ENCINDEX): removed because depending on a static variable. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (fptr_finalize): close the IO object even if finish_writeconv orakr2008-12-261-0/+3
| | | | | | | | | | | | | | | flush is failed. (finish_writeconv): don't raise. return errno or exception. (finish_writeconv_arg): removed. (finish_writeconv_sync): follow finish_writeconv change. * transcode.c (rb_econv_make_exception): new function. * include/ruby/encoding.h (rb_econv_make_exception): declared. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/zlib/zlib.c: remove obsolete prototype macros.matz2008-10-211-0/+1
| | | | | | | | | | | | | | | | | | | | * ext/zlib/zlib.c (struct gzfile): add encoding field to gzfile structure. * ext/zlib/zlib.c (rb_gzreader_getc): now works on characters. * ext/zlib/zlib.c (rb_gzreader_getbyte): new method to retrieve single byte. * ext/zlib/zlib.c (rb_gzreader_readbyte): ditto. * ext/zlib/zlib.c (rb_gzreader_each_byte): renamed from each_char * ext/zlib/zlib.c (rb_gzreader_ungetc): allow unget strings. * ext/zlib/zlib.c (rb_gzreader_ungetbyte): renamed from ungetc. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (ExportStringValue): new macro to convertmatz2008-10-201-1/+2
| | | | | | | | | | | | | string in internal encoding to external to export. * string.c (rb_str_export): new function to do conversion to external encoding. * ext/sdbm/init.c: encoding conversion support. * ext/dbm/dbm.c: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_external_str_new): a new function to convert frommatz2008-10-181-0/+2
| | | | | | | | | | | | | | external encoding to internal encoding. if something went wrong, it returns a string with the external encoding. * string.c (rb_external_str_new_with_enc): same as above besides you can specify the source encoding. * ruby.c (ruby_set_argv): use rb_external_str_new() * ruby.c (set_arg0, ruby_script): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * encoding.c (rb_default_internal_encoding): merged a patch frommatz2008-10-071-0/+3
| | | | | | | | | | | Michael Selig <michael.selig at fs.com.au> in [ruby-core:18985]. * io.c (rb_io_ext_int_to_encs): ditto. * ruby.c (proc_options): support default internal encoding in -E option. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_str_encode): renamed fromakr2008-09-261-2/+2
| | | | | | | | | | | | | rb_str_transcode. [ruby-dev:36593] (rb_econv_has_convpath_p): renamed from rb_transcode_convertible. * transcode.c: follow the renaming. * io.c: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * transcode.c, include/ruby/encoding.c (rb_transcode_convertible):usa2008-09-261-0/+1
| | | | | | | | new function. checking the existance of converter. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (enum): ISO C forbids comma at end ofshyouhei2008-09-221-1/+1
| | | | | | | enumerator list git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * grapheme cluster implementation reverted. [ruby-dev:36375]akr2008-09-181-4/+3
| | | | git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_casecmp): don't use rb_enc_codepoint.akr2008-09-171-3/+3
| | | | git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/oniguruma.h (OnigEncodingTypeST): add precise_retakr2008-09-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | argument for mbc_to_code. (ONIGENC_MBC_TO_CODE): provide NULL for precise_ret. (ONIGENC_MBC_PRECISE_CODEPOINT): defined. * include/ruby/encoding.h (rb_enc_mbc_precise_codepoint): defined. * regenc.h (onigenc_single_byte_mbc_to_code): precise_ret argument added. (onigenc_mbn_mbc_to_code): ditto. * regenc.c (onigenc_single_byte_mbc_to_code): precise_ret argument added. (onigenc_mbn_mbc_to_code): ditto. * string.c (count_utf8_lead_bytes_with_word): removed. (str_utf8_nth): removed. (str_utf8_offset): removed. (str_strlen): UTF-8 codepoint oriented optimization removed. (rb_str_substr): ditto. (enc_succ_char): use rb_enc_mbc_precise_codepoint. (enc_pred_char): ditto. (rb_str_succ): ditto. * encoding.c (rb_enc_ascget): check length with rb_enc_mbc_precise_codepoint. (rb_enc_codepoint): use rb_enc_mbc_precise_codepoint. * regexec.c (string_cmp_ic): add text_end argument. (match_at): check end of character after exact string matches. * enc/utf_8.c (graphme_table): defined for extended graphme cluster boundary. (grapheme_cmp): defined. (get_grapheme_properties): defined. (grapheme_boundary_p): defined. (MAX_BYTES_LENGTH): defined. (comb_char_enc_len): defined. (mbc_to_code0): extracted from mbc_to_code. (mbc_to_code): use mbc_to_code0. (left_adjust_combchar_head): defined. (utf_8): use a extended graphme cluster as a unit. * enc/unicode.c (onigenc_unicode_mbc_case_fold): use ONIGENC_MBC_PRECISE_CODEPOINT to extract codepoints. (onigenc_unicode_get_case_fold_codes_by_str): ditto. * enc/euc_jp.c (mbc_to_code): follow mbc_to_code field change. use onigenc_mbn_mbc_to_code. * enc/shift_jis.c (mbc_to_code): ditto. * enc/emacs_mule.c (mbc_to_code): ditto. * enc/gbk.c (gbk_mbc_to_code): follow mbc_to_code field and onigenc_mbn_mbc_to_code change. * enc/cp949.c (cp949_mbc_to_code): ditto. * enc/big5.c (big5_mbc_to_code): ditto. * enc/euc_tw.c (euctw_mbc_to_code): ditto. * enc/euc_kr.c (euckr_mbc_to_code): ditto. * enc/gb18030.c (gb18030_mbc_to_code): ditto. * enc/utf_32be.c (utf32be_mbc_to_code): follow mbc_to_code field change. * enc/utf_16be.c (utf16be_mbc_to_code): ditto. * enc/utf_32le.c (utf32le_mbc_to_code): ditto. * enc/utf_16le.c (utf16le_mbc_to_code): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/oniguruma.h (OnigEncodingTypeST): add end argument forakr2008-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | left_adjust_char_head. (ONIGENC_LEFT_ADJUST_CHAR_HEAD): add end argument. (onigenc_get_left_adjust_char_head): ditto. * include/ruby/encoding.h (rb_enc_left_char_head): add end argument. * regenc.h (onigenc_single_byte_left_adjust_char_head): ditto. * regenc.c (onigenc_get_right_adjust_char_head): follow the interface change. (onigenc_get_right_adjust_char_head_with_prev): ditto. (onigenc_get_prev_char_head): ditto. (onigenc_step_back): ditto. (onigenc_get_left_adjust_char_head): ditto. (onigenc_single_byte_code_to_mbc): ditto. * re.c: ditto. * string.c: ditto. * io.c: ditto. * regexec.c: ditto. * enc/euc_jp.c: ditto. * enc/cp949.c: ditto. * enc/shift_jis.c: ditto. * enc/gbk.c: ditto. * enc/big5.c: ditto. * enc/euc_tw.c: ditto. * enc/euc_kr.c: ditto. * enc/emacs_mule.c: ditto. * enc/gb18030.c: ditto. * enc/utf_8.c: ditto. * enc/utf_16le.c: ditto. * enc/utf_16be.c: ditto. * enc/utf_32le.c: ditto. * enc/utf_32be.c: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/oniguruma.h (onigenc_get_prev_char_head): add endakr2008-09-131-3/+3
| | | | | | | | | | | | | | | | | | | | argument. * include/ruby/encoding.h (rb_enc_prev_char): ditto. * regenc.c (onigenc_get_prev_char_head): add end argument. * regparse.c: follow the interface change. * regexec.c: ditto. * string.c: ditto. * parse.y: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/oniguruma.h (onigenc_get_right_adjust_char_head): addakr2008-09-131-1/+1
| | | | | | | | | | | | | | | | | | | end argument. * include/ruby/encoding.h (rb_enc_right_char_head): add end argument. * regenc.c (onigenc_get_right_adjust_char_head): use end argument. * re.c (rb_reg_adjust_startpos): follow the interface change. * string.c (rb_str_index): ditto. * regexec.c (backward_search_range): ditto. (onig_search): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* comment modified.akr2008-09-121-2/+2
| | | | git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/oniguruma.h (OnigCodePoint): unsigned long to unsigned int.naruse2008-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/ruby/encoding.h (rb_enc_codepoint): ditto. * encoding.c (rb_enc_codepoint): signed int to unsigned int. * encoding.c (rb_enc_ascget): ditto. * string.c (rb_str_casecmp): ditto. * string.c (enc_succ_alnum_char): ditto. * string.c (rb_str_inspect): ditto. * string.c (rb_str_upcase_bang): ditto. * string.c (rb_str_downcase_bang): ditto. * string.c (rb_str_capitalize_bang): ditto. * string.c (rb_str_swapcase_bang): ditto. * string.c (struct tr): ditto. * string.c (trnext): ditto. * string.c (tr_trans): ditto. * string.c (tr_setup_table): ditto. * string.c (tr_find): ditto. * string.c (rb_str_delete_bang): ditto. * string.c (rb_str_squeeze_bang): ditto. * string.c (rb_str_count): ditto. * string.c (rb_str_split_m): ditto. * string.c (rb_str_each_line): ditto. * string.c (rb_str_lstrip_bang): ditto. * string.c (rb_str_rstrip_bang): ditto. * string.c (rb_str_intern): ditto. * dir.c (char_casecmp): ditto. * sprintf.c (rb_str_format): ditto. * enc/emacs_mule.c (mbc_to_code): to be 32bit clean. * enc/emacs_mule.c (code_to_mbc): ditto. * enc/gb18030.c (mbc_to_code): ditto. * enc/gb18030.c (code_to_mbc): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (econv_after_output): renamed fromakr2008-09-091-2/+2
| | | | | | | | | | | | | econv_output_followed_by_input. (ECONV_AFTER_OUTPUT): renamed from ECONV_OUTPUT_FOLLOWED_BY_INPUT. * transcode.c: follow the renaming. * io.c: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (ECONV_DECORATOR_MASK): mergeakr2008-09-091-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | ECONV_ENCODER_MASK and ECONV_DECORATOR_MASK. (ECONV_UNIVERSAL_NEWLINE_DECORATOR): renamed from ECONV_UNIVERSAL_NEWLINE_DECODER. (ECONV_CRLF_NEWLINE_DECORATOR): renamed from ECONV_CRLF_NEWLINE_ENCODER. (ECONV_CR_NEWLINE_DECORATOR): renamed from ECONV_CR_NEWLINE_ENCODER. (ECONV_XML_TEXT_DECORATOR): renamed from ECONV_XML_TEXT_ENCODER. (ECONV_XML_ATTR_CONTENT_DECORATOR): renamed from ECONV_XML_ATTR_CONTENT_ENCODER. (ECONV_STATEFUL_DECORATOR_MASK): renamed from ECONV_STATEFUL_ENCODER_MASK. (ECONV_XML_ATTR_QUOTE_DECORATOR): renamed from ECONV_XML_ATTR_CONTENT_DECORATOR. * io.c: follow the renaming. * transcode.c: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix typos.akr2008-09-091-1/+1
| | | | git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_decorate_at_first): declared.akr2008-09-081-0/+4
| | | | | | | | | | | | | | | | | | | | (rb_econv_decorate_at_last): declared. * transcode.c (rb_econv_open_by_transcoder_entries): initialize replacement_enc. allocate outbuf for the last transcoder. (rb_econv_open0): extracted from rb_econv_open. (rb_econv_open): use rb_econv_open0 and decorate the result using rb_econv_decorate_at_first and rb_econv_decorate_at_last. (rb_econv_decorate_at): new function. (rb_econv_decorate_at_first): ditto. (rb_econv_decorate_at_last): ditto. (rb_econv_binmode): fix iteration end condition. (econv_init): don't set source_encoding_name and destination_encoding_name because they are set in rb_econv_open0. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_asciicompat_encoding): renamedakr2008-09-081-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from rb_econv_stateless_encoding to apply stateless ASCII incompatible encodings such as UTF-16BE. * io.c (make_writeconv): use rb_econv_asciicompat_encoding. * transcode_data.h (rb_transcoder_asciicompat_type_t): renamed from rb_transcoder_stateful_type_t. (rb_transcoder): use rb_transcoder_asciicompat_type_t. * transcode.c: follow the type change. (asciicompat_encoding_i): renamed from stateless_encoding_i. (rb_econv_asciicompat_encoding): renamed from rb_econv_stateless_encoding. (econv_s_asciicompat_encoding): method renamed. * tool/transcode-tblgen.rb: follow the type change. * enc/trans/utf_16_32.trans: follow the type change. rb_from_UTF_16BE to UTF-8 is asciicompat_decoder. rb_from_UTF_16LE to UTF-8 is asciicompat_decoder. rb_from_UTF_32BE to UTF-8 is asciicompat_decoder. rb_from_UTF_32LE to UTF-8 is asciicompat_decoder. UTF-8 to rb_to_UTF_16BE is asciicompat_encoder. UTF-8 to rb_to_UTF_16LE is asciicompat_encoder. UTF-8 to rb_to_UTF_32BE is asciicompat_encoder. UTF-8 to rb_to_UTF_32LE is asciicompat_encoder. * enc/trans/newline.trans: follow the type change. universal newline decoder is asciicompat_converter. * enc/trans/escape.trans: follow the type change. * enc/trans/iso2022.trans: ditto. * enc/trans/japanese.trans: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_set_replacement): renamed fromakr2008-09-071-1/+1
| | | | | | | | | | rb_econv_set_replacemenet. * transcode.c: follow the renaming. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (ECONV_XML_ATTR_CONTENT_ENCODER): defined.akr2008-09-071-1/+4
| | | | | | | | | | | | | | | | | | | | (ECONV_STATEFUL_ENCODER_MASK): defined. (ECONV_XML_ATTR_QUOTE_ENCODER): defined. (ECONV_XML_ATTR_ENCODER): removed. * enc/trans/escape.trans (rb_escape_xml_attr_content): defined. (rb_escape_xml_attr_quote): defined. (rb_escape_xml_attr): removed. * io.c (NEED_WRITECONV): writeconv is required if supplemental converter is used. (make_writeconv): apply stateful encoder in writeconv. * transcode.c: follow the constant change. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (ECONV_ERROR_HANDLER_MASK): defined.akr2008-09-061-12/+17
| | | | | | | | | | | | (ECONV_DECODER_MASK): defined. (ECONV_ENCODER_MASK): defined. * io.c (make_writeconv): restrict ecflags for writeconv with ECONV_ERROR_HANDLER_MASK. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (ECONV_XML_TEXT_ENCODER): renamed fromakr2008-09-061-2/+2
| | | | | | | | | | | | | ECONV_HTML_TEXT_ENCODER. (ECONV_XML_ATTR_ENCODER): renamed from ECONV_HTML_ATTR_ENCODER. * enc/trans/escape.trans: follow the renaming. * transcode.c: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (ECONV_HTML_TEXT_ENCODER): new constant.akr2008-09-061-0/+2
| | | | | | | | | | | | | (ECONV_HTML_ATTR_ENCODER): ditto. * transcode.c (rb_econv_open): check ECONV_HTML_TEXT_ENCODER and ECONV_HTML_ATTR_ENCODER. (Init_transcode): Encoding::Converter::HTML_TEXT_ENCODER and Encoding::Converter::HTML_ATTR_ENCODER defined. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* comment updated.akr2008-09-051-2/+2
| | | | git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (ECONV_UNDEF_HEX_CHARREF): defined.akr2008-09-051-0/+1
| | | | | | | | | | | * transcode.c (output_hex_charref): new function. (rb_econv_convert): call output_hex_charref if ECONV_UNDEF_HEX_CHARREF. (Init_transcode): Encoding::Converter::UNDEF_HEX_CHARREF added. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (ECONV_INVALID_IGNORE): removed becauseakr2008-09-041-2/+0
| | | | | | | | | | | | | | | it tend to cause security problem. If the behaviour is really required, ECONV_INVALID_REPLACE with empty string can be used. For example, CVE-2006-2313, CVE-2008-1036, [ruby-core:15645] (ECONV_UNDEF_IGNORE): ditto. * transcode.c (rb_econv_convert): follow the above change. (econv_opts): ditto. (Init_transcode): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/io.h (rb_io_t): new fields: encs.ecopts andakr2008-09-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | writeconv_pre_ecopts. (MakeOpenFile): initialize them. * include/ruby/encoding.h (rb_str_transcode): take ecopts argument. (rb_econv_flags): removed. (rb_econv_prepare_opts): declared. (rb_econv_open_opts): declared. * io.c (make_writeconv): use rb_econv_open_opts. (make_readconv): ditto. (io_fwrite): follow rb_str_transcode change. (rb_io_extract_modeenc): use rb_econv_prepare_opts. (rb_file_open_generic): initialize encs.ecopts. (rb_file_open_internal): ditto. (rb_io_reopen): ditto. (argf_ecopts): defined. (argf_next_argv): set encs.ecopts. (io_encoding_set): use rb_econv_prepare_opts. (argf_set_encoding): set argf_ecopts. * gc.c (gc_mark_children): mark encs.ecopts and writeconv_pre_ecopts in T_FILE. * transcode.c (transcode_loop): take ecopts argument. use rb_econv_open_opts. (rb_econv_flags): removed. (rb_econv_prepare_opts): defined. (rb_econv_open_opts): defined. (str_transcode0): take ecopts. (str_transcode): use rb_econv_prepare_opts. (rb_str_transcode): take ecopts. (econv_init): accept hash argument. (econv_insert_output): follow rb_str_transcode change. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_set_replacemenet): declared.akr2008-09-031-0/+3
| | | | | | | | | | | | | | | | | * transcode.c (rb_econv_t): new fields: replacement_str, replacement_len, replacement_enc and replacement_allocated. (get_replacement_character): make len as size_t. (rb_econv_open_by_transcoder_entries): initialize the new fields. (rb_econv_close): deallocate replacement_str if it allocated. (make_replacement): new function. (output_replacement_character): use make_replacement. (rb_econv_set_replacemenet): defined. (econv_get_replacement): new method. (econv_set_replacement): new method. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_option_t): removed. Sinceakr2008-09-031-9/+4
| | | | | | | | | | | | | | | rb_econv_option_t has only one field, int flags, rb_econv_option_t is replaced by int. * include/ruby/io.h: follow the above change. * io.c: ditto. * transcode.c: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_result_t): enumeration constant:akr2008-08-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | econv_incomplete_input. * io.c (finish_writeconv): check econv_incomplete_input. * transcode.c (transcode_restartable0): return econv_incomplete_input for unexpected end of source buffer. (trans_sweep): check econv_incomplete_input. (rb_trans_conv): ditto. (rb_econv_convert0): ditto. (rb_econv_convert): ditto. (transcode_loop): ditto. (make_econv_exception): change message for econv_incomplete_input. (econv_result_to_symbol): return :incomplete_input for econv_incomplete_input. (ecerr_incomplete_input): new method. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_elem_t): move to transcode.cakr2008-08-261-41/+1
| | | | | | | | | | | (rb_econv_t): defined as an incomplete type. * transcode.c (rb_econv_elem_t): moved from encoding.h. (rb_econv_t): complete type defined. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * transcode.c (rb_econv_open): disable newline conversion for ASCIIakr2008-08-261-0/+6
| | | | | | | | incompatible encodings. (str_transcode0): don't need disable newline conversion here. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_t): use rb_econv_option_t.akr2008-08-241-5/+5
| | | | | | | | * transcode.c: follow the rb_econv_t change. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_str_transcode): make 3rd argumentakr2008-08-241-2/+2
| | | | | | | | | | | | | | | | rb_econv_option_t*. * transcode.c (transcode_loop): take rb_econv_option_t* as a argument. (str_transcode0): ditto. (str_transcode): make rb_econv_option_t and call str_transcode0 with it. (rb_str_transcode): take rb_econv_option_t*. * io.c (io_fwrite): follow the rb_str_transcode change. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add comment.akr2008-08-241-0/+1
| | | | git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_opts): declared.akr2008-08-241-0/+2
| | | | | | | | | | * transcode.c (rb_econv_opts): defined. * io.c (rb_io_extract_modeenc): use rb_econv_opts. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_option_t): defined.akr2008-08-241-2/+6
| | | | | | | | | | | | | | | | (rb_econv_open): 3rd arg changed. (rb_econv_open_exc): ditto. * io.c (make_writeconv): use rb_econv_option_t. (make_readconv): ditto. (rb_econv_open): take rb_econv_option_t for options. (rb_econv_open_exc): ditto. (transcode_loop): use rb_econv_option_t. (econv_init): use rb_econv_option_t. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_str_transcode): add ecflags argument.akr2008-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | * transcode.c (econv_opts): extracted from str_transcode. (str_transcode_enc_args): extracted from str_transcode. (str_transcode0): extracted from str_transcode. (str_transcode): use econv_opts, str_transcode_enc_args, str_transcode0. (rb_str_transcode): call str_transcode0. (econv_primitive_insert_output): give the additional argument for rb_str_transcode. * io.c (make_writeconv): use invalid/undef flags. (io_fwrite): ditto. (rb_scan_open_args): give the additional argument for rb_str_transcode. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_substr_append): renamed fromakr2008-08-241-1/+4
| | | | | | | | | | | | | | | | | | | rb_econv_string. (rb_econv_str_convert): declared. (rb_econv_substr_convert): declared. (rb_econv_str_append): declared. * io.c (io_fwrite): use rb_econv_str_convert instead of rb_econv_string. * transcode.c (rb_econv_substr_append): renamed from rb_econv_string. (rb_econv_str_append): new function. (rb_econv_substr_convert): ditto. (rb_econv_str_convert): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
t">, 1073741827), Rational(1073741789, 1073741827)), Complex(1073741789, 0) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(-1073741789, 1073741827)), Complex(1073741789, 0) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921429444920521, 1073741827), Rational(1152921429444920521, 1073741827)), Complex(1073741789, 0) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1073741827, 2), Rational(-1073741827, 2)), Complex(1073741789, 0) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1073741827, 1073741789)), Complex(1073741789, 0) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921428371178694, 1073741789), Rational(-1073741827, 1073741789)), Complex(1073741789, 0) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(1073741827, 1073741827), Complex(1073741789, 0) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921429444920521, 2147483654), Rational(-1152921429444920521, 2147483654)), Complex(1073741789, 0) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1073741827, 1073741789)), Complex(1073741789, 0) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(-1073741827, 1073741789)), Complex(1073741789, 0) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921429444920521, 1073741827), 1073741827), Complex(1073741789, 0) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1427247510601733037449111325195428279286542707, 2658455833113515253509575011810600482), Rational(-1427247611623052908177132720890654139107803443, 2658455833113515253509575011810600482)), Complex(1073741789, 0) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(1073741827, 0), +Complex(1073741827, 0)) assert_equal(Complex(-1073741827, 0), -Complex(1073741827, 0)) assert_equal(Complex(1073741828, 0), Complex(1073741827, 0) + Complex(1, 0)) assert_equal(Complex(1073741826, 0), Complex(1073741827, 0) - Complex(1, 0)) assert_equal(Complex(1073741827, 0), Complex(1073741827, 0) * Complex(1, 0)) assert_equal(Complex(1073741827, 0), Complex(1073741827, 0) / Complex(1, 0)) assert_equal(Complex(2147483616, 0), Complex(1073741827, 0) + Complex(1073741789, 0)) assert_equal(Complex(38, 0), Complex(1073741827, 0) - Complex(1073741789, 0)) assert_equal(Complex(1152921470247108503, 0), Complex(1073741827, 0) * Complex(1073741789, 0)) assert_equal(Complex(Rational(1073741827, 1073741789), 0), Complex(1073741827, 0) / Complex(1073741789, 0)) assert_equal(Complex(2147483654, 0), Complex(1073741827, 0) + Complex(1073741827, 0)) assert_equal(Complex(0, 0), Complex(1073741827, 0) - Complex(1073741827, 0)) assert_equal(Complex(1152921511049297929, 0), Complex(1073741827, 0) * Complex(1073741827, 0)) assert_equal(Complex(1, 0), Complex(1073741827, 0) / Complex(1073741827, 0)) assert_equal(Complex(2147483616, 1073741789), Complex(1073741827, 0) + Complex(1073741789, 1073741789)) assert_equal(Complex(38, -1073741789), Complex(1073741827, 0) - Complex(1073741789, 1073741789)) assert_equal(Complex(1152921470247108503, 1152921470247108503), Complex(1073741827, 0) * Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(1073741827, 2147483578), Rational(-1073741827, 2147483578)), Complex(1073741827, 0) / Complex(1073741789, 1073741789)) assert_equal(Complex(2147483616, 1073741827), Complex(1073741827, 0) + Complex(1073741789, 1073741827)) assert_equal(Complex(38, -1073741827), Complex(1073741827, 0) - Complex(1073741789, 1073741827)) assert_equal(Complex(1152921470247108503, 1152921511049297929), Complex(1073741827, 0) * Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(1152921470247108503, 2305842940494218450), Rational(-1152921511049297929, 2305842940494218450)), Complex(1073741827, 0) / Complex(1073741789, 1073741827)) assert_equal(Complex(2147483654, 1073741827), Complex(1073741827, 0) + Complex(1073741827, 1073741827)) assert_equal(Complex(0, -1073741827), Complex(1073741827, 0) - Complex(1073741827, 1073741827)) assert_equal(Complex(1152921511049297929, 1152921511049297929), Complex(1073741827, 0) * Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(1, 2), Rational(-1, 2)), Complex(1073741827, 0) / Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1073741789, 1073741827)), Complex(1073741827, 0) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921509975556140, 1073741827), Rational(-1073741789, 1073741827)), Complex(1073741827, 0) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(1073741789, 1073741789), Complex(1073741827, 0) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921511049297929, 2147483578), Rational(-1152921511049297929, 2147483578)), Complex(1073741827, 0) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921471320850330, 1073741789), Rational(1073741827, 1073741789)), Complex(1073741827, 0) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921469173366676, 1073741789), Rational(-1073741827, 1073741789)), Complex(1073741827, 0) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921511049297929, 1073741789), Rational(1152921511049297929, 1073741789)), Complex(1073741827, 0) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1073741789, 2), Rational(-1073741789, 2)), Complex(1073741827, 0) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1073741827, 1073741789)), Complex(1073741827, 0) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921509975556140, 1073741827), Rational(-1073741827, 1073741789)), Complex(1073741827, 0) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(1073741789, Rational(1152921511049297929, 1073741789)), Complex(1073741827, 0) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1427247561112392079020469430422559713421565101, 2658455833113515253509575011810600482), Rational(-1427247662133715524919164459706626955683034349, 2658455833113515253509575011810600482)), Complex(1073741827, 0) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(1073741789, 1073741789), +Complex(1073741789, 1073741789)) assert_equal(Complex(-1073741789, -1073741789), -Complex(1073741789, 1073741789)) assert_equal(Complex(1073741790, 1073741789), Complex(1073741789, 1073741789) + Complex(1, 0)) assert_equal(Complex(1073741788, 1073741789), Complex(1073741789, 1073741789) - Complex(1, 0)) assert_equal(Complex(1073741789, 1073741789), Complex(1073741789, 1073741789) * Complex(1, 0)) assert_equal(Complex(1073741789, 1073741789), Complex(1073741789, 1073741789) / Complex(1, 0)) assert_equal(Complex(2147483578, 1073741789), Complex(1073741789, 1073741789) + Complex(1073741789, 0)) assert_equal(Complex(0, 1073741789), Complex(1073741789, 1073741789) - Complex(1073741789, 0)) assert_equal(Complex(1152921429444920521, 1152921429444920521), Complex(1073741789, 1073741789) * Complex(1073741789, 0)) assert_equal(Complex(1, 1), Complex(1073741789, 1073741789) / Complex(1073741789, 0)) assert_equal(Complex(2147483616, 1073741789), Complex(1073741789, 1073741789) + Complex(1073741827, 0)) assert_equal(Complex(-38, 1073741789), Complex(1073741789, 1073741789) - Complex(1073741827, 0)) assert_equal(Complex(1152921470247108503, 1152921470247108503), Complex(1073741789, 1073741789) * Complex(1073741827, 0)) assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)), Complex(1073741789, 1073741789) / Complex(1073741827, 0)) assert_equal(Complex(2147483578, 2147483578), Complex(1073741789, 1073741789) + Complex(1073741789, 1073741789)) assert_equal(Complex(0, 0), Complex(1073741789, 1073741789) - Complex(1073741789, 1073741789)) assert_equal(Complex(0, 2305842858889841042), Complex(1073741789, 1073741789) * Complex(1073741789, 1073741789)) assert_equal(Complex(1, 0), Complex(1073741789, 1073741789) / Complex(1073741789, 1073741789)) assert_equal(Complex(2147483578, 2147483616), Complex(1073741789, 1073741789) + Complex(1073741789, 1073741827)) assert_equal(Complex(0, -38), Complex(1073741789, 1073741789) - Complex(1073741789, 1073741827)) assert_equal(Complex(-40802187982, 2305842899692029024), Complex(1073741789, 1073741789) * Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(1152921449846014512, 1152921470247109225), Rational(-20401093991, 1152921470247109225)), Complex(1073741789, 1073741789) / Complex(1073741789, 1073741827)) assert_equal(Complex(2147483616, 2147483616), Complex(1073741789, 1073741789) + Complex(1073741827, 1073741827)) assert_equal(Complex(-38, -38), Complex(1073741789, 1073741789) - Complex(1073741827, 1073741827)) assert_equal(Complex(0, 2305842940494217006), Complex(1073741789, 1073741789) * Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(1073741789, 1073741827), 0), Complex(1073741789, 1073741789) / Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921471320850292, 1073741827)), Complex(1073741789, 1073741789) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(1152921469173366714, 1073741827)), Complex(1073741789, 1073741789) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(0, Rational(2305842858889841042, 1073741827)), Complex(1073741789, 1073741789) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(1073741827, 0), Complex(1073741789, 1073741789) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1152921430518662348, 1073741789)), Complex(1073741789, 1073741789) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921428371178694, 1073741789), Rational(1152921428371178694, 1073741789)), Complex(1073741789, 1073741789) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(0, 2147483654), Complex(1073741789, 1073741789) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921429444920521, 1073741827), 0), Complex(1073741789, 1073741789) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921430518662348, 1073741789)), Complex(1073741789, 1073741789) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(1152921428371178694, 1073741789)), Complex(1073741789, 1073741789) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-81604377408, 1073741827), Rational(2305842940494218450, 1073741827)), Complex(1073741789, 1073741789) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1427247561112392972813122023043041209197173075, 1329227916556757626754787505905300241), Rational(-50510659935364010697847612929910630368, 1329227916556757626754787505905300241)), Complex(1073741789, 1073741789) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(1073741789, 1073741827), +Complex(1073741789, 1073741827)) assert_equal(Complex(-1073741789, -1073741827), -Complex(1073741789, 1073741827)) assert_equal(Complex(1073741790, 1073741827), Complex(1073741789, 1073741827) + Complex(1, 0)) assert_equal(Complex(1073741788, 1073741827), Complex(1073741789, 1073741827) - Complex(1, 0)) assert_equal(Complex(1073741789, 1073741827), Complex(1073741789, 1073741827) * Complex(1, 0)) assert_equal(Complex(1073741789, 1073741827), Complex(1073741789, 1073741827) / Complex(1, 0)) assert_equal(Complex(2147483578, 1073741827), Complex(1073741789, 1073741827) + Complex(1073741789, 0)) assert_equal(Complex(0, 1073741827), Complex(1073741789, 1073741827) - Complex(1073741789, 0)) assert_equal(Complex(1152921429444920521, 1152921470247108503), Complex(1073741789, 1073741827) * Complex(1073741789, 0)) assert_equal(Complex(1, Rational(1073741827, 1073741789)), Complex(1073741789, 1073741827) / Complex(1073741789, 0)) assert_equal(Complex(2147483616, 1073741827), Complex(1073741789, 1073741827) + Complex(1073741827, 0)) assert_equal(Complex(-38, 1073741827), Complex(1073741789, 1073741827) - Complex(1073741827, 0)) assert_equal(Complex(1152921470247108503, 1152921511049297929), Complex(1073741789, 1073741827) * Complex(1073741827, 0)) assert_equal(Complex(Rational(1073741789, 1073741827), 1), Complex(1073741789, 1073741827) / Complex(1073741827, 0)) assert_equal(Complex(2147483578, 2147483616), Complex(1073741789, 1073741827) + Complex(1073741789, 1073741789)) assert_equal(Complex(0, 38), Complex(1073741789, 1073741827) - Complex(1073741789, 1073741789)) assert_equal(Complex(-40802187982, 2305842899692029024), Complex(1073741789, 1073741827) * Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(1073741808, 1073741789), Rational(19, 1073741789)), Complex(1073741789, 1073741827) / Complex(1073741789, 1073741789)) assert_equal(Complex(2147483578, 2147483654), Complex(1073741789, 1073741827) + Complex(1073741789, 1073741827)) assert_equal(Complex(0, 0), Complex(1073741789, 1073741827) - Complex(1073741789, 1073741827)) assert_equal(Complex(-81604377408, 2305842940494217006), Complex(1073741789, 1073741827) * Complex(1073741789, 1073741827)) assert_equal(Complex(1, 0), Complex(1073741789, 1073741827) / Complex(1073741789, 1073741827)) assert_equal(Complex(2147483616, 2147483654), Complex(1073741789, 1073741827) + Complex(1073741827, 1073741827)) assert_equal(Complex(-38, 0), Complex(1073741789, 1073741827) - Complex(1073741827, 1073741827)) assert_equal(Complex(-40802189426, 2305842981296406432), Complex(1073741789, 1073741827) * Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(1073741808, 1073741827), Rational(19, 1073741827)), Complex(1073741789, 1073741827) / Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921512123039718, 1073741827)), Complex(1073741789, 1073741827) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(1152921509975556140, 1073741827)), Complex(1073741789, 1073741827) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(-40802187982, 1073741827), Rational(2305842899692029024, 1073741827)), Complex(1073741789, 1073741827) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921490648203216, 1073741789), Rational(20401094713, 1073741789)), Complex(1073741789, 1073741827) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1152921471320850330, 1073741789)), Complex(1073741789, 1073741827) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921428371178694, 1073741789), Rational(1152921469173366676, 1073741789)), Complex(1073741789, 1073741827) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-40802189426, 1073741789), Rational(2305842981296406432, 1073741789)), Complex(1073741789, 1073741827) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921449846014512, 1073741827), Rational(20401093991, 1073741827)), Complex(1073741789, 1073741827) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921471320850330, 1073741789)), Complex(1073741789, 1073741827) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(1152921469173366676, 1073741789)), Complex(1073741789, 1073741827) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-131433047608170424214, 1152921470247108503), 2147483616), Complex(1073741789, 1073741827) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1427247586367724281184137892451027617484788528, 1329227916556757626754787505905300241), Rational(-25255330414578331645234047212843119171, 1329227916556757626754787505905300241)), Complex(1073741789, 1073741827) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(1073741827, 1073741827), +Complex(1073741827, 1073741827)) assert_equal(Complex(-1073741827, -1073741827), -Complex(1073741827, 1073741827)) assert_equal(Complex(1073741828, 1073741827), Complex(1073741827, 1073741827) + Complex(1, 0)) assert_equal(Complex(1073741826, 1073741827), Complex(1073741827, 1073741827) - Complex(1, 0)) assert_equal(Complex(1073741827, 1073741827), Complex(1073741827, 1073741827) * Complex(1, 0)) assert_equal(Complex(1073741827, 1073741827), Complex(1073741827, 1073741827) / Complex(1, 0)) assert_equal(Complex(2147483616, 1073741827), Complex(1073741827, 1073741827) + Complex(1073741789, 0)) assert_equal(Complex(38, 1073741827), Complex(1073741827, 1073741827) - Complex(1073741789, 0)) assert_equal(Complex(1152921470247108503, 1152921470247108503), Complex(1073741827, 1073741827) * Complex(1073741789, 0)) assert_equal(Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)), Complex(1073741827, 1073741827) / Complex(1073741789, 0)) assert_equal(Complex(2147483654, 1073741827), Complex(1073741827, 1073741827) + Complex(1073741827, 0)) assert_equal(Complex(0, 1073741827), Complex(1073741827, 1073741827) - Complex(1073741827, 0)) assert_equal(Complex(1152921511049297929, 1152921511049297929), Complex(1073741827, 1073741827) * Complex(1073741827, 0)) assert_equal(Complex(1, 1), Complex(1073741827, 1073741827) / Complex(1073741827, 0)) assert_equal(Complex(2147483616, 2147483616), Complex(1073741827, 1073741827) + Complex(1073741789, 1073741789)) assert_equal(Complex(38, 38), Complex(1073741827, 1073741827) - Complex(1073741789, 1073741789)) assert_equal(Complex(0, 2305842940494217006), Complex(1073741827, 1073741827) * Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(1073741827, 1073741789), 0), Complex(1073741827, 1073741827) / Complex(1073741789, 1073741789)) assert_equal(Complex(2147483616, 2147483654), Complex(1073741827, 1073741827) + Complex(1073741789, 1073741827)) assert_equal(Complex(38, 0), Complex(1073741827, 1073741827) - Complex(1073741789, 1073741827)) assert_equal(Complex(-40802189426, 2305842981296406432), Complex(1073741827, 1073741827) * Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(1152921490648203216, 1152921470247109225), Rational(-20401094713, 1152921470247109225)), Complex(1073741827, 1073741827) / Complex(1073741789, 1073741827)) assert_equal(Complex(2147483654, 2147483654), Complex(1073741827, 1073741827) + Complex(1073741827, 1073741827)) assert_equal(Complex(0, 0), Complex(1073741827, 1073741827) - Complex(1073741827, 1073741827)) assert_equal(Complex(0, 2305843022098595858), Complex(1073741827, 1073741827) * Complex(1073741827, 1073741827)) assert_equal(Complex(1, 0), Complex(1073741827, 1073741827) / Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1152921512123039718, 1073741827)), Complex(1073741827, 1073741827) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921509975556140, 1073741827), Rational(1152921509975556140, 1073741827)), Complex(1073741827, 1073741827) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(0, 2147483578), Complex(1073741827, 1073741827) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921511049297929, 1073741789), 0), Complex(1073741827, 1073741827) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921471320850330, 1073741789), Rational(1152921471320850330, 1073741789)), Complex(1073741827, 1073741827) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921469173366676, 1073741789), Rational(1152921469173366676, 1073741789)), Complex(1073741827, 1073741827) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(0, Rational(2305843022098595858, 1073741789)), Complex(1073741827, 1073741827) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(1073741789, 0), Complex(1073741827, 1073741827) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1152921471320850330, 1073741789)), Complex(1073741827, 1073741827) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921509975556140, 1073741827), Rational(1152921469173366676, 1073741789)), Complex(1073741827, 1073741827) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-81604377408, 1073741789), Rational(2305842940494218450, 1073741789)), Complex(1073741827, 1073741827) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1427247611623053801969816945064593334552299725, 1329227916556757626754787505905300241), Rational(-50510661722949347514642033621130734624, 1329227916556757626754787505905300241)), Complex(1073741827, 1073741827) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)), +Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(-1073741789, 1073741827), Rational(-1073741789, 1073741827)), -Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(2147483616, 1073741827), Rational(1073741789, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1, 0)) assert_equal(Complex(Rational(-38, 1073741827), Rational(1073741789, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1, 0)) assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1, 0)) assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1, 0)) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1073741789, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1073741789, 0)) assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(1073741789, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1073741789, 0)) assert_equal(Complex(Rational(1152921429444920521, 1073741827), Rational(1152921429444920521, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1073741789, 0)) assert_equal(Complex(Rational(1, 1073741827), Rational(1, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1073741789, 0)) assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1073741789, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1073741827, 0)) assert_equal(Complex(Rational(-1152921509975556140, 1073741827), Rational(1073741789, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1073741827, 0)) assert_equal(Complex(1073741789, 1073741789), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1073741827, 0)) assert_equal(Complex(Rational(1073741789, 1152921511049297929), Rational(1073741789, 1152921511049297929)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1073741827, 0)) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921471320850292, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(-1152921469173366714, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1073741789, 1073741789)) assert_equal(Complex(0, Rational(2305842858889841042, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(1, 1073741827), 0), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921512123039718, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(-1152921509975556140, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(-40802187982, 1073741827), Rational(2305842899692029024, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(1152921449846014512, 1237940005850657200720054075), Rational(-20401093991, 1237940005850657200720054075)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1152921512123039718, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(-1152921509975556140, 1073741827), Rational(-1152921509975556140, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1073741827, 1073741827)) assert_equal(Complex(0, 2147483578), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(1073741789, 1152921511049297929), 0), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(2147483578, 1073741827), Rational(2147483578, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(0, 0), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(0, Rational(2305842858889841042, 1152921511049297929)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(1, 0), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(2305842940494218450, 1152921470247108503), Rational(2305842940494218450, 1152921470247108503)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-81604377408, 1152921470247108503), Rational(-81604377408, 1152921470247108503)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(0, 2), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921429444920521, 1152921511049297929), 0), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(2147483578, 1073741827), Rational(2305842940494218450, 1152921470247108503)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(0, Rational(-81604377408, 1152921470247108503)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-81604377408, 1152921511049297929), Rational(2305842940494218450, 1152921511049297929)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1329227869515036572020512360130906225, 1329227916556757626754787505905300241), Rational(-47041717725097069072123994784, 1329227916556757626754787505905300241)), Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)), +Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-1073741827, 1073741789), Rational(-1073741827, 1073741789)), -Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(2147483616, 1073741789), Rational(1073741827, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1, 0)) assert_equal(Complex(Rational(38, 1073741789), Rational(1073741827, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1, 0)) assert_equal(Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1, 0)) assert_equal(Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1, 0)) assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1073741827, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1073741789, 0)) assert_equal(Complex(Rational(-1152921428371178694, 1073741789), Rational(1073741827, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1073741789, 0)) assert_equal(Complex(1073741827, 1073741827), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1073741789, 0)) assert_equal(Complex(Rational(1073741827, 1152921429444920521), Rational(1073741827, 1152921429444920521)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1073741789, 0)) assert_equal(Complex(Rational(1152921471320850330, 1073741789), Rational(1073741827, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1073741827, 0)) assert_equal(Complex(Rational(-1152921469173366676, 1073741789), Rational(1073741827, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1073741827, 0)) assert_equal(Complex(Rational(1152921511049297929, 1073741789), Rational(1152921511049297929, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1073741827, 0)) assert_equal(Complex(Rational(1, 1073741789), Rational(1, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1073741827, 0)) assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1152921430518662348, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(-1152921428371178694, 1073741789), Rational(-1152921428371178694, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1073741789, 1073741789)) assert_equal(Complex(0, 2147483654), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(1073741827, 1152921429444920521), 0), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1152921471320850330, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(-1152921428371178694, 1073741789), Rational(-1152921469173366676, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(-40802189426, 1073741789), Rational(2305842981296406432, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(1152921490648203216, 1237939962039641331329903525), Rational(-20401094713, 1237939962039641331329903525)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(1152921471320850330, 1073741789), Rational(1152921471320850330, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(-1152921469173366676, 1073741789), Rational(-1152921469173366676, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1073741827, 1073741827)) assert_equal(Complex(0, Rational(2305843022098595858, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(1, 1073741789), 0), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(2305842940494218450, 1152921470247108503), Rational(2305842940494218450, 1152921470247108503)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(81604377408, 1152921470247108503), Rational(81604377408, 1152921470247108503)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(0, 2), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921511049297929, 1152921429444920521), 0), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(2147483654, 1073741789), Rational(2147483654, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(0, 0), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(0, Rational(2305843022098595858, 1152921429444920521)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(1, 0), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(2305842940494218450, 1152921470247108503), Rational(2147483654, 1073741789)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(81604377408, 1152921470247108503), 0), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-81604377408, 1152921429444920521), Rational(2305842940494218450, 1152921429444920521)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1329227963598475351851856578029295025, 1329227916556757626754787505905300241), Rational(-47041721054734275145774394016, 1329227916556757626754787505905300241)), Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)), +Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-1073741789, 1073741827), Rational(-1073741827, 1073741789)), -Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(2147483616, 1073741827), Rational(1073741827, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1, 0)) assert_equal(Complex(Rational(-38, 1073741827), Rational(1073741827, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1, 0)) assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1, 0)) assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1, 0)) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1073741827, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1073741789, 0)) assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(1073741827, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1073741789, 0)) assert_equal(Complex(Rational(1152921429444920521, 1073741827), 1073741827), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1073741789, 0)) assert_equal(Complex(Rational(1, 1073741827), Rational(1073741827, 1152921429444920521)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1073741789, 0)) assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1073741827, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1073741827, 0)) assert_equal(Complex(Rational(-1152921509975556140, 1073741827), Rational(1073741827, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1073741827, 0)) assert_equal(Complex(1073741789, Rational(1152921511049297929, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1073741827, 0)) assert_equal(Complex(Rational(1073741789, 1152921511049297929), Rational(1, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1073741827, 0)) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921430518662348, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(-1152921428371178694, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(-81604377408, 1073741827), Rational(2305842940494218450, 1073741827)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(1152921470247109225, 1237939962039640556088331867), Rational(40802188704, 1237939962039640556088331867)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1073741789, 1073741789)) assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921471320850330, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(-1152921469173366676, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(-131433047608170424214, 1152921470247108503), 2147483616), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(1237939983945150041266564176, 1329227916556755129526882950667240175), Rational(19, 1152921470247109225)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1073741789, 1073741827)) assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1152921471320850330, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(-1152921509975556140, 1073741827), Rational(-1152921469173366676, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(-81604377408, 1073741789), Rational(2305842940494218450, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(1152921470247109225, 1237940005850656425478454981), Rational(40802188704, 1237940005850656425478454981)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1073741827, 1073741827)) assert_equal(Complex(Rational(2147483578, 1073741827), Rational(2305842940494218450, 1152921470247108503)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(0, Rational(81604377408, 1152921470247108503)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(-81604377408, 1152921511049297929), Rational(2305842940494218450, 1152921511049297929)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(1152921470247109225, 1152921429444920521), Rational(40802188704, 1152921429444920521)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827))) assert_equal(Complex(Rational(2305842940494218450, 1152921470247108503), Rational(2147483654, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-81604377408, 1152921470247108503), 0), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-81604377408, 1152921429444920521), Rational(2305842940494218450, 1152921429444920521)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(1152921470247109225, 1152921511049297929), Rational(40802188704, 1152921511049297929)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(2147483578, 1073741827), Rational(2147483654, 1073741789)), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(0, 0), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(Rational(-188166877559662688435796777600, 1329227916556754297117581432254901009), 2), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) assert_equal(Complex(1, 0), Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789))) end def test_kumi2 assert_equal('0.0+0.0i', (+Complex(+0.0, +0.0)).to_s) assert_equal('-0.0-0.0i', (-Complex(+0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) + Complex(+0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) - Complex(+0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) * Complex(+0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) + Complex(-0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) - Complex(-0.0, +0.0)).to_s) assert_equal('-0.0+0.0i', (Complex(+0.0, +0.0) * Complex(-0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) + Complex(+0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) - Complex(+0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) * Complex(+0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) + Complex(-0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) - Complex(-0.0, -0.0)).to_s) assert_equal('0.0-0.0i', (Complex(+0.0, +0.0) * Complex(-0.0, -0.0)).to_s) assert_equal('-0.0+0.0i', (+Complex(-0.0, +0.0)).to_s) assert_equal('0.0-0.0i', (-Complex(-0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) + Complex(+0.0, +0.0)).to_s) assert_equal('-0.0+0.0i', (Complex(-0.0, +0.0) - Complex(+0.0, +0.0)).to_s) assert_equal('-0.0+0.0i', (Complex(-0.0, +0.0) * Complex(+0.0, +0.0)).to_s) assert_equal('-0.0+0.0i', (Complex(-0.0, +0.0) + Complex(-0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) - Complex(-0.0, +0.0)).to_s) assert_equal('0.0-0.0i', (Complex(-0.0, +0.0) * Complex(-0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) + Complex(+0.0, -0.0)).to_s) assert_equal('-0.0+0.0i', (Complex(-0.0, +0.0) - Complex(+0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) * Complex(+0.0, -0.0)).to_s) assert_equal('-0.0+0.0i', (Complex(-0.0, +0.0) + Complex(-0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) - Complex(-0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) * Complex(-0.0, -0.0)).to_s) assert_equal('0.0-0.0i', (+Complex(+0.0, -0.0)).to_s) assert_equal('-0.0+0.0i', (-Complex(+0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) + Complex(+0.0, +0.0)).to_s) assert_equal('0.0-0.0i', (Complex(+0.0, -0.0) - Complex(+0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) * Complex(+0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) + Complex(-0.0, +0.0)).to_s) assert_equal('0.0-0.0i', (Complex(+0.0, -0.0) - Complex(-0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) * Complex(-0.0, +0.0)).to_s) assert_equal('0.0-0.0i', (Complex(+0.0, -0.0) + Complex(+0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) - Complex(+0.0, -0.0)).to_s) assert_equal('0.0-0.0i', (Complex(+0.0, -0.0) * Complex(+0.0, -0.0)).to_s) assert_equal('0.0-0.0i', (Complex(+0.0, -0.0) + Complex(-0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) - Complex(-0.0, -0.0)).to_s) assert_equal('-0.0+0.0i', (Complex(+0.0, -0.0) * Complex(-0.0, -0.0)).to_s) assert_equal('-0.0-0.0i', (+Complex(-0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (-Complex(-0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(-0.0, -0.0) + Complex(+0.0, +0.0)).to_s) assert_equal('-0.0-0.0i', (Complex(-0.0, -0.0) - Complex(+0.0, +0.0)).to_s) assert_equal('0.0-0.0i', (Complex(-0.0, -0.0) * Complex(+0.0, +0.0)).to_s) assert_equal('-0.0+0.0i', (Complex(-0.0, -0.0) + Complex(-0.0, +0.0)).to_s) assert_equal('0.0-0.0i', (Complex(-0.0, -0.0) - Complex(-0.0, +0.0)).to_s) assert_equal('0.0+0.0i', (Complex(-0.0, -0.0) * Complex(-0.0, +0.0)).to_s) assert_equal('0.0-0.0i', (Complex(-0.0, -0.0) + Complex(+0.0, -0.0)).to_s) assert_equal('-0.0+0.0i', (Complex(-0.0, -0.0) - Complex(+0.0, -0.0)).to_s) assert_equal('-0.0+0.0i', (Complex(-0.0, -0.0) * Complex(+0.0, -0.0)).to_s) assert_equal('-0.0-0.0i', (Complex(-0.0, -0.0) + Complex(-0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(-0.0, -0.0) - Complex(-0.0, -0.0)).to_s) assert_equal('0.0+0.0i', (Complex(-0.0, -0.0) * Complex(-0.0, -0.0)).to_s) end end