move to test folder and fix import bug in shell

This commit is contained in:
2023-03-20 00:17:43 +00:00
parent b56c1fc485
commit 4a320008b2
9 changed files with 37 additions and 8 deletions

View File

@@ -1,10 +1,13 @@
package main
import "sync"
import (
"fmt"
"sync"
)
func ArThread(args ...any) (any, ArErr) {
if len(args) == 0 {
return nil, ArErr{TYPE: "TypeError", message: "Cannot call thread without a function", EXISTS: true}
if len(args) != 1 {
return nil, ArErr{TYPE: "TypeError", message: "Invalid number of arguments, expected 1, got " + fmt.Sprint(len(args)), EXISTS: true}
}
var tocall any
switch x := args[0].(type) {
@@ -26,6 +29,9 @@ func ArThread(args ...any) (any, ArErr) {
if hasrun {
return nil, ArErr{TYPE: "Runtime Error", message: "Cannot start a thread twice", EXISTS: true}
}
if len(args) != 0 {
return nil, ArErr{TYPE: "TypeError", message: "Invalid number of arguments, expected 0, got " + fmt.Sprint(len(args)), EXISTS: true}
}
hasrun = true
wg.Add(1)
go func() {
@@ -40,6 +46,9 @@ func ArThread(args ...any) (any, ArErr) {
} else if joined {
return nil, ArErr{TYPE: "Runtime Error", message: "Cannot join a thread twice", EXISTS: true}
}
if len(args) != 0 {
return nil, ArErr{TYPE: "TypeError", message: "Invalid number of arguments, expected 0, got " + fmt.Sprint(len(args)), EXISTS: true}
}
joined = true
wg.Wait()
return resp, err