Skip to content

Commit 69c9850

Browse files
committed
TODO languages with tests in implementation files
1 parent 48f64d8 commit 69c9850

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

model/llm/llm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ type llmWriteTestSourceFilePromptContext struct {
145145

146146
// llmWriteTestForFilePromptTemplate is the template for generating an LLM test generation prompt.
147147
var llmWriteTestForFilePromptTemplate = template.Must(template.New("model-llm-write-test-for-file-prompt").Parse(bytesutil.StringTrimIndentations(`
148-
Given the following {{ .Language.Name }} code file "{{ .FilePath }}" with package "{{ .ImportPath }}", provide a test file for this code{{ with .TestFramework }} with {{ . }} as a test framework{{ end }}.
148+
Given the following {{ .Language.Name }} code file "{{ .FilePath }}" {{- with .ImportPath }} with package "{{ . }}" {{- end }}, provide {{- if .Language.HasTestsInSource }} tests {{ else }} a test file {{ end -}} for this code{{ with .TestFramework }} with {{ . }} as a test framework{{ end }}.
149149
The tests should produce 100 percent code coverage and must compile.
150150
The response must contain only the test code in a fenced code block and nothing else.
151151

model/llm/llm_test.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/symflower/eval-dev-quality/language"
2222
"github.com/symflower/eval-dev-quality/language/golang"
2323
"github.com/symflower/eval-dev-quality/language/java"
24+
"github.com/symflower/eval-dev-quality/language/rust"
2425
"github.com/symflower/eval-dev-quality/log"
2526
"github.com/symflower/eval-dev-quality/model"
2627
"github.com/symflower/eval-dev-quality/provider"
@@ -654,6 +655,68 @@ func TestFormatPromptContext(t *testing.T) {
654655
` + "```" + `
655656
`),
656657
})
658+
659+
validate(t, &testCase{
660+
Name: "No Import path",
661+
662+
Context: &llmWriteTestSourceFilePromptContext{
663+
llmSourceFilePromptContext: llmSourceFilePromptContext{
664+
Language: &golang.Language{},
665+
666+
Code: bytesutil.StringTrimIndentations(`
667+
package increment
668+
669+
func increment(i int) int
670+
return i + 1
671+
}
672+
`),
673+
FilePath: filepath.Join("path", "to", "increment.go"),
674+
ImportPath: "",
675+
},
676+
},
677+
678+
ExpectedMessage: bytesutil.StringTrimIndentations(`
679+
Given the following Go code file "path/to/increment.go", provide a test file for this code.
680+
The tests should produce 100 percent code coverage and must compile.
681+
The response must contain only the test code in a fenced code block and nothing else.
682+
683+
` + "```" + `golang
684+
package increment
685+
686+
func increment(i int) int
687+
return i + 1
688+
}
689+
` + "```" + `
690+
`),
691+
})
692+
693+
validate(t, &testCase{
694+
Name: "Tests in source file",
695+
696+
Context: &llmWriteTestSourceFilePromptContext{
697+
llmSourceFilePromptContext: llmSourceFilePromptContext{
698+
Language: &rust.Language{},
699+
700+
Code: bytesutil.StringTrimIndentations(`
701+
fn main() {
702+
}
703+
`),
704+
FilePath: filepath.Join("path", "to", "main.rs"),
705+
ImportPath: "",
706+
},
707+
},
708+
709+
ExpectedMessage: bytesutil.StringTrimIndentations(`
710+
Given the following Rust code file "path/to/main.rs", provide tests for this code.
711+
The tests should produce 100 percent code coverage and must compile.
712+
The response must contain only the test code in a fenced code block and nothing else.
713+
714+
` + "```" + `rust
715+
fn main() {
716+
}
717+
` + "```" + `
718+
`),
719+
})
657720
})
658721

659722
validate(t, &testCase{

0 commit comments

Comments
 (0)