New tests

This commit is contained in:
Dmitry Stogov 2023-10-12 15:01:27 +03:00
parent 1970a16496
commit dd227dfa25
13 changed files with 265 additions and 0 deletions

21
tests/c/ge_004.irt Normal file
View File

@ -0,0 +1,21 @@
--TEST--
004: ge function
--ARGS--
--emit-c
--CODE--
{
l_1 = START(l_4);
uint32_t x = PARAM(l_1, "x", 1);
uint32_t y = PARAM(l_1, "y", 2);
bool ret = GE(x, y);
l_4 = RETURN(l_1, ret);
}
--EXPECT--
bool test(uint32_t x, uint32_t y)
{
uint32_t d_1 = x;
uint32_t d_2 = y;
bool d_3;
d_3 = d_2 <= d_1;
return d_3;
}

21
tests/c/ge_006.irt Normal file
View File

@ -0,0 +1,21 @@
--TEST--
006: ge function
--ARGS--
--emit-c
--CODE--
{
l_1 = START(l_4);
double x = PARAM(l_1, "x", 1);
double y = PARAM(l_1, "y", 2);
bool ret = GE(x, y);
l_4 = RETURN(l_1, ret);
}
--EXPECT--
bool test(double x, double y)
{
double d_1 = x;
double d_2 = y;
bool d_3;
d_3 = d_2 <= d_1;
return d_3;
}

21
tests/c/gt_004.irt Normal file
View File

@ -0,0 +1,21 @@
--TEST--
004: gt function
--ARGS--
--emit-c
--CODE--
{
l_1 = START(l_4);
uint32_t x = PARAM(l_1, "x", 1);
uint32_t y = PARAM(l_1, "y", 2);
bool ret = GT(x, y);
l_4 = RETURN(l_1, ret);
}
--EXPECT--
bool test(uint32_t x, uint32_t y)
{
uint32_t d_1 = x;
uint32_t d_2 = y;
bool d_3;
d_3 = d_2 < d_1;
return d_3;
}

21
tests/c/gt_006.irt Normal file
View File

@ -0,0 +1,21 @@
--TEST--
006: gt function
--ARGS--
--emit-c
--CODE--
{
l_1 = START(l_4);
double x = PARAM(l_1, "x", 1);
double y = PARAM(l_1, "y", 2);
bool ret = GT(x, y);
l_4 = RETURN(l_1, ret);
}
--EXPECT--
bool test(double x, double y)
{
double d_1 = x;
double d_2 = y;
bool d_3;
d_3 = d_2 < d_1;
return d_3;
}

21
tests/c/le_004.irt Normal file
View File

@ -0,0 +1,21 @@
--TEST--
004: le function
--ARGS--
--emit-c
--CODE--
{
l_1 = START(l_4);
uint32_t x = PARAM(l_1, "x", 1);
uint32_t y = PARAM(l_1, "y", 2);
bool ret = LE(x, y);
l_4 = RETURN(l_1, ret);
}
--EXPECT--
bool test(uint32_t x, uint32_t y)
{
uint32_t d_1 = x;
uint32_t d_2 = y;
bool d_3;
d_3 = d_2 >= d_1;
return d_3;
}

21
tests/c/le_006.irt Normal file
View File

@ -0,0 +1,21 @@
--TEST--
006: le function
--ARGS--
--emit-c
--CODE--
{
l_1 = START(l_4);
double x = PARAM(l_1, "x", 1);
double y = PARAM(l_1, "y", 2);
bool ret = LE(x, y);
l_4 = RETURN(l_1, ret);
}
--EXPECT--
bool test(double x, double y)
{
double d_1 = x;
double d_2 = y;
bool d_3;
d_3 = d_2 >= d_1;
return d_3;
}

21
tests/c/lt_004.irt Normal file
View File

