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

Function TestVariableDeclToExprDecl

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

Source from the content-addressed store, hash-verified

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