diff options
| -rw-r--r-- | README.md | 16 | ||||
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | mise.toml | 1 | ||||
| -rw-r--r-- | pyproject.toml | 4 | ||||
| -rw-r--r-- | pyrightconfig.json | 7 | ||||
| -rw-r--r-- | src/json/json.c | 2 | ||||
| -rw-r--r-- | src/json/test_json.c | 2 | ||||
| -rw-r--r-- | src/std/test_vec.c | 6 | ||||
| -rw-r--r-- | src/std/time.c | 11 | ||||
| -rw-r--r-- | uv.lock | 26 |
10 files changed, 58 insertions, 19 deletions
@@ -10,6 +10,22 @@ - escape chars - unicode - fail on any control character in string +- benchmark kind of tests + +```c +SDL_GetError(); +SDL_Window *window = SDL_CreateWindow("Hello World!", 100, 100, width, height, SDL_WINDOW_SHOWN); +SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); +SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); +SDL_RenderClear(renderer); +SDL_RenderPresent(renderer); +SDL_Delay(500); +SDL_Rect rect = {c_position->x, c_position->y, 4, 4}; +SDL_RenderFillRect(renderer, &rect); +SDL_Quit(); +SDL_DestroyRenderer(renderer); +SDL_DestroyWindow(window); +``` ## Benchmarks @@ -4,8 +4,8 @@ #include <sys/stat.h> #include <time.h> -#include "src/std/assert.h" #include "src/json/json.h" +#include "src/std/assert.h" #include "src/std/memory.h" #include "src/std/testing.h" #include "src/std/types.h" @@ -40,5 +40,6 @@ run = [ "clang-format --dry-run src/**/*.c src/**/*.h *.c --fail-on-incomplete-format", "ruff check", "ruff format --check", + "uv run ty check", "mise run test" ] diff --git a/pyproject.toml b/pyproject.toml index 857fbb5..7b2811f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,4 +7,8 @@ requires-python = ">=3.13" dependencies = [ "pysimdjson>=7.0.2", "ruff>=0.12.10", + "ty>=0.0.1a7", ] + +[tool.ty.rules] +division-by-zero = "error" diff --git a/pyrightconfig.json b/pyrightconfig.json deleted file mode 100644 index efb7f00..0000000 --- a/pyrightconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/microsoft/pyright/refs/heads/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json", - "strict": [ - "." - ], - "typeCheckingMode": "strict" -} diff --git a/src/json/json.c b/src/json/json.c index d16415b..b25839f 100644 --- a/src/json/json.c +++ b/src/json/json.c @@ -9,9 +9,9 @@ #include <string.h> #include "../std/assert.h" -#include "json.h" #include "../std/str.h" #include "../std/types.h" +#include "json.h" JSONObject *JSONObject_new(Arena *a) { JSONObject *object = new(a, JSONObject, 1); diff --git a/src/json/test_json.c b/src/json/test_json.c index 058f191..b1df94b 100644 --- a/src/json/test_json.c +++ b/src/json/test_json.c @@ -1,5 +1,5 @@ -#include "json.h" #include "../std/testing.h" +#include "json.h" #define JSON_parse_raw(a, s) JSON_parse(a, s, lengthof(s)); diff --git a/src/std/test_vec.c b/src/std/test_vec.c index e95a1b6..451b965 100644 --- a/src/std/test_vec.c +++ b/src/std/test_vec.c @@ -34,7 +34,8 @@ i32 test_vec_push() { Vec v = Vec_new(&perm, i32, 4); i32 vals[] = {10, 20, 30}; - for (i32 i = 0; i < 3; i++) Vec_push(&perm, &v, &vals[i]); + for (i32 i = 0; i < 3; i++) + Vec_push(&perm, &v, &vals[i]); t_assert_equal(v.len, 3); t_assert_equal(*Vec_get(v, i32, 0), 10); @@ -49,7 +50,8 @@ i32 test_vec_grow() { Arena perm = Arena_new(128e3); Vec v = Vec_new(&perm, i32, 2); - for (i32 i = 0; i < 8; i++) Vec_push(&perm, &v, &i); + for (i32 i = 0; i < 8; i++) + Vec_push(&perm, &v, &i); t_assert_equal(v.len, 8); t_assert_equal(Arena_get_used(perm), sizeof(i32) * (2 + 4 + 8)); diff --git a/src/std/time.c b/src/std/time.c index 331f1d5..7a14f06 100644 --- a/src/std/time.c +++ b/src/std/time.c @@ -6,13 +6,12 @@ Time Time_get() { struct timespec system_time; - assert(clock_gettime(CLOCK_MONOTONIC, &system_time) == 0, "clock_gettime failed"); + assert(clock_gettime(CLOCK_MONOTONIC, &system_time) == 0, + "clock_gettime failed"); return (Time){system_time.tv_sec, system_time.tv_nsec}; } -f32 Time_ms(Time time) { - return time.s * 1e3 + time.ns / 1e6; -} +f32 Time_ms(Time time) { return time.s * 1e3 + time.ns / 1e6; } Duration Time_diff(Time end, Time start) { Duration d; @@ -25,9 +24,7 @@ Duration Time_diff(Time end, Time start) { return d; } -f32 Duration_ms(Duration d) { - return d.s * 1e3 + d.ns / 1e6; -} +f32 Duration_ms(Duration d) { return d.s * 1e3 + d.ns / 1e6; } Duration Duration_from_ms(f32 ms) { Duration d; @@ -9,12 +9,14 @@ source = { virtual = "." } dependencies = [ { name = "pysimdjson" }, { name = "ruff" }, + { name = "ty" }, ] [package.metadata] requires-dist = [ { name = "pysimdjson", specifier = ">=7.0.2" }, { name = "ruff", specifier = ">=0.12.10" }, + { name = "ty", specifier = ">=0.0.1a7" }, ] [[package]] @@ -62,3 +64,27 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ad/14/2ad38fd4037daab9e023456a4a40ed0154e9971f8d6aed41bdea390aabd9/ruff-0.12.10-py3-none-win_amd64.whl", hash = "sha256:7837eca8787f076f67aba2ca559cefd9c5cbc3a9852fd66186f4201b87c1563e", size = 13004616, upload-time = "2025-08-21T18:23:17.422Z" }, { url = "https://files.pythonhosted.org/packages/24/3c/21cf283d67af33a8e6ed242396863af195a8a6134ec581524fd22b9811b6/ruff-0.12.10-py3-none-win_arm64.whl", hash = "sha256:cc138cc06ed9d4bfa9d667a65af7172b47840e1a98b02ce7011c391e54635ffc", size = 12074225, upload-time = "2025-08-21T18:23:20.137Z" }, ] + +[[package]] +name = "ty" +version = "0.0.29" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/47/d5/853561de49fae38c519e905b2d8da9c531219608f1fccc47a0fc2c896980/ty-0.0.29.tar.gz", hash = "sha256:e7936cca2f691eeda631876c92809688dbbab68687c3473f526cd83b6a9228d8", size = 5469221, upload-time = "2026-04-05T15:01:21.328Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/03/b7/911f9962115acfa24e3b2ec9d4992dd994c38e8769e1b1d7680bb4d28a51/ty-0.0.29-py3-none-linux_armv6l.whl", hash = "sha256:b8a40955f7660d3eaceb0d964affc81b790c0765e7052921a5f861ff8a471c30", size = 10568206, upload-time = "2026-04-05T15:01:19.165Z" }, + { url = "https://files.pythonhosted.org/packages/fe/c3/fcae2167d4c77a97269f92f11d1b43b03617f81de1283d5d05b43432110c/ty-0.0.29-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6b6849adae15b00bbe2d3c5b078967dcb62eba37d38936b8eeb4c81a82d2e3b8", size = 10442530, upload-time = "2026-04-05T15:01:28.471Z" }, + { url = "https://files.pythonhosted.org/packages/97/33/5a6bfa240cfcb9c36046ae2459fa9ea23238d20130d8656ff5ac4d6c012a/ty-0.0.29-py3-none-macosx_11_0_arm64.whl", hash = "sha256:dcdd9b17209788152f7b7ea815eda07989152325052fe690013537cc7904ce49", size = 9915735, upload-time = "2026-04-05T15:01:10.365Z" }, + { url = "https://files.pythonhosted.org/packages/b3/1e/318f45fae232118e81a6306c30f50de42c509c412128d5bd231eab699ffb/ty-0.0.29-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9d8ed4789bae78ffaf94462c0d25589a734cab0366b86f2bbcb1bb90e1a7a169", size = 10419748, upload-time = "2026-04-05T15:01:32.375Z" }, + { url = "https://files.pythonhosted.org/packages/a9/a8/5687872e2ab5a0f7dd4fd8456eac31e9381ad4dc74961f6f29965ad4dd91/ty-0.0.29-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:91ec374b8565e0ad0900011c24641ebbef2da51adbd4fb69ff3280c8a7eceb02", size = 10394738, upload-time = "2026-04-05T15:01:06.473Z" }, + { url = "https://files.pythonhosted.org/packages/de/68/015d118097eeb95e6a44c4abce4c0a28b7b9dfb3085b7f0ee48e4f099633/ty-0.0.29-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:298a8d5faa2502d3810bbbb47a030b9455495b9921594206043c785dd61548cf", size = 10910613, upload-time = "2026-04-05T15:01:17.17Z" }, + { url = "https://files.pythonhosted.org/packages/1c/01/47ce3c6c53e0670eadbe80756b167bf80ed6681d1ba57cfde2e8065a13d1/ty-0.0.29-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c8fba1a3524c6109d1e020d92301c79d41bf442fa8d335b9fa366239339cb70", size = 11475750, upload-time = "2026-04-05T15:01:30.461Z" }, + { url = "https://files.pythonhosted.org/packages/c4/cf/e361845b1081c9264ad5b7c963231bab03f2666865a9f2a115c4233f2137/ty-0.0.29-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4c48adf88a70d264128c39ee922ed14a947817fced1e93c08c1a89c9244edcde", size = 11190055, upload-time = "2026-04-05T15:01:12.369Z" }, + { url = "https://files.pythonhosted.org/packages/79/12/0fb0857e9a62cb11586e9a712103877bbf717f5fb570d16634408cfdefee/ty-0.0.29-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ce0a7a0e96bc7b42518cd3a1a6a6298ef64ff40ca4614355c1aa807059b5c6f", size = 11020539, upload-time = "2026-04-05T15:01:37.022Z" }, + { url = "https://files.pythonhosted.org/packages/20/36/5a26753802083f80cd125db6c4348ad42b3c982ec36e718e0bf4c18f75e5/ty-0.0.29-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:a6ac86a05b4a3731d45365ab97780acc7b8146fa62fccb3cbe94fe6546c67a97", size = 10396399, upload-time = "2026-04-05T15:01:26.167Z" }, + { url = "https://files.pythonhosted.org/packages/00/e6/b4e75b5752239ab3ab400f19faef4dbef81d05aab5d3419fda0c062a3765/ty-0.0.29-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:6bbbf53141af0f3150bf288d716263f1a3550054e4b3551ca866d38192ba9891", size = 10421461, upload-time = "2026-04-05T15:01:08.367Z" }, + { url = "https://files.pythonhosted.org/packages/c0/21/1084b5b609f9abed62070ec0b31c283a403832a6310c8bbc208bd45ee1e6/ty-0.0.29-py3-none-musllinux_1_2_i686.whl", hash = "sha256:1c9e06b770c1d0ff5efc51e34312390db31d53fcf3088163f413030b42b74f84", size = 10599187, upload-time = "2026-04-05T15:01:23.52Z" }, + { url = "https://files.pythonhosted.org/packages/ab/a1/ce19a2ca717bbcc1ee11378aba52ef70b6ce5b87245162a729d9fdc2360f/ty-0.0.29-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:0307fe37e3f000ef1a4ae230bbaf511508a78d24a5e51b40902a21b09d5e6037", size = 11121198, upload-time = "2026-04-05T15:01:15.22Z" }, + { url = "https://files.pythonhosted.org/packages/6b/6b/f1430b279af704321566ce7ec2725d3d8258c2f815ebd93e474c64cd4543/ty-0.0.29-py3-none-win32.whl", hash = "sha256:7a2a898217960a825f8bc0087e1fdbaf379606175e98f9807187221d53a4a8ed", size = 9995331, upload-time = "2026-04-05T15:01:01.32Z" }, + { url = "https://files.pythonhosted.org/packages/d2/ef/3ef01c17785ff9a69378465c7d0faccd48a07b163554db0995e5d65a5a23/ty-0.0.29-py3-none-win_amd64.whl", hash = "sha256:fc1294200226b91615acbf34e0a9ad81caf98c081e9c6a912a31b0a7b603bc3f", size = 11023644, upload-time = "2026-04-05T15:01:04.432Z" }, + { url = "https://files.pythonhosted.org/packages/2c/55/87280a994d6a2d2647c65e12abbc997ed49835794366153c04c4d9304d76/ty-0.0.29-py3-none-win_arm64.whl", hash = "sha256:f9794bbd1bb3ce13f78c191d0c89ae4c63f52c12b6daa0c6fe220b90d019d12c", size = 10428165, upload-time = "2026-04-05T15:01:34.665Z" }, +] |
