fspl/generator/function_test.go

64 lines
1.0 KiB
Go

package generator
import "testing"
func TestFunction (test *testing.T) {
testString (test,
`
`,
`
[puts string: *Byte]: Index
Greeter: (message: String)
Greeter.[greet] = [puts [@[.this.message 0]]]
[main] = {
greeter: Greeter = (
message: 'hello\0'
)
greeter.[doNothing]
}
Greeter.[doNothing] = { }
Greeter.[getMessage]: String = {
[puts 'getting']
this.message
[puts 'got']
this.message
}
`)
}
// [write 1 (* 72 101 108 108 111 114 108 100 0) 7]
// [puts string:*Byte]:I32
// [main argc:I32 argv:**Byte] = {
// loop {
// [puts (* 100 100 0)]
// }
// }
// [puts string:*Byte]:I32
// [read fd:Int buf:*Byte count:Index]:Index
//
// [itoa value:Int buffer:String base:Int]:String = {
// if [== base 0] then { base = 10 }
// index:Index = 0
//
// loop {
// digit:Int = [% value base]
// [.buffer index] = [~Byte [+ digit '0']]
// value = [/ value base]
// index = [++index]
// }
//
// buffer
// }
//
// [main argc:I32 argv:**Byte] = {
// [itoa 5 string:16:Byte 10]
// [.string 15] = 0
// [puts [.[@string]]]
// }