diff --git a/tests/01_int.py b/tests/010_int.py similarity index 100% rename from tests/01_int.py rename to tests/010_int.py diff --git a/tests/02_float.py b/tests/020_float.py similarity index 100% rename from tests/02_float.py rename to tests/020_float.py diff --git a/tests/03_bool.py b/tests/030_bool.py similarity index 100% rename from tests/03_bool.py rename to tests/030_bool.py diff --git a/tests/04_line_continue.py b/tests/040_line_continue.py similarity index 100% rename from tests/04_line_continue.py rename to tests/040_line_continue.py diff --git a/tests/04_str.py b/tests/041_str.py similarity index 100% rename from tests/04_str.py rename to tests/041_str.py diff --git a/tests/05_list.py b/tests/050_list.py similarity index 100% rename from tests/05_list.py rename to tests/050_list.py diff --git a/tests/06_tuple.py b/tests/060_tuple.py similarity index 100% rename from tests/06_tuple.py rename to tests/060_tuple.py diff --git a/tests/07_listcomp.py b/tests/070_listcomp.py similarity index 100% rename from tests/07_listcomp.py rename to tests/070_listcomp.py diff --git a/tests/08_dict.py b/tests/080_dict.py similarity index 100% rename from tests/08_dict.py rename to tests/080_dict.py diff --git a/tests/08_dictcomp.py b/tests/081_dictcomp.py similarity index 100% rename from tests/08_dictcomp.py rename to tests/081_dictcomp.py diff --git a/tests/15_assign.py b/tests/150_assign.py similarity index 100% rename from tests/15_assign.py rename to tests/150_assign.py diff --git a/tests/15_cmp.py b/tests/151_cmp.py similarity index 100% rename from tests/15_cmp.py rename to tests/151_cmp.py diff --git a/tests/15_controlflow.py b/tests/152_controlflow.py similarity index 100% rename from tests/15_controlflow.py rename to tests/152_controlflow.py diff --git a/tests/16_functions.py b/tests/160_functions.py similarity index 100% rename from tests/16_functions.py rename to tests/160_functions.py diff --git a/tests/16_typehints.py b/tests/161_typehints.py similarity index 100% rename from tests/16_typehints.py rename to tests/161_typehints.py diff --git a/tests/24_inline_blocks.py b/tests/240_inline_blocks.py similarity index 100% rename from tests/24_inline_blocks.py rename to tests/240_inline_blocks.py diff --git a/tests/25_rfstring.py b/tests/250_rfstring.py similarity index 100% rename from tests/25_rfstring.py rename to tests/250_rfstring.py diff --git a/tests/26_multiline.py b/tests/260_multiline.py similarity index 100% rename from tests/26_multiline.py rename to tests/260_multiline.py diff --git a/tests/28_exception.py b/tests/280_exception.py similarity index 100% rename from tests/28_exception.py rename to tests/280_exception.py diff --git a/tests/29_iter.py b/tests/290_iter.py similarity index 100% rename from tests/29_iter.py rename to tests/290_iter.py diff --git a/tests/30_import.py b/tests/300_import.py similarity index 100% rename from tests/30_import.py rename to tests/300_import.py diff --git a/tests/31_modulereload.py b/tests/310_modulereload.py similarity index 100% rename from tests/31_modulereload.py rename to tests/310_modulereload.py diff --git a/tests/40_class.py b/tests/400_class.py similarity index 100% rename from tests/40_class.py rename to tests/400_class.py diff --git a/tests/41_class_ex.py b/tests/410_class_ex.py similarity index 100% rename from tests/41_class_ex.py rename to tests/410_class_ex.py diff --git a/tests/42_decorator.py b/tests/420_decorator.py similarity index 100% rename from tests/42_decorator.py rename to tests/420_decorator.py diff --git a/tests/43_closure.py b/tests/430_closure.py similarity index 100% rename from tests/43_closure.py rename to tests/430_closure.py diff --git a/tests/44_star.py b/tests/440_star.py similarity index 100% rename from tests/44_star.py rename to tests/440_star.py diff --git a/tests/46_bytes.py b/tests/460_bytes.py similarity index 100% rename from tests/46_bytes.py rename to tests/460_bytes.py diff --git a/tests/47_set.py b/tests/470_set.py similarity index 100% rename from tests/47_set.py rename to tests/470_set.py diff --git a/tests/48_setcomp.py b/tests/480_setcomp.py similarity index 100% rename from tests/48_setcomp.py rename to tests/480_setcomp.py diff --git a/tests/50_reflection.py b/tests/500_reflection.py similarity index 100% rename from tests/50_reflection.py rename to tests/500_reflection.py diff --git a/tests/51_yield.py b/tests/510_yield.py similarity index 100% rename from tests/51_yield.py rename to tests/510_yield.py diff --git a/tests/52_context.py b/tests/520_context.py similarity index 100% rename from tests/52_context.py rename to tests/520_context.py diff --git a/tests/66_eval.py b/tests/660_eval.py similarity index 100% rename from tests/66_eval.py rename to tests/660_eval.py diff --git a/tests/67_locals_vs_globals.py b/tests/670_locals_vs_globals.py similarity index 100% rename from tests/67_locals_vs_globals.py rename to tests/670_locals_vs_globals.py diff --git a/tests/70_base64.py b/tests/700_base64.py similarity index 100% rename from tests/70_base64.py rename to tests/700_base64.py diff --git a/tests/70_bisect.py b/tests/701_bisect.py similarity index 100% rename from tests/70_bisect.py rename to tests/701_bisect.py diff --git a/tests/70_builtins.py b/tests/702_builtins.py similarity index 100% rename from tests/70_builtins.py rename to tests/702_builtins.py diff --git a/tests/70_heapq.py b/tests/703_heapq.py similarity index 100% rename from tests/70_heapq.py rename to tests/703_heapq.py diff --git a/tests/70_math.py b/tests/704_math.py similarity index 100% rename from tests/70_math.py rename to tests/704_math.py diff --git a/tests/70_random.py b/tests/705_random.py similarity index 100% rename from tests/70_random.py rename to tests/705_random.py diff --git a/tests/71_cmath.py b/tests/710_cmath.py similarity index 100% rename from tests/71_cmath.py rename to tests/710_cmath.py diff --git a/tests/71_gc.py b/tests/711_gc.py similarity index 100% rename from tests/71_gc.py rename to tests/711_gc.py diff --git a/tests/71_gc_bug.py b/tests/712_gc_bug.py similarity index 100% rename from tests/71_gc_bug.py rename to tests/712_gc_bug.py diff --git a/tests/72_collections.py b/tests/720_collections.py similarity index 100% rename from tests/72_collections.py rename to tests/720_collections.py diff --git a/tests/72_json.py b/tests/721_json.py similarity index 100% rename from tests/72_json.py rename to tests/721_json.py diff --git a/tests/72_lz4.py b/tests/722_lz4.py similarity index 100% rename from tests/72_lz4.py rename to tests/722_lz4.py diff --git a/tests/72_msgpack.py b/tests/723_msgpack.py similarity index 100% rename from tests/72_msgpack.py rename to tests/723_msgpack.py diff --git a/tests/73_functools.py b/tests/730_functools.py similarity index 100% rename from tests/73_functools.py rename to tests/730_functools.py diff --git a/tests/73_json_alt.py b/tests/731_json_alt.py similarity index 100% rename from tests/73_json_alt.py rename to tests/731_json_alt.py diff --git a/tests/73_json_indent.py b/tests/732_json_indent.py similarity index 100% rename from tests/73_json_indent.py rename to tests/732_json_indent.py diff --git a/tests/73_typing.py b/tests/733_typing.py similarity index 100% rename from tests/73_typing.py rename to tests/733_typing.py diff --git a/tests/74_operator.py b/tests/740_operator.py similarity index 100% rename from tests/74_operator.py rename to tests/740_operator.py diff --git a/tests/75_compile.py b/tests/750_compile.py similarity index 100% rename from tests/75_compile.py rename to tests/750_compile.py diff --git a/tests/76_dna.py b/tests/760_dna.py similarity index 100% rename from tests/76_dna.py rename to tests/760_dna.py diff --git a/tests/76_misc.py b/tests/761_misc.py similarity index 100% rename from tests/76_misc.py rename to tests/761_misc.py diff --git a/tests/76_prime.py b/tests/762_prime.py similarity index 100% rename from tests/76_prime.py rename to tests/762_prime.py diff --git a/tests/77_builtin_func_1.py b/tests/770_builtin_func_1.py similarity index 100% rename from tests/77_builtin_func_1.py rename to tests/770_builtin_func_1.py diff --git a/tests/77_builtin_func_2.py b/tests/771_builtin_func_2.py similarity index 100% rename from tests/77_builtin_func_2.py rename to tests/771_builtin_func_2.py diff --git a/tests/79_datetime.py b/tests/790_datetime.py similarity index 100% rename from tests/79_datetime.py rename to tests/790_datetime.py diff --git a/tests/79_easing.py b/tests/791_easing.py similarity index 100% rename from tests/79_easing.py rename to tests/791_easing.py diff --git a/tests/79_file.py b/tests/792_file.py similarity index 100% rename from tests/79_file.py rename to tests/792_file.py diff --git a/tests/80_color32.py b/tests/800_color32.py similarity index 100% rename from tests/80_color32.py rename to tests/800_color32.py diff --git a/tests/801_sys.py b/tests/801_sys.py new file mode 100644 index 00000000..2a91949a --- /dev/null +++ b/tests/801_sys.py @@ -0,0 +1,4 @@ +import sys + +assert len(sys.argv) == 2 +assert (sys.argv[1] == 'tests/801_sys.py'), sys.argv diff --git a/tests/80_traceback.py b/tests/802_traceback.py similarity index 89% rename from tests/80_traceback.py rename to tests/802_traceback.py index d3a4b840..42750226 100644 --- a/tests/80_traceback.py +++ b/tests/802_traceback.py @@ -7,7 +7,7 @@ except KeyError: actual = traceback.format_exc() expected = '''Traceback (most recent call last): - File "tests/80_traceback.py", line 5 + File "tests/802_traceback.py", line 5 b = a[6] KeyError: 6''' diff --git a/tests/80_vmath.py b/tests/803_vmath.py similarity index 100% rename from tests/80_vmath.py rename to tests/803_vmath.py diff --git a/tests/80_sys.py b/tests/80_sys.py deleted file mode 100644 index f60f65cf..00000000 --- a/tests/80_sys.py +++ /dev/null @@ -1,4 +0,0 @@ -import sys - -assert len(sys.argv) == 2 -assert (sys.argv[1] == 'tests/80_sys.py'), sys.argv diff --git a/tests/81_dataclasses.py b/tests/810_dataclasses.py similarity index 100% rename from tests/81_dataclasses.py rename to tests/810_dataclasses.py diff --git a/tests/82_enum.py b/tests/820_enum.py similarity index 100% rename from tests/82_enum.py rename to tests/820_enum.py diff --git a/tests/83_unicodedata.py b/tests/830_unicodedata.py similarity index 100% rename from tests/83_unicodedata.py rename to tests/830_unicodedata.py diff --git a/tests/90_array2d.py b/tests/900_array2d.py similarity index 100% rename from tests/90_array2d.py rename to tests/900_array2d.py diff --git a/tests/901_array2d_extra1.py b/tests/901_array2d_extra1.py new file mode 100644 index 00000000..b5b42e6e --- /dev/null +++ b/tests/901_array2d_extra1.py @@ -0,0 +1,145 @@ +from array2d import array2d, chunked_array2d +from vmath import color32, vec2i + +''' +src/modules/array2d.c +''' + +# =====array2d_like_render +data = [ + [1,2,3], + [4,5,6], +] +assert array2d.fromlist(data).render() == "123\n456" + +# ====array2d_like_render_with_color +text_data = [] +color_fg = [] +color_bg = [] +for i in range(51): + r = i * 5 # r in [0,5,10,15...250,255] + g = i * 5 # g in [0,5,10,15...250,255] + + row_fg = [] + row_bg = [] + row_text_data = [] + for j in range(51): + b = j * 5 # j in [0,5,10,15...250,255] + row_fg.append(color32(255-r, 255-g, 255-b, 255)) + row_bg.append(color32(r, g, b, 255)) + row_text_data.append("A") + + color_fg.append(row_fg) + color_bg.append(row_bg) + text_data.append(row_text_data) + + +array2d.fromlist(text_data).render_with_color( + array2d.fromlist(color_fg), + array2d.fromlist(color_bg) + ) + +array2d.fromlist(text_data).render_with_color( + array2d.fromlist(color_fg), + array2d(51, 51, None) + ) + +array2d.fromlist(text_data).render_with_color( + array2d(51, 51, None), + array2d.fromlist(color_bg) + ) + +# (curr_fg.u32 != 0 || curr_bg.u32 != 0) == false +array2d.fromlist(text_data).render_with_color( + array2d(51, 51, None), + array2d(51, 51, None) + ) + +try: + array2d.fromlist(text_data).render_with_color( + array2d.fromlist(color_fg), + array2d(51, 51, 1) + ) + assert False, "here expect a TypeError" +except TypeError as e: + assert "color32" in str(e) or "None" in str(e) + +try: + array2d.fromlist(text_data).render_with_color( + array2d(51, 51, 1), + array2d.fromlist(color_bg) + ) + assert False, "here expect a TypeError" +except TypeError as e: + assert "color32" in str(e) or "None" in str(e) + + +# ====array2d_like_any +data = [[False, False], [False, False]] +assert array2d.fromlist(data).any() == False + +# ====c11_array2d_view__set +data = chunked_array2d(4) +data[vec2i(3,3)] = 0 +data.view()[1,1] = 10 +assert data.view() == array2d.fromlist([ + [None, None, None, None,], + [None, 10, None, None,], + [None, None, 0, None,], + [None, None, None, None,], + ]) + +# ====array2d_view_origin +assert data.view()[vec2i(1,1)-data.view().origin] == data[vec2i(1,1)] +assert data.view()[vec2i(3,3)-data.view().origin] == data[vec2i(3,3)] + +# ====chunked_array2d__delitem__ +data = chunked_array2d(4) +for i in range(10): + for j in range(10): + data[vec2i(i,j)] = 10 + +del data[vec2i(0,0)] +assert data[vec2i(0,0)] == data.default + +# ====chunked_array2d__len__ +data = chunked_array2d(4) +for i in range(10): + for j in range(10): + data[vec2i(i,j)] = 10 + +assert len(data) == 9 + +# ====c11_chunked_array2d__mark +import gc + +def gc_collect_callback(statue, msg): + if statue == 'stop': + for line in msg.split('\n'): + print(line) + if "5290" in line and "str" in line: + return + print(msg) + raise AssertionError("Expected GC output not found") + +gc.collect() +gc.setup_debug_callback(gc_collect_callback) +def create_garbage(): + data = chunked_array2d(4) + # [str ] small: 0 large: 5290 + for x in range(23): + for y in range(230): + data[vec2i(x, y)] = "garbage"*100 + +create_garbage() +gc.collect() + + +# ====chunked_array2d_view_chunks +data = chunked_array2d(4, default = 0) +data[vec2i(-10,-10)] = -1 +assert data.view_chunks(vec2i(-3, -3), 6, 6)[vec2i(2, 2)] == -1 +data.view_chunks(vec2i(-3, -3), 6, 6)[vec2i(22, 22)] = 1 +assert data[vec2i(10,10)] == 1 + + diff --git a/tests/90_chunked_array2d.py b/tests/902_chunked_array2d.py similarity index 100% rename from tests/90_chunked_array2d.py rename to tests/902_chunked_array2d.py diff --git a/tests/90_colorcvt.py b/tests/903_colorcvt.py similarity index 100% rename from tests/90_colorcvt.py rename to tests/903_colorcvt.py diff --git a/tests/90_pickle.py b/tests/904_pickle.py similarity index 100% rename from tests/90_pickle.py rename to tests/904_pickle.py diff --git a/tests/91_line_profiler.py b/tests/910_line_profiler.py similarity index 100% rename from tests/91_line_profiler.py rename to tests/910_line_profiler.py diff --git a/tests/92_picoterm.py b/tests/920_picoterm.py similarity index 100% rename from tests/92_picoterm.py rename to tests/920_picoterm.py diff --git a/tests/92_pkpy.py b/tests/921_pkpy.py similarity index 100% rename from tests/92_pkpy.py rename to tests/921_pkpy.py diff --git a/tests/93_deterministic_float.py b/tests/930_deterministic_float.py similarity index 100% rename from tests/93_deterministic_float.py rename to tests/930_deterministic_float.py diff --git a/tests/95_bugs.py b/tests/950_bugs.py similarity index 100% rename from tests/95_bugs.py rename to tests/950_bugs.py diff --git a/tests/95_dis.py b/tests/951_dis.py similarity index 100% rename from tests/95_dis.py rename to tests/951_dis.py diff --git a/tests/96_pep695_py312.py b/tests/960_pep695_py312.py similarity index 100% rename from tests/96_pep695_py312.py rename to tests/960_pep695_py312.py diff --git a/tests/97_inspect.py b/tests/970_inspect.py similarity index 100% rename from tests/97_inspect.py rename to tests/970_inspect.py diff --git a/tests/98_thread.py b/tests/980_thread.py similarity index 100% rename from tests/98_thread.py rename to tests/980_thread.py diff --git a/tests/99_extras.py b/tests/990_extras.py similarity index 100% rename from tests/99_extras.py rename to tests/990_extras.py