MCPcopy Create free account
hub / github.com/JuliusBrussee/caveman / TestCodeCompressorPython

Function TestCodeCompressorPython

engine/compressors/code_cgo_test.go:49–66  ·  view source on GitHub ↗

With cgo (tree-sitter) the code compressor handles Python and TypeScript too. A successful compression implies the output re-parsed without error, because the compressor validates the re-parse before returning ok.

(t *testing.T)

Source from the content-addressed store, hash-verified

47// A successful compression implies the output re-parsed without error, because
48// the compressor validates the re-parse before returning ok.
49func TestCodeCompressorPython(t *testing.T) {
50 c := codeCompressor(t)
51 out, ok := c.Compress([]byte(pySource))
52 if !ok {
53 t.Fatal("expected Python to compress")
54 }
55 if len(out) >= len(pySource) {
56 t.Error("expected Python source to shrink")
57 }
58 for _, want := range []string{"def add(a, b):", "class Calc:", "def mul(self, a, b):", "import os"} {
59 if !bytes.Contains(out, []byte(want)) {
60 t.Errorf("output must keep %q:\n%s", want, out)
61 }
62 }
63 if bytes.Contains(out, []byte("total = a + b")) {
64 t.Error("Python body should be elided")
65 }
66}
67
68func TestCodeCompressorTypeScript(t *testing.T) {
69 c := codeCompressor(t)

Callers

nothing calls this directly

Calls 3

codeCompressorStruct · 0.70
CompressMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected