Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions server/src/e2e/tolk/testcases/completion/keywords.test
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ fun foo() {
2 createEmptyCell(): cell
2 createEmptyDict(): dict
2 createEmptyList(): tuple
2 createEmptyMap<K, V>(): map<K, V>
2 createEmptySlice(): slice
2 createEmptyTuple(): tuple
2 createExternalLogMessage<TBody>(options: CreateExternalLogMessageOptions<TBody>): OutMessage
2 createMapFromLowLevelDict<K, V>(d: dict): map<K, V>
2 createMessage<TBody>(options: CreateMessageOptions<TBody>): OutMessage
2 divMod(x: int, y: int): (int, int)
2 foo()
Expand Down Expand Up @@ -121,6 +123,8 @@ fun foo() {
21 ExtOutLogBucket {}
21 InMessage {}
21 InMessageBounced {}
21 MapEntry {}
21 MapLookupResult {}
21 OutMessage {}
21 PackOptions {}
21 StateInit {}
Expand All @@ -129,8 +133,9 @@ fun foo() {
21 blockchain
21 contract
21 debug
21 map
21 random
24 ExtraCurrenciesDict
24 ExtraCurrenciesMap
24 RemainingBitsAndRefs
24 address
24 bits256
Expand Down Expand Up @@ -243,9 +248,11 @@ fun foo() {
2 createEmptyCell(): cell
2 createEmptyDict(): dict
2 createEmptyList(): tuple
2 createEmptyMap<K, V>(): map<K, V>
2 createEmptySlice(): slice
2 createEmptyTuple(): tuple
2 createExternalLogMessage<TBody>(options: CreateExternalLogMessageOptions<TBody>): OutMessage
2 createMapFromLowLevelDict<K, V>(d: dict): map<K, V>
2 createMessage<TBody>(options: CreateMessageOptions<TBody>): OutMessage
2 divMod(x: int, y: int): (int, int)
2 foo()
Expand Down Expand Up @@ -307,6 +314,8 @@ fun foo() {
21 ExtOutLogBucket {}
21 InMessage {}
21 InMessageBounced {}
21 MapEntry {}
21 MapLookupResult {}
21 OutMessage {}
21 PackOptions {}
21 StateInit {}
Expand All @@ -315,8 +324,9 @@ fun foo() {
21 blockchain
21 contract
21 debug
21 map
21 random
24 ExtraCurrenciesDict
24 ExtraCurrenciesMap
24 RemainingBitsAndRefs
24 address
24 bits256
Expand Down Expand Up @@ -418,9 +428,11 @@ fun foo() {
2 createEmptyCell(): cell
2 createEmptyDict(): dict
2 createEmptyList(): tuple
2 createEmptyMap<K, V>(): map<K, V>
2 createEmptySlice(): slice
2 createEmptyTuple(): tuple
2 createExternalLogMessage<TBody>(options: CreateExternalLogMessageOptions<TBody>): OutMessage
2 createMapFromLowLevelDict<K, V>(d: dict): map<K, V>
2 createMessage<TBody>(options: CreateMessageOptions<TBody>): OutMessage
2 divMod(x: int, y: int): (int, int)
2 foo()
Expand Down Expand Up @@ -482,6 +494,8 @@ fun foo() {
21 ExtOutLogBucket {}
21 InMessage {}
21 InMessageBounced {}
21 MapEntry {}
21 MapLookupResult {}
21 OutMessage {}
21 PackOptions {}
21 StateInit {}
Expand All @@ -490,8 +504,9 @@ fun foo() {
21 blockchain
21 contract
21 debug
21 map
21 random
24 ExtraCurrenciesDict
24 ExtraCurrenciesMap
24 RemainingBitsAndRefs
24 address
24 bits256
Expand Down
5 changes: 4 additions & 1 deletion server/src/e2e/tolk/testcases/completion/struct.test
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ struct Foo {
21 Foo
21 InMessage
21 InMessageBounced
21 MapEntry
21 MapLookupResult
21 OutMessage
21 PackOptions
21 StateInit
Expand All @@ -71,8 +73,9 @@ struct Foo {
21 blockchain
21 contract
21 debug
21 map
21 random
24 ExtraCurrenciesDict
24 ExtraCurrenciesMap
24 RemainingBitsAndRefs
24 address
24 bits256
Expand Down
7 changes: 6 additions & 1 deletion server/src/e2e/tolk/testcases/completion/top-level.test
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ fun foo() {
2 createEmptyCell(): cell
2 createEmptyDict(): dict
2 createEmptyList(): tuple
2 createEmptyMap<K, V>(): map<K, V>
2 createEmptySlice(): slice
2 createEmptyTuple(): tuple
2 createExternalLogMessage<TBody>(options: CreateExternalLogMessageOptions<TBody>): OutMessage
2 createMapFromLowLevelDict<K, V>(d: dict): map<K, V>
2 createMessage<TBody>(options: CreateMessageOptions<TBody>): OutMessage
2 divMod(x: int, y: int): (int, int)
2 foo()
Expand Down Expand Up @@ -199,6 +201,8 @@ fun foo() {
21 ExtOutLogBucket {}
21 InMessage {}
21 InMessageBounced {}
21 MapEntry {}
21 MapLookupResult {}
21 OutMessage {}
21 PackOptions {}
21 StateInit {}
Expand All @@ -207,8 +211,9 @@ fun foo() {
21 blockchain
21 contract
21 debug
21 map
21 random
24 ExtraCurrenciesDict
24 ExtraCurrenciesMap
24 RemainingBitsAndRefs
24 address
24 bits256
Expand Down
4 changes: 2 additions & 2 deletions server/src/e2e/tolk/testcases/documentation/basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ struct <caret>CreateMessageOptions<TBody = never> {
/// whether a message will bounce back on error
bounce: bool;
/// message value: attached tons (or tons + extra currencies)
value: coins | (coins, ExtraCurrenciesDict);
value: coins | (coins, ExtraCurrenciesMap);
/// destination is either a provided address, or is auto-calculated by stateInit
dest: | address // either just send a message to some address
| builder // ... or a manually constructed builder with a valid address
Expand All @@ -196,7 +196,7 @@ struct <caret>CreateMessageOptions<TBody = never> {
```tolk
struct CreateMessageOptions<TBody = never> {
bounce: bool
value: coins | (coins, ExtraCurrenciesDict)
value: coins | (coins, ExtraCurrenciesMap)
dest: | address // either just send a message to some address
| builder // ... or a manually constructed builder with a valid address
| (int8, uint256) // ... or to workchain + hash (also known as accountID)
Expand Down
7 changes: 3 additions & 4 deletions server/src/e2e/tolk/testcases/documentation/map.test
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ type dict =

---

In Tolk v1.x there would be a type `map<K,V>`.
Currently, working with dictionaries is still low-level, with raw cells.
But just for clarity, we use "dict" instead of a "cell?" where a cell-dictionary is assumed.
Every dictionary object can be null. TVM NULL is essentially "empty dictionary".
`dict` is a low-level TVM dictionary.
Think of it as "a map with unknown keys and unknown values".
Prefer using `map<K, V>`, not `dict`.
```tolk
fun emptyMap
V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ fun test() {
foo.<caret>toCell();
}
------------------------------------------------------------------------
4:8 -> 258:6 resolved
4:8 -> 354:6 resolved

========================================================================
Generic struct alias method resolving
Expand Down
6 changes: 3 additions & 3 deletions server/src/e2e/tolk/testcases/resolving/type-parameters.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ Default type for function type parameter
========================================================================
fun foo<T=<caret>int>() {}
------------------------------------------------------------------------
0:10 -> 1:5 resolved
0:10 -> 10:5 resolved

========================================================================
Default type for struct type parameter
========================================================================
struct Foo<T=<caret>int> {}
------------------------------------------------------------------------
0:13 -> 1:5 resolved
0:13 -> 10:5 resolved

========================================================================
Default type for type alias type parameter
========================================================================
type Foo<T=<caret>int> = T | null;
------------------------------------------------------------------------
0:11 -> 1:5 resolved
0:11 -> 10:5 resolved

========================================================================
T receiver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ fun test118(x: int) {
return (i1, i2, st.owner.remainingBitsCount(), i3.0);
}

@method_id(119)
fun test119(a: int, b: int) {
var t: tuple = [a + 1, b * 2] as tuple;
val l = t.size();
val [c,d:int] = [t.0 as int, t.1];
return (l, c, d);
}



fun main(value: int, ) {
Expand Down Expand Up @@ -279,6 +287,7 @@ fun main(value: int, ) {
@testcase | 116 | | 1 2 3 4 [ 1 2 3 4 ]
@testcase | 117 | | [ 20 ]
@testcase | 118 | 3 | 10 3 0 1
@testcase | 119 | 1 2 | 2 2 4


@fif_codegen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ fun test11(a: int, b: int) {
return ((b < a), (b <= a), (b > a), (b >= a));
}

fun main() {}
fun main() {
// mark used to codegen them
cmp1; cmp2; cmp3; cmp4;
leq1; leq2; leq3; leq4;
}

/**
@testcase | 101 | 10 | 10 15 100 12 3 110 300
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ fun endCell(b: builder): cell
fun beginParse(c: cell): slice
asm "CTOS";

@noinline
fun triggerOverflowIntConst() {
return beginCell().storeInt(10, 4)
}

@noinline
fun triggerOverflowUintConst() {
return beginCell().storeUint(123, 6)
}

@method_id(101)
fun test1(): [int,int,int,int,int] {
var b: builder = beginCell().storeUint(1, 32);
Expand Down Expand Up @@ -249,6 +259,7 @@ fun test18() {
return (s.loadUint(14), s.loadInt(8), s.loadUint(4));
}

@method_id(119)
fun test19() {
// numbers with potential overflow for STU are not joined, check via codegen
var b = beginCell();
Expand All @@ -267,6 +278,7 @@ fun test20() {
return (s.loadBool(), s.loadBool(), s.loadBool(), s.loadUint(8), s.loadBool(), s.loadCoins());
}

@method_id(121)
fun test21(s: slice) {
// successive skipBits are also joined
var x = 8;
Expand Down Expand Up @@ -433,6 +445,30 @@ fun test34(p: int, n: int) {
return b;
}

@method_id(135)
fun test35(overflowMode: int) {
try {
val b: builder = match (overflowMode) {
1 => triggerOverflowIntConst(),
2 => triggerOverflowUintConst(),
3 => beginCell().storeUint(10, -4),
4 => beginCell().storeInt(100, 1),
5 => beginCell().storeInt(1, 0),
6 => beginCell().storeInt(115792089237316195423570985008687907853269984665640564039457584007913129639935, 256),
7 => beginCell().storeInt(15, 4),
8 => beginCell().storeUint(1<<170, 169),
else => beginCell(),
};
return b.endCell().beginParse().loadUint(1) * 1000
}
catch (ex) { return ex }
}

@method_id(136)
fun test36() {
return beginCell().storeInt(0, 0)
}

fun main(): int {
return 0;
}
Expand Down Expand Up @@ -467,6 +503,15 @@ fun main(): int {
@testcase | 132 | 0 | BC{00080000000a}
@testcase | 133 | 0 | BC{00020a}
@testcase | 134 | 0 8 | BC{00020a}
@testcase | 135 | 1 | 5
@testcase | 135 | 2 | 5
@testcase | 135 | 3 | 5
@testcase | 135 | 4 | 5
@testcase | 135 | 5 | 5
@testcase | 135 | 6 | 5
@testcase | 135 | 7 | 5
@testcase | 135 | 8 | 5
@testcase | 136 | | BC{0000}

We test that consequtive storeInt/storeUint with constants are joined into a single number

Expand Down Expand Up @@ -628,4 +673,32 @@ We test that consequtive storeInt/storeUint with constants are joined into a sin
}>
"""

@fif_codegen
"""
triggerOverflowIntConst() PROC:<{
10 PUSHINT
NEWC
4 STI
}>
"""

@fif_codegen
"""
triggerOverflowUintConst() PROC:<{
123 PUSHINT
NEWC
6 STU
}>
"""

@fif_codegen
"""
test36() PROC:<{
0 PUSHINT
NEWC
OVER
STIX
}>
"""

*/
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fun demo_fields_def(x: int) {
}

fun main() {
var cb = demo_fields_def;
return 1;
}

Expand Down
Loading
Loading