-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial tests coverage for golang jenny
- Loading branch information
Showing
18 changed files
with
472 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package golang | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/grafana/cog/internal/ast" | ||
"github.com/grafana/cog/internal/txtartest" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestRawTypes_Generate(t *testing.T) { | ||
test := txtartest.TxTarTest{ | ||
Root: "../../../testdata/jennies/rawtypes", | ||
Name: "jennies/GoRawTypes", | ||
} | ||
|
||
jenny := RawTypes{} | ||
compilerPasses := CompilerPasses() | ||
|
||
test.Run(t, func(tc *txtartest.Test) { | ||
req := require.New(tc) | ||
|
||
var err error | ||
processedAsts := []*ast.File{tc.TypesIR()} | ||
|
||
// We run the compiler passes defined fo Go since without them, we | ||
// might not be able to translate some of the IR's semantics into Go. | ||
// Example: disjunctions. | ||
for _, compilerPass := range compilerPasses { | ||
processedAsts, err = compilerPass.Process(processedAsts) | ||
req.NoError(err) | ||
} | ||
|
||
req.Len(processedAsts, 1, "we somehow got more ast.File than we put in") | ||
|
||
files, err := jenny.Generate(processedAsts[0]) | ||
req.NoError(err) | ||
|
||
tc.WriteFiles(files) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.