From f616503caa683c68b8569cbd539170639868ba17 Mon Sep 17 00:00:00 2001 From: mguinhos Date: Tue, 20 Oct 2026 20:05:58 -0300 Subject: [PATCH] Harness: teste de regressao ao arrastar bloco da Caneta para o chapeu --- aa.json | 754 +++++++++++++++++++++++++++++++++++++++++ teste.json | 322 ++++++++++++++++++ tests/editor_harness.c | 18 + 3 files changed, 1094 insertions(+) create mode 100644 aa.json create mode 100644 teste.json diff --git a/aa.json b/aa.json new file mode 100644 index 0000000..dcdf444 --- /dev/null +++ b/aa.json @@ -0,0 +1,754 @@ +{ + "format": "tinyblocks-project", + "version": 1, + "cur_tab": 1, + "tabs": [ + { + "name": "Código", + "composite": false, + "comp_id": -1, + "color": 0, + "ws_sx": 0, + "ws_sy": 0, + "blocks": [ + { + "i": 0, + "type": "Events.WhenRun", + "x": 40, + "y": 40, + "parent": -1, + "prel": -1, + "next": 7, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 1, + "type": "Variables.Set", + "x": 42, + "y": 183, + "parent": 7, + "prel": 0, + "next": 2, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "x", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 2, + "type": "Control.Repeat", + "x": 0, + "y": 0, + "parent": 1, + "prel": 0, + "next": 6, + "sub": [ + 3, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "5", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 3, + "type": "Variables.Change", + "x": 0, + "y": 0, + "parent": 2, + "prel": 1, + "next": 4, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "x", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 4, + "type": "IO.Print", + "x": 0, + "y": 0, + "parent": 3, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + 5, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "x vale", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 5, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 4, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "x", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 6, + "type": "Stage.Clear", + "x": 51, + "y": 90, + "parent": 2, + "prel": 0, + "next": 9, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 7, + "type": "Stage.Clear", + "x": 55, + "y": 109, + "parent": 0, + "prel": 0, + "next": 1, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 8, + "type": "Stage.Text", + "x": 117, + "y": 406, + "parent": 9, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "Olá!", + "-40", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 9, + "type": "Stage.Clear", + "x": 43, + "y": 115, + "parent": 6, + "prel": 0, + "next": 8, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + } + ], + "top": [ + 0 + ] + }, + { + "name": "Código 2", + "composite": false, + "comp_id": -1, + "color": 0, + "ws_sx": 0, + "ws_sy": 0, + "blocks": [ + { + "i": 0, + "type": "Events.WhenRun", + "x": 229, + "y": 55, + "parent": -1, + "prel": -1, + "next": 1, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 1, + "type": "Stage.Clear", + "x": 222, + "y": 103, + "parent": 0, + "prel": 0, + "next": 2, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 2, + "type": "Stage.Background", + "x": 243, + "y": 137, + "parent": 1, + "prel": 0, + "next": 3, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "255", + "255", + "255", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 3, + "type": "Stage.Rect", + "x": 219, + "y": 345, + "parent": 2, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "0", + "0", + "120", + "80", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + } + ], + "top": [ + 0 + ] + }, + { + "name": "aa", + "composite": true, + "comp_id": 0, + "color": 0, + "ws_sx": 0, + "ws_sy": 0, + "blocks": [], + "top": [] + } + ], + "user_blocks": [ + { + "name": "aa", + "color": 0, + "tab": 2, + "inputs": [], + "outputs": [], + "parts": [] + } + ], + "variables": [] +} diff --git a/teste.json b/teste.json new file mode 100644 index 0000000..4df88b8 --- /dev/null +++ b/teste.json @@ -0,0 +1,322 @@ +{ + "format": "tinyblocks-project", + "version": 1, + "cur_tab": 0, + "tabs": [ + { + "name": "Código", + "composite": false, + "comp_id": -1, + "color": 0, + "ws_sx": 0, + "ws_sy": 0, + "blocks": [ + { + "i": 0, + "type": "Events.WhenRun", + "x": 40, + "y": 40, + "parent": -1, + "prel": -1, + "next": 1, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 1, + "type": "Variables.Set", + "x": 0, + "y": 0, + "parent": 0, + "prel": 0, + "next": 2, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "x", + "0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 2, + "type": "Control.Repeat", + "x": 0, + "y": 0, + "parent": 1, + "prel": 0, + "next": -1, + "sub": [ + 3, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "5", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 3, + "type": "Variables.Change", + "x": 0, + "y": 0, + "parent": 2, + "prel": 1, + "next": 4, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "x", + "1", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 4, + "type": "IO.Print", + "x": 0, + "y": 0, + "parent": 3, + "prel": 0, + "next": -1, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + 5, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "x vale", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + }, + { + "i": 5, + "type": "Variables.Get", + "x": 0, + "y": 0, + "parent": 4, + "prel": 4, + "next": -1, + "sub": [ + -1, + -1 + ], + "args": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "in_text": [ + "x", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "lit": "" + } + ], + "top": [ + 0 + ] + } + ], + "user_blocks": [], + "variables": [] +} diff --git a/tests/editor_harness.c b/tests/editor_harness.c index e063ef5..8c871ec 100644 --- a/tests/editor_harness.c +++ b/tests/editor_harness.c @@ -345,6 +345,24 @@ int main(void) { CHECK(any_has("Exportado xml"), "exportar XML pelo menu escreve o arquivo"); remove(expf); + /* 15. Regressao: arrastar um bloco da Caneta para o chapeu */ + if (need("Caneta", R_CAT, 0, &x, &y)) click(x, y); + frame(0, 0, 0, 0, 0, 0, NULL); + int clear_before = 0; + { float a, b; for (int k = 0; find("apague tudo", R_WS, k, &a, &b); k++) clear_before++; } + if (need("apague tudo", R_FLY, 0, &x, &y)) { + float hx, hy; + if (need("quando a bandeira for clicado", R_WS, 0, &hx, &hy)) { + float bx = hx - 3 - 10, by = hy - 18 - 18; + float gx = x - 3 - 10, gy = y - 18; + drag(x, y, x + (bx - gx), y + (by + 54 - gy) + 6); + } + } + frame(0, 0, 0, 0, 0, 0, NULL); + int clear_after = 0; + { float a, b; for (int k = 0; find("apague tudo", R_WS, k, &a, &b); k++) clear_after++; } + CHECK(clear_after == clear_before + 1, "arrastar bloco da Caneta para o chapeu"); + printf("comandos de desenho no último frame: %u\n", ncmd); tinyblocks_deinit(&rt); printf(fails ? "\n%d FALHA(S)\n" : "\nTUDO OK\n", fails);