|
| 1 | +// the goal of this file is not only to @testcase results — |
| 2 | +// but to check that this file compiles |
| 3 | + |
| 4 | +fun eq<X>(value: X): X { return value; } |
| 5 | + |
| 6 | +fun test1(x: int, y: int) { |
| 7 | + __expect_type(0, "int"); |
| 8 | + __expect_type("0"c, "int"); |
| 9 | + __expect_type(x, "int"); |
| 10 | + __expect_type(x + y, "int"); |
| 11 | + __expect_type(x * y, "int"); |
| 12 | + __expect_type(x & y, "int"); |
| 13 | + __expect_type(x << y, "int"); |
| 14 | + __expect_type((((x))), "int"); |
| 15 | + __expect_type(x = x, "int"); |
| 16 | + __expect_type(x += x, "int"); |
| 17 | + __expect_type(x &= x, "int"); |
| 18 | + __expect_type(random() ? x : y, "int"); |
| 19 | + __expect_type(eq(x), "int"); |
| 20 | + __expect_type(eq<int>(x), "int"); |
| 21 | + __expect_type(eq<int>(null), "int"); |
| 22 | + __expect_type(x as int, "int"); |
| 23 | + __expect_type(+x, "int"); |
| 24 | + __expect_type(~x, "int"); |
| 25 | + { |
| 26 | + var x: slice = beginCell().endCell().beginParse(); |
| 27 | + __expect_type(x, "slice"); |
| 28 | + __expect_type(beginCell(), "builder"); |
| 29 | + __expect_type(beginCell().endCell(), "cell"); |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +fun test2(x: int, y: bool) { |
| 34 | + __expect_type(!x, "bool"); |
| 35 | + __expect_type(x != x, "bool"); |
| 36 | + __expect_type(x <= x, "bool"); |
| 37 | + __expect_type(x <=> x, "bool"); |
| 38 | + __expect_type(x <=> x, "bool"); |
| 39 | + __expect_type(!random(), "bool"); |
| 40 | + __expect_type(!!(x != null), "bool"); |
| 41 | + __expect_type(x ? x != null : null == x, "bool"); |
| 42 | + __expect_type(y & true, "bool"); |
| 43 | + __expect_type(y ^= false, "bool"); |
| 44 | + __expect_type(x && y, "bool"); |
| 45 | + __expect_type(true && false && true, "bool"); |
| 46 | + __expect_type(x || x, "bool"); |
| 47 | + __expect_type(x || !x || (true & false), "bool"); |
| 48 | +} |
| 49 | + |
| 50 | +fun test3() { |
| 51 | + __expect_type(true as int, "int"); |
| 52 | + __expect_type(!random() as int, "int"); |
| 53 | +} |
| 54 | + |
| 55 | +fun test4(x: int) { |
| 56 | + __expect_type((), "()"); |
| 57 | + __expect_type((x, x), "(int, int)"); |
| 58 | + __expect_type((x, (x, x), x), "(int, (int, int), int)"); |
| 59 | +} |
| 60 | + |
| 61 | +fun test5(x: int) { |
| 62 | + __expect_type([], "[]"); |
| 63 | + __expect_type([x], "[int]"); |
| 64 | + __expect_type([x, x >= 1], "[int, bool]"); |
| 65 | + __expect_type([x, x >= 1, null as slice], "[int, bool, slice]"); |
| 66 | + __expect_type((x, [x], [[x], x]), "(int, [int], [[int], int])"); |
| 67 | + __expect_type(getMyOriginalBalanceWithExtraCurrencies(), "[int, cell]"); |
| 68 | +} |
| 69 | + |
| 70 | +fun test6() { |
| 71 | + var t = createEmptyTuple(); |
| 72 | + __expect_type(t, "tuple"); |
| 73 | + t.tuplePush(1); |
| 74 | + __expect_type(t, "tuple"); |
| 75 | +} |
| 76 | + |
| 77 | +fun test7() { |
| 78 | + __expect_type(test3(), "void"); |
| 79 | + __expect_type(test3, "() -> void"); |
| 80 | + var cb = test1; |
| 81 | + __expect_type(cb, "(int, int) -> void"); |
| 82 | + var t = createEmptyTuple(); |
| 83 | + __expect_type(beginCell().endCell, "(builder) -> cell"); |
| 84 | + // __expect_type(eq<(int, slice)>, "(int, slice) -> (int, slice)"); |
| 85 | +} |
| 86 | + |
| 87 | + |
| 88 | +fun main() { |
| 89 | + return 0; |
| 90 | +} |
| 91 | + |
| 92 | +/** |
| 93 | +@testcase | 0 | | 0 |
| 94 | +*/ |
0 commit comments