aboutsummaryrefslogtreecommitdiffhomepage
path: root/testexec/mainapp/main.slul
blob: 6d143011b42a53bfac75d17e45c0ec906b2eaa2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

#
# Test application written in SLUL
#
# Copyright © 2021-2024 Samuel Lidén Borell <samuel@kodafritt.se>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

\slul 0.0.0
\name mainapp
\depends somelib 0.12.3
\depends otherlib 3.0.1
\depends nesteddep 1.24 nestedonly

\source comments.slul
\source constexpr.slul
\source datadefs.slul
\source definedness.slul
\source expressions.slul
\source for_loops.slul
\source funccalls.slul
\source generics.slul
\source return.slul
\source statements.slul
\source typecompat.slul
\source typedefs.slul

data int global = 123

func do_stuff(ref OtherClosedType ot)
{
    var UseNestedDep und = (
        .nested = (
            .nestedvalue = 123,
            .nested_other = .external_constructor(true),
        ),
    )
    und.nested.nestedvalue += 1

    # Test of type-identifiers declared outside of the module of the type
    assert ot.external_method(123, false)
    var OtherClosedType ot2 = .external_constructor(456)
    var OtherClosedType ot3 = .external_data_typeident

    # Normal type-identifiers should still work
    ot2 = .constructor(789)
    assert ot2.method(1, false)
    ot3 = .data_typeident
}

func use_conflicting_type(ref var NameConflictInOtherlibV4 obj)
{
    # This type exists in both otherlib v4 and in somelib
    # But we're using otherlib v3, so we're fine,
    # and this function should use the type and methods in somelib.
    obj.set(3, 5)
    assert obj.get_sum() == 8
    ref NameConflictInOtherlibV4 obj1 = .get_default()
}

type ImplType = struct {
    int x
    int y
}

func SlulApp.main() -> SlulExitStatus
{
    constexpr_test()
    datadefs_test()
    definedness_test()
    expressions_test()
    for_loops_test()
    funccalls_test()
    generics_test()
    return_test()
    statements_test()
    typecompat_test()
    own SomeThing st = make_some_thing()
    var int zero = 0
    if global == zero return 2
    else if global == zero+123 { }
    else return st.x
    free_some_thing(st)
    return 123
}