2022-08-25 14:08:18 -06:00
|
|
|
package parser
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
2022-08-25 18:01:12 -06:00
|
|
|
func TestFunc (test *testing.T) {
|
2022-08-25 14:08:18 -06:00
|
|
|
checkTree ("../tests/parser/func",
|
|
|
|
`:arf
|
|
|
|
---
|
|
|
|
func ro aBasicExternal
|
|
|
|
> someInput:Int:mut
|
|
|
|
< someOutput:Int 4
|
|
|
|
---
|
|
|
|
external
|
|
|
|
func ro bMethod
|
|
|
|
@ bird:{Bird}
|
|
|
|
> someInput:Int:mut
|
|
|
|
< someOutput:Int 4
|
|
|
|
---
|
|
|
|
external
|
|
|
|
func ro cBasicPhrases
|
|
|
|
---
|
2022-09-03 18:07:25 -06:00
|
|
|
[fn 329 983 7]
|
|
|
|
[fn 329 983 7]
|
|
|
|
[fn 329 983 57]
|
|
|
|
[fn [gn 329 983 57] 123]
|
2022-08-25 14:08:18 -06:00
|
|
|
func ro dArgumentTypes
|
|
|
|
---
|
2022-09-05 09:35:32 -06:00
|
|
|
[bird tree butterfly.wing "hello world" grass:Int:8:mut]
|
2022-08-25 14:08:18 -06:00
|
|
|
func ro eMath
|
2022-09-03 10:56:20 -06:00
|
|
|
> x:Int
|
|
|
|
> y:Int
|
|
|
|
< z:Int
|
|
|
|
---
|
2022-08-25 14:08:18 -06:00
|
|
|
[++ x]
|
|
|
|
[-- y]
|
2022-09-03 18:32:27 -06:00
|
|
|
[= z [+ [* 250 0] 98 x [/ 9832 y] 930]]
|
|
|
|
[== 4 4]
|
2022-08-25 14:08:18 -06:00
|
|
|
[! true]
|
2022-09-03 18:07:25 -06:00
|
|
|
[~ 1]
|
|
|
|
[~= x]
|
2022-08-25 14:08:18 -06:00
|
|
|
[% 873 32]
|
2022-09-03 10:56:20 -06:00
|
|
|
[= 5 5]
|
2022-08-25 14:08:18 -06:00
|
|
|
[!= 4 4]
|
2022-09-03 10:56:20 -06:00
|
|
|
[<= 4 98]
|
|
|
|
[< 4 98]
|
2022-09-03 18:07:25 -06:00
|
|
|
[<< 15 4]
|
|
|
|
[<<= x 4]
|
2022-09-03 10:56:20 -06:00
|
|
|
[>= 98 4]
|
|
|
|
[> 98 4]
|
2022-09-03 18:07:25 -06:00
|
|
|
[>> 240 4]
|
|
|
|
[>>= x 4]
|
|
|
|
[| 1 2]
|
|
|
|
[|= x 2]
|
|
|
|
[& 6 3]
|
|
|
|
[&= x 3]
|
2022-08-25 14:08:18 -06:00
|
|
|
[&& true true]
|
|
|
|
[|| true false]
|
|
|
|
func ro fReturnDirection
|
|
|
|
< err:Error
|
|
|
|
---
|
|
|
|
[someFunc 498 2980 90] -> thing:Int err
|
|
|
|
[otherFunc] -> thing err:Error
|
2022-09-03 18:07:25 -06:00
|
|
|
[fn 329 983 57] -> thing:Int err
|
2022-08-25 14:08:18 -06:00
|
|
|
func ro gControlFlow
|
|
|
|
---
|
2022-09-03 18:07:25 -06:00
|
|
|
[defer]
|
|
|
|
[something]
|
|
|
|
[otherThing]
|
2022-08-25 14:08:18 -06:00
|
|
|
[if condition]
|
|
|
|
[something]
|
|
|
|
[if condition]
|
|
|
|
[something]
|
|
|
|
[elseif]
|
|
|
|
[otherThing]
|
|
|
|
[else]
|
|
|
|
[finalThing]
|
|
|
|
[while [< x 432]]
|
|
|
|
[something]
|
|
|
|
[switch value]
|
|
|
|
[: 324]
|
|
|
|
[something]
|
|
|
|
[: 93284]
|
2022-09-03 18:07:25 -06:00
|
|
|
[otherThing]
|
2022-08-25 14:08:18 -06:00
|
|
|
[: 9128 34738 7328]
|
2022-09-03 18:07:25 -06:00
|
|
|
[multipleCases]
|
2022-08-25 14:08:18 -06:00
|
|
|
[:]
|
|
|
|
[defaultThing]
|
|
|
|
[for index:Size element:Int someArray]
|
|
|
|
[something]
|
|
|
|
[someNextThing]
|
|
|
|
[justMakingSureBlockParsingWorks]
|
|
|
|
[if condition]
|
|
|
|
[if condition]
|
|
|
|
[nestedThing]
|
|
|
|
[else]
|
|
|
|
[otherThing]
|
|
|
|
[else]
|
|
|
|
[if condition]
|
|
|
|
[nestedThing]
|
|
|
|
[else]
|
|
|
|
[otherThing]
|
2022-09-03 18:07:25 -06:00
|
|
|
func ro hSetPhrase
|
2022-08-25 14:08:18 -06:00
|
|
|
---
|
2022-09-03 18:32:27 -06:00
|
|
|
[= x:Int 3]
|
|
|
|
[= y:{Int} [loc x]]
|
2022-09-05 09:35:32 -06:00
|
|
|
[= z:Int:8]
|
2022-08-25 14:08:18 -06:00
|
|
|
398
|
|
|
|
9
|
|
|
|
2309
|
|
|
|
983
|
|
|
|
-2387
|
|
|
|
478
|
|
|
|
555
|
|
|
|
123
|
2022-09-03 18:32:27 -06:00
|
|
|
[= bird:Bird]
|
2022-08-25 14:08:18 -06:00
|
|
|
.that
|
|
|
|
.whenYou 99999
|
|
|
|
.this 324
|
|
|
|
`, test)
|
|
|
|
}
|