mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[Tolk] v0.6 syntax: fun
, import
, var
, types on the right, etc.
Lots of changes, actually. Most noticeable are: - traditional //comments - #include -> import - a rule "import what you use" - ~ found -> !found (for -1/0) - null() -> null - is_null?(v) -> v == null - throw is a keyword - catch with swapped arguments - throw_if, throw_unless -> assert - do until -> do while - elseif -> else if - drop ifnot, elseifnot - drop rarely used operators A testing framework also appears here. All tests existed earlier, but due to significant syntax changes, their history is useless.
This commit is contained in:
parent
5a3e3595d6
commit
e2edadba92
133 changed files with 8196 additions and 2605 deletions
145
tolk-tester/tests/asm_arg_order.tolk
Normal file
145
tolk-tester/tests/asm_arg_order.tolk
Normal file
|
@ -0,0 +1,145 @@
|
|||
@pure
|
||||
fun empty_tuple2(): tuple
|
||||
asm "NIL";
|
||||
@pure
|
||||
fun tpush2<X>(t: tuple, x: X): (tuple, ())
|
||||
asm "TPUSH";
|
||||
fun emptyTuple(): tuple { return empty_tuple2(); }
|
||||
fun tuplePush<X>(t: tuple, value: X): (tuple, ()) { return tpush2(t, value); }
|
||||
|
||||
@pure
|
||||
fun asm_func_1(x: int, y: int, z: int): tuple
|
||||
asm "3 TUPLE";
|
||||
@pure
|
||||
fun asm_func_2(x: int, y: int, z: int): tuple
|
||||
asm (z y x -> 0) "3 TUPLE";
|
||||
@pure
|
||||
fun asm_func_3(x: int, y: int, z: int): tuple
|
||||
asm (y z x -> 0) "3 TUPLE";
|
||||
@pure
|
||||
fun asm_func_4(a: int, b: (int, (int, int)), c: int): tuple
|
||||
asm (b a c -> 0) "5 TUPLE";
|
||||
|
||||
fun asmFunc1(x: int, y: int, z: int): tuple { return asm_func_1(x, y, z); }
|
||||
fun asmFunc3(x: int, y: int, z: int): tuple { return asm_func_3(x, y, z); }
|
||||
|
||||
@pure
|
||||
fun asm_func_modify(a: tuple, b: int, c: int): (tuple, ())
|
||||
asm (c b a -> 0) "SWAP TPUSH SWAP TPUSH";
|
||||
fun asmFuncModify(a: tuple, b: int, c: int): (tuple, ()) { return asm_func_modify(a, b, c); }
|
||||
|
||||
global t: tuple;
|
||||
|
||||
fun foo(x: int): int {
|
||||
t~tuplePush(x);
|
||||
return x * 10;
|
||||
}
|
||||
|
||||
@method_id(11)
|
||||
fun test_old_1(): (tuple, tuple) {
|
||||
t = empty_tuple2();
|
||||
var t2: tuple = asmFunc1(foo(11), foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(12)
|
||||
fun test_old_2(): (tuple, tuple) {
|
||||
t = emptyTuple();
|
||||
var t2: tuple = asm_func_2(foo(11), foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(13)
|
||||
fun test_old_3(): (tuple, tuple) {
|
||||
t = empty_tuple2();
|
||||
var t2: tuple = asm_func_3(foo(11), foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(14)
|
||||
fun test_old_4(): (tuple, tuple) {
|
||||
t = emptyTuple();
|
||||
var t2: tuple = empty_tuple2();
|
||||
// This actually computes left-to-right even without compute-asm-ltr
|
||||
t2 = asm_func_4(foo(11), (foo(22), (foo(33), foo(44))), foo(55));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(15)
|
||||
fun test_old_modify(): (tuple, tuple) {
|
||||
t = empty_tuple2();
|
||||
var t2: tuple = empty_tuple2();
|
||||
t2~asmFuncModify(foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(16)
|
||||
fun test_old_dot(): (tuple, tuple) {
|
||||
t = empty_tuple2();
|
||||
var t2: tuple = foo(11).asmFunc3(foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(21)
|
||||
fun test_new_1(): (tuple, tuple) {
|
||||
t = empty_tuple2();
|
||||
var t2: tuple = asmFunc1(foo(11), foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(22)
|
||||
fun test_new_2(): (tuple, tuple) {
|
||||
t = empty_tuple2();
|
||||
var t2: tuple = asm_func_2(foo(11), foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(23)
|
||||
fun test_new_3(): (tuple, tuple) {
|
||||
t = empty_tuple2();
|
||||
var t2: tuple = asm_func_3(foo(11), foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(24)
|
||||
fun test_new_4(): (tuple, tuple) {
|
||||
t = empty_tuple2();
|
||||
var t2: tuple = asm_func_4(foo(11), (foo(22), (foo(33), foo(44))), foo(55));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(25)
|
||||
fun test_new_modify(): (tuple, tuple) {
|
||||
t = empty_tuple2();
|
||||
var t2: tuple = empty_tuple2();
|
||||
t2~asm_func_modify(foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
@method_id(26)
|
||||
fun test_new_dot(): (tuple, tuple) {
|
||||
t = empty_tuple2();
|
||||
var t2: tuple = foo(11).asm_func_3(foo(22), foo(33));
|
||||
return (t, t2);
|
||||
}
|
||||
|
||||
fun main() {
|
||||
}
|
||||
|
||||
/**
|
||||
method_id | in | out
|
||||
@testcase | 11 | | [ 11 22 33 ] [ 110 220 330 ]
|
||||
@testcase | 12 | | [ 11 22 33 ] [ 330 220 110 ]
|
||||
@testcase | 13 | | [ 11 22 33 ] [ 220 330 110 ]
|
||||
@testcase | 14 | | [ 11 22 33 44 55 ] [ 220 330 440 110 550 ]
|
||||
@testcase | 15 | | [ 22 33 ] [ 220 330 ]
|
||||
@testcase | 16 | | [ 11 22 33 ] [ 220 330 110 ]
|
||||
@testcase | 21 | | [ 11 22 33 ] [ 110 220 330 ]
|
||||
@testcase | 22 | | [ 11 22 33 ] [ 330 220 110 ]
|
||||
@testcase | 23 | | [ 11 22 33 ] [ 220 330 110 ]
|
||||
@testcase | 24 | | [ 11 22 33 44 55 ] [ 220 330 440 110 550 ]
|
||||
@testcase | 25 | | [ 22 33 ] [ 220 330 ]
|
||||
@testcase | 26 | | [ 11 22 33 ] [ 220 330 110 ]
|
||||
|
||||
@code_hash 93068291567112337250118419287631047120002003622184251973082208096953112184588
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue