Просмотр исходного кода

Increase coverage 2025 12 01 (#412)

* 通过引发py_call错误覆盖相关调用者的ok==false分支

* Revert "通过引发py_call错误覆盖相关调用者的ok==false分支"

This reverts commit 36dc0b5d81a02a83dfdeca2d4d6d265f5f793b4b.

* add test

* rename test files

* fix bugs

* fix bugs
zhs628 3 месяцев назад
Родитель
Сommit
fc991ab697
85 измененных файлов с 150 добавлено и 5 удалено
  1. 0 0
      tests/010_int.py
  2. 0 0
      tests/020_float.py
  3. 0 0
      tests/030_bool.py
  4. 0 0
      tests/040_line_continue.py
  5. 0 0
      tests/041_str.py
  6. 0 0
      tests/050_list.py
  7. 0 0
      tests/060_tuple.py
  8. 0 0
      tests/070_listcomp.py
  9. 0 0
      tests/080_dict.py
  10. 0 0
      tests/081_dictcomp.py
  11. 0 0
      tests/150_assign.py
  12. 0 0
      tests/151_cmp.py
  13. 0 0
      tests/152_controlflow.py
  14. 0 0
      tests/160_functions.py
  15. 0 0
      tests/161_typehints.py
  16. 0 0
      tests/240_inline_blocks.py
  17. 0 0
      tests/250_rfstring.py
  18. 0 0
      tests/260_multiline.py
  19. 0 0
      tests/280_exception.py
  20. 0 0
      tests/290_iter.py
  21. 0 0
      tests/300_import.py
  22. 0 0
      tests/310_modulereload.py
  23. 0 0
      tests/400_class.py
  24. 0 0
      tests/410_class_ex.py
  25. 0 0
      tests/420_decorator.py
  26. 0 0
      tests/430_closure.py
  27. 0 0
      tests/440_star.py
  28. 0 0
      tests/460_bytes.py
  29. 0 0
      tests/470_set.py
  30. 0 0
      tests/480_setcomp.py
  31. 0 0
      tests/500_reflection.py
  32. 0 0
      tests/510_yield.py
  33. 0 0
      tests/520_context.py
  34. 0 0
      tests/660_eval.py
  35. 0 0
      tests/670_locals_vs_globals.py
  36. 0 0
      tests/700_base64.py
  37. 0 0
      tests/701_bisect.py
  38. 0 0
      tests/702_builtins.py
  39. 0 0
      tests/703_heapq.py
  40. 0 0
      tests/704_math.py
  41. 0 0
      tests/705_random.py
  42. 0 0
      tests/710_cmath.py
  43. 0 0
      tests/711_gc.py
  44. 0 0
      tests/712_gc_bug.py
  45. 0 0
      tests/720_collections.py
  46. 0 0
      tests/721_json.py
  47. 0 0
      tests/722_lz4.py
  48. 0 0
      tests/723_msgpack.py
  49. 0 0
      tests/730_functools.py
  50. 0 0
      tests/731_json_alt.py
  51. 0 0
      tests/732_json_indent.py
  52. 0 0
      tests/733_typing.py
  53. 0 0
      tests/740_operator.py
  54. 0 0
      tests/750_compile.py
  55. 0 0
      tests/760_dna.py
  56. 0 0
      tests/761_misc.py
  57. 0 0
      tests/762_prime.py
  58. 0 0
      tests/770_builtin_func_1.py
  59. 0 0
      tests/771_builtin_func_2.py
  60. 0 0
      tests/790_datetime.py
  61. 0 0
      tests/791_easing.py
  62. 0 0
      tests/792_file.py
  63. 0 0
      tests/800_color32.py
  64. 4 0
      tests/801_sys.py
  65. 1 1
      tests/802_traceback.py
  66. 0 0
      tests/803_vmath.py
  67. 0 4
      tests/80_sys.py
  68. 0 0
      tests/810_dataclasses.py
  69. 0 0
      tests/820_enum.py
  70. 0 0
      tests/830_unicodedata.py
  71. 0 0
      tests/900_array2d.py
  72. 145 0
      tests/901_array2d_extra1.py
  73. 0 0
      tests/902_chunked_array2d.py
  74. 0 0
      tests/903_colorcvt.py
  75. 0 0
      tests/904_pickle.py
  76. 0 0
      tests/910_line_profiler.py
  77. 0 0
      tests/920_picoterm.py
  78. 0 0
      tests/921_pkpy.py
  79. 0 0
      tests/930_deterministic_float.py
  80. 0 0
      tests/950_bugs.py
  81. 0 0
      tests/951_dis.py
  82. 0 0
      tests/960_pep695_py312.py
  83. 0 0
      tests/970_inspect.py
  84. 0 0
      tests/980_thread.py
  85. 0 0
      tests/990_extras.py

+ 0 - 0
tests/01_int.py → tests/010_int.py


+ 0 - 0
tests/02_float.py → tests/020_float.py


+ 0 - 0
tests/03_bool.py → tests/030_bool.py


+ 0 - 0
tests/04_line_continue.py → tests/040_line_continue.py


+ 0 - 0
tests/04_str.py → tests/041_str.py


+ 0 - 0
tests/05_list.py → tests/050_list.py


+ 0 - 0
tests/06_tuple.py → tests/060_tuple.py


+ 0 - 0
tests/07_listcomp.py → tests/070_listcomp.py


+ 0 - 0
tests/08_dict.py → tests/080_dict.py


+ 0 - 0
tests/08_dictcomp.py → tests/081_dictcomp.py


+ 0 - 0
tests/15_assign.py → tests/150_assign.py


+ 0 - 0
tests/15_cmp.py → tests/151_cmp.py


+ 0 - 0
tests/15_controlflow.py → tests/152_controlflow.py


+ 0 - 0
tests/16_functions.py → tests/160_functions.py


+ 0 - 0
tests/16_typehints.py → tests/161_typehints.py


+ 0 - 0
tests/24_inline_blocks.py → tests/240_inline_blocks.py


+ 0 - 0
tests/25_rfstring.py → tests/250_rfstring.py


+ 0 - 0
tests/26_multiline.py → tests/260_multiline.py


+ 0 - 0
tests/28_exception.py → tests/280_exception.py


+ 0 - 0
tests/29_iter.py → tests/290_iter.py


+ 0 - 0
tests/30_import.py → tests/300_import.py


+ 0 - 0
tests/31_modulereload.py → tests/310_modulereload.py


+ 0 - 0
tests/40_class.py → tests/400_class.py


+ 0 - 0
tests/41_class_ex.py → tests/410_class_ex.py


+ 0 - 0
tests/42_decorator.py → tests/420_decorator.py


+ 0 - 0
tests/43_closure.py → tests/430_closure.py


+ 0 - 0
tests/44_star.py → tests/440_star.py


+ 0 - 0
tests/46_bytes.py → tests/460_bytes.py


+ 0 - 0
tests/47_set.py → tests/470_set.py


+ 0 - 0
tests/48_setcomp.py → tests/480_setcomp.py


+ 0 - 0
tests/50_reflection.py → tests/500_reflection.py


+ 0 - 0
tests/51_yield.py → tests/510_yield.py


+ 0 - 0
tests/52_context.py → tests/520_context.py


+ 0 - 0
tests/66_eval.py → tests/660_eval.py


+ 0 - 0
tests/67_locals_vs_globals.py → tests/670_locals_vs_globals.py


+ 0 - 0
tests/70_base64.py → tests/700_base64.py


+ 0 - 0
tests/70_bisect.py → tests/701_bisect.py


+ 0 - 0
tests/70_builtins.py → tests/702_builtins.py


+ 0 - 0
tests/70_heapq.py → tests/703_heapq.py


+ 0 - 0
tests/70_math.py → tests/704_math.py


+ 0 - 0
tests/70_random.py → tests/705_random.py


+ 0 - 0
tests/71_cmath.py → tests/710_cmath.py


+ 0 - 0
tests/71_gc.py → tests/711_gc.py


+ 0 - 0
tests/71_gc_bug.py → tests/712_gc_bug.py


+ 0 - 0
tests/72_collections.py → tests/720_collections.py


+ 0 - 0
tests/72_json.py → tests/721_json.py


+ 0 - 0
tests/72_lz4.py → tests/722_lz4.py


+ 0 - 0
tests/72_msgpack.py → tests/723_msgpack.py


+ 0 - 0
tests/73_functools.py → tests/730_functools.py


+ 0 - 0
tests/73_json_alt.py → tests/731_json_alt.py


+ 0 - 0
tests/73_json_indent.py → tests/732_json_indent.py


+ 0 - 0
tests/73_typing.py → tests/733_typing.py


+ 0 - 0
tests/74_operator.py → tests/740_operator.py


+ 0 - 0
tests/75_compile.py → tests/750_compile.py


+ 0 - 0
tests/76_dna.py → tests/760_dna.py


+ 0 - 0
tests/76_misc.py → tests/761_misc.py


+ 0 - 0
tests/76_prime.py → tests/762_prime.py


+ 0 - 0
tests/77_builtin_func_1.py → tests/770_builtin_func_1.py


+ 0 - 0
tests/77_builtin_func_2.py → tests/771_builtin_func_2.py


+ 0 - 0
tests/79_datetime.py → tests/790_datetime.py


+ 0 - 0
tests/79_easing.py → tests/791_easing.py


+ 0 - 0
tests/79_file.py → tests/792_file.py


+ 0 - 0
tests/80_color32.py → tests/800_color32.py


+ 4 - 0
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

+ 1 - 1
tests/80_traceback.py → 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'''
 

+ 0 - 0
tests/80_vmath.py → tests/803_vmath.py


+ 0 - 4
tests/80_sys.py

@@ -1,4 +0,0 @@
-import sys
-
-assert len(sys.argv) == 2
-assert (sys.argv[1] == 'tests/80_sys.py'), sys.argv

+ 0 - 0
tests/81_dataclasses.py → tests/810_dataclasses.py


+ 0 - 0
tests/82_enum.py → tests/820_enum.py


+ 0 - 0
tests/83_unicodedata.py → tests/830_unicodedata.py


+ 0 - 0
tests/90_array2d.py → tests/900_array2d.py


+ 145 - 0
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
+
+

+ 0 - 0
tests/90_chunked_array2d.py → tests/902_chunked_array2d.py


+ 0 - 0
tests/90_colorcvt.py → tests/903_colorcvt.py


+ 0 - 0
tests/90_pickle.py → tests/904_pickle.py


+ 0 - 0
tests/91_line_profiler.py → tests/910_line_profiler.py


+ 0 - 0
tests/92_picoterm.py → tests/920_picoterm.py


+ 0 - 0
tests/92_pkpy.py → tests/921_pkpy.py


+ 0 - 0
tests/93_deterministic_float.py → tests/930_deterministic_float.py


+ 0 - 0
tests/95_bugs.py → tests/950_bugs.py


+ 0 - 0
tests/95_dis.py → tests/951_dis.py


+ 0 - 0
tests/96_pep695_py312.py → tests/960_pep695_py312.py


+ 0 - 0
tests/97_inspect.py → tests/970_inspect.py


+ 0 - 0
tests/98_thread.py → tests/980_thread.py


+ 0 - 0
tests/99_extras.py → tests/990_extras.py