X-Git-Url: https://gitweb.ps.run/toc/blobdiff_plain/3b7b6d9a84bfc5f328c2ed78ca72a836a67468ae..HEAD:/test/test.toc diff --git a/test/test.toc b/test/test.toc index b3ff1ea..bff757a 100644 --- a/test/test.toc +++ b/test/test.toc @@ -7,13 +7,13 @@ var global1 : int; var global2 : double = 123.45; func globalFunc() : void { - //puts("Hello\n"); + puts("Hello\n"); } // structs and functions can be declared generic // by providing a list of placeholder typenames struct S1 { - t1: T1; + t1: T1 *; t2: T1; m1() : T2 { @@ -21,12 +21,6 @@ struct S1 { } } -struct S2 { - s: char *; - abc(): S2 { } - xyz(): S2 { } -} - func generic1(a1 : A, a2 : A) : A { return a1 + a2; } @@ -64,6 +58,14 @@ namespace N1 { } } + struct S2 { + s: char *; + abc(): S1 { + var result : S1; + return result; + } + } + func f1() : void { // these have the same type var s1 : N1::N2::S1; @@ -74,6 +76,13 @@ namespace N1 { } } +struct List { + array: T *; + get(index: int): T { + return this->array[index]; + } +} + func main(argc : int, argv : char**) : int { var s1 : N1::N2::S1; var s2 : N1::N2::S1; @@ -93,8 +102,13 @@ func main(argc : int, argv : char**) : int { generic1(1, 2); generic1(3.4, 5.6); - var s: S2; - s.abc().xyz(); + var s: N1::N2::S2; + s.abc(); + + var l1: List; + l1.get(1); + + var i1: int = generic1(1, 2); return 0; } \ No newline at end of file