1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

[FunC] Apply camelCase to some tests to ensure code_hash remains unchanged

In auto-tests, @code_hash controls bytecode stability.
In legacy tests, expected hashes are specified in a separate file.
This commit is contained in:
Aleksandr Kirsanov 2024-04-27 19:50:51 +05:00
parent c74e49d467
commit a174f858be
No known key found for this signature in database
GPG key ID: B758BBAA01FFB3D3
8 changed files with 85 additions and 38 deletions

View file

@ -6,6 +6,8 @@
return (Dx / D, Dy / D);
}
int mulDivR(int x, int y, int z) { return muldivr(x, y, z); }
int calc_phi() {
var n = 1;
repeat (70) { n *= 10; }
@ -13,7 +15,7 @@ int calc_phi() {
do {
(p, q) = (q, p + q);
} until (q > n);
return muldivr(p, n, q);
return mulDivR(p, n, q);
}
int calc_sqrt2() {
@ -24,7 +26,7 @@ int calc_sqrt2() {
var t = p + q;
(p, q) = (q, t + q);
} until (q > n);
return muldivr(p, n, q);
return mulDivR(p, n, q);
}
var calc_root(m) {
@ -73,14 +75,18 @@ int ataninv(int base, int q) { ;; computes base*atan(1/q)
return sum;
}
int arctanInv(int base, int q) { return ataninv(base, q); }
int calc_pi() {
int base = 64;
repeat (70) { base *= 10; }
return (ataninv(base << 2, 5) - ataninv(base, 239)) ~>> 4;
return (arctanInv(base << 2, 5) - arctanInv(base, 239)) ~>> 4;
}
int calcPi() { return calc_pi(); }
int main() {
return calc_pi();
return calcPi();
}
{-

View file

@ -6,8 +6,12 @@ forall X -> tuple unsafe_tuple(X x) asm "NOP";
return (x + y, y * 10);
}
(int, int) incWrap(int x, int y) {
return inc(x, y);
}
(int, int, int, int, int, int, int) test_return(int x) method_id(11) {
return (x, x~inc(x / 20), x, x = x * 2, x, x += 1, x);
return (x, x~incWrap(x / 20), x, x = x * 2, x, x += 1, x);
}
(int, int, int, int, int, int, int) test_assign(int x) method_id(12) {
@ -16,7 +20,7 @@ forall X -> tuple unsafe_tuple(X x) asm "NOP";
}
tuple test_tuple(int x) method_id(13) {
tuple t = unsafe_tuple([x, x~inc(x / 20), x, x = x * 2, x, x += 1, x]);
tuple t = unsafe_tuple([x, x~incWrap(x / 20), x, x = x * 2, x, x += 1, x]);
return t;
}
@ -39,7 +43,7 @@ tuple test_tuple(int x) method_id(13) {
}
(int, int, int, int, int, int, int) test_call_2(int x) method_id(16) {
return foo2(x, x~inc(x / 20), (x, x = x * 2, x, x += 1), x);
return foo2(x, x~incWrap(x / 20), (x, x = x * 2, x, x += 1), x);
}
(int, int, int, int, int, int, int) asm_func(int x1, int x2, int x3, int x4, int x5, int x6, int x7) asm
@ -52,13 +56,13 @@ tuple test_tuple(int x) method_id(13) {
#pragma compute-asm-ltr;
(int, int, int, int, int, int, int) test_call_asm_new(int x) method_id(18) {
return asm_func(x, x~inc(x / 20), x, x = x * 2, x, x += 1, x);
return asm_func(x, x~incWrap(x / 20), x, x = x * 2, x, x += 1, x);
}
global int xx;
(int, int, int, int, int, int, int) test_global(int x) method_id(19) {
xx = x;
return (xx, xx~inc(xx / 20), xx, xx = xx * 2, xx, xx += 1, xx);
return (xx, xx~incWrap(xx / 20), xx, xx = xx * 2, xx, xx += 1, xx);
}
(int, int, int, int, int) test_if_else(int x) method_id(20) {

View file

@ -1,28 +1,34 @@
tuple empty_tuple() asm "NIL";
forall X -> (tuple, ()) tpush(tuple t, X x) asm "TPUSH";
tuple emptyTuple() { return empty_tuple(); }
forall X -> (tuple, ()) tuplePush(tuple t, X value) { return tpush(t, value); }
tuple asm_func_1(int x, int y, int z) asm "3 TUPLE";
tuple asm_func_2(int x, int y, int z) asm (z y x -> 0) "3 TUPLE";
tuple asm_func_3(int x, int y, int z) asm (y z x -> 0) "3 TUPLE";
tuple asm_func_4(int a, (int, (int, int)) b, int c) asm (b a c -> 0) "5 TUPLE";
_ asmFunc1(int x, int y, int z) { return asm_func_1(x, y, z); }
_ asmFunc3(int x, int y, int z) { return asm_func_3(x, y, z); }
(tuple, ()) asm_func_modify(tuple a, int b, int c) asm (c b a -> 0) "SWAP TPUSH SWAP TPUSH";
(tuple, ()) asmFuncModify(tuple a, int b, int c) { return asm_func_modify(a, b, c); }
global tuple t;
int foo(int x) {
t~tpush(x);
t~tuplePush(x);
return x * 10;
}
(tuple, tuple) test_old_1() method_id(11) {
t = empty_tuple();
tuple t2 = asm_func_1(foo(11), foo(22), foo(33));
tuple t2 = asmFunc1(foo(11), foo(22), foo(33));
return (t, t2);
}
(tuple, tuple) test_old_2() method_id(12) {
t = empty_tuple();
t = emptyTuple();
tuple t2 = asm_func_2(foo(11), foo(22), foo(33));
return (t, t2);
}
@ -34,7 +40,7 @@ int foo(int x) {
}
(tuple, tuple) test_old_4() method_id(14) {
t = empty_tuple();
t = emptyTuple();
tuple t2 = empty_tuple();
;; This actually computes left-to-right even without compute-asm-ltr
tuple t2 = asm_func_4(foo(11), (foo(22), (foo(33), foo(44))), foo(55));
@ -44,13 +50,13 @@ int foo(int x) {
(tuple, tuple) test_old_modify() method_id(15) {
t = empty_tuple();
tuple t2 = empty_tuple();
t2~asm_func_modify(foo(22), foo(33));
t2~asmFuncModify(foo(22), foo(33));
return (t, t2);
}
(tuple, tuple) test_old_dot() method_id(16) {
t = empty_tuple();
tuple t2 = foo(11).asm_func_3(foo(22), foo(33));
tuple t2 = foo(11).asmFunc3(foo(22), foo(33));
return (t, t2);
}
@ -58,7 +64,7 @@ int foo(int x) {
(tuple, tuple) test_new_1() method_id(21) {
t = empty_tuple();
tuple t2 = asm_func_1(foo(11), foo(22), foo(33));
tuple t2 = asmFunc1(foo(11), foo(22), foo(33));
return (t, t2);
}

View file

@ -33,6 +33,10 @@ slice endcs(builder b) asm "ENDC" "CTOS";
int sdeq (slice s1, slice s2) asm "SDEQ";
builder stslicer(builder b, slice s) asm "STSLICER";
builder storeUint(builder b, int x, int len) { return store_uint(b, x, len); }
_ endSlice(builder b) { return endcs(b); }
() throwUnless(int excno, int cond) impure { return throw_unless(excno, cond); }
_ main() {
int i1 = iget1();
int i2 = iget2();
@ -46,8 +50,8 @@ _ main() {
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(int111, sdeq(s1, newc().storeUint(str1int, 12 * nibbles).endcs()));
throwUnless(112, sdeq(s2, newc().store_uint(str2int, 6 * nibbles).endSlice()));
throw_unless(113, sdeq(s3, newc().store_uint(0x636f6e737431AABBCC, 18 * nibbles).endcs()));
int i4 = iget240();

View file

@ -17,8 +17,11 @@ int foo(int y) {
}
return (x + 1, y);
}
(int,int) bar2(int x, int y) {
return bar(x, y);
}
(int, int) main(int x, int y) {
(x, y) = bar(x, y);
(x, y) = bar2(x, y);
return (x, y * 10);
}
{-