"junte", "tamanho de" e o separador da lista aceitam qualquer valor
"junte [n=] (n)" saía "n=": o bloco só lia entradas de texto e tratava um número como vazio (o mesmo no "tamanho de", no literal de texto e no separador do "junte os itens"). Agora convertem como o resto (tb_block_input_text). "tamanho de" conta letras, não bytes (maçã = 4). Achado testando o servidor MCP do editor; test-stdlib cobre. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
11d6e5317b
commit
10a8099c46
4 files changed
+36
-19
No files matched your search
@@ -11,6 +11,7 @@
|
||||
#include <tb_string.h>
|
||||
#include <tb_number.h>
|
||||
#include <tb_vector.h>
|
||||
#include <tb_operators.h>
|
||||
|
||||
static int fails = 0;
|
||||
#define CHECK(c, m) do { if (c) printf("ok %s\n", m); else { printf("FAIL %s\n", m); fails++; } } while (0)
|
||||
@@ -77,6 +78,26 @@ int main(void) {
|
||||
TinyBlocks_LibraryBlock* ls = tb_library_register(rt, tb_string_get_library());
|
||||
TinyBlocks_LibraryBlock* ln = tb_library_register(rt, tb_number_get_library());
|
||||
TinyBlocks_LibraryBlock* lv = tb_library_register(rt, tb_vector_get_library());
|
||||
tb_library_register(rt, tb_operators_get_library());
|
||||
|
||||
/* entradas que nao sao texto viram texto (junte [n=] (4) = "n=4") */
|
||||
{
|
||||
TinyBlocks_Block* j = tb_block_create(rt, tb_rt_find_type(rt, "Text.Concat"));
|
||||
TinyBlocks_Value a = tb_value_text("n="), b = tb_value_integer(4);
|
||||
tb_block_set_default(j, 0, a);
|
||||
tb_block_set_default(j, 1, b);
|
||||
tb_value_free(&a);
|
||||
tb_block_eval(j, rt);
|
||||
CHECK(is_text(&j->outputs[0], "n=4"), "junte texto com número");
|
||||
tb_block_destroy(j, rt);
|
||||
TinyBlocks_Block* l = tb_block_create(rt, tb_rt_find_type(rt, "Text.Length"));
|
||||
TinyBlocks_Value n = tb_value_integer(1234);
|
||||
tb_block_set_default(l, 0, n);
|
||||
tb_block_eval(l, rt);
|
||||
CHECK(is_int(&l->outputs[0], 4), "tamanho de um número (1234 tem 4)");
|
||||
CHECK(is_int(run("Text.Length", "maçã", NULL, NULL), 4), "tamanho de conta letras (maçã = 4)");
|
||||
tb_block_destroy(l, rt);
|
||||
}
|
||||
CHECK(ls && ln && lv, "libraries string, number e vector registradas");
|
||||
CHECK(!strcmp(tb_library_category(ls)->name, "Texto") &&
|
||||
!strcmp(tb_library_category(ln)->name, "Números") &&
|
||||
|
||||
Reference in new issue
Block a user