1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-13 03:32:22 +00:00
ton/tolk-tester/tests/a10.tolk
tolk-vm 12ff28ac94
[Tolk] Completely rework stdlib: multiple files and renaming
- split stdlib.tolk into multiple files (tolk-stdlib/ folder)
  (the "core" common.tolk is auto-imported, the rest are
  needed to be explicitly imported like "@stdlib/tvm-dicts.tolk")
- all functions were renamed to long and clear names
- new naming is camelCase
2024-11-02 03:44:13 +04:00

87 lines
1.5 KiB
Text

fun pair_first<X, Y>(p: [X, Y]): X asm "FIRST";
fun one(dummy: tuple) {
return 1;
}
fun main(a: int, x: int) {
var y: int = 0;
var z: int = 0;
while ((y = x * x) > a) {
x -= 1;
z = one(null);
}
return (y, z);
}
fun throwIfLt10(x: int): void {
if (x > 10) {
return;
}
throw 234;
return;
}
@method_id(88)
fun test88(x: int) {
try {
var x: void = throwIfLt10(x);
return 0;
} catch(code) {
return code;
}
}
@method_id(89)
fun test89(last: int) {
var t: tuple = createEmptyTuple();
t~tuplePush(1);
t~tuplePush(2);
t~tuplePush(3);
t~tuplePush(last);
return (t.tupleAt(0), t.tupleAt(t.tupleSize() - 1), t.tupleFirst(), t.tupleLast());
}
@method_id(93)
fun testStartBalanceCodegen1() {
var t = getMyOriginalBalanceWithExtraCurrencies();
var first = t.pair_first();
return first;
}
@method_id(94)
fun testStartBalanceCodegen2() {
var first = getMyOriginalBalance();
return first;
}
/**
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
@testcase | 0 | 100 10 | 100 0
@testcase | 88 | 5 | 234
@testcase | 88 | 50 | 0
@testcase | 89 | 4 | 1 4 1 4
@fif_codegen
"""
testStartBalanceCodegen1 PROC:<{
//
BALANCE // t
FIRST // first
}>
"""
@fif_codegen
"""
testStartBalanceCodegen2 PROC:<{
//
BALANCE
FIRST // first
}>
"""
*/