mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-13 03:32:22 +00:00
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.
61 lines
1.6 KiB
Text
61 lines
1.6 KiB
Text
get ascii_slice(): slice {
|
|
return"string";
|
|
}
|
|
|
|
get raw_slice(): slice {
|
|
return "abcdef"s;
|
|
}
|
|
|
|
get addr_slice(): slice {
|
|
return "Ef8zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzM0vF"a;
|
|
}
|
|
|
|
get string_hex(): int {
|
|
return "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"u;
|
|
}
|
|
|
|
get fun string_minihash(): int { // 'get' and 'get fun' both possible
|
|
return "transfer(slice, int)"h;
|
|
}
|
|
|
|
get fun string_maxihash(): int {
|
|
return "transfer(slice, int)"H;
|
|
}
|
|
|
|
get fun string_crc32(): int {
|
|
return "transfer(slice, int)"c;
|
|
}
|
|
|
|
@pure
|
|
fun newc(): builder
|
|
asm "NEWC";
|
|
fun endcs(b: builder): slice
|
|
asm "ENDC" "CTOS";
|
|
@pure
|
|
fun sdeq(s1: slice, s2: slice): int
|
|
asm "SDEQ";
|
|
|
|
fun main() {
|
|
var s_ascii: slice = ascii_slice();
|
|
var s_raw: slice = raw_slice();
|
|
var s_addr: slice = addr_slice();
|
|
var i_hex: int = string_hex();
|
|
var i_mini: int = string_minihash();
|
|
var i_maxi: int = string_maxihash();
|
|
var i_crc: int = string_crc32();
|
|
assert(sdeq(s_ascii, newc().store_uint(0x737472696E67, 12 * 4).endcs())) throw 101;
|
|
assert(sdeq(s_raw, newc().store_uint(0xABCDEF, 6 * 4).endcs())) throw 102;
|
|
assert(sdeq(s_addr, newc().store_uint(4, 3).store_int(-1, 8)
|
|
.store_uint(0x3333333333333333333333333333333333333333333333333333333333333333, 256).endcs()), 103);
|
|
assert(i_hex == 0x4142434445464748494A4B4C4D4E4F505152535455565758595A303132333435) throw 104;
|
|
assert(i_mini == 0x7a62e8a8) throw 105;
|
|
assert(i_maxi == 0x7a62e8a8ebac41bd6de16c65e7be363bc2d2cbc6a0873778dead4795c13db979) throw 106;
|
|
assert(i_crc == 2235694568) throw 107;
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
@testcase | 0 | | 0
|
|
|
|
@code_hash 13830542019509784148027107880226447201604257839069192762244575629978154217223
|
|
*/
|