Skip to content

Commit

Permalink
Add code generation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leewei05 authored and Lai-YT committed Oct 19, 2024
1 parent e8a2b6b commit c1c13be
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/codegen/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,19 @@ int main() {
bd1.date = bd1.date + 2;
__builtin_print(bd1.date);

struct book {
int fiction;
int sci_fi;
int history;
} library = {
.fiction = 100,
.sci_fi = 50,
.history = 500,
};

__builtin_print(library.fiction);
__builtin_print(library.sci_fi);
__builtin_print(library.history);

return 0;
}
3 changes: 3 additions & 0 deletions test/codegen/struct.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
5
1998
5
100
50
500
9 changes: 9 additions & 0 deletions test/codegen/union.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,14 @@ int main() {
__builtin_print(s.circle);
__builtin_print(s.triangle);

union gender {
int male;
int female;
} girl = {
.female = 1,
};

__builtin_print(girl.female);

return 0;
}
1 change: 1 addition & 0 deletions test/codegen/union.exp
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
4
4
4
1

0 comments on commit c1c13be

Please sign in to comment.