@ -0,0 +1,21 @@
--TEST--
004: lt function
--ARGS--
--emit-c
--CODE--
{
l_1 = START(l_4);
uint32_t x = PARAM(l_1, "x", 1);
uint32_t y = PARAM(l_1, "y", 2);
bool ret = LT(x, y);
l_4 = RETURN(l_1, ret);
}
--EXPECT--
bool test(uint32_t x, uint32_t y)
{
uint32_t d_1 = x;
uint32_t d_2 = y;
bool d_3;
d_3 = d_2 > d_1;
return d_3;
}

21
tests/c/lt_006.irt Normal file
View File

@ -0,0 +1,21 @@
--TEST--
006: lt function
--ARGS--
--emit-c
--CODE--
{
l_1 = START(l_4);
double x = PARAM(l_1, "x", 1);
double y = PARAM(l_1, "y", 2);
bool ret = LT(x, y);
l_4 = RETURN(l_1, ret);
}
--EXPECT--
bool test(double x, double y)
{
double d_1 = x;
double d_2 = y;
bool d_3;
d_3 = d_2 > d_1;
return d_3;
}

19
tests/c/not_003.irt Normal file
View File

@ -0,0 +1,19 @@
--TEST--
003: not function
--ARGS--
--emit-c
--CODE--
{
l_1 = START(l_4);
uint32_t x = PARAM(l_1, "x", 1);
bool ret = NOT(x);
l_4 = RETURN(l_1, ret);
}
--EXPECT--
bool test(uint32_t x)
{
uint32_t d_1 = x;
bool d_2;
d_2 = !d_1;
return d_2;
}

19
tests/c/not_004.irt Normal file
View File

@ -0,0 +1,19 @@
--TEST--
004: not function
--ARGS--
--emit-c
--CODE--
{
l_1 = START(l_4);
double x = PARAM(l_1, "x", 1);
bool ret = NOT(x);
l_4 = RETURN(l_1, ret);
}
--EXPECT--
bool test(double x)
{
double d_1 = x;
bool d_2;
d_2 = !d_1;
return d_2;
}

22
tests/llvm/guard_001.irt Normal file
View File

@ -0,0 +1,22 @@
--TEST--
GUARD
--ARGS--
--emit-llvm
--CODE--
{
uintptr_t exit = 0xbaddad;
l_1 = START(l_4);
int32_t cond = PARAM(l_1, "cond", 1);
l_2 = GUARD(l_1, cond, exit);
l_4 = RETURN(l_2);
}
--EXPECT--
define void @test(i32 %d2)
{
%t3 = icmp ne i32 %d2, 0
br i1 %t3, label %l3_true, label %l3_false
l3_false:
indirectbr ptr inttoptr(i64 u0xbaddad to ptr), []
l3_true:
ret void
}

22
tests/llvm/guard_002.irt Normal file
View File

@ -0,0 +1,22 @@
--TEST--
GUARD_NOT
--ARGS--
--emit-llvm
--CODE--
{
uintptr_t exit = 0xbaddad;
l_1 = START(l_4);
int32_t cond = PARAM(l_1, "cond", 1);
l_2 = GUARD_NOT(l_1, cond, exit);
l_4 = RETURN(l_2);
}
--EXPECT--
define void @test(i32 %d2)
{
%t3 = icmp ne i32 %d2, 0
br i1 %t3, label %l3_true, label %l3_false
l3_true:
indirectbr ptr inttoptr(i64 u0xbaddad to ptr), []
l3_false:
ret void
}

15
tests/llvm/ijmp_002.irt Normal file
View File

@ -0,0 +1,15 @@
--TEST--
002: IJMP - computed goto (constant addr)
--ARGS--
--emit-llvm
--CODE--
{
uintptr_t p = 0xbaddad;
l_1 = START(l_2);
l_2 = IJMP(l_1, p);
}
--EXPECT--
define void @test()
{
indirectbr ptr inttoptr(i64 u0xbaddad to ptr), []
}