test the hello_world

This commit is contained in:
anon 2024-10-28 16:38:05 +01:00
parent 73ab612997
commit 6e67d04fcb
2 changed files with 29 additions and 0 deletions

@ -3,6 +3,22 @@ class CMDTEST_master_batch < Cmdtest::Testcase
import_file "test/file2str.h", "./"
end
def test_hw
source = "hello_world2"
import_file "test/#{source}.tbsp", "./"
cmd "tbsp -o #{source}.tb.c #{source}.tbsp" do
created_files ["#{source}.tb.c"]
end
cmd "gcc -w -o #{source}.out #{source}.tb.c $(pkg-config --cflags --libs tree-sitter tree-sitter-c)" do
created_files ["#{source}.out"]
end
cmd "./#{source}.out" do
stdout_equal /.+/
end
end
def test_converter
source = "convert"

13
test/hello_world2.tbsp Normal file

@ -0,0 +1,13 @@
%top{
int fun(void) { return 10; }
}
%language c
%%
enter translation_unit { puts("Hello World!"); }
%%
// @BAKE tbsp $@; gcc top_function.tb.c $(pkg-config --libs tree-sitter tree-sitter-c); ./a.out
signed main(void) {
tbtraverse("int i = 0;");
return 0;
}