Skip to content

Commit

Permalink
Update cel-spec and fix strings.format to be conformant
Browse files Browse the repository at this point in the history
Signed-off-by: Justin King <[email protected]>
  • Loading branch information
jcking committed Jan 25, 2025
1 parent 2f7606a commit 081bd28
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ go_repository(
go_repository(
name = "dev_cel_expr",
importpath = "cel.dev/expr",
sum = "h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4=",
version = "v0.19.1",
sum = "h1:V354PbqIXr9IQdwy4SYA4xa0HXaWq1BUPAGzugBY5V4=",
version = "v0.19.2",
)

# local_repository(
Expand Down
7 changes: 7 additions & 0 deletions conformance/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ _TESTS_TO_SKIP = [
# Future enhancments.
"enums/strong_proto2",
"enums/strong_proto3",

# Type deductions.
"type_deductions/wrappers/wrapper_promotion_2",
"type_deductions/legacy_nullable_types/null_assignable_to_message_parameter_candidate",
"type_deductions/legacy_nullable_types/null_assignable_to_duration_parameter_candidate",
"type_deductions/legacy_nullable_types/null_assignable_to_timestamp_parameter_candidate",
"type_deductions/legacy_nullable_types/null_assignable_to_abstract_parameter_candidate",
]

go_test(
Expand Down
2 changes: 1 addition & 1 deletion conformance/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/google/cel-go/conformance
go 1.21.1

require (
cel.dev/expr v0.19.1
cel.dev/expr v0.19.2
github.com/bazelbuild/rules_go v0.49.0
github.com/google/cel-go v0.21.0
github.com/google/go-cmp v0.6.0
Expand Down
8 changes: 2 additions & 6 deletions conformance/go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
cel.dev/expr v0.18.0 h1:CJ6drgk+Hf96lkLikr4rFf19WrU0BOWEihyZnI2TAzo=
cel.dev/expr v0.18.0/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
cel.dev/expr v0.19.0 h1:lXuo+nDhpyJSpWxpPVi5cPUwzKb+dsdOiw6IreM5yt0=
cel.dev/expr v0.19.0/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
cel.dev/expr v0.19.1 h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4=
cel.dev/expr v0.19.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
cel.dev/expr v0.19.2 h1:V354PbqIXr9IQdwy4SYA4xa0HXaWq1BUPAGzugBY5V4=
cel.dev/expr v0.19.2/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
github.com/bazelbuild/rules_go v0.49.0 h1:5vCbuvy8Q11g41lseGJDc5vxhDjJtfxr6nM/IC4VmqM=
Expand Down
5 changes: 2 additions & 3 deletions ext/formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ func clauseForType(argType ref.Type) (clauseImpl, error) {
if !ok {
return "", fmt.Errorf("couldn't convert %s to float64", arg.Type().TypeName())
}
fmtStr := fmt.Sprintf("%%.%df", defaultPrecision)
return fmt.Sprintf(fmtStr, argDouble), nil
return strconv.FormatFloat(argDouble, 'f', -1, 64), nil
}, nil
case types.TypeType:
return func(arg ref.Val, locale string) (string, error) {
Expand Down Expand Up @@ -333,7 +332,7 @@ func (c *stringFormatter) Scientific(precision *int) func(ref.Val, string) (stri
return "", fmt.Errorf("error matching locale: %w", err)
}
fmtStr := fmt.Sprintf("%%%de", *precision)
return message.NewPrinter(matchedLocale).Sprintf(fmtStr, argFloat), nil
return strings.ReplaceAll(message.NewPrinter(matchedLocale).Sprintf(fmtStr, argFloat), "\u202f", ""), nil
}
}

Expand Down
8 changes: 4 additions & 4 deletions ext/strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func TestStringFormat(t *testing.T) {
name: "scientific notation formatting clause",
format: "%.6e",
formatArgs: "1052.032911275",
expectedOutput: "1.052033\u202f\u00d7\u202f10\u2070\u00b3",
expectedOutput: "1.052033\u00d710\u2070\u00b3",
expectedRuntimeCost: 11,
expectedEstimatedCost: checker.CostEstimate{Min: 11, Max: 11},
locale: "en_US",
Expand All @@ -688,7 +688,7 @@ func TestStringFormat(t *testing.T) {
name: "default precision for scientific notation",
format: "%e",
formatArgs: "2.71828",
expectedOutput: "2.718280\u202f\u00d7\u202f10\u2070\u2070",
expectedOutput: "2.718280\u00d710\u2070\u2070",
expectedRuntimeCost: 11,
expectedEstimatedCost: checker.CostEstimate{Min: 11, Max: 11},
locale: "en_US",
Expand Down Expand Up @@ -733,7 +733,7 @@ func TestStringFormat(t *testing.T) {
name: "unicode output for scientific notation",
format: "unescaped unicode: %e, escaped unicode: %e",
formatArgs: "2.71828, 2.71828",
expectedOutput: "unescaped unicode: 2.718280 × 10⁰⁰, escaped unicode: 2.718280\u202f\u00d7\u202f10\u2070\u2070",
expectedOutput: "unescaped unicode: 2.718280×10⁰⁰, escaped unicode: 2.718280\u00d710\u2070\u2070",
expectedRuntimeCost: 15,
expectedEstimatedCost: checker.CostEstimate{Min: 15, Max: 15},
locale: "en_US",
Expand Down Expand Up @@ -996,7 +996,7 @@ func TestStringFormat(t *testing.T) {
dynArgs: map[string]any{
"dynE": 2.71828,
},
expectedOutput: "(dyntype) e: 2.718280\u202f\u00d7\u202f10\u2070\u2070",
expectedOutput: "(dyntype) e: 2.718280\u00d710\u2070\u2070",
expectedRuntimeCost: 13,
expectedEstimatedCost: checker.CostEstimate{Min: 13, Max: 13},
locale: "en_US",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21.1
toolchain go1.23.0

require (
cel.dev/expr v0.19.1
cel.dev/expr v0.19.2
github.com/antlr4-go/antlr/v4 v4.13.0
github.com/stoewer/go-strcase v1.2.0
golang.org/x/text v0.16.0
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
cel.dev/expr v0.18.0 h1:CJ6drgk+Hf96lkLikr4rFf19WrU0BOWEihyZnI2TAzo=
cel.dev/expr v0.18.0/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
cel.dev/expr v0.19.0 h1:lXuo+nDhpyJSpWxpPVi5cPUwzKb+dsdOiw6IreM5yt0=
cel.dev/expr v0.19.0/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
cel.dev/expr v0.19.1 h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4=
cel.dev/expr v0.19.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
cel.dev/expr v0.19.2 h1:V354PbqIXr9IQdwy4SYA4xa0HXaWq1BUPAGzugBY5V4=
cel.dev/expr v0.19.2/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cel.dev/expr v0.19.1
# cel.dev/expr v0.19.2
## explicit; go 1.21.1
cel.dev/expr
# github.com/antlr4-go/antlr/v4 v4.13.0
Expand Down

0 comments on commit 081bd28

Please sign in to comment.