-
Notifications
You must be signed in to change notification settings - Fork 3
Add inferred types to test data #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
timostamm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment from me, see below. I also opened a small clean-up PR based on this. This looks good to me.
| export interface IncrementalTest { | ||
| name: string; | ||
| original: SimpleTest; | ||
| ast?: string; | ||
| type?: string; | ||
| error?: string; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The upstream SimpleTest definition already provides means to expect an error, and to expect a type. See https://github.com/google/cel-spec/blob/v0.25.1/proto/cel/expr/conformance/test/simple.proto#L109 and https://github.com/google/cel-spec/blob/v0.25.1/proto/cel/expr/conformance/test/simple.proto#L132.
They are used in the CEL conformance test data, see https://github.com/google/cel-spec/blob/v0.25.1/tests/simple/testdata/lists.textproto#L72 and https://github.com/google/cel-spec/blob/v0.25.1/tests/simple/testdata/type_deduction.textproto#L17.
So our generated test data ends up with redundant information, for example the expectation that the expression "true" is type bool:
{
original: {
name: "bool",
expr: "true",
typedResult: {
result: { boolValue: true },
deducedType: { primitive: "BOOL" },
},
},
ast: "true^#*expr.Constant_BoolValue#",
type: "bool",
}I wish this could be consolidated. If we can't right now, the least we should do is to add documentation to the properties of the IncrementalTest type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timostamm I went ahead and added documentation.
| // An `IncrementalTest` supplements a test extracted from the conformance suite | ||
| // or from the `cel-go` source code with additional information derived from the | ||
| // `cel-go` implementation. | ||
| export interface IncrementalTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great info, thanks!
Can we use JSDoc blocks? E.g. https://github.com/bufbuild/cel-es/blob/v0.3.0/packages/cel/src/timestamp.ts#L18-L21
I realize now that the doc style isn't consistent in this repository 🙈 JSDoc blocks are for user-facing docs (but we don't use JSDoc tags). Line comments are for internal implementation notes.
This reworks how we handle tests a little, adding inferred types that we can use to test the upcoming type-checker implementation.
packages/cel-spec/README.md explains the philosophy thusly: