From 6e67d04fcb090e2f3afda6f40768e58a2a0dd212 Mon Sep 17 00:00:00 2001 From: anon Date: Mon, 28 Oct 2024 16:38:05 +0100 Subject: [PATCH] test the hello_world --- test/CMDTEST_tbsp.rb | 16 ++++++++++++++++ test/hello_world2.tbsp | 13 +++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/hello_world2.tbsp diff --git a/test/CMDTEST_tbsp.rb b/test/CMDTEST_tbsp.rb index 192b32b..7e5e73c 100644 --- a/test/CMDTEST_tbsp.rb +++ b/test/CMDTEST_tbsp.rb @@ -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" diff --git a/test/hello_world2.tbsp b/test/hello_world2.tbsp new file mode 100644 index 0000000..87d9801 --- /dev/null +++ b/test/hello_world2.tbsp @@ -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; +}