MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestVariableDeclToExprDecl

Function TestVariableDeclToExprDecl

common/decls/decls_test.go:1294–1314  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1292}
1293
1294func TestVariableDeclToExprDecl(t *testing.T) {
1295 a, err := VariableDeclToExprDecl(NewVariable("a", types.BoolType))
1296 if err != nil {
1297 t.Fatalf("VariableDeclToExprDecl() failed: %v", err)
1298 }
1299 if !proto.Equal(a, chkdecls.NewVar("a", chkdecls.Bool)) {
1300 t.Error("proto.Equal() returned false, wanted true")
1301 }
1302
1303 docVar := NewVariableWithDoc("a", types.BoolType, "doc")
1304 a, err = VariableDeclToExprDecl(docVar)
1305 if err != nil {
1306 t.Fatalf("VariableDeclToExprDecl() failed: %v", err)
1307 }
1308 if docVar.Description() != a.GetIdent().GetDoc() {
1309 t.Errorf("docVar.Description() got %s, wanted %s", docVar.Description(), a.GetIdent().GetDoc())
1310 }
1311 if !proto.Equal(a, chkdecls.NewVarWithDoc("a", chkdecls.Bool, "doc")) {
1312 t.Error("proto.Equal() returned false, wanted true")
1313 }
1314}
1315
1316func TestVariableDeclToExprDeclInvalid(t *testing.T) {
1317 out, err := VariableDeclToExprDecl(NewVariable("bad", &types.Type{}))

Callers

nothing calls this directly

Calls 6

VariableDeclToExprDeclFunction · 0.85
NewVariableFunction · 0.70
NewVariableWithDocFunction · 0.70
EqualMethod · 0.65
DescriptionMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected