mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 00:46:07 +00:00
move to test folder and fix import bug in shell
This commit is contained in:
@@ -107,7 +107,11 @@ func importMod(realpath string, origin string, main bool) (ArObject, ArErr) {
|
||||
return ArObject{}, translationerr
|
||||
}
|
||||
ArgsArArray := []any{}
|
||||
for _, arg := range Args[1:] {
|
||||
withoutarfile := []string{}
|
||||
if len(Args) > 1 {
|
||||
withoutarfile = Args[1:]
|
||||
}
|
||||
for _, arg := range withoutarfile {
|
||||
ArgsArArray = append(ArgsArArray, arg)
|
||||
}
|
||||
global := newscope()
|
||||
|
||||
@@ -194,7 +194,9 @@ func runVal(line any, stack stack, stacklevel int) (any, ArErr) {
|
||||
case bool:
|
||||
return x, ArErr{}
|
||||
case nil:
|
||||
return nil, ArErr{}
|
||||
return x, ArErr{}
|
||||
case ArObject:
|
||||
return x, ArErr{}
|
||||
}
|
||||
if stackoverflow {
|
||||
return nil, ArErr{
|
||||
|
||||
@@ -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
|
||||
|
||||
3
tests/test.ar
Normal file
3
tests/test.ar
Normal file
@@ -0,0 +1,3 @@
|
||||
import "csv" as csv
|
||||
|
||||
term.log(csv.read("tests/test.csv"))
|
||||
14
tests/thread.ar
Normal file
14
tests/thread.ar
Normal file
@@ -0,0 +1,14 @@
|
||||
f() = do
|
||||
term.log("Hello, world!")
|
||||
term.time("threaded function")
|
||||
for (i from 0 to 1000000) do
|
||||
if (i % 100000 == 0) do
|
||||
term.log("i = " + i)
|
||||
term.timeEnd("threaded function")
|
||||
term.log("Goodbye, world!")
|
||||
|
||||
t = thread(f)
|
||||
t.start()
|
||||
term.time("main thread")
|
||||
t.join()
|
||||
term.timeEnd("main thread")
|
||||
Reference in New Issue
Block a user