mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[FunC] Add builtin
keyword to be used in stdlib later on
This commit is contained in:
parent
acf0043342
commit
cdef8302b0
6 changed files with 99 additions and 36 deletions
33
crypto/func/auto-tests/tests/builtin-keyword.fc
Normal file
33
crypto/func/auto-tests/tests/builtin-keyword.fc
Normal file
|
@ -0,0 +1,33 @@
|
|||
(int, int) moddiv(int x, int y) pure builtin;
|
||||
() throw_if(int excno, int cond) builtin;
|
||||
|
||||
() throwIf(int excNo, int cond) { return throw_if(excNo, cond); }
|
||||
|
||||
forall X -> int null?(X x) pure builtin;
|
||||
|
||||
_ test1() method_id(101) {
|
||||
try {
|
||||
var (rem, _) = moddiv(1, 1);
|
||||
throwIf(101, rem != 100500);
|
||||
return 0;
|
||||
} catch(_, excNo) {
|
||||
return excNo;
|
||||
}
|
||||
}
|
||||
|
||||
(int, int, int) main() {
|
||||
int x = 112;
|
||||
int y = 3;
|
||||
var wh = x~moddiv(y);
|
||||
throwIf(103, wh != 37);
|
||||
var cc = nil;
|
||||
return (wh, x, null?(cc));
|
||||
}
|
||||
|
||||
{-
|
||||
TESTCASE | 0 | | 37 1 -1
|
||||
TESTCASE | 101 | | 101
|
||||
|
||||
@fif_codegen_avoid DECLPROC moddiv
|
||||
@fif_codegen_avoid DECLPROC throwIf
|
||||
-}
|
10
crypto/func/auto-tests/tests/invalid-builtin-1.fc
Normal file
10
crypto/func/auto-tests/tests/invalid-builtin-1.fc
Normal file
|
@ -0,0 +1,10 @@
|
|||
(int, int) moddiv2(int x, int y) builtin;
|
||||
|
||||
{-
|
||||
@compilation_should_fail
|
||||
@stderr
|
||||
"""
|
||||
`builtin` used for non-builtin function
|
||||
(int, int) moddiv2
|
||||
"""
|
||||
-}
|
Loading…
Add table
Add a link
Reference in a new issue