単体テストすらちゃんとしてなかったり
ちゃんと単体テストしようw
setterとgetter 単体テスト書いたー
#include "longint.hsp" #module m_one_plus_float member_bool_value,member_inner_value,member_LI_value,member_decimal_type,member_LI_decimal,member_double_decimal,member_decimal_places,member_after_mul,member_after_DIV,member_after_DIV_at_inner // member_bool_value // member_inner_value // member_LI_value // member_decimal_type // member_LI_decimal // member_double_decimal // member_decimal_places // member_after_mul // member_after_DIV // member_after_DIV_at_inner #modfunc local get_member_bool_value var _p_v _p_v=member_bool_value:return #modfunc local get_member_inner_value var _p_v _p_v=member_inner_value:return #modfunc local get_member_LI_value var _p_v _p_v=member_LI_value:return #modfunc local get_member_decimal_type var _p_v _p_v=member_decimal_type:return #modfunc local get_member_LI_decimal var _p_v _p_v=member_LI_decimal:return #modfunc local get_member_double_decimal var _p_v _p_v=member_double_decimal:return #modfunc local get_member_decimal_places var _p_v _p_v=member_decimal_places:return #modfunc local get_member_after_mul var _p_v _p_v=member_after_mul:return #modfunc local get_member_after_DIV var _p_v _p_v=member_after_DIV:return #modfunc local get_member_after_DIV_at_inner var _p_v _p_v=member_after_DIV_at_inner:return #modfunc local set_member_bool_value var _p_v member_bool_value = _p_v:return #modfunc local set_member_inner_value var _p_v member_inner_value = _p_v:return #modfunc local set_member_LI_value var _p_v member_LI_value = _p_v:return #modfunc local set_member_decimal_type var _p_v member_decimal_type = _p_v:return #modfunc local set_member_LI_decimal var _p_v member_LI_decimal = _p_v:return #modfunc local set_member_double_decimal var _p_v member_double_decimal = _p_v:return #modfunc local set_member_decimal_places var _p_v member_decimal_places = _p_v:return #modfunc local set_member_after_mul var _p_v member_after_mul = _p_v:return #modfunc local set_member_after_DIV var _p_v member_after_DIV = _p_v:return #modfunc local set_member_after_DIV_at_inner var _p_v member_after_DIV_at_inner = _p_v:return #modinit if _keta_flag==0{ _10keta=LongInt(100000) _10keta*=100000 _keta_flag=1 } member_bool_value = 0 member_inner_value=LongInt(0) member_LI_value=LongInt(0) member_LI_decimal=LongInt(0) member_decimal_type=8 member_double_decimal=0.0 member_decimal_places=10 member_after_mul=0 member_after_div=0 // 後でこの値で割ってね member_after_div_at_inner=LongInt(1) // decimal:小数 // place:桁 return // member_bool_value // member_inner_value // member_LI_value // member_decimal_type // member_LI_decimal // member_double_decimal // member_decimal_places // member_after_mul // member_after_DIV // member_after_DIV_at_inner #modfunc local dat_reset member_bool_value = 0 member_inner_value=LongInt(0) member_LI_value=LongInt(0) member_decimal_type=0 member_LI_decimal=LongInt(0) member_double_decimal=0.0 member_decimal_places=0 member_after_mul=LongInt(0) member_after_div=LongInt(0) member_after_div_at_inner=LongInt(0) return #modfunc local inner2value member_LI_value=member_inner_value/_10keta if member_decimal_places==10{ member_LI_decimal = member_inner_value\_10keta return } if member_decimal_places==4{ member_LI_decimal = member_inner_value\_10keta member_LI_decimal/=(1000*1000) return } logmes "error inner2value@m_one_plus_float placesの値が10か4ではありません" return #modfunc local value2inner member_inner_value=member_LI_value member_inner_value*=100000 member_inner_value*=100000 member_after_div_at_inner=LongInt(1) member_after_div_at_inner*=100000 member_after_div_at_inner*=100000 if member_decimal_places==10{ member_inner_value+=member_LI_decimal return } if member_decimal_places==4{ member_inner_value+=(member_LI_decimal*1000*1000) return } logmes "error value2inner@m_one_plus_float placesの値が10か4ではありません" return #modfunc local dbl2LI member_double_decimal*=100000 member_double_decimal*=100000 member_LI_decimal=LongInt(member_double_decimal) member_double_decimal=0.0 member_decimal_type=8 member_decimal_places=10 return #modfunc local dump logmes "bool_value:"+str(member_bool_value) logmes "LI_value:"+str(member_LI_value) logmes "LI_type:"+str(vartype(member_LI_value)) logmes "LI_decimal:"+str(member_LI_decimal) logmes "decimal_type:"+str(member_decimal_type) logmes "LI_double:"+str(member_double_decimal) logmes "桁(小数):"+str(member_decimal_places) ; logmes "_10keta:"+str(_10keta) logmes "after_mul:"+str(member_after_mul) logmes "after_div:"+str(member_after_div) logmes "after_div_at_inner:"+str(member_after_div_inner) return #modfunc local cut_by_10keta member_LI_decimal\=_10keta return #modfunc local cut_by_4keta member_LI_decimal\=_10keta member_LI_decimal/=1000000 return // もっと大きい桁の計算で使いそう #modfunc local cut_by_x_keta int p_keta,local loc_10kai loc_10kai=LongInt(1) repeat p_keta loc_10kai*=10 loop member_LI_decimal\=loc_10kai return #modfunc local set_values var _p_value,var _p_decimal,int _p_places member_LI_value=LongInt(_p_value) member_decimal_type=vartype(_p_decimal) if member_decimal_type==3{ member_decimal_type=3 member_double_decimal=_p_decimal }else{ member_LI_decimal=LongInt(_p_decimal) member_decimal_type=vartype(member_LI_decimal) } member_decimal_places=_p_places return #global /////////////////////////////////////////////////////////////// // TEST newmod obj4test,m_one_plus_float tmp=1 set_member_bool_value@m_one_plus_float obj4test,tmp tmp=LongInt("123456789012345") set_member_inner_value@m_one_plus_float obj4test,tmp tmp=LongInt("345678901234567") set_member_LI_value@m_one_plus_float obj4test,tmp tmp=3 set_member_decimal_type@m_one_plus_float obj4test,tmp tmp=LongInt("567890123456789") set_member_LI_decimal@m_one_plus_float obj4test,tmp tmp=78.901 set_member_double_decimal@m_one_plus_float obj4test,tmp tmp=4 set_member_decimal_places@m_one_plus_float obj4test,tmp tmp=1 set_member_after_mul@m_one_plus_float obj4test,tmp tmp=2 set_member_after_div@m_one_plus_float obj4test,tmp tmp=3 set_member_after_div_at_inner@m_one_plus_float obj4test,tmp logmes "++obj4test:setter" dump@m_one_plus_float obj4test logmes "++obj4test:getter" get_member_bool_value@m_one_plus_float obj4test,tmp logmes str(tmp) get_member_inner_value@m_one_plus_float obj4test,tmp logmes str(tmp) get_member_LI_value@m_one_plus_float obj4test,tmp logmes str(tmp) get_member_decimal_type@m_one_plus_float obj4test,tmp logmes str(tmp) get_member_LI_decimal@m_one_plus_float obj4test,tmp logmes str(tmp) get_member_double_decimal@m_one_plus_float obj4test,tmp logmes str(tmp) get_member_decimal_places@m_one_plus_float obj4test,tmp logmes str(tmp) get_member_after_mul@m_one_plus_float obj4test,tmp logmes str(tmp) get_member_after_div@m_one_plus_float obj4test,tmp logmes str(tmp) get_member_after_div_at_inner@m_one_plus_float obj4test,tmp logmes str(tmp) /////////////////////////////////////////////////////////////// #module m_plus_float result_mf_obj,arg_1st_mf_obj,obj_operand,arg_2nd_mf_obj #modinit newmod arg_1st_mf_obj,m_one_plus_float obj_operand="" // operand:演算子 newmod arg_2nd_mf_obj,m_one_plus_float newmod result_mf_obj,m_one_plus_float return #modfunc local dat_reset_result_obj dat_reset@m_one_plus_float result_mf_obj return #modfunc local dat_arg_1st_obj dat_reset@m_one_plus_float arg_1st_mf_obj return #modfunc local dat_arg_2nd_obj dat_reset@m_one_plus_float arg_2nd_mf_obj return #modfunc local dat_move_arg_1st_to_result local loc_1a,local loc_2b,local loc_3c,local loc_4d,local loc_5e,local loc_6f,local loc_7g,local loc_8h,local loc_9i,local loc_0j get_member_inner_value@m_one_plus_float arg_1st_mf_obj,loc_1a get_member_LI_value@m_one_plus_float arg_1st_mf_obj,loc_2b get_member_decimal_type@m_one_plus_float arg_1st_mf_obj,loc_3c get_member_LI_decimal@m_one_plus_float arg_1st_mf_obj,loc_4d get_member_double_decimal@m_one_plus_float arg_1st_mf_obj,loc_5e get_member_decimal_places@m_one_plus_float arg_1st_mf_obj,loc_6f get_member_after_mul@m_one_plus_float arg_1st_mf_obj,loc_7g get_member_after_DIV@m_one_plus_float arg_1st_mf_obj,loc_8h get_member_after_DIV_at_inner@m_one_plus_float arg_1st_mf_obj,loc_9i get_member_bool_value@m_one_plus_float arg_1st_mf_obj,loc_0j dat_reset@m_one_plus_float result_mf_obj set_member_inner_value@m_one_plus_float result_mf_obj,loc_1a set_member_LI_value@m_one_plus_float result_mf_obj,loc_2b set_member_decimal_type@m_one_plus_float result_mf_obj,loc_3c set_member_LI_decimal@m_one_plus_float result_mf_obj,loc_4d set_member_double_decimal@m_one_plus_float result_mf_obj,loc_5e set_member_decimal_places@m_one_plus_float result_mf_obj,loc_6f set_member_after_mul@m_one_plus_float result_mf_obj,loc_7g set_member_after_DIV@m_one_plus_float result_mf_obj,loc_8h set_member_after_DIV_at_inner@m_one_plus_float result_mf_obj,loc_9i set_member_bool_value@m_one_plus_float result_mf_obj,loc_0j return #modfunc local dat_move_arg_2nd_to_result local loc_1a,local loc_2b,local loc_3c,local loc_4d,local loc_5e,local loc_6f,local loc_7g,local loc_8h,local loc_9i,local loc_0j get_member_inner_value@m_one_plus_float arg_2nd_mf_obj,loc_1a get_member_LI_value@m_one_plus_float arg_2nd_mf_obj,loc_2b get_member_decimal_type@m_one_plus_float arg_2nd_mf_obj,loc_3c get_member_LI_decimal@m_one_plus_float arg_2nd_mf_obj,loc_4d get_member_double_decimal@m_one_plus_float arg_2nd_mf_obj,loc_5e get_member_decimal_places@m_one_plus_float arg_2nd_mf_obj,loc_6f get_member_after_mul@m_one_plus_float arg_2nd_mf_obj,loc_7g get_member_after_DIV@m_one_plus_float arg_2nd_mf_obj,loc_8h get_member_after_DIV_at_inner@m_one_plus_float arg_2nd_mf_obj,loc_9i get_member_bool_value@m_one_plus_float arg_2nd_mf_obj,loc_0j dat_reset@m_one_plus_float result_mf_obj set_member_inner_value@m_one_plus_float result_mf_obj,loc_1a set_member_LI_value@m_one_plus_float result_mf_obj,loc_2b set_member_decimal_type@m_one_plus_float result_mf_obj,loc_3c set_member_LI_decimal@m_one_plus_float result_mf_obj,loc_4d set_member_double_decimal@m_one_plus_float result_mf_obj,loc_5e set_member_decimal_places@m_one_plus_float result_mf_obj,loc_6f set_member_after_mul@m_one_plus_float result_mf_obj,loc_7g set_member_after_DIV@m_one_plus_float result_mf_obj,loc_8h set_member_after_DIV_at_inner@m_one_plus_float result_mf_obj,loc_9i set_member_bool_value@m_one_plus_float result_mf_obj,loc_0j return #modfunc local dat_move_arg_result_to_1st local loc_1a,local loc_2b,local loc_3c,local loc_4d,local loc_5e,local loc_6f,local loc_7g,local loc_8h,local loc_9i,local loc_0j get_member_inner_value@m_one_plus_float result_mf_obj,loc_1a get_member_LI_value@m_one_plus_float result_mf_obj,loc_2b get_member_decimal_type@m_one_plus_float result_mf_obj,loc_3c get_member_LI_decimal@m_one_plus_float result_mf_obj,loc_4d get_member_double_decimal@m_one_plus_float resut_mf_obj,loc_5e get_member_decimal_places@m_one_plus_float result_mf_obj,loc_6f get_member_after_mul@m_one_plus_float result_mf_obj,loc_7g get_member_after_DIV@m_one_plus_float result_mf_obj,loc_8h get_member_after_DIV_at_inner@m_one_plus_float result_mf_obj,loc_9i get_member_bool_value@m_one_plus_float result_mf_obj,loc_0j dat_reset@m_one_plus_float arg_1st_mf_obj set_member_inner_value@m_one_plus_float arg_1st_mf_obj,loc_1a set_member_LI_value@m_one_plus_float arg_1st_mf_obj,loc_2b set_member_decimal_type@m_one_plus_float arg_1st_mf_obj,loc_3c set_member_LI_decimal@m_one_plus_float arg_1st_mf_obj,loc_4d set_member_double_decimal@m_one_plus_float arg_1st_mf_obj,loc_5e set_member_decimal_places@m_one_plus_float arg_1st_mf_obj,loc_6f set_member_after_mul@m_one_plus_float arg_1st_mf_obj,loc_7g set_member_after_DIV@m_one_plus_float arg_1st_mf_obj,loc_8h set_member_after_DIV_at_inner@m_one_plus_float arg_1st_mf_obj,loc_9i set_member_bool_value@m_one_plus_float arg_1st_mf_obj,loc_0j return #modfunc local dat_move_arg_result_to_2nd local loc_1a,local loc_2b,local loc_3c,local loc_4d,local loc_5e,local loc_6f,local loc_7g,local loc_8h,local loc_9i,local loc_0j get_member_inner_value@m_one_plus_float result_mf_obj,loc_1a get_member_LI_value@m_one_plus_float result_mf_obj,loc_2b get_member_decimal_type@m_one_plus_float result_mf_obj,loc_3c get_member_LI_decimal@m_one_plus_float result_mf_obj,loc_4d get_member_double_decimal@m_one_plus_float resut_mf_obj,loc_5e get_member_decimal_places@m_one_plus_float result_mf_obj,loc_6f get_member_after_mul@m_one_plus_float result_mf_obj,loc_7g get_member_after_DIV@m_one_plus_float result_mf_obj,loc_8h get_member_after_DIV_at_inner@m_one_plus_float result_mf_obj,loc_9i get_member_bool_value@m_one_plus_float result_mf_obj,loc_0j dat_reset@m_one_plus_float arg_2nd_mf_obj set_member_inner_value@m_one_plus_float arg_2nd_mf_obj,loc_1a set_member_LI_value@m_one_plus_float arg_2nd_mf_obj,loc_2b set_member_decimal_type@m_one_plus_float arg_2nd_mf_obj,loc_3c set_member_LI_decimal@m_one_plus_float arg_2nd_mf_obj,loc_4d set_member_double_decimal@m_one_plus_float arg_2nd_mf_obj,loc_5e set_member_decimal_places@m_one_plus_float arg_2nd_mf_obj,loc_6f set_member_after_mul@m_one_plus_float arg_2nd_mf_obj,loc_7g set_member_after_DIV@m_one_plus_float arg_2nd_mf_obj,loc_8h set_member_after_DIV_at_inner@m_one_plus_float arg_2nd_mf_obj,loc_9i set_member_bool_value@m_one_plus_float arg_2nd_mf_obj,loc_0j return // member_bool_value // member_inner_value // member_LI_value // member_decimal_type // member_LI_decimal // member_double_decimal // member_decimal_places // member_after_mul // member_after_DIV // member_after_DIV_at_inner #modfunc local dump logmes "1st arg" dump@m_one_plus_float arg_1st_mf_obj logmes "演算:"+obj_operand logmes "2nd arg" dump@m_one_plus_float arg_2nd_mf_obj return #modfunc local set_operand str p_operand obj_operand=p_operand return #modfunc local set_arg_1st_values var p_value,var p_decimal,int p_places set_values@m_one_plus_float arg_1st_mf_obj,p_value,p_decimal,p_places return #modfunc local set_arg_2nd_values var p_value,var p_decimal,int p_places set_values@m_one_plus_float arg_2nd_mf_obj,p_value,p_decimal,p_places return #modfunc local dbl2LI_1st dbl2LI@m_one_plus_float arg_1st_mf_obj return #modfunc local dbl2LI_2nd dbl2LI@m_one_plus_float arg_2nd_mf_obj return #modfunc local cut_by_10keta_1st cut_by_10keta@m_one_plus_float arg_1st_mf_obj return #modfunc local cut_by_4keta_1st cut_by_4keta@m_one_plus_float arg_1st_mf_obj return #modfunc local cut_by_10keta_2nd cut_by_10keta@m_one_plus_float arg_2nd_mf_obj return #modfunc local cut_by_4keta_2nd cut_by_4keta@m_one_plus_float arg_2nd_mf_obj return #global /////////////////////////////////////////////////////////////// // TEST newmod tmp_LI,m_plus_float tmp_l1=LongInt(12345678) tmp_l1*=100000000 tmp_l1+=12345678 tmp_l2=LongInt(56781234) tmp_l2*=100000000 tmp_l2+=56781234 tmp_l3=10 ;logmes str(vartype(tmp_l1)) set_arg_1st_values@m_plus_float tmp_LI,tmp_l1,tmp_l2,tmp_l3 set_operand@m_plus_float tmp_LI,"SUB" tmp_arg_l1=LongInt("8765432187654321") ;tmp_arg_l2=LongInt("4321876543218765") tmp_arg_l2=0.12345 tmp_arg_l3=10 set_arg_2nd_values@m_plus_float tmp_LI,tmp_arg_l1,tmp_arg_l2,tmp_arg_l3 logmes "++begin" dump@m_plus_float tmp_LI dbl2LI_2nd@m_plus_float tmp_LI logmes "++2LI" dump@m_plus_float tmp_LI cut_by_10keta_1st@m_plus_float tmp_LI cut_by_10keta_2nd@m_plus_float tmp_LI logmes "++cut_by_10keta" dump@m_plus_float tmp_LI cut_by_4keta_1st@m_plus_float tmp_LI cut_by_4keta_2nd@m_plus_float tmp_LI logmes "++cut_by_4keta" dump@m_plus_float tmp_LI newmod tmp_LI_2nd,m_plus_float tmp_l1=12345 tmp_l2=67890 tmp_l3=10 ;logmes str(vartype(tmp_l1)) set_arg_1st_values@m_plus_float tmp_LI_2nd,tmp_l1,tmp_l2,tmp_l3 set_operand@m_plus_float tmp_LI_2nd,"MUL" tmp_arg_l1=LongInt("8765432187654321") ;tmp_arg_l2=LongInt("4321876543218765") tmp_arg_l2=0.12345 tmp_arg_l3=10 set_arg_2nd_values@m_plus_float tmp_LI_2nd,tmp_arg_l1,tmp_arg_l2,tmp_arg_l3 logmes "++begin_2nd" dump@m_plus_float tmp_LI_2nd