Skip to content

Commit 6b53aa0

Browse files
Reintroduce CEL spec version in filename
Dropped in #374, but needed to pick up updates to the file trivially with `make`. Also, bump to 0.25.1 now that it's been released.
1 parent 23aac2c commit 6b53aa0

File tree

3 files changed

+83
-4
lines changed

3 files changed

+83
-4
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ ADD_LICENSE_HEADER := $(BIN)/license-header \
1818
# This version should be kept in sync with the version in buf.yaml
1919
PROTOVALIDATE_VERSION ?= v1.0.0
2020
# Version of the cel-spec that this implementation is conformant with
21-
CEL_SPEC_VERSION ?= v0.25.0
22-
TESTDATA_FILE := test/testdata/string_ext.textproto
21+
# This should be kept in sync with the version in test/test_format.py
22+
CEL_SPEC_VERSION ?= v0.25.1
23+
TESTDATA_FILE := test/testdata/string_ext_$(CEL_SPEC_VERSION).textproto
2324

2425
.PHONY: help
2526
help: ## Describe useful make targets

test/test_format.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
from protovalidate.internal import extra_func
2727
from protovalidate.internal.cel_field_presence import InterpretedRunner
2828

29+
# Version of the cel-spec that this implementation is conformant with.
30+
# This should be kept in sync with the version in ../Makefile.
31+
CEL_SPEC_VERSION = "v0.25.1"
32+
2933
skipped_tests = [
3034
# cel-python seems to have a bug with ints and booleans in the same map which evaluate to the same value
3135
# which the test data for this test has. For example: {1: 'value1', true: 'value2'}]).
@@ -79,7 +83,7 @@ def get_eval_error_message(test: simple_pb2.SimpleTest) -> str | None:
7983

8084

8185
# The test data from the cel-spec conformance tests
82-
cel_test_data = load_test_data("test/testdata/string_ext.textproto")
86+
cel_test_data = load_test_data(f"test/testdata/string_ext_{CEL_SPEC_VERSION}.textproto")
8387
# Our supplemental tests of functionality not in the cel conformance file, but defined in the spec.
8488
supplemental_test_data = load_test_data("test/testdata/string_ext_supplemental.textproto")
8589

test/testdata/string_ext.textproto renamed to test/testdata/string_ext_v0.25.1.textproto

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ section: {
9292
section: {
9393
name: "last_index_of"
9494
test: {
95-
name: "empty"
95+
name: "empty_string"
96+
expr: "''.lastIndexOf('@@') == -1"
97+
}
98+
test: {
99+
name: "empty_argument"
96100
expr: "'tacocat'.lastIndexOf('') == 7"
97101
}
98102
test: {
@@ -884,6 +888,76 @@ section: {
884888
string_value: '2.718280',
885889
}
886890
}
891+
test: {
892+
name: "format_%f_insignificant_zeroes_removed"
893+
expr: '"%.0f".format([123.000000])'
894+
value: {
895+
string_value: '123',
896+
}
897+
}
898+
test: {
899+
name: "format_%f_positive_round_to_whole_number"
900+
expr: '"%.0f".format([3.5001])'
901+
value: {
902+
string_value: '4',
903+
}
904+
}
905+
test: {
906+
name: "format_%f_negative_truncate_to_whole_number"
907+
expr: '"%.0f".format([3.4999])'
908+
value: {
909+
string_value: '3',
910+
}
911+
}
912+
test: {
913+
name: "format_%f_halfway_round_up_to_nearest_even"
914+
expr: '"%.0f".format([1.5])'
915+
value: {
916+
string_value: '2',
917+
}
918+
}
919+
test: {
920+
name: "format_%f_halfway_truncate_to_nearest_even"
921+
expr: '"%.0f".format([2.5])'
922+
value: {
923+
string_value: '2',
924+
}
925+
}
926+
test: {
927+
name: "format_%f_positive_round_up"
928+
expr: '"%.3f".format([123.4999])'
929+
value: {
930+
string_value: '123.500',
931+
}
932+
}
933+
test: {
934+
name: "format_%f_positive_round_down"
935+
expr: '"%.3f".format([123.4994])'
936+
value: {
937+
string_value: '123.499',
938+
}
939+
}
940+
test: {
941+
name: "format_%f_negative_round_up"
942+
expr: '"%.3f".format([-123.4999])'
943+
value: {
944+
string_value: '-123.500',
945+
}
946+
}
947+
test: {
948+
name: "format_%f_negative_round_down"
949+
expr: '"%.3f".format([-123.4994])'
950+
value: {
951+
string_value: '-123.499',
952+
}
953+
}
954+
test: {
955+
name: "format_%f_zero_padding"
956+
expr: '"%.5f".format([-1.2])'
957+
value: {
958+
string_value: '-1.20000',
959+
}
960+
}
887961
}
888962
section: {
889963
name: "format_errors"

0 commit comments

Comments
 (0)