-
Notifications
You must be signed in to change notification settings - Fork 228
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
Document overflow behavior, add tests. #130
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,8 +190,6 @@ section { | |
eval_error: { | ||
errors: { message: "return error for overflow" } | ||
} | ||
## Current behavior: | ||
## value: { int64_value: -9223372036854775808 } | ||
} | ||
test { | ||
name: "int64_overflow_negative" | ||
|
@@ -200,8 +198,14 @@ section { | |
eval_error: { | ||
errors: { message: "return error for overflow" } | ||
} | ||
## Current behavior: | ||
## value: { int64_value: 9223372036854775807 } | ||
} | ||
test { | ||
name: "int64_min_negate" | ||
description: "Negated LLONG_MIN is not representable." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: extra There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Gabriel was using standard C constants, where "long" might only be 32-bits, so it's for "long long min", guaranteeing at least 64 bits. Long long could be bigger than that, but C's flexibility for integer sizes is mostly theoretical these days - at least outside the embedded market. |
||
expr: "-(-9223372036854775808)" | ||
eval_error: { | ||
errors: { message: "return error for overflow" } | ||
} | ||
} | ||
test { | ||
name: "uint64_overflow_positive" | ||
|
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.
Could we add a test to ensure negating the minimum
int
value will overflow?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.
Done. Thanks, good catch. In cel-go it wraps back to itself, but for consistency we should expect an error.