mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Tests for func with scripts
This commit is contained in:
parent
6a72aba9af
commit
5c2ad4a6c7
25 changed files with 1011 additions and 0 deletions
17
crypto/func/auto-tests/tests/a10.fc
Normal file
17
crypto/func/auto-tests/tests/a10.fc
Normal file
|
@ -0,0 +1,17 @@
|
|||
_ main(int a, int x) {
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
while ((y = x * x) > a) {
|
||||
x -= 1;
|
||||
z = 1;
|
||||
}
|
||||
return (y, z);
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 101 15 | 100 1
|
||||
TESTCASE | 0 | 101 14 | 100 1
|
||||
TESTCASE | 0 | 101 10 | 100 0
|
||||
TESTCASE | 0 | 100 10 | 100 0
|
||||
-}
|
89
crypto/func/auto-tests/tests/a6.fc
Normal file
89
crypto/func/auto-tests/tests/a6.fc
Normal file
|
@ -0,0 +1,89 @@
|
|||
(int, int) f(int a, int b, int c, int d, int e, int f) {
|
||||
;; solve a 2x2 linear equation
|
||||
int D = a * d - b * c;
|
||||
int Dx = e * d - b * f;
|
||||
int Dy = a * f - e * c;
|
||||
return (Dx / D, Dy / D);
|
||||
}
|
||||
|
||||
int calc_phi() {
|
||||
var n = 1;
|
||||
repeat (70) { n *= 10; }
|
||||
var p = var q = 1;
|
||||
do {
|
||||
(p, q) = (q, p + q);
|
||||
} until (q > n);
|
||||
return muldivr(p, n, q);
|
||||
}
|
||||
|
||||
int calc_sqrt2() {
|
||||
var n = 1;
|
||||
repeat (70) { n *= 10; }
|
||||
var p = var q = 1;
|
||||
do {
|
||||
var t = p + q;
|
||||
(p, q) = (q, t + q);
|
||||
} until (q > n);
|
||||
return muldivr(p, n, q);
|
||||
}
|
||||
|
||||
var calc_root(m) {
|
||||
int base = 1;
|
||||
repeat(70) { base *= 10; }
|
||||
var (a, b, c) = (1, 0, - m);
|
||||
var (p1, q1, p2, q2) = (1, 0, 0, 1);
|
||||
do {
|
||||
int k = -1;
|
||||
var (a1, b1, c1) = (0, 0, 0);
|
||||
do {
|
||||
k += 1;
|
||||
(a1, b1, c1) = (a, b, c);
|
||||
c += b;
|
||||
c += b += a;
|
||||
} until (c > 0);
|
||||
(a, b, c) = (- c1, - b1, - a1);
|
||||
(p1, q1) = (k * p1 + q1, p1);
|
||||
(p2, q2) = (k * p2 + q2, p2);
|
||||
} until (p1 > base);
|
||||
return (p1, q1, p2, q2);
|
||||
}
|
||||
|
||||
{-
|
||||
operator _/%_ infix 20;
|
||||
|
||||
(int, int) ((int x) /% (int y)) {
|
||||
return (x / y, x % y);
|
||||
}
|
||||
|
||||
(int, int) _/%_ (int x, int y) {
|
||||
return (x / y, x % y);
|
||||
}
|
||||
-}
|
||||
|
||||
int ataninv(int base, int q) { ;; computes base*atan(1/q)
|
||||
base ~/= q;
|
||||
q *= - q;
|
||||
int sum = 0;
|
||||
int n = 1;
|
||||
do {
|
||||
sum += base ~/ n;
|
||||
base ~/= q;
|
||||
n += 2;
|
||||
} until base == 0;
|
||||
return sum;
|
||||
}
|
||||
|
||||
int calc_pi() {
|
||||
int base = 64;
|
||||
repeat (70) { base *= 10; }
|
||||
return (ataninv(base << 2, 5) - ataninv(base, 239)) ~>> 4;
|
||||
}
|
||||
|
||||
int main() {
|
||||
return calc_pi();
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | | 31415926535897932384626433832795028841971693993751058209749445923078164
|
||||
-}
|
16
crypto/func/auto-tests/tests/a6_1.fc
Normal file
16
crypto/func/auto-tests/tests/a6_1.fc
Normal file
|
@ -0,0 +1,16 @@
|
|||
(int, int) main(int a, int b, int c, int d, int e, int f) {
|
||||
int D = a * d - b * c;
|
||||
int Dx = e * d - b * f;
|
||||
int Dy = a * f - e * c;
|
||||
return (Dx / D, Dy / D);
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 1 1 1 -1 10 6 | 8 2
|
||||
TESTCASE | 0 | 817 -31 624 -241 132272 272276 | 132 -788
|
||||
TESTCASE | 0 | -886 562 498 -212 -36452 -68958 | -505 -861
|
||||
TESTCASE | 0 | 448 -433 -444 792 150012 -356232 | -218 -572
|
||||
TESTCASE | 0 | -40 -821 433 -734 -721629 -741724 | -206 889
|
||||
TESTCASE | 0 | -261 -98 -494 868 -166153 733738 | 263 995
|
||||
-}
|
24
crypto/func/auto-tests/tests/a6_5.fc
Normal file
24
crypto/func/auto-tests/tests/a6_5.fc
Normal file
|
@ -0,0 +1,24 @@
|
|||
var twice(f, x) {
|
||||
return f (f x);
|
||||
}
|
||||
|
||||
_ sqr(x) {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
var main(x) {
|
||||
var f = sqr;
|
||||
return twice(f, x) * f(x);
|
||||
}
|
||||
|
||||
var pow6(x) method_id(4) {
|
||||
return twice(sqr, x) * sqr(x);
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 3 | 729
|
||||
TESTCASE | 0 | 10 | 1000000
|
||||
TESTCASE | 4 | 3 | 729
|
||||
TESTCASE | 4 | 10 | 1000000
|
||||
-}
|
24
crypto/func/auto-tests/tests/a7.fc
Normal file
24
crypto/func/auto-tests/tests/a7.fc
Normal file
|
@ -0,0 +1,24 @@
|
|||
() main() { }
|
||||
int steps(int x) method_id(1) {
|
||||
var n = 0;
|
||||
while (x > 1) {
|
||||
n += 1;
|
||||
if (x & 1) {
|
||||
x = 3 * x + 1;
|
||||
} else {
|
||||
x >>= 1;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 1 | 1 | 0
|
||||
TESTCASE | 1 | 2 | 1
|
||||
TESTCASE | 1 | 5 | 5
|
||||
TESTCASE | 1 | 19 | 20
|
||||
TESTCASE | 1 | 27 | 111
|
||||
TESTCASE | 1 | 100 | 25
|
||||
-}
|
||||
|
17
crypto/func/auto-tests/tests/c2.fc
Normal file
17
crypto/func/auto-tests/tests/c2.fc
Normal file
|
@ -0,0 +1,17 @@
|
|||
global ((int, int) -> int) op;
|
||||
|
||||
int check_assoc(int a, int b, int c) {
|
||||
return op(op(a, b), c) == op(a, op(b, c));
|
||||
}
|
||||
|
||||
int main(int x, int y, int z) {
|
||||
op = _+_;
|
||||
return check_assoc(x, y, z);
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 2 3 9 | -1
|
||||
TESTCASE | 0 | 11 22 44 | -1
|
||||
TESTCASE | 0 | -1 -10 -20 | -1
|
||||
-}
|
14
crypto/func/auto-tests/tests/c2_1.fc
Normal file
14
crypto/func/auto-tests/tests/c2_1.fc
Normal file
|
@ -0,0 +1,14 @@
|
|||
_ check_assoc(op, a, b, c) {
|
||||
return op(op(a, b), c) == op(a, op(b, c));
|
||||
}
|
||||
|
||||
int main(int x, int y, int z) {
|
||||
return check_assoc(_+_, x, y, z);
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 2 3 9 | -1
|
||||
TESTCASE | 0 | 11 22 44 | -1
|
||||
TESTCASE | 0 | -1 -10 -20 | -1
|
||||
-}
|
60
crypto/func/auto-tests/tests/co1.fc
Normal file
60
crypto/func/auto-tests/tests/co1.fc
Normal file
|
@ -0,0 +1,60 @@
|
|||
const int1 = 1, int2 = 2;
|
||||
|
||||
const int int101 = 101;
|
||||
const int int111 = 111;
|
||||
|
||||
const int1r = int1;
|
||||
|
||||
const str1 = "const1", str2 = "aabbcc"s;
|
||||
|
||||
const slice str2r = str2;
|
||||
|
||||
const str1int = 0x636f6e737431;
|
||||
const str2int = 0xAABBCC;
|
||||
|
||||
const int nibbles = 4;
|
||||
|
||||
int iget1() { return int1; }
|
||||
int iget2() { return int2; }
|
||||
int iget3() { return int1 + int2; }
|
||||
|
||||
int iget1r() { return int1r; }
|
||||
|
||||
slice sget1() { return str1; }
|
||||
slice sget2() { return str2; }
|
||||
slice sget2r() { return str2r; }
|
||||
|
||||
const int int240 = ((int1 + int2) * 10) << 3;
|
||||
|
||||
int iget240() { return int240; }
|
||||
|
||||
builder newc() asm "NEWC";
|
||||
slice endcs(builder b) asm "ENDC" "CTOS";
|
||||
int sdeq (slice s1, slice s2) asm "SDEQ";
|
||||
builder stslicer(builder b, slice s) asm "STSLICER";
|
||||
|
||||
_ main() {
|
||||
int i1 = iget1();
|
||||
int i2 = iget2();
|
||||
int i3 = iget3();
|
||||
|
||||
throw_unless(int101, i1 == 1);
|
||||
throw_unless(102, i2 == 2);
|
||||
throw_unless(103, i3 == 3);
|
||||
|
||||
slice s1 = sget1();
|
||||
slice s2 = sget2();
|
||||
slice s3 = newc().stslicer(str1).stslicer(str2r).endcs();
|
||||
|
||||
throw_unless(int111, sdeq(s1, newc().store_uint(str1int, 12 * nibbles).endcs()));
|
||||
throw_unless(112, sdeq(s2, newc().store_uint(str2int, 6 * nibbles).endcs()));
|
||||
throw_unless(113, sdeq(s3, newc().store_uint(0x636f6e737431AABBCC, 18 * nibbles).endcs()));
|
||||
|
||||
int i4 = iget240();
|
||||
throw_unless(104, i4 == 240);
|
||||
return 0;
|
||||
}
|
||||
|
||||
{-
|
||||
TESTCASE | 0 | | 0
|
||||
-}
|
19
crypto/func/auto-tests/tests/code_after_ifelse.fc
Normal file
19
crypto/func/auto-tests/tests/code_after_ifelse.fc
Normal file
|
@ -0,0 +1,19 @@
|
|||
int foo(int x) inline method_id(1) {
|
||||
if (x == 1) {
|
||||
return 111;
|
||||
} else {
|
||||
x *= 2;
|
||||
}
|
||||
return x + 1;
|
||||
}
|
||||
(int, int) main(int x) {
|
||||
return (foo(x), 222);
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 1 | 1 | 111
|
||||
TESTCASE | 1 | 3 | 7
|
||||
TESTCASE | 0 | 1 | 111 222
|
||||
TESTCASE | 0 | 3 | 7 222
|
||||
-}
|
61
crypto/func/auto-tests/tests/inline_big.fc
Normal file
61
crypto/func/auto-tests/tests/inline_big.fc
Normal file
|
@ -0,0 +1,61 @@
|
|||
int foo(int x) inline {
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
x = x * 10 + 1;
|
||||
return x;
|
||||
}
|
||||
|
||||
(int) main(int x) {
|
||||
return foo(x) * 10 + 5;
|
||||
}
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 9 | 9111111111111111111111111111111111111111111111111115
|
||||
-}
|
26
crypto/func/auto-tests/tests/inline_if.fc
Normal file
26
crypto/func/auto-tests/tests/inline_if.fc
Normal file
|
@ -0,0 +1,26 @@
|
|||
int foo1(int x) {
|
||||
if (x == 1) {
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
int foo2(int x) inline {
|
||||
if (x == 1) {
|
||||
return 11;
|
||||
}
|
||||
return 22;
|
||||
}
|
||||
int foo3(int x) inline_ref {
|
||||
if (x == 1) {
|
||||
return 111;
|
||||
}
|
||||
return 222;
|
||||
}
|
||||
(int, int, int) main(int x) {
|
||||
return (foo1(x) + 1, foo2(x) + 1, foo3(x) + 1);
|
||||
}
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 1 | 2 12 112
|
||||
TESTCASE | 0 | 2 | 3 23 223
|
||||
-}
|
43
crypto/func/auto-tests/tests/inline_loops.fc
Normal file
43
crypto/func/auto-tests/tests/inline_loops.fc
Normal file
|
@ -0,0 +1,43 @@
|
|||
global int g;
|
||||
|
||||
_ foo_repeat() impure inline {
|
||||
g = 1;
|
||||
repeat(5) {
|
||||
g *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
int foo_until() impure inline {
|
||||
g = 1;
|
||||
int i = 0;
|
||||
do {
|
||||
g *= 2;
|
||||
i += 1;
|
||||
} until (i >= 8);
|
||||
return i;
|
||||
}
|
||||
|
||||
int foo_while() impure inline {
|
||||
g = 1;
|
||||
int i = 0;
|
||||
while (i < 10) {
|
||||
g *= 2;
|
||||
i += 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
_ main() {
|
||||
foo_repeat();
|
||||
int x = g;
|
||||
foo_until();
|
||||
int y = g;
|
||||
foo_while();
|
||||
int z = g;
|
||||
return (x, y, z);
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | | 32 256 1024
|
||||
-}
|
12
crypto/func/auto-tests/tests/method_id.fc
Normal file
12
crypto/func/auto-tests/tests/method_id.fc
Normal file
|
@ -0,0 +1,12 @@
|
|||
int foo1() method_id(1) { return 111; }
|
||||
int foo2() method_id(3) { return 222; }
|
||||
int foo3() method_id(10) { return 333; }
|
||||
int main() { return 999; }
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 1 | | 111
|
||||
TESTCASE | 3 | | 222
|
||||
TESTCASE | 10 | | 333
|
||||
TESTCASE | 0 | | 999
|
||||
-}
|
54
crypto/func/auto-tests/tests/s1.fc
Normal file
54
crypto/func/auto-tests/tests/s1.fc
Normal file
|
@ -0,0 +1,54 @@
|
|||
slice ascii_slice() method_id {
|
||||
return "string";
|
||||
}
|
||||
|
||||
slice raw_slice() method_id {
|
||||
return "abcdef"s;
|
||||
}
|
||||
|
||||
slice addr_slice() method_id {
|
||||
return "Ef8zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzM0vF"a;
|
||||
}
|
||||
|
||||
int string_hex() method_id {
|
||||
return "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"u;
|
||||
}
|
||||
|
||||
int string_minihash() method_id {
|
||||
return "transfer(slice, int)"h;
|
||||
}
|
||||
|
||||
int string_maxihash() method_id {
|
||||
return "transfer(slice, int)"H;
|
||||
}
|
||||
|
||||
int string_crc32() method_id {
|
||||
return "transfer(slice, int)"c;
|
||||
}
|
||||
|
||||
builder newc() asm "NEWC";
|
||||
slice endcs(builder b) asm "ENDC" "CTOS";
|
||||
int sdeq (slice s1, slice s2) asm "SDEQ";
|
||||
|
||||
_ main() {
|
||||
slice s_ascii = ascii_slice();
|
||||
slice s_raw = raw_slice();
|
||||
slice s_addr = addr_slice();
|
||||
int i_hex = string_hex();
|
||||
int i_mini = string_minihash();
|
||||
int i_maxi = string_maxihash();
|
||||
int i_crc = string_crc32();
|
||||
throw_unless(101, sdeq(s_ascii, newc().store_uint(0x737472696E67, 12 * 4).endcs()));
|
||||
throw_unless(102, sdeq(s_raw, newc().store_uint(0xABCDEF, 6 * 4).endcs()));
|
||||
throw_unless(103, sdeq(s_addr, newc().store_uint(4, 3).store_int(-1, 8)
|
||||
.store_uint(0x3333333333333333333333333333333333333333333333333333333333333333, 256).endcs()));
|
||||
throw_unless(104, i_hex == 0x4142434445464748494A4B4C4D4E4F505152535455565758595A303132333435);
|
||||
throw_unless(105, i_mini == 0x7a62e8a8);
|
||||
throw_unless(106, i_maxi == 0x7a62e8a8ebac41bd6de16c65e7be363bc2d2cbc6a0873778dead4795c13db979);
|
||||
throw_unless(107, i_crc == 2235694568);
|
||||
return 0;
|
||||
}
|
||||
|
||||
{-
|
||||
TESTCASE | 0 | | 0
|
||||
-}
|
17
crypto/func/auto-tests/tests/unbalanced_ret.fc
Normal file
17
crypto/func/auto-tests/tests/unbalanced_ret.fc
Normal file
|
@ -0,0 +1,17 @@
|
|||
(int, int) main(int x) {
|
||||
int y = 5;
|
||||
if (x < 0) {
|
||||
x *= 2;
|
||||
y += 1;
|
||||
if (x == -10) {
|
||||
return (111, 0);
|
||||
}
|
||||
}
|
||||
return (x + 1, y);
|
||||
}
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 10 | 11 5
|
||||
TESTCASE | 0 | -5 | 111 0
|
||||
TESTCASE | 0 | -4 | -7 6
|
||||
-}
|
18
crypto/func/auto-tests/tests/unbalanced_ret_inline.fc
Normal file
18
crypto/func/auto-tests/tests/unbalanced_ret_inline.fc
Normal file
|
@ -0,0 +1,18 @@
|
|||
int foo(int x) inline {
|
||||
if (x < 0) {
|
||||
x *= 2;
|
||||
if (x == -10) {
|
||||
return 111;
|
||||
}
|
||||
}
|
||||
return x + 1;
|
||||
}
|
||||
int main(int x) {
|
||||
return foo(x) * 10;
|
||||
}
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 10 | 110
|
||||
TESTCASE | 0 | -5 | 1110
|
||||
TESTCASE | 0 | -4 | -70
|
||||
-}
|
48
crypto/func/auto-tests/tests/unbalanced_ret_loops.fc
Normal file
48
crypto/func/auto-tests/tests/unbalanced_ret_loops.fc
Normal file
|
@ -0,0 +1,48 @@
|
|||
_ main() { }
|
||||
|
||||
int foo_repeat(int x) method_id(1) {
|
||||
repeat(10) {
|
||||
x += 10;
|
||||
if (x >= 100) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int foo_while(int x) method_id(2) {
|
||||
int i = 0;
|
||||
while (i < 10) {
|
||||
x += 10;
|
||||
if (x >= 100) {
|
||||
return x;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int foo_until(int x) method_id(3) {
|
||||
int i = 0;
|
||||
do {
|
||||
x += 10;
|
||||
if (x >= 100) {
|
||||
return x;
|
||||
}
|
||||
i += 1;
|
||||
} until (i >= 10);
|
||||
return -1;
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 1 | 40 | 100
|
||||
TESTCASE | 1 | 33 | 103
|
||||
TESTCASE | 1 | -5 | -1
|
||||
TESTCASE | 2 | 40 | 100
|
||||
TESTCASE | 2 | 33 | 103
|
||||
TESTCASE | 2 | -5 | -1
|
||||
TESTCASE | 3 | 40 | 100
|
||||
TESTCASE | 3 | 33 | 103
|
||||
TESTCASE | 3 | -5 | -1
|
||||
-}
|
35
crypto/func/auto-tests/tests/unbalanced_ret_nested.fc
Normal file
35
crypto/func/auto-tests/tests/unbalanced_ret_nested.fc
Normal file
|
@ -0,0 +1,35 @@
|
|||
int foo(int y) {
|
||||
if (y < 0) {
|
||||
y *= 2;
|
||||
if (y == -10) {
|
||||
return 111;
|
||||
}
|
||||
}
|
||||
return y + 1;
|
||||
}
|
||||
(int, int) bar(int x, int y) {
|
||||
if (x < 0) {
|
||||
y = foo(y);
|
||||
x *= 2;
|
||||
if (x == -10) {
|
||||
return (111, y);
|
||||
}
|
||||
}
|
||||
return (x + 1, y);
|
||||
}
|
||||
(int, int) main(int x, int y) {
|
||||
(x, y) = bar(x, y);
|
||||
return (x, y * 10);
|
||||
}
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 3 3 | 4 30
|
||||
TESTCASE | 0 | 3 -5 | 4 -50
|
||||
TESTCASE | 0 | 3 -4 | 4 -40
|
||||
TESTCASE | 0 | -5 3 | 111 40
|
||||
TESTCASE | 0 | -5 -5 | 111 1110
|
||||
TESTCASE | 0 | -5 -4 | 111 -70
|
||||
TESTCASE | 0 | -4 3 | -7 40
|
||||
TESTCASE | 0 | -4 -5 | -7 1110
|
||||
TESTCASE | 0 | -4 -4 | -7 -70
|
||||
-}
|
14
crypto/func/auto-tests/tests/w1.fc
Normal file
14
crypto/func/auto-tests/tests/w1.fc
Normal file
|
@ -0,0 +1,14 @@
|
|||
(int, int) main(int id) {
|
||||
if (id > 0) {
|
||||
if (id > 10) {
|
||||
return (2 * id, 3 * id);
|
||||
}
|
||||
}
|
||||
return (5, 6);
|
||||
}
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 0 | 5 6
|
||||
TESTCASE | 0 | 4 | 5 6
|
||||
TESTCASE | 0 | 11 | 22 33
|
||||
-}
|
18
crypto/func/auto-tests/tests/w2.fc
Normal file
18
crypto/func/auto-tests/tests/w2.fc
Normal file
|
@ -0,0 +1,18 @@
|
|||
_ f(cs) {
|
||||
return (cs~load_uint(8), cs~load_uint(8), cs~load_uint(8), cs~load_uint(8),
|
||||
cs~load_uint(8), cs~load_uint(8), cs~load_uint(8), cs~load_uint(8),
|
||||
cs~load_uint(8), cs~load_uint(8), cs~load_uint(8), cs~load_uint(8),
|
||||
cs~load_uint(8), cs~load_uint(8), cs~load_uint(8), cs~load_uint(8),
|
||||
cs~load_uint(8), cs~load_uint(8), cs~load_uint(8), cs~load_uint(8));
|
||||
}
|
||||
|
||||
_ main(cs) {
|
||||
var (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10,
|
||||
x11, x12, x13, x14, x15, x16, x17, x18, x19) = f(cs);
|
||||
return x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9
|
||||
+ x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17 + x18 + x19;
|
||||
}
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | x{000102030405060708090a0b0c0d0e0f10111213} | 190
|
||||
-}
|
17
crypto/func/auto-tests/tests/w6.fc
Normal file
17
crypto/func/auto-tests/tests/w6.fc
Normal file
|
@ -0,0 +1,17 @@
|
|||
int main(int x) {
|
||||
int i = 0;
|
||||
;; int f = false;
|
||||
do {
|
||||
i = i + 1;
|
||||
if (i > 5) {
|
||||
return 1;
|
||||
}
|
||||
int f = (i * i == 64);
|
||||
} until (f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 0 | 1
|
||||
-}
|
24
crypto/func/auto-tests/tests/w7.fc
Normal file
24
crypto/func/auto-tests/tests/w7.fc
Normal file
|
@ -0,0 +1,24 @@
|
|||
int test(int y) method_id(1) {
|
||||
int x = 1;
|
||||
if (y > 0) {
|
||||
return 1;
|
||||
}
|
||||
return x > 0;
|
||||
}
|
||||
|
||||
int f(int y) method_id(2) {
|
||||
if (y > 0) {
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
_ main() { }
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 1 | 10 | 1
|
||||
TESTCASE | 1 | -5 | -1
|
||||
TESTCASE | 2 | 10 | 1
|
||||
TESTCASE | 2 | -5 | 2
|
||||
-}
|
14
crypto/func/auto-tests/tests/w9.fc
Normal file
14
crypto/func/auto-tests/tests/w9.fc
Normal file
|
@ -0,0 +1,14 @@
|
|||
_ main(s) {
|
||||
var (z, t) = (17, s);
|
||||
while (z > 0) {
|
||||
t = s;
|
||||
z -= 1;
|
||||
}
|
||||
return ~ t;
|
||||
}
|
||||
|
||||
{-
|
||||
method_id | in | out
|
||||
TESTCASE | 0 | 1 | -2
|
||||
TESTCASE | 0 | 5 | -6
|
||||
-}
|
Loading…
Add table
Add a link
Reference in a new issue