add some tests

master
Josh Wolfe 2017-09-20 21:27:13 -07:00
parent bf6d32f8cb
commit 05c1a8b3cc
1 changed files with 39 additions and 0 deletions

View File

@ -315,6 +315,28 @@ pub fn addCases(cases: &tests.ParseCContext) {
\\pub const LUA_GLOBALSINDEX = -10002; \\pub const LUA_GLOBALSINDEX = -10002;
); );
cases.add("post increment",
\\unsigned foo1(unsigned a) {
\\ a++;
\\ return a;
\\}
\\int foo2(int a) {
\\ a++;
\\ return a;
\\}
,
\\export fn foo1(_arg_a: c_uint) -> c_uint {
\\ var a = _arg_a;
\\ a +%= 1;
\\ return a;
\\}
\\export fn foo2(_arg_a: c_int) -> c_int {
\\ var a = _arg_a;
\\ a += 1;
\\ return a;
\\}
);
cases.add("shift right assign", cases.add("shift right assign",
\\int log2(unsigned a) { \\int log2(unsigned a) {
\\ int i = 0; \\ int i = 0;
@ -334,6 +356,23 @@ pub fn addCases(cases: &tests.ParseCContext) {
\\} \\}
); );
cases.add("if statement",
\\int max(int a, int b) {
\\ if (a < b)
\\ return b;
\\
\\ if (a < b)
\\ return b;
\\ else
\\ return a;
\\}
,
\\export fn max(a: c_int, b: c_int) -> c_int {
\\ if (a < b) return b;
\\ if (a < b) return b else return a;
\\}
);
cases.add("shift right assign with a fixed size type", cases.add("shift right assign with a fixed size type",
\\#include <stdint.h> \\#include <stdint.h>
\\int log2(uint32_t a) { \\int log2(uint32_t a) {