Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fixes around ref / deref #374

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions env/spreadsheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion evaldo/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
55 changes: 35 additions & 20 deletions tests/main.rye
Original file line number Diff line number Diff line change
Expand Up @@ -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 } {
Expand Down
Loading