Skip to content

Commit

Permalink
Modified CodeGeneratorTest to use all command line options.
Browse files Browse the repository at this point in the history
  • Loading branch information
clnhlzmn committed Mar 22, 2021
1 parent 8ea7ef9 commit 99d158b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
3 changes: 2 additions & 1 deletion makina-compiler/test/code_generator_test/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
out
out
.vscode
4 changes: 2 additions & 2 deletions makina-compiler/test/code_generator_test/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ test: out/test
./out/test

out/test: test_driver.c out/test.c out/test.h out
gcc test_driver.c out/test.c -std=c99 -Wall -Wextra -o out/test
gcc test_driver.c out/test.c -I "." -std=c99 -Wall -Wextra -o out/test

out/test.c:
java -jar ../../out/artifacts/makina_compiler_jar/makina-compiler.jar test_source.mkna -o out
java -jar ../../out/artifacts/makina_compiler_jar/makina-compiler.jar test_source.mkna -m "struct machine_data" -e "struct event_data" -i "test_data.h" -o out

out:
mkdir out
Expand Down
12 changes: 12 additions & 0 deletions makina-compiler/test/code_generator_test/test_data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef TEST_DATA_H
#define TEST_DATA_H

struct machine_data {
char _;
};

struct event_data {
int guard;
};

#endif /*TEST_DATA_H*/
17 changes: 7 additions & 10 deletions makina-compiler/test/code_generator_test/test_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ int s1_s2_entry(struct test *self, struct test_event *event) {
return 0;
}

int s1_s2_e1_guard_value = 0;

int s1_s2_e1_guard(struct test *self, struct test_event *event) {
fprintf(output, "s1_s2_e1_guard\n");
return s1_s2_e1_guard_value;
return event->ctx.guard;
}

int s1_s2_e1_action(struct test *self, struct test_event *event) {
Expand Down Expand Up @@ -75,13 +73,12 @@ int main (void) {
output = fopen("out/test_output.txt", "w+");
struct test instance;
test_init(&instance); //s1_entry, s1_s2_entry
test_process_event(&instance, &(struct test_event) {.id = test_event_e1}); //s1_s2_e1_guard, s1_s2_exit, s1_exit, s2_entry, s2_s1_entry
test_process_event(&instance, &(struct test_event) {.id = test_event_e2}); //...
test_process_event(&instance, &(struct test_event) {.id = test_event_e1}); //s2_s1_exit, s2_exit, s2_s1_e1_action, s1_entry, s1_s2_entry
s1_s2_e1_guard_value = 1;
test_process_event(&instance, &(struct test_event) {.id = test_event_e1}); //s1_s2_e1_guard, s1_s2_e1_action
test_process_event(&instance, &(struct test_event) {.id = test_event_e2}); //s1_s2_exit, s1_exit, s2_entry, s2_s3_entry
test_process_event(&instance, &(struct test_event) {.id = test_event_e2}); //s2_s3_exit, s2_exit, s1_entry, s1_s2_entry
test_process_event(&instance, &(struct test_event) {.id = test_event_e1, .ctx = (struct event_data){0}}); //s1_s2_e1_guard, s1_s2_exit, s1_exit, s2_entry, s2_s1_entry
test_process_event(&instance, &(struct test_event) {.id = test_event_e2, .ctx = (struct event_data){0}}); //...
test_process_event(&instance, &(struct test_event) {.id = test_event_e1, .ctx = (struct event_data){0}}); //s2_s1_exit, s2_exit, s2_s1_e1_action, s1_entry, s1_s2_entry
test_process_event(&instance, &(struct test_event) {.id = test_event_e1, .ctx = (struct event_data){1}}); //s1_s2_e1_guard, s1_s2_e1_action
test_process_event(&instance, &(struct test_event) {.id = test_event_e2, .ctx = (struct event_data){0}}); //s1_s2_exit, s1_exit, s2_entry, s2_s3_entry
test_process_event(&instance, &(struct test_event) {.id = test_event_e2, .ctx = (struct event_data){0}}); //s2_s3_exit, s2_exit, s1_entry, s1_s2_entry
fclose(output);
return 0;
}

0 comments on commit 99d158b

Please sign in to comment.