aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-10-09 13:26:28 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-10-09 13:26:28 -0400
commit074cf22ad462eafe963e4a749b2b74cab51211a1 (patch)
treee1d7f938f2d949cc5dcf67ca648f200663e36562 /test
parent47fca946065508cff4151a32b3008c161983fd9d (diff)
Change function syntax from `func(args)->ret` to `func(args -> ret)`
Diffstat (limited to 'test')
-rw-r--r--test/corecursive_func.tm4
-rw-r--r--test/defer.tm2
-rw-r--r--test/enums.tm2
-rw-r--r--test/extern.tm2
-rw-r--r--test/for.tm8
-rw-r--r--test/functions.tm4
-rw-r--r--test/import.tm4
-rw-r--r--test/iterators.tm4
-rw-r--r--test/lambdas.tm6
-rw-r--r--test/lang.tm6
-rw-r--r--test/metamethods.tm30
-rw-r--r--test/minmax.tm2
-rw-r--r--test/optionals.tm24
-rw-r--r--test/use_import.tm2
14 files changed, 50 insertions, 50 deletions
diff --git a/test/corecursive_func.tm b/test/corecursive_func.tm
index 168300d4..b5f5f13e 100644
--- a/test/corecursive_func.tm
+++ b/test/corecursive_func.tm
@@ -1,10 +1,10 @@
-func ping(x:Int)->[Text]:
+func ping(x:Int->[Text]):
if x > 0:
return ["ping: $x"] ++ pong(x-1)
else:
return ["ping: $x"]
-func pong(x:Int)->[Text]:
+func pong(x:Int->[Text]):
if x > 0:
return ["pong: $x"] ++ ping(x-1)
else:
diff --git a/test/defer.tm b/test/defer.tm
index 5d3c55b5..911ed672 100644
--- a/test/defer.tm
+++ b/test/defer.tm
@@ -76,7 +76,7 @@ func defer_func(return_early=no):
say("Finished defer_func")
-func make_counter()->func()->Int:
+func make_counter(->func(->Int)):
i := 1
return func():
defer: i += 1
diff --git a/test/enums.tm b/test/enums.tm
index 0699fc97..c2ffce4c 100644
--- a/test/enums.tm
+++ b/test/enums.tm
@@ -1,6 +1,6 @@
enum Foo(Zero, One(x:Int), Two(x:Int, y:Int), Three(x:Int, y:Text, z:Bool), Four(x,y,z,w:Int), Last(t:Text))
-func choose_text(f:Foo)->Text:
+func choose_text(f:Foo->Text):
>> f
when f is Zero:
return "Zero"
diff --git a/test/extern.tm b/test/extern.tm
index 4823b21f..ddd800d0 100644
--- a/test/extern.tm
+++ b/test/extern.tm
@@ -1,4 +1,4 @@
-extern sqrt:func(n:Num)->Num
+extern sqrt:func(n:Num->Num)
func main():
>> sqrt(4)
diff --git a/test/for.tm b/test/for.tm
index 6ac77be6..ae5f786e 100644
--- a/test/for.tm
+++ b/test/for.tm
@@ -1,5 +1,5 @@
-func all_nums(nums:[Int])->Text:
+func all_nums(nums:[Int] -> Text):
result := ""
for num in nums:
result ++= "$num,"
@@ -7,7 +7,7 @@ func all_nums(nums:[Int])->Text:
return "EMPTY"
return result
-func labeled_nums(nums:[Int])->Text:
+func labeled_nums(nums:[Int] -> Text):
result := ""
for i,num in nums:
result ++= "$i:$num,"
@@ -15,14 +15,14 @@ func labeled_nums(nums:[Int])->Text:
return "EMPTY"
return result
-func table_str(t:{Text:Text})->Text:
+func table_str(t:{Text:Text} -> Text):
str := ""
for k,v in t:
str ++= "$k:$v,"
else: return "EMPTY"
return str
-func table_key_str(t:{Text:Text})->Text:
+func table_key_str(t:{Text:Text} -> Text):
str := ""
for k in t:
str ++= "$k,"
diff --git a/test/functions.tm b/test/functions.tm
index 426c33b1..22d950d4 100644
--- a/test/functions.tm
+++ b/test/functions.tm
@@ -1,7 +1,7 @@
-func add(x:Int, y:Int)->Int:
+func add(x:Int, y:Int -> Int):
return x + y
-func cached_heap(x:Int; cached)->@Int:
+func cached_heap(x:Int->@Int; cached):
return @x
func main():
diff --git a/test/import.tm b/test/import.tm
index 9362e085..a7b198b9 100644
--- a/test/import.tm
+++ b/test/import.tm
@@ -1,10 +1,10 @@
vectors := use ../examples/vectors/vectors.tm
use ./use_import.tm
-func returns_vec()->vectors.Vec2:
+func returns_vec(->vectors.Vec2):
return vectors.Vec2(1, 2)
-func returns_imported_type()->ImportedType:
+func returns_imported_type(->ImportedType):
return get_value() # Imported from ./use_import.tm
func main():
diff --git a/test/iterators.tm b/test/iterators.tm
index 6893c595..fca91b2d 100644
--- a/test/iterators.tm
+++ b/test/iterators.tm
@@ -1,14 +1,14 @@
struct Pair(x:Text, y:Text)
-func pairwise(strs:[Text])->func()->Pair?:
+func pairwise(strs:[Text] -> func(->Pair?)):
i := 1
return func():
if i + 1 > strs.length: return !Pair
i += 1
return Pair(strs[i-1], strs[i])?
-func range(first:Int, last:Int)->func()->Int?:
+func range(first:Int, last:Int -> func(->Int?)):
i := first
return func():
if i > last:
diff --git a/test/lambdas.tm b/test/lambdas.tm
index 62b5fd36..d830a36f 100644
--- a/test/lambdas.tm
+++ b/test/lambdas.tm
@@ -1,10 +1,10 @@
-func make_adder(x:Int)-> func(y:Int)->Int:
+func make_adder(x:Int -> func(y:Int->Int)):
return func(y:Int): x + y
-func suffix_fn(fn:func(t:Text)->Text, suffix:Text)->func(t:Text)->Text:
+func suffix_fn(fn:func(t:Text->Text), suffix:Text -> func(t:Text->Text)):
return func(t:Text): fn(t)++suffix
-func mul_func(n:Int, fn:func(x:Int)->Int)-> func(x:Int)->Int:
+func mul_func(n:Int, fn:func(x:Int->Int) -> func(x:Int->Int)):
return func(x:Int): n*fn(x)
func main():
diff --git a/test/lang.tm b/test/lang.tm
index 9a05eb11..b30bcbea 100644
--- a/test/lang.tm
+++ b/test/lang.tm
@@ -1,6 +1,6 @@
lang HTML:
HEADER := $HTML"<!DOCTYPE HTML>"
- func escape(t:Text)->HTML:
+ func escape(t:Text->HTML):
t = t:replace_all({
$/&/: "&amp;",
$/</: "&lt;",
@@ -11,10 +11,10 @@ lang HTML:
return HTML.without_escaping(t)
- func escape_int(i:Int)->HTML:
+ func escape_int(i:Int->HTML):
return HTML.without_escaping("$i")
- func paragraph(content:HTML)->HTML:
+ func paragraph(content:HTML->HTML):
return $HTML"<p>$content</p>"
func main():
diff --git a/test/metamethods.tm b/test/metamethods.tm
index 0b4bf87c..5566b4e9 100644
--- a/test/metamethods.tm
+++ b/test/metamethods.tm
@@ -1,47 +1,47 @@
struct Vec2(x,y:Int):
- func plus(a,b:Vec2; inline)->Vec2:
+ func plus(a,b:Vec2 -> Vec2; inline):
return Vec2(a.x+b.x, a.y+b.y)
- func minus(a,b:Vec2; inline)->Vec2:
+ func minus(a,b:Vec2 -> Vec2; inline):
return Vec2(a.x-b.x, a.y-b.y)
- func dot(a,b:Vec2; inline)->Int:
+ func dot(a,b:Vec2 -> Int; inline):
return a.x*b.x + a.y*b.y
- func scaled_by(a:Vec2, k:Int; inline)->Vec2:
+ func scaled_by(a:Vec2, k:Int -> Vec2; inline):
return Vec2(a.x*k, a.y*k)
- func times(a,b:Vec2; inline)->Vec2:
+ func times(a,b:Vec2 -> Vec2; inline):
return Vec2(a.x*b.x, a.y*b.y)
- func divided_by(a:Vec2, k:Int; inline)->Vec2:
+ func divided_by(a:Vec2, k:Int -> Vec2; inline):
return Vec2(a.x/k, a.y/k)
- func negative(v:Vec2; inline)->Vec2:
+ func negative(v:Vec2 -> Vec2; inline):
return Vec2(-v.x, -v.y)
- func negated(v:Vec2; inline)->Vec2:
+ func negated(v:Vec2 -> Vec2; inline):
return Vec2(not v.x, not v.y)
- func bit_and(a,b:Vec2; inline)->Vec2:
+ func bit_and(a,b:Vec2 -> Vec2; inline):
return Vec2(a.x and b.x, a.y and b.y)
- func bit_or(a,b:Vec2; inline)->Vec2:
+ func bit_or(a,b:Vec2 -> Vec2; inline):
return Vec2(a.x or b.x, a.y or b.y)
- func bit_xor(a,b:Vec2; inline)->Vec2:
+ func bit_xor(a,b:Vec2 -> Vec2; inline):
return Vec2(a.x xor b.x, a.y xor b.y)
- func left_shifted(v:Vec2, bits:Int; inline)->Vec2:
+ func left_shifted(v:Vec2, bits:Int -> Vec2; inline):
return Vec2(v.x >> bits, v.y >> bits)
- func right_shifted(v:Vec2, bits:Int; inline)->Vec2:
+ func right_shifted(v:Vec2, bits:Int -> Vec2; inline):
return Vec2(v.x << bits, v.y << bits)
- func modulo(v:Vec2, modulus:Int; inline)->Vec2:
+ func modulo(v:Vec2, modulus:Int -> Vec2; inline):
return Vec2(v.x mod modulus, v.y mod modulus)
- func modulo1(v:Vec2, modulus:Int; inline)->Vec2:
+ func modulo1(v:Vec2, modulus:Int -> Vec2; inline):
return Vec2(v.x mod1 modulus, v.y mod1 modulus)
func main():
diff --git a/test/minmax.tm b/test/minmax.tm
index c2f070f6..fa0e8bd8 100644
--- a/test/minmax.tm
+++ b/test/minmax.tm
@@ -1,6 +1,6 @@
struct Foo(x:Int, y:Int):
- func len(f:Foo)->Num:
+ func len(f:Foo->Num):
return Num.sqrt(f.x*f.x + f.y*f.y)
func main():
diff --git a/test/optionals.tm b/test/optionals.tm
index c0cc116e..612ab76b 100644
--- a/test/optionals.tm
+++ b/test/optionals.tm
@@ -1,73 +1,73 @@
struct Struct(x:Int, y:Text):
- func maybe(should_i:Bool)->Struct?:
+ func maybe(should_i:Bool->Struct?):
if should_i:
return Struct(123, "hello")
else:
return !Struct
enum Enum(X, Y(y:Int)):
- func maybe(should_i:Bool)->Enum?:
+ func maybe(should_i:Bool->Enum?):
if should_i:
return Enum.Y(123)
else:
return !Enum
-func maybe_int(should_i:Bool)->Int?:
+func maybe_int(should_i:Bool->Int?):
if should_i:
return 123
else:
return !Int
-func maybe_int64(should_i:Bool)->Int64?:
+func maybe_int64(should_i:Bool->Int64?):
if should_i:
return 123[64]
else:
return !Int64
-func maybe_array(should_i:Bool)->[Int]?:
+func maybe_array(should_i:Bool->[Int]?):
if should_i:
return [10, 20, 30]
else:
return ![Int]
-func maybe_bool(should_i:Bool)->Bool?:
+func maybe_bool(should_i:Bool->Bool?):
if should_i:
return no
else:
return !Bool
-func maybe_text(should_i:Bool)->Text?:
+func maybe_text(should_i:Bool->Text?):
if should_i:
return "Hello"
else:
return !Text
-func maybe_num(should_i:Bool)->Num?:
+func maybe_num(should_i:Bool->Num?):
if should_i:
return 12.3
else:
return !Num
-func maybe_lambda(should_i:Bool)-> func()?:
+func maybe_lambda(should_i:Bool-> func()?):
if should_i:
return func(): say("hi!")
else:
return !func()
-func maybe_c_string(should_i:Bool)->CString?:
+func maybe_c_string(should_i:Bool->CString?):
if should_i:
return ("hi":as_c_string())?
else:
return !CString
-func maybe_channel(should_i:Bool)->|Int|?:
+func maybe_channel(should_i:Bool->|Int|?):
if should_i:
return |:Int|?
else:
return !|Int|
-func maybe_thread(should_i:Bool)->Thread?:
+func maybe_thread(should_i:Bool->Thread?):
if should_i:
return Thread.new(func(): pass)
else:
diff --git a/test/use_import.tm b/test/use_import.tm
index 979256bb..714c26b0 100644
--- a/test/use_import.tm
+++ b/test/use_import.tm
@@ -2,7 +2,7 @@ struct ImportedType(name:Text)
needs_initializing := 999999999999999999
-func get_value()->ImportedType:
+func get_value(->ImportedType):
return ImportedType("Hello")
func main():