From ef2f0501753e5dfdc1226fcb21fa99f3c4216263 Mon Sep 17 00:00:00 2001 From: refaktor Date: Mon, 7 Oct 2024 23:07:43 +0200 Subject: [PATCH 1/2] small fixes around ref / deref --- env/spreadsheet.go | 6 +----- evaldo/builtins.go | 6 +++++- runner/runner.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/env/spreadsheet.go b/env/spreadsheet.go index 9d361fe8..1eb7e6d9 100644 --- a/env/spreadsheet.go +++ b/env/spreadsheet.go @@ -322,11 +322,7 @@ func (s SpreadsheetRow) GetKind() int { // Inspect returns a string func (s SpreadsheetRow) Inspect(e Idxs) string { - p := "" - if IsPointer(s) { - p = "REF:" - } - return "[" + p + "SpreadsheetRow(" + strconv.Itoa(len(s.Values)) + ")" + "]" + return "[SpreadsheetRow(" + strconv.Itoa(len(s.Values)) + ")" + "]" } // Inspect returns a string representation of the Integer. diff --git a/evaldo/builtins.go b/evaldo/builtins.go index 58f98822..10e07c4d 100644 --- a/evaldo/builtins.go +++ b/evaldo/builtins.go @@ -859,6 +859,8 @@ var builtins = map[string]*env.Builtin{ return &sp case env.Block: return &sp + case env.String: + return &sp case env.Native: sp.Value = env.ReferenceAny(sp.Value) return &sp @@ -906,6 +908,8 @@ var builtins = map[string]*env.Builtin{ return *sp case *env.Block: return *sp + case *env.String: + return *sp case *env.Native: sp.Value = env.DereferenceAny(sp.Value) return *sp @@ -1752,7 +1756,7 @@ var builtins = map[string]*env.Builtin{ Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object { p := "" if env.IsPointer(arg0) { - p = "REF:" + p = "REF" } fmt.Println(p + arg0.Inspect(*ps.Idx)) return arg0 diff --git a/runner/runner.go b/runner/runner.go index 3af6bad4..eff3cf94 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -383,7 +383,7 @@ func main_rye_file(file string, sig bool, subc bool, here bool, interactive bool // READ STDIN IF var stValue env.Object - stValue = env.NewString("") + stValue = *env.NewString("") if stin == "all" || stin == "a" { // TODO add modes like lines, maybe load / lines, do / lines) var stInput string @@ -395,7 +395,7 @@ func main_rye_file(file string, sig bool, subc bool, here bool, interactive bool } stInput += stLine } - stValue = env.NewString(stInput) + stValue = *env.NewString(stInput) } ps := env.NewProgramStateNEW() From e7ce6786373de760b9c0bea86adda308dc875be9 Mon Sep 17 00:00:00 2001 From: refaktor Date: Tue, 8 Oct 2024 10:06:25 +0200 Subject: [PATCH 2/2] improved the testing tool --- tests/main.rye | 55 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/tests/main.rye b/tests/main.rye index be5f5f9f..d1b02d31 100644 --- a/tests/main.rye +++ b/tests/main.rye @@ -85,32 +85,47 @@ generate-doc-file: fn { filename menu } { menu: { "basics" "structures" "validation" "misc" "spreadsheet_mutations" } -switch first args { +print-help: does { + print `# Rye's simple testing tool + + use test or doc command + +Examples: + rye . test # runs all tests + rye . doc # generates the docs out of tests + rye . test ls # lists the test sections available + rye . test basics # runs a specific test section +` +} + +first args |^fix { print-help } |switch { test { - errors: 0 - either args .length? = 1 { - for menu { + ".rye" |to-file |load |do\in* test-framework |+ errors ::errors } + sections: { } + either args .length? > 1 { + either ( second args ) = 'ls { + print "Test sections available:" + menu .for { .concat* " * " |print } + } { + sections:: [ second args ] + } } { - - args .second + ".rye" |to-file |load |do\in* test-framework |+ errors ::errors + sections:: menu + } + if sections .length? > 0 { ; todo add is-empty builtin + errors: 0 + for sections { .to-string + ".rye" |to-file |load |^check { "group does not exist!" } |do\in* test-framework |+ errors ::errors } + print "===================" + print " FAILED TESTS: " + errors + print "" + print "run `rye .` to see the new test tool options" } - print "===================" - print " FAILED TESTS: " + errors } doc { - for menu { .generate-doc-file menu } + for menu { .generate-doc-file menu } + print "docs generated" } - _ { print "use test or doc command" } -} - - - - - - - - - + _ { print-help } +} ; maybe we need this at some point ; true: fn { test } {