MCPcopy Create free account
hub / github.com/php/frankenphp / TestConstantParserErrors

Function TestConstantParserErrors

internal/extgen/constparser_test.go:173–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

171}
172
173func TestConstantParserErrors(t *testing.T) {
174 tests := []struct {
175 name string
176 input string
177 }{
178 {
179 name: "invalid constant declaration",
180 input: `package main
181
182//export_php:const
183const = "missing name"`,
184 },
185 {
186 name: "malformed constant",
187 input: `package main
188
189//export_php:const
190const InvalidSyntax`,
191 },
192 }
193
194 for _, tt := range tests {
195 t.Run(tt.name, func(t *testing.T) {
196 tmpDir := t.TempDir()
197 tmpFile := filepath.Join(tmpDir, tt.name+".go")
198 require.NoError(t, os.WriteFile(tmpFile, []byte(tt.input), 0644))
199
200 parser := &ConstantParser{}
201 _, err := parser.parse(tmpFile)
202 assert.Error(t, err, "Expected error but got none")
203 })
204 }
205}
206
207func TestConstantParserIotaSequence(t *testing.T) {
208 input := `package main

Callers

nothing calls this directly

Calls 2

parseMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected