From 831b6e76b919a3398067e51e7e322f22eca5457a Mon Sep 17 00:00:00 2001 From: Sean Huh Date: Thu, 12 Nov 2026 22:40:56 +0000 Subject: [PATCH] Remove migrated conformance tests and test protos The CEL conformance test suites and test proto definitions have been migrated to https://github.com/cel-expr/cel-conformance. Checked-in Go protobuf packages under conformance/{proto2,proto3,test} (cel.dev/expr/conformance/*) are retained for now to avoid breaking downstream Go consumers until cel-conformance publishes a Go module. --- .bcr/presubmit.yml | 2 - proto/buf.yaml | 3 - proto/cel/expr/conformance/proto2/BUILD.bazel | 87 - .../conformance/proto2/test_all_types.proto | 360 -- .../proto2/test_all_types_extensions.proto | 44 - proto/cel/expr/conformance/proto3/BUILD.bazel | 84 - .../conformance/proto3/test_all_types.proto | 350 -- proto/cel/expr/conformance/test/BUILD.bazel | 82 - proto/cel/expr/conformance/test/simple.proto | 145 - proto/cel/expr/conformance/test/suite.proto | 156 - tests/BUILD.bazel | 7 - tests/README.md | 19 - tests/simple/BUILD.bazel | 7 - tests/simple/testdata/README.md | 66 - tests/simple/testdata/basic.textproto | 287 -- tests/simple/testdata/bindings_ext.textproto | 102 - tests/simple/testdata/block_ext.textproto | 1070 ------ tests/simple/testdata/comparisons.textproto | 3080 ----------------- tests/simple/testdata/conversions.textproto | 622 ---- tests/simple/testdata/dynamic.textproto | 2289 ------------ tests/simple/testdata/encoders_ext.textproto | 44 - tests/simple/testdata/enums.textproto | 391 --- tests/simple/testdata/fields.textproto | 674 ---- tests/simple/testdata/fp_math.textproto | 167 - tests/simple/testdata/integer_math.textproto | 386 --- tests/simple/testdata/lists.textproto | 245 -- tests/simple/testdata/lists_ext.textproto | 293 -- tests/simple/testdata/logic.textproto | 198 -- tests/simple/testdata/macros.textproto | 289 -- tests/simple/testdata/macros2.textproto | 354 -- tests/simple/testdata/math_ext.textproto | 1266 ------- tests/simple/testdata/namespace.textproto | 262 -- tests/simple/testdata/network_ext.textproto | 420 --- tests/simple/testdata/optionals.textproto | 601 ---- tests/simple/testdata/parse.textproto | 1414 -------- tests/simple/testdata/plumbing.textproto | 74 - tests/simple/testdata/proto2.textproto | 1290 ------- tests/simple/testdata/proto2_ext.textproto | 372 -- tests/simple/testdata/proto3.textproto | 818 ----- tests/simple/testdata/sets_ext.textproto | 493 --- tests/simple/testdata/string.textproto | 288 -- tests/simple/testdata/string_ext.textproto | 1535 -------- tests/simple/testdata/timestamps.textproto | 610 ---- .../simple/testdata/type_deduction.textproto | 1353 -------- tests/simple/testdata/unknowns.textproto | 5 - tests/simple/testdata/wrappers.textproto | 520 --- 46 files changed, 23224 deletions(-) delete mode 100644 proto/cel/expr/conformance/proto2/BUILD.bazel delete mode 100644 proto/cel/expr/conformance/proto2/test_all_types.proto delete mode 100644 proto/cel/expr/conformance/proto2/test_all_types_extensions.proto delete mode 100644 proto/cel/expr/conformance/proto3/BUILD.bazel delete mode 100644 proto/cel/expr/conformance/proto3/test_all_types.proto delete mode 100644 proto/cel/expr/conformance/test/BUILD.bazel delete mode 100644 proto/cel/expr/conformance/test/simple.proto delete mode 100644 proto/cel/expr/conformance/test/suite.proto delete mode 100644 tests/BUILD.bazel delete mode 100644 tests/README.md delete mode 100644 tests/simple/BUILD.bazel delete mode 100644 tests/simple/testdata/README.md delete mode 100644 tests/simple/testdata/basic.textproto delete mode 100644 tests/simple/testdata/bindings_ext.textproto delete mode 100644 tests/simple/testdata/block_ext.textproto delete mode 100644 tests/simple/testdata/comparisons.textproto delete mode 100644 tests/simple/testdata/conversions.textproto delete mode 100644 tests/simple/testdata/dynamic.textproto delete mode 100644 tests/simple/testdata/encoders_ext.textproto delete mode 100644 tests/simple/testdata/enums.textproto delete mode 100644 tests/simple/testdata/fields.textproto delete mode 100644 tests/simple/testdata/fp_math.textproto delete mode 100644 tests/simple/testdata/integer_math.textproto delete mode 100644 tests/simple/testdata/lists.textproto delete mode 100644 tests/simple/testdata/lists_ext.textproto delete mode 100644 tests/simple/testdata/logic.textproto delete mode 100644 tests/simple/testdata/macros.textproto delete mode 100644 tests/simple/testdata/macros2.textproto delete mode 100644 tests/simple/testdata/math_ext.textproto delete mode 100644 tests/simple/testdata/namespace.textproto delete mode 100644 tests/simple/testdata/network_ext.textproto delete mode 100644 tests/simple/testdata/optionals.textproto delete mode 100644 tests/simple/testdata/parse.textproto delete mode 100644 tests/simple/testdata/plumbing.textproto delete mode 100644 tests/simple/testdata/proto2.textproto delete mode 100644 tests/simple/testdata/proto2_ext.textproto delete mode 100644 tests/simple/testdata/proto3.textproto delete mode 100644 tests/simple/testdata/sets_ext.textproto delete mode 100644 tests/simple/testdata/string.textproto delete mode 100644 tests/simple/testdata/string_ext.textproto delete mode 100644 tests/simple/testdata/timestamps.textproto delete mode 100644 tests/simple/testdata/type_deduction.textproto delete mode 100644 tests/simple/testdata/unknowns.textproto delete mode 100644 tests/simple/testdata/wrappers.textproto diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index d65a2b5c..27d26394 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -21,8 +21,6 @@ tasks: - '@cel-spec//proto/cel/expr:explain_cc_proto' - '@cel-spec//proto/cel/expr:syntax_cc_proto' - '@cel-spec//proto/cel/expr:value_cc_proto' - - '@cel-spec//proto/cel/expr/conformance/proto2:test_all_types_cc_proto' - - '@cel-spec//proto/cel/expr/conformance/proto3:test_all_types_cc_proto' verify_targets_windows: name: "Verify Windows build targets" diff --git a/proto/buf.yaml b/proto/buf.yaml index 89cbaf08..28edf4a3 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -4,9 +4,6 @@ deps: build: excludes: [test, dev] lint: - ignore: - - cel/expr/conformance/proto2/test_all_types.proto - - cel/expr/conformance/proto3/test_all_types.proto except: - PACKAGE_VERSION_SUFFIX - ENUM_VALUE_PREFIX diff --git a/proto/cel/expr/conformance/proto2/BUILD.bazel b/proto/cel/expr/conformance/proto2/BUILD.bazel deleted file mode 100644 index df18a74f..00000000 --- a/proto/cel/expr/conformance/proto2/BUILD.bazel +++ /dev/null @@ -1,87 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -############################################################################## -# Common -############################################################################## - -load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") - -proto_library( - name = "test_all_types_proto", - srcs = [ - "test_all_types.proto", - "test_all_types_extensions.proto", - ], - strip_import_prefix = "/proto", - deps = [ - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:field_mask_proto", - "@com_google_protobuf//:struct_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:wrappers_proto", - ], -) - -############################################################################## -# Java -############################################################################## - -load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library") - -java_proto_library( - name = "test_all_types_java_proto", - deps = [":test_all_types_proto"], -) - -############################################################################## -# Javalite -############################################################################## - -load("@com_google_protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library") - -java_lite_proto_library( - name = "test_all_types_java_proto_lite", - deps = [":test_all_types_proto"], -) - -############################################################################### -## Go -############################################################################### - -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") - -go_proto_library( - name = "test_all_types_go_proto", - importpath = "cel.dev/expr/conformance/proto2", - protos = [":test_all_types_proto"], -) - -############################################################################### -## C++ -############################################################################### - -load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") - -cc_proto_library( - name = "test_all_types_cc_proto", - deps = [":test_all_types_proto"], -) - -############################################################################### -## upb -############################################################################### - -load("@com_google_protobuf//bazel:upb_c_proto_library.bzl", "upb_c_proto_library") -load("@com_google_protobuf//bazel:upb_proto_reflection_library.bzl", "upb_proto_reflection_library") - -upb_c_proto_library( - name = "test_all_types_upb_proto", - deps = [":test_all_types_proto"], -) - -upb_proto_reflection_library( - name = "test_all_types_upb_proto_reflection", - deps = [":test_all_types_proto"], -) diff --git a/proto/cel/expr/conformance/proto2/test_all_types.proto b/proto/cel/expr/conformance/proto2/test_all_types.proto deleted file mode 100644 index 620a1e4f..00000000 --- a/proto/cel/expr/conformance/proto2/test_all_types.proto +++ /dev/null @@ -1,360 +0,0 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto2"; - -package cel.expr.conformance.proto2; - -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option cc_enable_arenas = true; -option go_package = "cel.dev/expr/conformance/proto2"; -option java_multiple_files = true; -option java_outer_classname = "TestAllTypesProto"; -option java_package = "dev.cel.expr.conformance.proto2"; - -// This proto includes every type of field in both singular and repeated -// forms. -message TestAllTypes { - message NestedMessage { - // The field name "b" fails to compile in proto1 because it conflicts with - // a local variable named "b" in one of the generated methods. - // This file needs to compile in proto1 to test backwards-compatibility. - optional int32 bb = 1; - } - - enum NestedEnum { - FOO = 0; - BAR = 1; - BAZ = 2; - } - - // Singular - optional int32 single_int32 = 1 [default = -32]; - optional int64 single_int64 = 2 [default = -64]; - optional uint32 single_uint32 = 3 [default = 32]; - optional uint64 single_uint64 = 4 [default = 64]; - optional sint32 single_sint32 = 5; - optional sint64 single_sint64 = 6; - optional fixed32 single_fixed32 = 7; - optional fixed64 single_fixed64 = 8; - optional sfixed32 single_sfixed32 = 9; - optional sfixed64 single_sfixed64 = 10; - optional float single_float = 11 [default = 3.0]; - optional double single_double = 12 [default = 6.4]; - optional bool single_bool = 13 [default = true]; - optional string single_string = 14 [default = "empty"]; - optional bytes single_bytes = 15 [default = "none"]; - - // Collides with 'in' operator. - optional bool in = 18; - - // Wellknown. - optional google.protobuf.Any single_any = 100; - optional google.protobuf.Duration single_duration = 101; - optional google.protobuf.Timestamp single_timestamp = 102; - optional google.protobuf.Struct single_struct = 103; - optional google.protobuf.Value single_value = 104; - optional google.protobuf.Int64Value single_int64_wrapper = 105; - optional google.protobuf.Int32Value single_int32_wrapper = 106; - optional google.protobuf.DoubleValue single_double_wrapper = 107; - optional google.protobuf.FloatValue single_float_wrapper = 108; - optional google.protobuf.UInt64Value single_uint64_wrapper = 109; - optional google.protobuf.UInt32Value single_uint32_wrapper = 110; - optional google.protobuf.StringValue single_string_wrapper = 111; - optional google.protobuf.BoolValue single_bool_wrapper = 112; - optional google.protobuf.BytesValue single_bytes_wrapper = 113; - optional google.protobuf.ListValue list_value = 114; - optional google.protobuf.NullValue null_value = 115; - optional google.protobuf.NullValue optional_null_value = 116; - optional google.protobuf.FieldMask field_mask = 117; - optional google.protobuf.Empty empty = 118; - - // Nested messages - oneof nested_type { - NestedMessage single_nested_message = 21; - NestedEnum single_nested_enum = 22 [default = BAR]; - } - optional NestedMessage standalone_message = 23; - optional NestedEnum standalone_enum = 24; - - // Repeated - repeated int32 repeated_int32 = 31; - repeated int64 repeated_int64 = 32; - repeated uint32 repeated_uint32 = 33; - repeated uint64 repeated_uint64 = 34; - repeated sint32 repeated_sint32 = 35; - repeated sint64 repeated_sint64 = 36; - repeated fixed32 repeated_fixed32 = 37; - repeated fixed64 repeated_fixed64 = 38; - repeated sfixed32 repeated_sfixed32 = 39; - repeated sfixed64 repeated_sfixed64 = 40; - repeated float repeated_float = 41; - repeated double repeated_double = 42; - repeated bool repeated_bool = 43; - repeated string repeated_string = 44; - repeated bytes repeated_bytes = 45; - - // Repeated and nested - repeated NestedMessage repeated_nested_message = 51; - repeated NestedEnum repeated_nested_enum = 52; - repeated string repeated_string_piece = 53 [ctype = STRING_PIECE]; - repeated string repeated_cord = 54 [ctype = CORD]; - repeated NestedMessage repeated_lazy_message = 55; - - // Repeated wellknown. - repeated google.protobuf.Any repeated_any = 120; - repeated google.protobuf.Duration repeated_duration = 121; - repeated google.protobuf.Timestamp repeated_timestamp = 122; - repeated google.protobuf.Struct repeated_struct = 123; - repeated google.protobuf.Value repeated_value = 124; - repeated google.protobuf.Int64Value repeated_int64_wrapper = 125; - repeated google.protobuf.Int32Value repeated_int32_wrapper = 126; - repeated google.protobuf.DoubleValue repeated_double_wrapper = 127; - repeated google.protobuf.FloatValue repeated_float_wrapper = 128; - repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 129; - repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 130; - repeated google.protobuf.StringValue repeated_string_wrapper = 131; - repeated google.protobuf.BoolValue repeated_bool_wrapper = 132; - repeated google.protobuf.BytesValue repeated_bytes_wrapper = 133; - repeated google.protobuf.ListValue repeated_list_value = 134; - repeated google.protobuf.NullValue repeated_null_value = 135; - - // Map - map map_int64_nested_type = 62; - - map map_bool_bool = 63; - map map_bool_string = 64; - map map_bool_bytes = 65; - map map_bool_int32 = 66; - map map_bool_int64 = 67; - map map_bool_uint32 = 68; - map map_bool_uint64 = 69; - map map_bool_float = 70; - map map_bool_double = 71; - map map_bool_enum = 72; - map map_bool_message = 73; - map map_bool_duration = 228; - map map_bool_timestamp = 229; - map map_bool_null_value = 230; - map map_bool_any = 246; - map map_bool_struct = 247; - map map_bool_value = 248; - map map_bool_list_value = 249; - map map_bool_int64_wrapper = 250; - map map_bool_int32_wrapper = 251; - map map_bool_double_wrapper = 252; - map map_bool_float_wrapper = 253; - map map_bool_uint64_wrapper = 254; - map map_bool_uint32_wrapper = 255; - map map_bool_string_wrapper = 256; - map map_bool_bool_wrapper = 257; - map map_bool_bytes_wrapper = 258; - - map map_int32_bool = 74; - map map_int32_string = 75; - map map_int32_bytes = 76; - map map_int32_int32 = 77; - map map_int32_int64 = 78; - map map_int32_uint32 = 79; - map map_int32_uint64 = 80; - map map_int32_float = 81; - map map_int32_double = 82; - map map_int32_enum = 83; - map map_int32_message = 84; - map map_int32_duration = 231; - map map_int32_timestamp = 232; - map map_int32_null_value = 233; - map map_int32_any = 259; - map map_int32_struct = 260; - map map_int32_value = 261; - map map_int32_list_value = 262; - map map_int32_int64_wrapper = 263; - map map_int32_int32_wrapper = 264; - map map_int32_double_wrapper = 265; - map map_int32_float_wrapper = 266; - map map_int32_uint64_wrapper = 267; - map map_int32_uint32_wrapper = 268; - map map_int32_string_wrapper = 269; - map map_int32_bool_wrapper = 270; - map map_int32_bytes_wrapper = 271; - - map map_int64_bool = 85; - map map_int64_string = 86; - map map_int64_bytes = 87; - map map_int64_int32 = 88; - map map_int64_int64 = 89; - map map_int64_uint32 = 90; - map map_int64_uint64 = 91; - map map_int64_float = 92; - map map_int64_double = 93; - map map_int64_enum = 94; - map map_int64_message = 95; - map map_int64_duration = 234; - map map_int64_timestamp = 235; - map map_int64_null_value = 236; - map map_int64_any = 272; - map map_int64_struct = 273; - map map_int64_value = 274; - map map_int64_list_value = 275; - map map_int64_int64_wrapper = 276; - map map_int64_int32_wrapper = 277; - map map_int64_double_wrapper = 278; - map map_int64_float_wrapper = 279; - map map_int64_uint64_wrapper = 280; - map map_int64_uint32_wrapper = 281; - map map_int64_string_wrapper = 282; - map map_int64_bool_wrapper = 283; - map map_int64_bytes_wrapper = 284; - - map map_uint32_bool = 96; - map map_uint32_string = 97; - map map_uint32_bytes = 98; - map map_uint32_int32 = 99; - map map_uint32_int64 = 200; - map map_uint32_uint32 = 201; - map map_uint32_uint64 = 202; - map map_uint32_float = 203; - map map_uint32_double = 204; - map map_uint32_enum = 205; - map map_uint32_message = 206; - map map_uint32_duration = 237; - map map_uint32_timestamp = 238; - map map_uint32_null_value = 239; - map map_uint32_any = 285; - map map_uint32_struct = 286; - map map_uint32_value = 287; - map map_uint32_list_value = 288; - map map_uint32_int64_wrapper = 289; - map map_uint32_int32_wrapper = 290; - map map_uint32_double_wrapper = 291; - map map_uint32_float_wrapper = 292; - map map_uint32_uint64_wrapper = 293; - map map_uint32_uint32_wrapper = 294; - map map_uint32_string_wrapper = 295; - map map_uint32_bool_wrapper = 296; - map map_uint32_bytes_wrapper = 297; - - map map_uint64_bool = 207; - map map_uint64_string = 208; - map map_uint64_bytes = 209; - map map_uint64_int32 = 210; - map map_uint64_int64 = 211; - map map_uint64_uint32 = 212; - map map_uint64_uint64 = 213; - map map_uint64_float = 214; - map map_uint64_double = 215; - map map_uint64_enum = 216; - map map_uint64_message = 217; - map map_uint64_duration = 240; - map map_uint64_timestamp = 241; - map map_uint64_null_value = 242; - map map_uint64_any = 298; - map map_uint64_struct = 299; - map map_uint64_value = 300; - map map_uint64_list_value = 301; - map map_uint64_int64_wrapper = 302; - map map_uint64_int32_wrapper = 303; - map map_uint64_double_wrapper = 304; - map map_uint64_float_wrapper = 305; - map map_uint64_uint64_wrapper = 306; - map map_uint64_uint32_wrapper = 307; - map map_uint64_string_wrapper = 308; - map map_uint64_bool_wrapper = 309; - map map_uint64_bytes_wrapper = 310; - - map map_string_bool = 218; - map map_string_string = 61; - map map_string_bytes = 219; - map map_string_int32 = 220; - map map_string_int64 = 221; - map map_string_uint32 = 222; - map map_string_uint64 = 223; - map map_string_float = 224; - map map_string_double = 225; - map map_string_enum = 226; - map map_string_message = 227; - map map_string_duration = 243; - map map_string_timestamp = 244; - map map_string_null_value = 245; - map map_string_any = 311; - map map_string_struct = 312; - map map_string_value = 313; - map map_string_list_value = 314; - map map_string_int64_wrapper = 315; - map map_string_int32_wrapper = 316; - map map_string_double_wrapper = 317; - map map_string_float_wrapper = 318; - map map_string_uint64_wrapper = 319; - map map_string_uint32_wrapper = 320; - map map_string_string_wrapper = 321; - map map_string_bool_wrapper = 322; - map map_string_bytes_wrapper = 323; - - oneof kind { - NestedTestAllTypes oneof_type = 400; - NestedMessage oneof_msg = 401; - bool oneof_bool = 402; - } - - optional group NestedGroup = 403 { - optional int32 single_id = 404; - optional string single_name = 405; - } - - // Field names formerly defined as reserved CEL identifiers. - optional bool as = 500; - optional bool break = 501; - optional bool const = 502; - optional bool continue = 503; - optional bool else = 504; - optional bool for = 505; - optional bool function = 506; - optional bool if = 507; - optional bool import = 508; - optional bool let = 509; - optional bool loop = 510; - optional bool package = 511; - optional bool namespace = 512; - optional bool return = 513; - optional bool var = 514; - optional bool void = 515; - optional bool while = 516; - - extensions 1000 to max; -} - -// This proto includes a recursively nested message. -message NestedTestAllTypes { - optional NestedTestAllTypes child = 1; - optional TestAllTypes payload = 2; -} - -// This proto has a required field. -message TestRequired { - required int32 required_int32 = 1; -} - -// This proto tests that global enums are resolved correctly. -enum GlobalEnum { - GOO = 0; - GAR = 1; - GAZ = 2; -} diff --git a/proto/cel/expr/conformance/proto2/test_all_types_extensions.proto b/proto/cel/expr/conformance/proto2/test_all_types_extensions.proto deleted file mode 100644 index 1c37f4f5..00000000 --- a/proto/cel/expr/conformance/proto2/test_all_types_extensions.proto +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto2"; - -package cel.expr.conformance.proto2; - -import "cel/expr/conformance/proto2/test_all_types.proto"; - -option cc_enable_arenas = true; -option go_package = "cel.dev/expr/conformance/proto2"; -option java_outer_classname = "TestAllTypesExtensions"; -option java_package = "dev.cel.expr.conformance.proto2"; -option java_multiple_files = true; - -// Package scoped extensions -extend TestAllTypes { - optional int32 int32_ext = 1000; - optional TestAllTypes nested_ext = 1001; - optional TestAllTypes test_all_types_ext = 1002; - optional TestAllTypes.NestedEnum nested_enum_ext = 1003; - repeated TestAllTypes repeated_test_all_types = 1004; -} - -// Message scoped extensions -message Proto2ExtensionScopedMessage { - extend TestAllTypes { - optional int64 int64_ext = 1005; - optional TestAllTypes message_scoped_nested_ext = 1006; - optional TestAllTypes.NestedEnum nested_enum_ext = 1007; - repeated TestAllTypes message_scoped_repeated_test_all_types = 1008; - } -} diff --git a/proto/cel/expr/conformance/proto3/BUILD.bazel b/proto/cel/expr/conformance/proto3/BUILD.bazel deleted file mode 100644 index 32fcfbb9..00000000 --- a/proto/cel/expr/conformance/proto3/BUILD.bazel +++ /dev/null @@ -1,84 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -############################################################################## -# Common -############################################################################## - -load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") - -proto_library( - name = "test_all_types_proto", - srcs = ["test_all_types.proto"], - strip_import_prefix = "/proto", - deps = [ - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:field_mask_proto", - "@com_google_protobuf//:struct_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:wrappers_proto", - ], -) - -############################################################################## -# Java -############################################################################## - -load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library") - -java_proto_library( - name = "test_all_types_java_proto", - deps = [":test_all_types_proto"], -) - -############################################################################## -# Javalite -############################################################################## - -load("@com_google_protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library") - -java_lite_proto_library( - name = "test_all_types_java_proto_lite", - deps = [":test_all_types_proto"], -) - -############################################################################### -## Go -############################################################################### - -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") - -go_proto_library( - name = "test_all_types_go_proto", - importpath = "cel.dev/expr/conformance/proto3", - protos = [":test_all_types_proto"], -) - -############################################################################### -## C++ -############################################################################### - -load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") - -cc_proto_library( - name = "test_all_types_cc_proto", - deps = [":test_all_types_proto"], -) - -############################################################################### -## upb -############################################################################### - -load("@com_google_protobuf//bazel:upb_c_proto_library.bzl", "upb_c_proto_library") -load("@com_google_protobuf//bazel:upb_proto_reflection_library.bzl", "upb_proto_reflection_library") - -upb_c_proto_library( - name = "test_all_types_upb_proto", - deps = [":test_all_types_proto"], -) - -upb_proto_reflection_library( - name = "test_all_types_upb_proto_reflection", - deps = [":test_all_types_proto"], -) diff --git a/proto/cel/expr/conformance/proto3/test_all_types.proto b/proto/cel/expr/conformance/proto3/test_all_types.proto deleted file mode 100644 index ff6f31a8..00000000 --- a/proto/cel/expr/conformance/proto3/test_all_types.proto +++ /dev/null @@ -1,350 +0,0 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package cel.expr.conformance.proto3; - -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option cc_enable_arenas = true; -option go_package = "cel.dev/expr/conformance/proto3"; -option java_multiple_files = true; -option java_outer_classname = "TestAllTypesProto"; -option java_package = "dev.cel.expr.conformance.proto3"; - -// This proto includes every type of field in both singular and repeated -// forms. -message TestAllTypes { - message NestedMessage { - // The field name "b" fails to compile in proto1 because it conflicts with - // a local variable named "b" in one of the generated methods. - // This file needs to compile in proto1 to test backwards-compatibility. - int32 bb = 1; - } - - enum NestedEnum { - FOO = 0; - BAR = 1; - BAZ = 2; - } - - // Singular - int32 single_int32 = 1; - int64 single_int64 = 2; - uint32 single_uint32 = 3; - uint64 single_uint64 = 4; - sint32 single_sint32 = 5; - sint64 single_sint64 = 6; - fixed32 single_fixed32 = 7; - fixed64 single_fixed64 = 8; - sfixed32 single_sfixed32 = 9; - sfixed64 single_sfixed64 = 10; - float single_float = 11; - double single_double = 12; - bool single_bool = 13; - string single_string = 14; - bytes single_bytes = 15; - optional bool optional_bool = 16; - optional string optional_string = 17; - - // Collides with 'in' operator. - bool in = 18; - - // Wellknown. - google.protobuf.Any single_any = 100; - google.protobuf.Duration single_duration = 101; - google.protobuf.Timestamp single_timestamp = 102; - google.protobuf.Struct single_struct = 103; - google.protobuf.Value single_value = 104; - google.protobuf.Int64Value single_int64_wrapper = 105; - google.protobuf.Int32Value single_int32_wrapper = 106; - google.protobuf.DoubleValue single_double_wrapper = 107; - google.protobuf.FloatValue single_float_wrapper = 108; - google.protobuf.UInt64Value single_uint64_wrapper = 109; - google.protobuf.UInt32Value single_uint32_wrapper = 110; - google.protobuf.StringValue single_string_wrapper = 111; - google.protobuf.BoolValue single_bool_wrapper = 112; - google.protobuf.BytesValue single_bytes_wrapper = 113; - google.protobuf.ListValue list_value = 114; - google.protobuf.NullValue null_value = 115; - optional google.protobuf.NullValue optional_null_value = 116; - google.protobuf.FieldMask field_mask = 117; - google.protobuf.Empty empty = 118; - - // Nested messages - oneof nested_type { - NestedMessage single_nested_message = 21; - NestedEnum single_nested_enum = 22; - } - NestedMessage standalone_message = 23; - NestedEnum standalone_enum = 24; - - // Repeated - repeated int32 repeated_int32 = 31; - repeated int64 repeated_int64 = 32; - repeated uint32 repeated_uint32 = 33; - repeated uint64 repeated_uint64 = 34; - repeated sint32 repeated_sint32 = 35; - repeated sint64 repeated_sint64 = 36; - repeated fixed32 repeated_fixed32 = 37; - repeated fixed64 repeated_fixed64 = 38; - repeated sfixed32 repeated_sfixed32 = 39; - repeated sfixed64 repeated_sfixed64 = 40; - repeated float repeated_float = 41; - repeated double repeated_double = 42; - repeated bool repeated_bool = 43; - repeated string repeated_string = 44; - repeated bytes repeated_bytes = 45; - - // Repeated and nested - repeated NestedMessage repeated_nested_message = 51; - repeated NestedEnum repeated_nested_enum = 52; - repeated string repeated_string_piece = 53 [ctype = STRING_PIECE]; - repeated string repeated_cord = 54 [ctype = CORD]; - repeated NestedMessage repeated_lazy_message = 55; - - // Repeated wellknown. - repeated google.protobuf.Any repeated_any = 120; - repeated google.protobuf.Duration repeated_duration = 121; - repeated google.protobuf.Timestamp repeated_timestamp = 122; - repeated google.protobuf.Struct repeated_struct = 123; - repeated google.protobuf.Value repeated_value = 124; - repeated google.protobuf.Int64Value repeated_int64_wrapper = 125; - repeated google.protobuf.Int32Value repeated_int32_wrapper = 126; - repeated google.protobuf.DoubleValue repeated_double_wrapper = 127; - repeated google.protobuf.FloatValue repeated_float_wrapper = 128; - repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 129; - repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 130; - repeated google.protobuf.StringValue repeated_string_wrapper = 131; - repeated google.protobuf.BoolValue repeated_bool_wrapper = 132; - repeated google.protobuf.BytesValue repeated_bytes_wrapper = 133; - repeated google.protobuf.ListValue repeated_list_value = 134; - repeated google.protobuf.NullValue repeated_null_value = 135; - - // Map - map map_int64_nested_type = 62; - - map map_bool_bool = 63; - map map_bool_string = 64; - map map_bool_bytes = 65; - map map_bool_int32 = 66; - map map_bool_int64 = 67; - map map_bool_uint32 = 68; - map map_bool_uint64 = 69; - map map_bool_float = 70; - map map_bool_double = 71; - map map_bool_enum = 72; - map map_bool_message = 73; - map map_bool_duration = 228; - map map_bool_timestamp = 229; - map map_bool_null_value = 230; - map map_bool_any = 246; - map map_bool_struct = 247; - map map_bool_value = 248; - map map_bool_list_value = 249; - map map_bool_int64_wrapper = 250; - map map_bool_int32_wrapper = 251; - map map_bool_double_wrapper = 252; - map map_bool_float_wrapper = 253; - map map_bool_uint64_wrapper = 254; - map map_bool_uint32_wrapper = 255; - map map_bool_string_wrapper = 256; - map map_bool_bool_wrapper = 257; - map map_bool_bytes_wrapper = 258; - - map map_int32_bool = 74; - map map_int32_string = 75; - map map_int32_bytes = 76; - map map_int32_int32 = 77; - map map_int32_int64 = 78; - map map_int32_uint32 = 79; - map map_int32_uint64 = 80; - map map_int32_float = 81; - map map_int32_double = 82; - map map_int32_enum = 83; - map map_int32_message = 84; - map map_int32_duration = 231; - map map_int32_timestamp = 232; - map map_int32_null_value = 233; - map map_int32_any = 259; - map map_int32_struct = 260; - map map_int32_value = 261; - map map_int32_list_value = 262; - map map_int32_int64_wrapper = 263; - map map_int32_int32_wrapper = 264; - map map_int32_double_wrapper = 265; - map map_int32_float_wrapper = 266; - map map_int32_uint64_wrapper = 267; - map map_int32_uint32_wrapper = 268; - map map_int32_string_wrapper = 269; - map map_int32_bool_wrapper = 270; - map map_int32_bytes_wrapper = 271; - - map map_int64_bool = 85; - map map_int64_string = 86; - map map_int64_bytes = 87; - map map_int64_int32 = 88; - map map_int64_int64 = 89; - map map_int64_uint32 = 90; - map map_int64_uint64 = 91; - map map_int64_float = 92; - map map_int64_double = 93; - map map_int64_enum = 94; - map map_int64_message = 95; - map map_int64_duration = 234; - map map_int64_timestamp = 235; - map map_int64_null_value = 236; - map map_int64_any = 272; - map map_int64_struct = 273; - map map_int64_value = 274; - map map_int64_list_value = 275; - map map_int64_int64_wrapper = 276; - map map_int64_int32_wrapper = 277; - map map_int64_double_wrapper = 278; - map map_int64_float_wrapper = 279; - map map_int64_uint64_wrapper = 280; - map map_int64_uint32_wrapper = 281; - map map_int64_string_wrapper = 282; - map map_int64_bool_wrapper = 283; - map map_int64_bytes_wrapper = 284; - - map map_uint32_bool = 96; - map map_uint32_string = 97; - map map_uint32_bytes = 98; - map map_uint32_int32 = 99; - map map_uint32_int64 = 200; - map map_uint32_uint32 = 201; - map map_uint32_uint64 = 202; - map map_uint32_float = 203; - map map_uint32_double = 204; - map map_uint32_enum = 205; - map map_uint32_message = 206; - map map_uint32_duration = 237; - map map_uint32_timestamp = 238; - map map_uint32_null_value = 239; - map map_uint32_any = 285; - map map_uint32_struct = 286; - map map_uint32_value = 287; - map map_uint32_list_value = 288; - map map_uint32_int64_wrapper = 289; - map map_uint32_int32_wrapper = 290; - map map_uint32_double_wrapper = 291; - map map_uint32_float_wrapper = 292; - map map_uint32_uint64_wrapper = 293; - map map_uint32_uint32_wrapper = 294; - map map_uint32_string_wrapper = 295; - map map_uint32_bool_wrapper = 296; - map map_uint32_bytes_wrapper = 297; - - map map_uint64_bool = 207; - map map_uint64_string = 208; - map map_uint64_bytes = 209; - map map_uint64_int32 = 210; - map map_uint64_int64 = 211; - map map_uint64_uint32 = 212; - map map_uint64_uint64 = 213; - map map_uint64_float = 214; - map map_uint64_double = 215; - map map_uint64_enum = 216; - map map_uint64_message = 217; - map map_uint64_duration = 240; - map map_uint64_timestamp = 241; - map map_uint64_null_value = 242; - map map_uint64_any = 298; - map map_uint64_struct = 299; - map map_uint64_value = 300; - map map_uint64_list_value = 301; - map map_uint64_int64_wrapper = 302; - map map_uint64_int32_wrapper = 303; - map map_uint64_double_wrapper = 304; - map map_uint64_float_wrapper = 305; - map map_uint64_uint64_wrapper = 306; - map map_uint64_uint32_wrapper = 307; - map map_uint64_string_wrapper = 308; - map map_uint64_bool_wrapper = 309; - map map_uint64_bytes_wrapper = 310; - - map map_string_bool = 218; - map map_string_string = 61; - map map_string_bytes = 219; - map map_string_int32 = 220; - map map_string_int64 = 221; - map map_string_uint32 = 222; - map map_string_uint64 = 223; - map map_string_float = 224; - map map_string_double = 225; - map map_string_enum = 226; - map map_string_message = 227; - map map_string_duration = 243; - map map_string_timestamp = 244; - map map_string_null_value = 245; - map map_string_any = 311; - map map_string_struct = 312; - map map_string_value = 313; - map map_string_list_value = 314; - map map_string_int64_wrapper = 315; - map map_string_int32_wrapper = 316; - map map_string_double_wrapper = 317; - map map_string_float_wrapper = 318; - map map_string_uint64_wrapper = 319; - map map_string_uint32_wrapper = 320; - map map_string_string_wrapper = 321; - map map_string_bool_wrapper = 322; - map map_string_bytes_wrapper = 323; - - oneof kind { - NestedTestAllTypes oneof_type = 400; - NestedMessage oneof_msg = 401; - bool oneof_bool = 402; - } - - // Field names formerly defined as reserved CEL identifiers. - bool as = 500; - bool break = 501; - bool const = 502; - bool continue = 503; - bool else = 504; - bool for = 505; - bool function = 506; - bool if = 507; - bool import = 508; - bool let = 509; - bool loop = 510; - bool package = 511; - bool namespace = 512; - bool return = 513; - bool var = 514; - bool void = 515; - bool while = 516; -} - -// This proto includes a recursively nested message. -message NestedTestAllTypes { - NestedTestAllTypes child = 1; - TestAllTypes payload = 2; -} - -// This proto tests that global enums are resolved correctly. -enum GlobalEnum { - GOO = 0; - GAR = 1; - GAZ = 2; -} diff --git a/proto/cel/expr/conformance/test/BUILD.bazel b/proto/cel/expr/conformance/test/BUILD.bazel deleted file mode 100644 index 09eba1fc..00000000 --- a/proto/cel/expr/conformance/test/BUILD.bazel +++ /dev/null @@ -1,82 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") - -############################################################################## -# Common -############################################################################## - -proto_library( - name = "simple_proto", - srcs = ["simple.proto"], - strip_import_prefix = "/proto", - deps = [ - "//proto/cel/expr:checked_proto", - "//proto/cel/expr:eval_proto", - "//proto/cel/expr:value_proto", - ], -) - -proto_library( - name = "suite_proto", - srcs = ["suite.proto"], - strip_import_prefix = "/proto", - deps = [ - "//proto/cel/expr:checked_proto", - "//proto/cel/expr:eval_proto", - "//proto/cel/expr:value_proto", - "//proto/cel/expr/conformance:env_config_proto", - "@com_google_protobuf//:any_proto", - ], -) - -############################################################################## -## C++ -############################################################################## - -cc_proto_library( - name = "simple_cc_proto", - deps = [":simple_proto"], -) - -cc_proto_library( - name = "suite_cc_proto", - deps = [":suite_proto"], -) - -############################################################################## -## Go -############################################################################## - -go_proto_library( - name = "simple_go_proto", - importpath = "cel.dev/expr/conformance/test", - protos = [":simple_proto"], - deps = [ - "//proto/cel/expr:expr_go_proto", - ], -) - -go_proto_library( - name = "suite_go_proto", - importpath = "cel.dev/expr/conformance/test", - protos = [":suite_proto"], - deps = [ - "//proto/cel/expr:expr_go_proto", - "//proto/cel/expr/conformance:env_config_go_proto", - ], -) - -############################################################################## -## Java -############################################################################## - -java_proto_library( - name = "simple_java_proto", - deps = [":simple_proto"], -) - -java_proto_library( - name = "suite_java_proto", - deps = [":suite_proto"], -) diff --git a/proto/cel/expr/conformance/test/simple.proto b/proto/cel/expr/conformance/test/simple.proto deleted file mode 100644 index 227fc091..00000000 --- a/proto/cel/expr/conformance/test/simple.proto +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Simple end-to-end conformance tests. - -syntax = "proto3"; - -package cel.expr.conformance.test; - -import "cel/expr/checked.proto"; -import "cel/expr/eval.proto"; -import "cel/expr/value.proto"; - -option cc_enable_arenas = true; -option go_package = "cel.dev/expr/conformance/test"; -option java_multiple_files = true; -option java_outer_classname = "SimpleProto"; -option java_package = "dev.cel.expr.conformance.test"; - -// The format of a simple test file, expected to be stored in text format. -// A file is the unit of granularity for selecting conformance tests, -// so tests of optional features should be segregated into separate files. -// -// Deprecated: Use cel.expr.conformance.test.Suite -message SimpleTestFile { - // Required. The name of the file. Should match the filename. - string name = 1; - - // A description of the file. - string description = 2; - - // The contained sections. - repeated SimpleTestSection section = 3; -} - -// A collection of related SimpleTests. -// -// The section is the unit of organization within a test file, and should -// guide where new tests are added. -message SimpleTestSection { - // Required. The name of the section. - string name = 1; - - // A description of the section. - string description = 2; - - // The contained tests. - repeated SimpleTest test = 3; -} - -// A test which should run the given CEL program through parsing, -// optionally through checking, then evaluation, with the results -// of the pipeline validated by the given result matcher. -message SimpleTest { - // Required. The name of the test, which should be unique in the test file. - string name = 1; - - // A description of the test. - string description = 2; - - // Required. The text of the CEL expression. - string expr = 3; - - // Disables all macro expansion in parsing. - bool disable_macros = 4; - - // Disables the check phase. - bool disable_check = 5; - - // Disables the evaluate phase. - bool check_only = 15; - - // The type environment to use for the check phase. - repeated cel.expr.Decl type_env = 6; - - // The container for name resolution. - string container = 13; - - // The locale to use for the evaluation phase. - string locale = 14; - - // Variable bindings to use for the eval phase. - map bindings = 7; - - // An unspecified result defaults to a matcher for the true boolean value. - oneof result_matcher { - // A normal value, which must match the evaluation result exactly - // via value equality semantics. This coincides with proto equality, - // except for: - // * maps are order-agnostic. - // * a floating point NaN should match any NaN. - cel.expr.Value value = 8; - - // A result and deduced expression type. - TypedResult typed_result = 16; - - // Matches error evaluation results. - cel.expr.ErrorSet eval_error = 9; - - // Matches one of several error results. - // (Using explicit message since oneof can't handle repeated.) - ErrorSetMatcher any_eval_errors = 10; - - // Matches unknown evaluation results. - cel.expr.UnknownSet unknown = 11; - - // Matches one of several unknown results. - // (Using explicit message since oneof can't handle repeated.) - UnknownSetMatcher any_unknowns = 12; - } - // Next is 17. -} - -// Matches a result along with deduced expression type. -message TypedResult { - // A normal value, which must match the evaluation result exactly - // via value equality semantics. This is ignored if the test is `check_only`. - cel.expr.Value result = 1; - - // The deduced type of the expression as reported by the checker. - cel.expr.Type deduced_type = 2; -} - -// Matches error results from Eval. -message ErrorSetMatcher { - // Success if we match any of these sets. - repeated cel.expr.ErrorSet errors = 1; -} - -// Matches unknown results from Eval. -message UnknownSetMatcher { - // Success if we match any of these sets. - repeated cel.expr.UnknownSet unknowns = 1; -} diff --git a/proto/cel/expr/conformance/test/suite.proto b/proto/cel/expr/conformance/test/suite.proto deleted file mode 100644 index f9feab4a..00000000 --- a/proto/cel/expr/conformance/test/suite.proto +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Unit tests and end-to-end conformance tests. - -syntax = "proto3"; - -package cel.expr.conformance.test; - -import "cel/expr/checked.proto"; -import "cel/expr/eval.proto"; -import "cel/expr/value.proto"; -import "cel/expr/conformance/env_config.proto"; -import "google/protobuf/any.proto"; - -option cc_enable_arenas = true; -option go_package = "cel.dev/expr/conformance/test"; -option java_multiple_files = true; -option java_outer_classname = "SuiteProto"; -option java_package = "dev.cel.expr.conformance.test"; - -// A test suite is a collection of tests designed to evaluate the correctness of -// a CEL policy, a CEL expression or the conformance of a CEL implementation to -// the standard specification. -message TestSuite { - // The name of the test suite. - string name = 1; - - // Description of the test suite. - string description = 2; - - // Test sections of the test suite. - // Each section represents a behavior to be tested. - repeated TestSection sections = 3; -} - -// A collection of related test cases. -message TestSection { - // Name of the test section. - string name = 1; - - // Description of the test section. - string description = 2; - - // Test cases of the test section. - // Each test case represents a test scenario. - repeated TestCase tests = 3; -} - -// A test to validate a CEL policy or expression. The test case encompasses -// evaluation of the compiled expression using the provided input bindings and -// asserting the result against the expected result. -// It can also validate a raw CEL expression string through parse, check and -// eval stages, making use of the augmenting CEL environment if provided. -message TestCase { - // Name of the test case. - string name = 1; - - // A description of the test. - string description = 2; - - // The text of the CEL expression. - string expr = 3; - - // Serialized environment to be used for compilation and evaluation of the - // CEL expression for the current test case. - // This option allows validating the same expression against multiple - // environments. - cel.expr.conformance.Environment env = 4; - - // A map representing a variable binding where the key is the name of the - // input variable. - map input = 5; - - // Input in the form of a context proto for the test case. - // Note: Only one of `input_bindings` and `input_context` can be provided. Providing - // both should result in an error. - InputContext input_context = 6; - - // Expected result of the test case. - TestOutput output = 7; - - // If specified validates that the deduced type at check time matches - // If the result kind is not set and this field is set, the test is considered - // "check-only". - cel.expr.Type deduced_type = 8; - - // Bypass the type-checking and only attempt to evaluate the parsed - // expression. - bool disable_check = 9; -} - -// Input context proto for the test case -message InputContext { - // The type of input context for the test case - oneof input_context_kind { - // A context message represents an input kind in the form of a proto - // message whose type is defined at runtime. - google.protobuf.Any context_message = 1; - - // A context expression representing a context proto variable. The - // fields of the input proto.Messages are used as top-level variables within - // an Activation. The expression is evaluated using the cel environment - // configured for the test suite. - string context_expr = 2; - } -} - -// The input value for a variable binding -message InputValue { - // The type of input value that can be used for a variable binding - oneof kind { - // A simple literal value for a variable binding - cel.expr.Value value = 1; - - // An expression which evaluates to the value of the variable binding. - // The expression is evaluated using the same runtime environment as the - // one used for evaluating the expression under test. - string expr = 2; - } -} - -// Expected result of the test case. -message TestOutput { - // Type of expected result of the test case. - oneof result_kind { - // A normal value, which must match the evaluation result exactly via value - // equality semantics. This coincides with proto equality, except for: - // * maps are order-agnostic - // * a floating point NaN should match any NaN - cel.expr.Value result_value = 8; - - // An expression to be evaluated using the cel environment configured for - // the test suite. The result of this expression must match the result of - // the test case. - string result_expr = 9; - - // An error evaluation result set. Success if we match all of the errors in - // the set. - cel.expr.ErrorSet eval_error = 10; - - // An unknown evaluation result. - cel.expr.UnknownSet unknown = 11; - } -} diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel deleted file mode 100644 index 07afb28b..00000000 --- a/tests/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -package( - default_visibility = ["//visibility:public"], -) - -licenses(["notice"]) # Apache 2.0 - -exports_files(["LICENSE"]) diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 469cb821..00000000 --- a/tests/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# CEL Conformance Tests - -The CEL conformance test suites provide a complementary specification -of the CEL language in the form of executable software. All CEL -implementations which pass the conformance tests should give valid CEL -expressions the same meaning. - -As much as possible, the tests are driven by data files. Implementations -are expected to read the `tests/simple/testdata` files as inputs to the -parse, check, and evaluation behaviors of a given implementation. Reference -implementations may be found in the following locations: - -* [cel-go conformance](https://github.com/cel-expr/cel-go/tree/master/conformance) -* [cel-cpp conformance](https://github.com/cel-expr/cel-cpp/tree/master/conformance) -* [cel-java conformance](https://github.com/cel-expr/cel-java/tree/main/conformance/src/test/java/dev/cel/conformance) - -Each CEL implementation should also have its own unit tests and benchmarks -for testing subcomponents, its API, and other implementation-dependent -features. diff --git a/tests/simple/BUILD.bazel b/tests/simple/BUILD.bazel deleted file mode 100644 index 462277c1..00000000 --- a/tests/simple/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -package( - default_visibility = ["//visibility:public"], -) - -licenses(["notice"]) # Apache 2.0 - -exports_files(["LICENSE"] + glob(["testdata/*.textproto"])) diff --git a/tests/simple/testdata/README.md b/tests/simple/testdata/README.md deleted file mode 100644 index b8275dc6..00000000 --- a/tests/simple/testdata/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Simple Conformance Test Data Files - -The test data files for the `simple` conformance test suite -are described by the `SimpleTestFile` message defined in -[`simple.proto`](../../../proto/cel/expr/conformance/test/simple.proto). -See the documentation in that file for the meaning of the various fields. - -A run of the simple tests chooses one or more data files and attempts -to run all the tests in those files. Test files are organized so that -implementations can implement a prescribed subset of CEL functionality. -For instance, implementations which don't support macros can avoid testing -against the `macros.textproto` file. - -The available test files are: - -- [`plumbing.textproto`](plumbing.textproto) Checks the basics of the CelService - protocol to ensure that the server is implemented correctly. - -- [`basic.textproto`](basic.textproto) Checks the most basic operations that - all CEL implementations should support: - - literals of various types; - - variables of various types. - -- [`comparisons.textproto`](comparisons.textproto) Checks the standard functions - that return a boolean value. - -- [`conversions.textproto`](conversions.textproto) Checks conversions between - types and type tests. - -- [`dynamic.textproto`](dynamic.textproto) Checks the automatic conversions - associated with the well-known protobuf messages. - -- [`enums.textproto`](enums.textproto) Checks handling of protobuf enums. - -- [`fields.textproto`](fields.textproto) Checks field selection in messages - and maps. - -- [`fp_math.textproto`](fp_math.textproto) Checks floating-point arithmetic. - -- [`integer_math.textproto`](integer_math.textproto) Checks integer arithmetic. - -- [`lists.textproto`](lists.textproto) Checks list operations. - -- [`logic.textproto`](logic.textproto) Checks special logical operators. - -- [`macros.textproto`](macros.textproto) Checks use of CEL macros. - -- [`namespace.textproto`](namespace.textproto) Checks use of namespaces and - qualified identifiers. - -- [`parse.textproto`](parse.textproto) End-to-end tests of parsing. More - detailed parsing tests will the subject of a later conformance suite. - -- [`proto2.textproto`](proto2.textproto) Checks use of protocol buffers version - 2. - -- [`proto3.textproto`](proto3.textproto) Checks use of protocol buffers version - 3. - -- [`string.textproto`](string.textproto) Checks functions on strings. - -- [`timestamps.textproto`](timestamps.textproto) Checks `timestamp` and `duration` - values and operations. - -- [`unknowns.textproto`](unknowns.textproto) Checks evaluation where some - inputs are marked as unknown. diff --git a/tests/simple/testdata/basic.textproto b/tests/simple/testdata/basic.textproto deleted file mode 100644 index 903f7982..00000000 --- a/tests/simple/testdata/basic.textproto +++ /dev/null @@ -1,287 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "basic" -description: "Basic conformance tests that all implementations should pass." -section { - name: "self_eval_zeroish" - description: "Simple self-evaluating forms to zero-ish values." - test { - name: "self_eval_int_zero" - expr: "0" - value: { int64_value: 0 } - } - test { - name: "self_eval_uint_zero" - expr: "0u" - value: { uint64_value: 0 } - } - test { - name: "self_eval_uint_alias_zero" - expr: "0U" - value: { uint64_value: 0 } - } - test { - name: "self_eval_float_zero" - expr: "0.0" - value: { double_value: 0 } - } - test { - name: "self_eval_float_zerowithexp" - expr: "0e+0" - value: { double_value: 0 } - } - test { - name: "self_eval_string_empty" - expr: "''" - value: { string_value: "" } - } - test { - name: "self_eval_string_empty_quotes" - expr: '""' - value: { string_value: "" } - } - test { - name: "self_eval_string_raw_prefix" - expr: 'r""' - value: { string_value: "" } - } - test { - name: "self_eval_bytes_empty" - expr: 'b""' - value: { bytes_value: "" } - } - test { - name: "self_eval_bool_false" - expr: "false" - value: { bool_value: false } - } - test { - name: "self_eval_null" - expr: "null" - value: { null_value: NULL_VALUE } - } - test { - name: "self_eval_empty_list" - expr: '[]' - value: { list_value: {} } - } - test { - name: "self_eval_empty_map" - expr: '{}' - value: { map_value: {} } - } - test { - name: "self_eval_string_raw_prefix_triple_double" - expr: 'r""""""' - value: { string_value: "" } - } - test { - name: "self_eval_string_raw_prefix_triple_single" - expr: "r''''''" - value: { string_value: "" } - } -} -section { - name: "self_eval_nonzeroish" - description: "Simple self-evaluating forms to non-zero-ish values." - test { - name: "self_eval_int_nonzero" - expr: "42" - value: { int64_value: 42 } - } - test { - name: "self_eval_uint_nonzero" - expr: "123456789u" - value: { uint64_value: 123456789 } - } - test { - name: "self_eval_uint_alias_nonzero" - expr: "123456789U" - value: { uint64_value: 123456789 } - } - test { - name: "self_eval_int_negative_min" - expr: "-9223372036854775808" - value: { int64_value: -9223372036854775808 } - } - test { - name: "self_eval_float_negative_exp" - expr: "-2.3e+1" - value: { double_value: -23.0 } - } - test { - name: "self_eval_string_excl" - expr: '"!"' - value: { string_value: "!" } - } - test { - name: "self_eval_string_escape" - expr: "'\\''" - value: { string_value: "'" } - } - test { - name: "self_eval_bytes_escape" - expr: "b'ÿ'" - value: { bytes_value: "\303\277" } - } - test { - name: "self_eval_bytes_invalid_utf8" - expr: "b'\\000\\xff'" - value: { bytes_value: "\000\377" } - } - test { - name: "self_eval_list_singleitem" - expr: "[-1]" - value: { - list_value { - values: { int64_value: -1 } - } - } - } - test { - name: "self_eval_map_singleitem" - expr: '{"k":"v"}' - value: { - map_value { - entries { - key: { string_value: "k" } - value: { string_value: "v" } - } - } - } - } - test { - name: "self_eval_bool_true" - expr: "true" - value: { bool_value: true } - } - test { - name: "self_eval_int_hex" - expr: "0x55555555" - value: { int64_value: 1431655765 } - } - test { - name: "self_eval_int_hex_negative" - expr: "-0x55555555" - value: { int64_value: -1431655765 } - } - test { - name: "self_eval_uint_hex" - expr: "0x55555555u" - value: { uint64_value: 1431655765 } - } - test { - name: "self_eval_uint_alias_hex" - expr: "0x55555555U" - value: { uint64_value: 1431655765 } - } - test { - name: "self_eval_unicode_escape_four" - expr: '"\\u270c"' - value: { string_value: "\xe2\x9c\x8c" } - } - test { - name: "self_eval_unicode_escape_eight" - expr: '"\\U0001f431"' - value: { string_value: "\xf0\x9f\x90\xb1" } - } - test { - name: "self_eval_ascii_escape_seq" - expr: '"\\a\\b\\f\\n\\r\\t\\v\\"\\\'\\\\"' - value: { string_value: "\a\b\f\n\r\t\v\"'\\" } - } -} -section { - name: "variables" - description: "Variable lookups." - test { - name: "self_eval_bound_lookup" - expr: "x" - type_env: { - name: "x", - ident: { type: { primitive: INT64 } } - } - bindings: { - key: "x" - value: { value: { int64_value: 123 } } - } - value: { int64_value: 123 } - } - test { - name: "self_eval_unbound_lookup" - description: "An unbound variable should be marked as an error during execution. See google/cel-go#154" - expr: "x" - disable_check: true - eval_error: { - errors: { message: "undeclared reference to 'x' (in container '')" } - } - } - test { - name: "unbound_is_runtime_error" - description: "Make sure we can short-circuit around an unbound variable." - expr: "x || true" - disable_check: true - value { bool_value: true } - } -} -section { - name: "functions" - description: "Basic mechanisms for function calls." - test { - name: "binop" - expr: "1 + 1" - value { int64_value: 2 } - } - test { - name: "unbound" - expr: "f_unknown(17)" - disable_check: true - eval_error { - errors { message: "unbound function" } - } - } -} -section { - name: "reserved_const" - description: "Named constants should never be shadowed by identifiers." - test { - name: "false" - expr: "false" - type_env: { - name: "false" - ident: { type: { primitive: BOOL } } - } - bindings { - key: "false" - value: { value: { bool_value: true } } - } - value: { bool_value: false } - } - test { - name: "true" - expr: "true" - type_env: { - name: "true" - ident: { type: { primitive: BOOL } } - } - bindings { - key: "true" - value: { value: { bool_value: false } } - } - value: { bool_value: true } - } - test { - name: "null" - expr: "null" - type_env: { - name: "null" - ident: { type: { primitive: BOOL } } - } - bindings { - key: "null" - value: { value: { bool_value: true } } - } - value: { null_value: 0 } - } -} diff --git a/tests/simple/testdata/bindings_ext.textproto b/tests/simple/testdata/bindings_ext.textproto deleted file mode 100644 index 62bf65c0..00000000 --- a/tests/simple/testdata/bindings_ext.textproto +++ /dev/null @@ -1,102 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "bindings_ext" -description: "Tests for the bindings extension library." -section: { - name: "bind" - test: { - name: "boolean_literal" - expr: "cel.bind(t, true, t)" - value: { - bool_value: true - } - } - test: { - name: "string_concat" - expr: "cel.bind(msg, \"hello\", msg + msg + msg)" - value: { - string_value: "hellohellohello" - } - } - test: { - name: "bind_nested" - expr: "cel.bind(t1, true, cel.bind(t2, true, t1 && t2))" - value: { - bool_value: true - } - } - test: { - name: "macro_exists" - expr: "cel.bind(valid_elems, [1, 2, 3], [3, 4, 5].exists(e, e in valid_elems))" - value: { - bool_value: true - } - } - test: { - name: "macro_not_exists" - expr: "cel.bind(valid_elems, [1, 2, 3], ![4, 5].exists(e, e in valid_elems))" - value: { - bool_value: true - } - } - test: { - name: "shadowing" - expr: "cel.bind(x, 0, x == 0)" - type_env: { - name: "x" - ident: { - type: { primitive: INT64 } - } - } - bindings: { - key: "x" - value: { - value: { int64_value: 1 } - } - } - value: { - bool_value: true - } - } - test: { - name: "shadowing_namespace_resolution" - expr: "cel.bind(x, 0, x == 0)" - container: "com.example" - type_env: { - name: "com.example.x" - ident: { - type: { primitive: INT64 } - } - } - bindings: { - key: "com.example.x" - value: { - value: { int64_value: 1 } - } - } - value: { - bool_value: true - } - } - test: { - name: "shadowing_namespace_resolution_selector" - expr: "cel.bind(x, {'y': 0}, x.y == 0)" - container: "com.example" - type_env: { - name: "com.example.x.y" - ident: { - type: { primitive: INT64 } - } - } - bindings: { - key: "com.example.x.y" - value: { - value: { int64_value: 1 } - } - } - value: { - bool_value: true - } - } -} diff --git a/tests/simple/testdata/block_ext.textproto b/tests/simple/testdata/block_ext.textproto deleted file mode 100644 index ebdf76f4..00000000 --- a/tests/simple/testdata/block_ext.textproto +++ /dev/null @@ -1,1070 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -# This conformance test relies on the test-only macros cel.block, cel.index, -# cel.iterVar, and cel.accuVar. These test-only macros allow exercising -# cel.block without the optimizers being present. -# `cel.block(l, e)` must rewrite itself to be `cel.block(l, e)` -# `cel.index(N)` must rewrite itself to `@indexN` -# `cel.iterVar(N, M)` must rewrite itself to `@it:N:M` -# `cel.accuVar(N, M)` must rewrite itself to `@ac:N:M` - -name: "block_ext" -description: "Tests for cel.block." -section: { - name: "basic" - test: { - name: "int_add" - expr: "cel.block([1, cel.index(0) + 1, cel.index(1) + 1, cel.index(2) + 1], cel.index(3))" - value: { - int64_value: 4 - } - } - test: { - name: "size_1" - expr: "cel.block([[1, 2], size(cel.index(0)), cel.index(1) + cel.index(1), cel.index(2) + 1], cel.index(3))" - value: { - int64_value: 5 - } - } - test: { - name: "size_2" - expr: "cel.block([[1, 2], size(cel.index(0)), 2 + cel.index(1), cel.index(2) + cel.index(1), cel.index(3) + 1], cel.index(4))" - value: { - int64_value: 7 - } - } - test: { - name: "size_3" - expr: "cel.block([[0], size(cel.index(0)), [1, 2], size(cel.index(2)), cel.index(1) + cel.index(1), cel.index(4) + cel.index(3), cel.index(5) + cel.index(3)], cel.index(6))" - value: { - int64_value: 6 - } - } - test: { - name: "size_4" - expr: "cel.block([[0], size(cel.index(0)), [1, 2], size(cel.index(2)), [1, 2, 3], size(cel.index(4)), 5 + cel.index(1), cel.index(6) + cel.index(1), cel.index(7) + cel.index(3), cel.index(8) + cel.index(3), cel.index(9) + cel.index(5), cel.index(10) + cel.index(5)], cel.index(11))" - value: { - int64_value: 17 - } - } - test: { - name: "timestamp" - expr: "cel.block([timestamp(1000000000), int(cel.index(0)), timestamp(cel.index(1)), cel.index(2).getFullYear(), timestamp(50), int(cel.index(4)), timestamp(cel.index(5)), timestamp(200), int(cel.index(7)), timestamp(cel.index(8)), cel.index(9).getFullYear(), timestamp(75), int(cel.index(11)), timestamp(cel.index(12)), cel.index(13).getFullYear(), cel.index(3) + cel.index(14), cel.index(6).getFullYear(), cel.index(15) + cel.index(16), cel.index(17) + cel.index(3), cel.index(6).getSeconds(), cel.index(18) + cel.index(19), cel.index(20) + cel.index(10), cel.index(21) + cel.index(10), cel.index(13).getMinutes(), cel.index(22) + cel.index(23), cel.index(24) + cel.index(3)], cel.index(25))" - value: { - int64_value: 13934 - } - } - test: { - name: "map_index" - expr: "cel.block([{\"a\": 2}, cel.index(0)[\"a\"], cel.index(1) * cel.index(1), cel.index(1) + cel.index(2)], cel.index(3))" - value: { - int64_value: 6 - } - } - test: { - name: "nested_map_construction" - expr: "cel.block([{\"b\": 1}, {\"e\": cel.index(0)}], {\"a\": cel.index(0), \"c\": cel.index(0), \"d\": cel.index(1), \"e\": cel.index(1)})" - value: { - map_value: { - entries { - key: { - string_value: 'a' - } - value: { - map_value: { - entries { - key: { - string_value: 'b' - } - value: { - int64_value: 1 - } - } - } - } - } - entries { - key: { - string_value: 'c' - } - value: { - map_value: { - entries { - key: { - string_value: 'b' - } - value: { - int64_value: 1 - } - } - } - } - } - entries { - key: { - string_value: 'd' - } - value: { - map_value: { - entries { - key: { - string_value: 'e' - } - value: { - map_value: { - entries { - key: { - string_value: 'b' - } - value: { - int64_value: 1 - } - } - } - } - } - } - } - } - entries { - key: { - string_value: 'e' - } - value: { - map_value: { - entries { - key: { - string_value: 'e' - } - value: { - map_value: { - entries { - key: { - string_value: 'b' - } - value: { - int64_value: 1 - } - } - } - } - } - } - } - } - } - } - } - test: { - name: "nested_list_construction" - expr: "cel.block([[1, 2, 3, 4], [1, 2], [cel.index(1), cel.index(0)]], [1, cel.index(0), 2, cel.index(0), 5, cel.index(0), 7, cel.index(2), cel.index(1)])" - value: { - list_value: { - values { - int64_value: 1 - } - values { - list_value: { - values { - int64_value: 1 - } - values { - int64_value: 2 - } - values { - int64_value: 3 - } - values { - int64_value: 4 - } - } - } - values { - int64_value: 2 - } - values { - list_value: { - values { - int64_value: 1 - } - values { - int64_value: 2 - } - values { - int64_value: 3 - } - values { - int64_value: 4 - } - } - } - values { - int64_value: 5 - } - values { - list_value: { - values { - int64_value: 1 - } - values { - int64_value: 2 - } - values { - int64_value: 3 - } - values { - int64_value: 4 - } - } - } - values { - int64_value: 7 - } - values { - list_value: { - values { - list_value: { - values { - int64_value: 1 - } - values { - int64_value: 2 - } - } - } - values { - list_value: { - values { - int64_value: 1 - } - values { - int64_value: 2 - } - values { - int64_value: 3 - } - values { - int64_value: 4 - } - } - } - } - } - values { - list_value: { - values { - int64_value: 1 - } - values { - int64_value: 2 - } - } - } - } - } - } - test: { - name: "select" - expr: "cel.block([msg.single_int64, cel.index(0) + cel.index(0)], cel.index(1))" - value: { - int64_value: 6 - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "select_nested_1" - expr: "cel.block([msg.oneof_type, cel.index(0).payload, cel.index(1).single_int64, cel.index(1).single_int32, cel.index(2) + cel.index(3), cel.index(4) + cel.index(2), msg.single_int64, cel.index(5) + cel.index(6), cel.index(1).oneof_type, cel.index(8).payload, cel.index(9).single_int64, cel.index(7) + cel.index(10)], cel.index(11))" - value: { - int64_value: 31 - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "select_nested_2" - expr: "cel.block([msg.oneof_type, cel.index(0).payload, cel.index(1).oneof_type, cel.index(2).payload, cel.index(3).oneof_type, cel.index(4).payload, cel.index(5).oneof_type, cel.index(6).payload, cel.index(7).single_bool, true || cel.index(8), cel.index(4).child, cel.index(10).child, cel.index(11).payload, cel.index(12).single_bool], cel.index(9) || cel.index(13))" - value: { - bool_value: true - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "select_nested_message_map_index_1" - expr: "cel.block([msg.oneof_type, cel.index(0).payload, cel.index(1).map_int32_int64, cel.index(2)[1], cel.index(3) + cel.index(3), cel.index(4) + cel.index(3)], cel.index(5))" - value: { - int64_value: 15 - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "select_nested_message_map_index_2" - expr: "cel.block([msg.oneof_type, cel.index(0).payload, cel.index(1).map_int32_int64, cel.index(2)[0], cel.index(2)[1], cel.index(3) + cel.index(4), cel.index(2)[2], cel.index(5) + cel.index(6)], cel.index(7))" - value: { - int64_value: 8 - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "ternary" - expr: "cel.block([msg.single_int64, cel.index(0) > 0, cel.index(1) ? cel.index(0) : 0], cel.index(2))" - value: { - int64_value: 3 - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "nested_ternary" - expr: "cel.block([msg.single_int64, msg.single_int32, cel.index(0) > 0, cel.index(1) > 0, cel.index(0) + cel.index(1), cel.index(3) ? cel.index(4) : 0, cel.index(2) ? cel.index(5) : 0], cel.index(6))" - value: { - int64_value: 8 - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "multiple_macros_1" - expr: "cel.block([[1].exists(cel.iterVar(0, 0), cel.iterVar(0, 0) > 0), size([cel.index(0)]), [2].exists(cel.iterVar(0, 0), cel.iterVar(0, 0) > 1), size([cel.index(2)])], cel.index(1) + cel.index(1) + cel.index(3) + cel.index(3))" - value: { - int64_value: 4 - } - } - test: { - name: "multiple_macros_2" - expr: "cel.block([[1].exists(cel.iterVar(0, 0), cel.iterVar(0, 0) > 0), [cel.index(0)], ['a'].exists(cel.iterVar(0, 1), cel.iterVar(0, 1) == 'a'), [cel.index(2)]], cel.index(1) + cel.index(1) + cel.index(3) + cel.index(3))" - value: { - list_value: { - values { - bool_value: true - } - values { - bool_value: true - } - values { - bool_value: true - } - values { - bool_value: true - } - } - } - } - test: { - name: "multiple_macros_3" - expr: "cel.block([[1].exists(cel.iterVar(0, 0), cel.iterVar(0, 0) > 0)], cel.index(0) && cel.index(0) && [1].exists(cel.iterVar(0, 0), cel.iterVar(0, 0) > 1) && [2].exists(cel.iterVar(0, 0), cel.iterVar(0, 0) > 1))" - value: { - bool_value: false - } - } - test: { - name: "nested_macros_1" - expr: "cel.block([[1, 2, 3]], cel.index(0).map(cel.iterVar(0, 0), cel.index(0).map(cel.iterVar(1, 0), cel.iterVar(1, 0) + 1)))" - value: { - list_value: { - values { - list_value: { - values { - int64_value: 2 - } - values { - int64_value: 3 - } - values { - int64_value: 4 - } - } - } - values { - list_value: { - values { - int64_value: 2 - } - values { - int64_value: 3 - } - values { - int64_value: 4 - } - } - } - values { - list_value: { - values { - int64_value: 2 - } - values { - int64_value: 3 - } - values { - int64_value: 4 - } - } - } - } - } - } - test: { - name: "nested_macros_2" - expr: "[1, 2].map(cel.iterVar(0, 0), [1, 2, 3].filter(cel.iterVar(1, 0), cel.iterVar(1, 0) == cel.iterVar(0, 0)))" - value: { - list_value: { - values { - list_value: { - values { - int64_value: 1 - } - } - } - values { - list_value: { - values { - int64_value: 2 - } - } - } - } - } - } - test: { - name: "adjacent_macros" - expr: "cel.block([[1, 2, 3], cel.index(0).map(cel.iterVar(0, 0), cel.index(0).map(cel.iterVar(1, 0), cel.iterVar(1, 0) + 1))], cel.index(1) == cel.index(1))" - value: { - bool_value: true - } - } - test: { - name: "macro_shadowed_variable_1" - expr: "cel.block([x - 1, cel.index(0) > 3], [cel.index(1) ? cel.index(0) : 5].exists(cel.iterVar(0, 0), cel.iterVar(0, 0) - 1 > 3) || cel.index(1))" - value: { - bool_value: true - } - type_env: { - name: "x" - ident: { type: { primitive: INT64 }} - } - bindings: { - key: "x" - value: { - value: { - int64_value: 5 - } - } - } - } - test: { - name: "macro_shadowed_variable_2" - expr: "['foo', 'bar'].map(cel.iterVar(1, 0), [cel.iterVar(1, 0) + cel.iterVar(1, 0), cel.iterVar(1, 0) + cel.iterVar(1, 0)]).map(cel.iterVar(0, 0), [cel.iterVar(0, 0) + cel.iterVar(0, 0), cel.iterVar(0, 0) + cel.iterVar(0, 0)])" - value: { - list_value: { - values { - list_value: { - values { - list_value: { - values { - string_value: "foofoo" - } - values { - string_value: "foofoo" - } - values { - string_value: "foofoo" - } - values { - string_value: "foofoo" - } - } - } - values { - list_value: { - values { - string_value: "foofoo" - } - values { - string_value: "foofoo" - } - values { - string_value: "foofoo" - } - values { - string_value: "foofoo" - } - } - } - } - } - values { - list_value: { - values { - list_value: { - values { - string_value: "barbar" - } - values { - string_value: "barbar" - } - values { - string_value: "barbar" - } - values { - string_value: "barbar" - } - } - } - values { - list_value: { - values { - string_value: "barbar" - } - values { - string_value: "barbar" - } - values { - string_value: "barbar" - } - values { - string_value: "barbar" - } - } - } - } - } - } - } - type_env: { - name: "x" - ident: { type: { primitive: INT64 }} - } - bindings: { - key: "x" - value: { - value: { - int64_value: 5 - } - } - } - } - test: { - name: "inclusion_list" - expr: "cel.block([[1, 2, 3], 1 in cel.index(0), 2 in cel.index(0), cel.index(1) && cel.index(2), [3, cel.index(0)], 3 in cel.index(4), cel.index(5) && cel.index(1)], cel.index(3) && cel.index(6))" - value: { - bool_value: true - } - } - test: { - name: "inclusion_map" - expr: "cel.block([{true: false}, {\"a\": 1, 2: cel.index(0), 3: cel.index(0)}], 2 in cel.index(1))" - value: { - bool_value: true - } - } - test: { - name: "presence_test" - expr: "cel.block([{\"a\": true}, has(cel.index(0).a), cel.index(0)[\"a\"]], cel.index(1) && cel.index(2))" - value: { - bool_value: true - } - } - test: { - name: "presence_test_2" - expr: "cel.block([{\"a\": true}, has(cel.index(0).a)], cel.index(1) && cel.index(1))" - value: { - bool_value: true - } - } - test: { - name: "presence_test_with_ternary" - expr: "cel.block([msg.oneof_type, has(cel.index(0).payload), cel.index(0).payload, cel.index(2).single_int64, cel.index(1) ? cel.index(3) : 0], cel.index(4))" - value: { - int64_value: 10 - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "presence_test_with_ternary_2" - expr: "cel.block([msg.oneof_type, cel.index(0).payload, cel.index(1).single_int64, has(cel.index(0).payload), cel.index(2) * 0, cel.index(3) ? cel.index(2) : cel.index(4)], cel.index(5))" - value: { - int64_value: 10 - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "presence_test_with_ternary_3" - expr: "cel.block([msg.oneof_type, cel.index(0).payload, cel.index(1).single_int64, has(cel.index(1).single_int64), cel.index(2) * 0, cel.index(3) ? cel.index(2) : cel.index(4)], cel.index(5))" - value: { - int64_value: 10 - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "presence_test_with_ternary_nested" - expr: "cel.block([msg.oneof_type, cel.index(0).payload, cel.index(1).map_string_string, has(msg.oneof_type), has(cel.index(0).payload), cel.index(3) && cel.index(4), has(cel.index(1).single_int64), cel.index(5) && cel.index(6), has(cel.index(1).map_string_string), has(cel.index(2).key), cel.index(8) && cel.index(9), cel.index(2).key, cel.index(11) == \"A\", cel.index(10) ? cel.index(12) : false], cel.index(7) ? cel.index(13) : false)" - value: { - bool_value: true - } - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" }} - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 3 - single_int32: 5 - oneof_type: { - payload: { - single_int32: 8 - single_int64: 10 - map_int32_int64 { - key: 0 - value: 1 - } - map_int32_int64 { - key: 1 - value: 5 - } - map_int32_int64 { - key: 2 - value: 2 - } - map_string_string { - key: "key" - value: "A" - } - } - } - } - } - } - } - } - } - test: { - name: "optional_list" - expr: "cel.block([optional.none(), [?cel.index(0), ?optional.of(opt_x)], [5], [10, ?cel.index(0), cel.index(1), cel.index(1)], [10, cel.index(2), cel.index(2)]], cel.index(3) == cel.index(4))" - value: { - bool_value: true - } - type_env: { - name: "opt_x" - ident: { type: { primitive: INT64 }} - } - bindings: { - key: "opt_x", - value: { - value: { - int64_value: 5 - } - } - } - } - test: { - name: "optional_map" - expr: "cel.block([optional.of(\"hello\"), {?\"hello\": cel.index(0)}, cel.index(1)[\"hello\"], cel.index(2) + cel.index(2)], cel.index(3) == \"hellohello\")" - value: { - bool_value: true - } - } - test: { - name: "optional_map_chained" - expr: "cel.block([{\"key\": \"test\"}, optional.of(\"test\"), {?\"key\": cel.index(1)}, cel.index(2)[?\"bogus\"], cel.index(0)[?\"bogus\"], cel.index(3).or(cel.index(4)), cel.index(0)[\"key\"], cel.index(5).orValue(cel.index(6))], cel.index(7))" - value: { - string_value: 'test' - } - } - test: { - name: "optional_message" - container: "cel.expr.conformance.proto3" - expr: "cel.block([optional.ofNonZeroValue(1), optional.of(4), TestAllTypes{?single_int64: cel.index(0), ?single_int32: cel.index(1)}, cel.index(2).single_int32, cel.index(2).single_int64, cel.index(3) + cel.index(4)], cel.index(5))" - value: { - int64_value: 5 - } - } - test: { - name: "call" - expr: "cel.block([\"h\" + \"e\", cel.index(0) + \"l\", cel.index(1) + \"l\", cel.index(2) + \"o\", cel.index(3) + \" world\"], cel.index(4).matches(cel.index(3)))" - value: { - bool_value: true - } - } -} diff --git a/tests/simple/testdata/comparisons.textproto b/tests/simple/testdata/comparisons.textproto deleted file mode 100644 index 6cbf729c..00000000 --- a/tests/simple/testdata/comparisons.textproto +++ /dev/null @@ -1,3080 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "comparisons" -description: "Tests for boolean-valued functions and operators." -section { - name: "eq_literal" - description: "Literals comparison on _==_" - test { - name: "eq_int" - expr: "1 == 1" - value: { bool_value: true } - } - test { - name: "not_eq_int" - expr: "-1 == 1" - value: { bool_value: false } - } - test { - name: "eq_int_uint" - expr: "dyn(1) == 1u" - value: { bool_value: true } - } - test { - name: "not_eq_int_uint" - expr: "dyn(2) == 1u" - value: { bool_value: false } - } - test { - name: "eq_int_double" - expr: "dyn(1) == 1.0" - value: { bool_value: true } - } - test { - name: "not_eq_int_double" - expr: "dyn(2) == 1.0" - value: { bool_value: false } - } - test { - name: "eq_uint" - expr: "2u == 2u" - value: { bool_value: true } - } - test { - name: "not_eq_uint" - expr: "1u == 2u" - value: { bool_value: false } - } - test { - name: "eq_uint_int" - expr: "dyn(1u) == 1" - value: { bool_value: true } - } - test { - name: "not_eq_uint_int" - expr: "dyn(2u) == 1" - value: { bool_value: false } - } - test { - name: "eq_uint_double" - expr: "dyn(1u) == 1.0" - value: { bool_value: true } - } - test { - name: "not_eq_uint_double" - expr: "dyn(2u) == 1.0" - value: { bool_value: false } - } - test { - name: "eq_double" - expr: "1.0 == 1.0e+0" - value: { bool_value: true } - } - test { - name: "not_eq_double" - expr: "-1.0 == 1.0" - value: { bool_value: false } - } - test { - name: "not_eq_double_nan" - expr: "0.0/0.0 == 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_eq_double_nan_left" - expr: "0.0/0.0 == 1.0" - value: { bool_value: false } - } - test { - name: "not_eq_double_nan_right" - expr: "1.0 == 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_eq_int_double_nan" - expr: "dyn(1) == 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_eq_double_nan_int" - expr: "dyn(0.0/0.0) == 1" - value: { bool_value: false } - } - test { - name: "not_eq_uint_double_nan" - expr: "dyn(1u) == 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_eq_double_nan_uint" - expr: "dyn(0.0/0.0) == 1u" - value: { bool_value: false } - } - test { - name: "eq_double_int" - expr: "dyn(1.0) == 1" - value: { bool_value: true } - } - test { - name: "not_eq_double_int" - expr: "dyn(2.0) == 1" - value: { bool_value: false } - } - test { - name: "eq_double_uint" - expr: "dyn(1.0) == 1u" - value: { bool_value: true } - } - test { - name: "not_eq_double_uint" - expr: "dyn(2.0) == 1u" - value: { bool_value: false } - } - test { - name: "eq_double_neg_zero" - expr: "-0.0 == 0.0" - value: { bool_value: true } - } - test { - name: "eq_double_zero_neg_zero" - expr: "0.0 == -0.0" - value: { bool_value: true } - } - test { - name: "eq_double_neg_zero_int" - expr: "dyn(-0.0) == 0" - value: { bool_value: true } - } - test { - name: "eq_int_double_neg_zero" - expr: "dyn(0) == -0.0" - value: { bool_value: true } - } - test { - name: "eq_double_neg_zero_uint" - expr: "dyn(-0.0) == 0u" - value: { bool_value: true } - } - test { - name: "eq_uint_double_neg_zero" - expr: "dyn(0u) == -0.0" - value: { bool_value: true } - } - test { - name: "eq_string" - expr: "'' == \"\"" - value: { bool_value: true } - } - test { - name: "not_eq_string" - expr: "'a' == 'b'" - value: { bool_value: false } - } - test { - name: "eq_raw_string" - expr: "'abc' == r'abc'" - value: { bool_value: true } - } - test { - name: "not_eq_string_case" - expr: "'abc' == 'ABC'" - value: { bool_value: false } - } - test { - name: "eq_string_unicode" - expr: "'ίσος' == 'ίσος'" - value: { bool_value: true } - } - test { - name: "not_eq_string_unicode_ascii" - expr: "'a' == 'à'" - value: { bool_value: false } - } - test { - name: "no_string_normalization" - description: "Should not normalize Unicode." - expr: "'Am\\u00E9lie' == 'Ame\\u0301lie'" - value: { bool_value: false } - } - test { - name: "eq_null" - expr: "null == null" - value: { bool_value: true } - } - test { - name: "eq_bool" - expr: "true == true" - value: { bool_value: true } - } - test { - name: "not_eq_bool" - expr: "false == true" - value: { bool_value: false } - } - test { - name: "eq_bytes" - description: "Test bytes literal equality with encoding" - expr: "b'ÿ' == b'\\303\\277'" - value: { bool_value: true } - } - test { - name: "not_eq_bytes" - expr: "b'abc' == b'abcd'" - value: { bool_value: false } - } - test { - name: "eq_list_empty" - expr: "[] == []" - value: { bool_value: true } - } - test { - name: "eq_list_null" - expr: "[null] == [null]" - value: { bool_value: true } - } - test { - name: "not_eq_list_null" - expr: "['1', '2', null] == ['1', '2', '3']" - value: { bool_value: false } - } - test { - name: "eq_list_numbers" - expr: "[1, 2, 3] == [1, 2, 3]" - value: { bool_value: true } - } - test { - name: "eq_list_mixed_type_numbers" - expr: "[1.0, 2.0, 3] == [1u, 2, 3u]" - value: { bool_value: true } - } - test { - name: "not_eq_list_mixed_type_numbers" - expr: "[1.0, 2.1] == [1u, 2]" - value: { bool_value: false } - } - test { - name: "not_eq_list_double_nan" - expr: "[0.0/0.0] == [0.0/0.0]" - value: { bool_value: false } - } - test { - name: "not_eq_nested_list_double_nan" - expr: "[[0.0/0.0]] == [[0.0/0.0]]" - value: { bool_value: false } - } - test { - name: "not_eq_nested_list_map_double_nan" - expr: "[{'k': [0.0/0.0]}] == [{'k': [0.0/0.0]}]" - value: { bool_value: false } - } - test { - name: "eq_list_double_neg_zero" - expr: "[-0.0] == [0.0]" - value: { bool_value: true } - } - test { - name: "eq_list_mixed_type_neg_zero" - expr: "[-0.0, 1] == [0, 1.0]" - value: { bool_value: true } - } - test { - name: "eq_list_mixed_type_neg_zero_uint" - expr: "[-0.0, 1u] == [0u, 1.0]" - value: { bool_value: true } - } - test { - name: "eq_nested_list_mixed_type_neg_zero" - expr: "[[-0.0, 1]] == [[0, 1u]]" - value: { bool_value: true } - } - test { - name: "not_eq_list_order" - expr: "[1, 2, 3] == [1, 3, 2]" - value: { bool_value: false } - } - test { - name: "not_eq_list_string_case" - expr: "['case'] == ['cAse']" - value: { bool_value: false } - } - test { - name: "not_eq_list_length" - expr: "['one'] == [2, 3]" - disable_check: true - value: { bool_value: false } - } - test { - name: "not_eq_list_false_vs_types" - expr: "[1, 'dos', 3] == [1, 2, 4]" - value: { bool_value: false } - } - test { - name: "eq_map_empty" - expr: "{} == {}" - value: { bool_value: true } - } - test { - name: "eq_map_null" - expr: "{'k': null} == {'k': null}" - value: { bool_value: true } - } - test { - name: "not_eq_map_null" - expr: "{'k': 1, 'j': 2} == {'k': 1, 'j': null}" - value: { bool_value: false } - } - test { - name: "eq_map_onekey" - expr: "{'k':'v'} == {\"k\":\"v\"}" - value: { bool_value: true } - } - test { - name: "eq_map_double_value" - expr: "{'k':1.0} == {'k':1e+0}" - value: { bool_value: true } - } - test { - name: "not_eq_map_double_nan" - expr: "{'k': 0.0/0.0} == {'k': 0.0/0.0}" - value: { bool_value: false } - } - test { - name: "not_eq_nested_map_list_double_nan" - expr: "{'k': [0.0/0.0, {'a': 1.0}]} == {'k': [0.0/0.0, {'a': 1.0}]}" - value: { bool_value: false } - } - test { - name: "eq_map_double_neg_zero" - expr: "{'k': -0.0} == {'k': 0.0}" - value: { bool_value: true } - } - test { - name: "eq_map_mixed_type_neg_zero" - expr: "{1: -0.0, 2: 0} == {1: 0, 2: -0.0}" - value: { bool_value: true } - } - test { - name: "eq_map_mixed_type_neg_zero_uint" - expr: "{1: -0.0, 2: 0u} == {1: 0u, 2: -0.0}" - value: { bool_value: true } - } - test { - name: "eq_nested_map_list_neg_zero" - expr: "{'k': [-0.0, {'a': -0.0, 'b': 1}]} == {'k': [0, {'a': 0u, 'b': 1.0}]}" - value: { bool_value: true } - } - test { - name: "eq_map_mixed_type_numbers" - expr: "{1: 1.0, 2u: 3u} == {1u: 1, 2: 3.0}" - value: { bool_value: true } - } - test { - name: "not_eq_map_value" - expr: "{'k':'v'} == {'k':'v1'}" - value: { bool_value: false } - } - test { - name: "not_eq_map_extra_key" - expr: "{'k':'v','k1':'v1'} == {'k':'v'}" - value: { bool_value: false } - } - test { - name: "eq_map_key_order" - expr: "{'k1':'v1','k2':'v2'} == {'k2':'v2','k1':'v1'}" - value: { bool_value: true } - } - test { - name: "not_eq_map_key_casing" - expr: "{'key':'value'} == {'Key':'value'}" - value: { bool_value: false } - } - test { - name: "not_eq_map_false_vs_types" - expr: "{'k1': 1, 'k2': 'dos', 'k3': 3} == {'k1': 1, 'k2': 2, 'k3': 4}" - value: { bool_value: false } - } - test { - name: "eq_mixed_types" - expr: "1.0 == 1" - disable_check: true # need to make it fail in the evaluation phase - value: { bool_value: true } - } - test { - name: "eq_list_elem_mixed_types" - expr: "[1] == [1.0]" - disable_check: true # need to make it fail in the evaluation phase - value: { bool_value: true } - } - test { - name: "eq_map_value_mixed_types" - expr: "{'k':'v', 1:1} == {'k':'v', 1:'v1'}" - value: { bool_value: false } - } - test { - name: "eq_dyn_json_null" - expr: "dyn(google.protobuf.Value{}) == null" - value: { bool_value: true } - } - test { - name: "not_eq_dyn_bool_null" - expr: "dyn(false) == null" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_bytes_null" - expr: "dyn(b'') == null" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_double_null" - expr: "dyn(2.1) == null" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_duration_null" - expr: "dyn(duration('0s')) == null" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_int_null" - expr: "dyn(1) == null" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_list_null" - expr: "dyn([]) == null" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_map_null" - expr: "dyn({}) == null" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_proto2_msg_null" - container: "cel.expr.conformance.proto2" - expr: "dyn(TestAllTypes{}) == null" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_proto3_msg_null" - container: "cel.expr.conformance.proto3" - expr: "dyn(TestAllTypes{}) == null" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_string_null" - expr: "dyn('') == null" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_timestamp_null" - expr: "dyn(timestamp(0)) == null" - value: { bool_value: false } - } - test { - name: "not_eq_list_elem_null" - expr: "[1, 2, null] == [1, null, 3]" - value: { bool_value: false } - } - test { - name: "not_eq_map_value_null" - expr: "{1:'hello', 2:'world'} == {1:'goodbye', 2:null}" - value: { bool_value: false } - } - test { - name: "eq_dyn_int_uint" - expr: "dyn(1) == 1u" - value: { bool_value: true } - } - test { - name: "eq_dyn_int_double" - expr: "dyn(1) == 1.0" - value: { bool_value: true } - } - test { - name: "eq_dyn_uint_int" - expr: "dyn(1u) == 1" - value: { bool_value: true } - } - test { - name: "eq_dyn_uint_double" - expr: "dyn(1u) == 1.0" - value: { bool_value: true } - } - test { - name: "eq_dyn_double_int" - expr: "dyn(1.0) == 1" - value: { bool_value: true } - } - test { - name: "eq_dyn_double_uint" - expr: "dyn(1.0) == 1u" - value: { bool_value: true } - } - test { - name: "not_eq_dyn_int_uint" - expr: "dyn(1) == 2u" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_int_double" - expr: "dyn(1) == 2.0" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_uint_int" - expr: "dyn(1u) == 2" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_uint_double" - expr: "dyn(1u) == 120" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_double_int" - expr: "dyn(1.0) == 2" - value: { bool_value: false } - } - test { - name: "not_eq_dyn_double_uint" - expr: "dyn(1.0) == 2u" - value: { bool_value: false } - } -} -section { - name: "eq_wrapper" - description: "Wrapper type comparison on _==_. Wrapper types treated as boxed primitives when they appear on message fields. An unset wrapper field should be treated as null. The tests show the distinction between unset, empty, and set equality behavior." - test { - name: "eq_bool" - expr: "google.protobuf.BoolValue{value: true} == true" - value: { bool_value: true } - } - test { - name: "eq_bool_empty" - expr: "google.protobuf.BoolValue{} == false" - value: { bool_value: true } - } - test { - name: "eq_bool_not_null" - expr: "google.protobuf.BoolValue{} != null" - value: { bool_value: true } - } - test { - name: "eq_bool_proto2_null" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_bool_wrapper == null" - value: { bool_value: true } - } - test { - name: "eq_bool_proto3_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_bool_wrapper == null" - value: { bool_value: true } - } - - test { - name: "eq_bytes" - expr: "google.protobuf.BytesValue{value: b'set'} == b'set'" - value: { bool_value: true } - } - test { - name: "eq_bytes_empty" - expr: "google.protobuf.BytesValue{} == b''" - value: { bool_value: true } - } - test { - name: "eq_bytes_not_null" - expr: "google.protobuf.BytesValue{} != null" - value: { bool_value: true } - } - test { - name: "eq_bytes_proto2_null" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_bytes_wrapper == null" - value: { bool_value: true } - } - test { - name: "eq_bytes_proto3_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_bytes_wrapper == null" - value: { bool_value: true } - } - - test { - name: "eq_double" - expr: "google.protobuf.DoubleValue{value: -1.175494e-40} == -1.175494e-40" - value: { bool_value: true } - } - test { - name: "eq_double_empty" - expr: "google.protobuf.DoubleValue{} == 0.0" - value: { bool_value: true } - } - test { - name: "eq_double_not_null" - expr: "google.protobuf.DoubleValue{} != null" - value: { bool_value: true } - } - test { - name: "eq_double_proto2_null" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_double_wrapper == null" - value: { bool_value: true } - } - test { - name: "eq_double_proto3_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_double_wrapper == null" - value: { bool_value: true } - } - - test { - name: "eq_float" - expr: "google.protobuf.FloatValue{value: -1.5} == -1.5" - value: { bool_value: true } - } - test { - name: "eq_float_empty" - expr: "google.protobuf.FloatValue{} == 0.0" - value: { bool_value: true } - } - test { - name: "eq_float_not_null" - expr: "google.protobuf.FloatValue{} != null" - value: { bool_value: true } - } - test { - name: "eq_float_proto2_null" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_float_wrapper == null" - value: { bool_value: true } - } - test { - name: "eq_float_proto3_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_float_wrapper == null" - value: { bool_value: true } - } - - test { - name: "eq_int32" - expr: "google.protobuf.Int32Value{value: 123} == 123" - value: { bool_value: true } - } - test { - name: "eq_int32_empty" - expr: "google.protobuf.Int32Value{} == 0" - value: { bool_value: true } - } - test { - name: "eq_int32_not_null" - expr: "google.protobuf.Int32Value{} != null" - value: { bool_value: true } - } - test { - name: "eq_int32_proto2_null" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_int32_wrapper == null" - value: { bool_value: true } - } - test { - name: "eq_int32_proto3_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_int32_wrapper == null" - value: { bool_value: true } - } - - test { - name: "eq_int64" - expr: "google.protobuf.Int64Value{value: 2147483650} == 2147483650" - value: { bool_value: true } - } - test { - name: "eq_int64_empty" - expr: "google.protobuf.Int64Value{} == 0" - value: { bool_value: true } - } - test { - name: "eq_int64_not_null" - expr: "google.protobuf.Int64Value{} != null" - value: { bool_value: true } - } - test { - name: "eq_int64_proto2_null" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_int64_wrapper == null" - value: { bool_value: true } - } - test { - name: "eq_int64_proto3_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_int64_wrapper == null" - value: { bool_value: true } - } - - test { - name: "eq_string" - expr: "google.protobuf.StringValue{value: 'set'} == 'set'" - value: { bool_value: true } - } - test { - name: "eq_string_empty" - expr: "google.protobuf.StringValue{} == ''" - value: { bool_value: true } - } - test { - name: "eq_string_not_null" - expr: "google.protobuf.StringValue{} != null" - value: { bool_value: true } - } - test { - name: "eq_string_proto2_null" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_string_wrapper == null" - value: { bool_value: true } - } - test { - name: "eq_string_proto3_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_string_wrapper == null" - value: { bool_value: true } - } - - test { - name: "eq_uint32" - expr: "google.protobuf.UInt32Value{value: 42u} == 42u" - value: { bool_value: true } - } - test { - name: "eq_uint32_empty" - expr: "google.protobuf.UInt32Value{} == 0u" - value: { bool_value: true } - } - test { - name: "eq_uint32_not_null" - expr: "google.protobuf.UInt32Value{} != null" - value: { bool_value: true } - } - test { - name: "eq_uint32_proto2_null" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_uint32_wrapper == null" - value: { bool_value: true } - } - test { - name: "eq_uint32_proto3_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_uint32_wrapper == null" - value: { bool_value: true } - } - - test { - name: "eq_uint64" - expr: "google.protobuf.UInt64Value{value: 4294967296u} == 4294967296u" - value: { bool_value: true } - } - test { - name: "eq_uint64_empty" - expr: "google.protobuf.UInt64Value{} == 0u" - value: { bool_value: true } - } - test { - name: "eq_uint64_not_null" - expr: "google.protobuf.UInt64Value{} != null" - value: { bool_value: true } - } - test { - name: "eq_uint64_proto2_null" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_uint64_wrapper == null" - value: { bool_value: true } - } - test { - name: "eq_uint64_proto3_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_uint64_wrapper == null" - value: { bool_value: true } - } - test { - name: "eq_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int64: 1234, single_string: '1234'} == TestAllTypes{single_int64: 1234, single_string: '1234'}" - value { bool_value: true } - } - test { - name: "eq_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64: 1234, single_string: '1234'} == TestAllTypes{single_int64: 1234, single_string: '1234'}" - value { bool_value: true } - } - test { - name: "eq_proto2_missing_fields_neq" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int64: 1234} == TestAllTypes{single_string: '1234'}" - value { bool_value: false } - } - test { - name: "eq_proto3_missing_fields_neq" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64: 1234} == TestAllTypes{single_string: '1234'}" - value { bool_value: false } - } - test { - name: "eq_proto_nan_equal" - container: "cel.expr.conformance.proto2" - description: "For proto equality, fields with NaN value are treated as not equal." - expr: "TestAllTypes{single_double: double('NaN')} == TestAllTypes{single_double: double('NaN')}" - value { bool_value: false } - } - test { - name: "eq_proto_different_types" - container: "cel.expr.conformance.proto2" - description: "At runtime, differently typed messages are treated as not equal." - expr: "dyn(TestAllTypes{}) == dyn(NestedTestAllTypes{})" - value { bool_value: false } - } - test { - name: "eq_proto2_any_unpack_equal" - description: "Any values should be unpacked and compared." - container: "cel.expr.conformance.proto2" - # Two equal messages with any fields serialized differently (but both are valid). - # TestAllTypes{single_any: [TestAllTypes]{single_int64: 1234, single_string: '1234'}} - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}} ==" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'r\\0041234\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001'}}" - value { bool_value: true } - } - test { - name: "eq_proto2_any_unpack_not_equal" - description: "Any values should be unpacked and compared." - container: "cel.expr.conformance.proto2" - # Two messages with any fields that are not equal - # TestAllTypes{single_any: [TestAllTypes]{single_int64: 1234, single_string: '1234'}} - # TestAllTypes{single_any: [TestAllTypes]{single_double: -1234.0, single_string: '1234'}} - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'a\\000\\000\\000\\000\\000H\\223\\300r\\0041234'}} ==" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'r\\0041234\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001'}}" - value { bool_value: false } - } - test { - name: "eq_proto2_any_unpack_bytewise_fallback_not_equal" - description: "If an any field is missing its type_url, the comparison should fallback to a bytewise comparison of the serialized proto." - container: "cel.expr.conformance.proto2" - # The missing type info any is doubly nested to skip create message validations. - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}} ==" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021r\\0041234\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001'}}" - value { bool_value: false } - } - test { - name: "eq_proto2_any_unpack_bytewise_fallback_equal" - description: "If an any field is missing its type_url, the comparison should fallback to a bytewise comparison of the serialized proto." - container: "cel.expr.conformance.proto2" - # The missing type info any is doubly nested to skip create message validations. - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}} ==" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}}" - value { bool_value: true } - } - test { - name: "eq_proto3_any_unpack_equal" - description: "Any values should be unpacked and compared." - container: "cel.expr.conformance.proto3" - # Two equal messages with any fields serialized differently (but both are valid). - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}} ==" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'r\\0041234\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001'}}" - value { bool_value: true } - } - test { - name: "eq_proto3_any_unpack_not_equal" - description: "Any values should be unpacked and compared." - container: "cel.expr.conformance.proto3" - # Two messages with any fields that are not equal - # TestAllTypes{single_any: [TestAllTypes]{single_int64: 1234, single_string: '1234'}} - # TestAllTypes{single_any: [TestAllTypes]{single_double: -1234.0, single_string: '1234'}} - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'a\\000\\000\\000\\000\\000H\\223\\300r\\0041234'}} ==" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'r\\0041234\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001'}}" - value { bool_value: false } - } - test { - name: "eq_proto3_any_unpack_bytewise_fallback_not_equal" - description: "If an any field is missing its type_url, the comparison should fallback to a bytewise comparison of the serialized proto." - container: "cel.expr.conformance.proto3" - # The missing type info any is doubly nested to skip create message validations. - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}} ==" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021r\\0041234\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001'}}" - value { bool_value: false } - } - test { - name: "eq_proto3_any_unpack_bytewise_fallback_equal" - description: "If an any field is missing its type_url, the comparison should fallback to a bytewise comparison of the serialized proto." - container: "cel.expr.conformance.proto3" - # The missing type info any is doubly nested to skip create message validations. - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}} ==" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}}" - value { bool_value: true } - } -} -section { - name: "ne_literal" - description: "Literals comparison on _!=_" - test { - name: "ne_int" - expr: "24 != 42" - value: { bool_value: true } - } - test { - name: "not_ne_int" - expr: "1 != 1" - value: { bool_value: false } - } - test { - name: "ne_int_double" - expr: "dyn(24) != 24.1" - value: { bool_value: true } - } - test { - name: "not_ne_int_double" - expr: "dyn(1) != 1.0" - value: { bool_value: false } - } - test { - name: "ne_int_uint" - expr: "dyn(24) != 42u" - value: { bool_value: true } - } - test { - name: "not_ne_int_uint" - expr: "dyn(1) != 1u" - value: { bool_value: false } - } - test { - name: "ne_uint" - expr: "1u != 2u" - value: { bool_value: true } - } - test { - name: "not_ne_uint" - expr: "99u != 99u" - value: { bool_value: false } - } - test { - name: "ne_uint_double" - expr: "dyn(1u) != 2.0" - value: { bool_value: true } - } - test { - name: "not_ne_uint_double" - expr: "dyn(99u) != 99.0" - value: { bool_value: false } - } - test { - name: "ne_double" - expr: "9.0e+3 != 9001.0" - value: { bool_value: true } - } - test { - name: "not_ne_double_nan" - expr: "0.0/0.0 != 0.0/0.0" - value: { bool_value: true } - } - test { - name: "ne_double_nan_left" - expr: "0.0/0.0 != 1.0" - value: { bool_value: true } - } - test { - name: "ne_double_nan_right" - expr: "1.0 != 0.0/0.0" - value: { bool_value: true } - } - test { - name: "not_ne_int_double_nan" - expr: "dyn(1) != 0.0/0.0" - value: { bool_value: true } - } - test { - name: "ne_double_nan_int" - expr: "dyn(0.0/0.0) != 1" - value: { bool_value: true } - } - test { - name: "not_ne_uint_double_nan" - expr: "dyn(1u) != 0.0/0.0" - value: { bool_value: true } - } - test { - name: "ne_double_nan_uint" - expr: "dyn(0.0/0.0) != 1u" - value: { bool_value: true } - } - test { - name: "not_ne_double" - expr: "1.0 != 1e+0" - value: { bool_value: false } - } - test { - name: "ne_double_int" - expr: "dyn(9000) != 9001.0" - value: { bool_value: true } - } - test { - name: "not_ne_double_int" - expr: "dyn(1) != 1e+0" - value: { bool_value: false } - } - test { - name: "ne_double_uint" - expr: "dyn(9000u) != 9001.0" - value: { bool_value: true } - } - test { - name: "not_ne_double_uint" - expr: "dyn(1u) != 1e+0" - value: { bool_value: false } - } - test { - name: "not_ne_double_neg_zero" - expr: "-0.0 != 0.0" - value: { bool_value: false } - } - test { - name: "not_ne_double_zero_neg_zero" - expr: "0.0 != -0.0" - value: { bool_value: false } - } - test { - name: "not_ne_double_neg_zero_int" - expr: "dyn(-0.0) != 0" - value: { bool_value: false } - } - test { - name: "not_ne_int_double_neg_zero" - expr: "dyn(0) != -0.0" - value: { bool_value: false } - } - test { - name: "not_ne_double_neg_zero_uint" - expr: "dyn(-0.0) != 0u" - value: { bool_value: false } - } - test { - name: "not_ne_uint_double_neg_zero" - expr: "dyn(0u) != -0.0" - value: { bool_value: false } - } - test { - name: "ne_double_nan" - expr: "0.0/0.0 != 0.0/0.0" - value: { bool_value: true } - } - test { - name: "ne_string" - expr: "'abc' != ''" - value: { bool_value: true } - } - test { - name: "not_ne_string" - expr: "'abc' != 'abc'" - value: { bool_value: false } - } - test { - name: "ne_string_unicode" - expr: "'résumé' != 'resume'" - value: { bool_value: true } - } - test { - name: "not_ne_string_unicode" - expr: "'ίδιο' != 'ίδιο'" - value: { bool_value: false } - } - test { - name: "ne_bytes" - expr: "b'\\x00\\xFF' != b'ÿ'" - value: { bool_value: true } - } - test { - name: "not_ne_bytes" - expr: "b'\\303\\277' != b'ÿ'" - value: { bool_value: false } - } - test { - name: "ne_bool" - expr: "false != true" - value: { bool_value: true } - } - test { - name: "not_ne_bool" - expr: "true != true" - value: { bool_value: false } - } - test { - name: "not_ne_null" - description: "null can only be equal to null, or else it won't match" - expr: "null != null" - value: { bool_value: false } - } - test { - name: "ne_list_empty" - expr: "[] != [1]" - value: { bool_value: true } - } - test { - name: "not_ne_list_empty" - expr: "[] != []" - value: { bool_value: false } - } - test { - name: "ne_list_bool" - expr: "[true, false, true] != [true, true, false]" - value: { bool_value: true } - } - test { - name: "not_ne_list_bool" - expr: "[false, true] != [false, true]" - value: { bool_value: false } - } - test { - name: "not_ne_list_of_list" - expr: "[[]] != [[]]" - value: { bool_value: false } - } - test { - name: "ne_list_double_nan" - expr: "[0.0/0.0] != [0.0/0.0]" - value: { bool_value: true } - } - test { - name: "ne_nested_list_double_nan" - expr: "[[0.0/0.0]] != [[0.0/0.0]]" - value: { bool_value: true } - } - test { - name: "ne_nested_list_map_double_nan" - expr: "[{'k': [0.0/0.0]}] != [{'k': [0.0/0.0]}]" - value: { bool_value: true } - } - test { - name: "not_ne_list_double_neg_zero" - expr: "[-0.0] != [0.0]" - value: { bool_value: false } - } - test { - name: "not_ne_list_mixed_type_neg_zero" - expr: "[-0.0, 1] != [0, 1.0]" - value: { bool_value: false } - } - test { - name: "not_ne_list_mixed_type_neg_zero_uint" - expr: "[-0.0, 1u] != [0u, 1.0]" - value: { bool_value: false } - } - test { - name: "not_ne_nested_list_mixed_type_neg_zero" - expr: "[[-0.0, 1]] != [[0, 1u]]" - value: { bool_value: false } - } - test { - name: "ne_map_by_value" - expr: "{'k':'v'} != {'k':'v1'}" - value: { bool_value: true } - } - test { - name: "ne_map_by_key" - expr: "{'k':true} != {'k1':true}" - value: { bool_value: true } - } - test { - name: "not_ne_map_int_to_float" - expr: "{1:1.0} != {1:1.0}" - value: { bool_value: false } - } - test { - name: "ne_map_double_nan" - expr: "{'k': 0.0/0.0} != {'k': 0.0/0.0}" - value: { bool_value: true } - } - test { - name: "ne_nested_map_list_double_nan" - expr: "{'k': [0.0/0.0, {'a': 1.0}]} != {'k': [0.0/0.0, {'a': 1.0}]}" - value: { bool_value: true } - } - test { - name: "not_ne_map_double_neg_zero" - expr: "{'k': -0.0} != {'k': 0.0}" - value: { bool_value: false } - } - test { - name: "not_ne_map_mixed_type_neg_zero" - expr: "{1: -0.0, 2: 0} != {1: 0, 2: -0.0}" - value: { bool_value: false } - } - test { - name: "not_ne_map_mixed_type_neg_zero_uint" - expr: "{1: -0.0, 2: 0u} != {1: 0u, 2: -0.0}" - value: { bool_value: false } - } - test { - name: "not_ne_nested_map_list_neg_zero" - expr: "{'k': [-0.0, {'a': -0.0, 'b': 1}]} != {'k': [0, {'a': 0u, 'b': 1.0}]}" - value: { bool_value: false } - } - test { - name: "not_ne_map_key_order" - expr: "{'a':'b','c':'d'} != {'c':'d','a':'b'}" - value: { bool_value: false } - } - test { - name: "ne_mixed_types" - expr: "2u != 2" - disable_check: true - value: { bool_value: false } - } - test { - name: "ne_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int64: 1234, single_string: '1234'} != TestAllTypes{single_int64: 1234, single_string: '1234'}" - value { bool_value: false } - } - test { - name: "ne_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64: 1234, single_string: '1234'} != TestAllTypes{single_int64: 1234, single_string: '1234'}" - value { bool_value: false } - } - test { - name: "ne_proto2_missing_fields_neq" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int64: 1234} != TestAllTypes{single_string: '1234'}" - value { bool_value: true } - } - test { - name: "ne_proto3_missing_fields_neq" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64: 1234} != TestAllTypes{single_string: '1234'}" - value { bool_value: true } - } - test { - name: "ne_proto_nan_not_equal" - container: "cel.expr.conformance.proto2" - description: "For proto equality, NaN field values are not considered equal." - expr: "TestAllTypes{single_double: double('NaN')} != TestAllTypes{single_double: double('NaN')}" - value { bool_value: true } - } - test { - name: "ne_proto_different_types" - container: "cel.expr.conformance.proto2" - description: "At runtime, comparing differently typed messages is false." - expr: "dyn(TestAllTypes{}) != dyn(NestedTestAllTypes{})" - value: { bool_value: true } - } - test { - name: "ne_proto2_any_unpack" - description: "Any values should be unpacked and compared." - container: "cel.expr.conformance.proto2" - # Two equal messages with any fields serialized differently (but both are valid). - # TestAllTypes{single_any: [TestAllTypes]{single_int64: 1234, single_string: '1234'}} - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}} !=" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'r\\0041234\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001'}}" - value { bool_value: false } - } - test { - name: "ne_proto2_any_unpack_bytewise_fallback" - description: "If an any field is missing its type_url, the comparison should fallback to a bytewise comparison of the serialized proto." - container: "cel.expr.conformance.proto3" - # The missing type info any is doubly nested to skip create - # message validations. - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}} !=" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021r\\0041234\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001'}}" - value { bool_value: true } - } - test { - name: "ne_proto3_any_unpack" - description: "Any values should be unpacked and compared." - container: "cel.expr.conformance.proto2" - # Two equal messages with any fields serialized differently (but both are valid). - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}} !=" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'r\\0041234\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001'}}" - value { bool_value: false } - } - test { - name: "ne_proto3_any_unpack_bytewise_fallback" - description: "If an any field is missing its type_url, the comparison should fallback to a bytewise comparison of the serialized proto." - container: "cel.expr.conformance.proto3" - # The missing type info any is doubly nested to skip create message validations. - expr: - "TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001r\\0041234'}} !=" - " TestAllTypes{single_any: google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\242\\006\\023\\022\\021r\\0041234\\020\\256\\366\\377\\377\\377\\377\\377\\377\\377\\001'}}" - value { bool_value: true } - } -} -section { - name: "lt_literal" - description: "Literals comparison on _<_. (a < b) == (b > a) == !(a >= b) == !(b <= a)" - test { - name: "lt_int" - expr: "-1 < 0" - value: { bool_value: true } - } - test { - name: "not_lt_int" - expr: "0 < 0" - value: { bool_value: false } - } - test { - name: "lt_uint" - expr: "0u < 1u" - value: { bool_value: true } - } - test { - name: "not_lt_uint" - expr: "2u < 2u" - value: { bool_value: false } - } - test { - name: "lt_double" - expr: "1.0 < 1.0000001" - value: { bool_value: true } - } - test { - name: "not_lt_double" - description: "Following IEEE 754, negative zero compares equal to zero" - expr: "-0.0 < 0.0" - value: { bool_value: false } - } - test { - name: "not_lt_double_zero_neg_zero" - expr: "0.0 < -0.0" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_double_neg_zero_int" - expr: "dyn(-0.0) < 0" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_int_double_neg_zero" - expr: "dyn(0) < -0.0" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_double_neg_zero_uint" - expr: "dyn(-0.0) < 0u" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_uint_double_neg_zero" - expr: "dyn(0u) < -0.0" - value: { bool_value: false } - } - test { - name: "not_lt_double_nan" - expr: "0.0/0.0 < 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_lt_double_nan_left" - expr: "0.0/0.0 < 1.0" - value: { bool_value: false } - } - test { - name: "not_lt_double_nan_right" - expr: "1.0 < 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_double_nan_int" - expr: "dyn(0.0/0.0) < 1" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_int_double_nan" - expr: "dyn(1) < 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_double_nan_uint" - expr: "dyn(0.0/0.0) < 1u" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_uint_double_nan" - expr: "dyn(1u) < 0.0/0.0" - value: { bool_value: false } - } - test { - name: "lt_string" - expr: "'a' < 'b'" - value: { bool_value: true } - } - test { - name: "lt_string_empty_to_nonempty" - expr: "'' < 'a'" - value: { bool_value: true } - } - test { - name: "lt_string_case" - expr: "'Abc' < 'aBC'" - value: { bool_value: true } - } - test { - name: "lt_string_length" - expr: "'abc' < 'abcd'" - value: { bool_value: true } - } - test { - name: "lt_string_diacritical_mark_sensitive" - description: "Verifies that the we're not using a string comparison function that strips diacritical marks (á)" - expr: "'a' < '\\u00E1'" - value: { bool_value: true } - } - test { - name: "not_lt_string_empty" - expr: "'' < ''" - value: { bool_value: false } - } - test { - name: "not_lt_string_same" - expr: "'abc' < 'abc'" - value: { bool_value: false } - } - test { - name: "not_lt_string_case_length" - expr: "'a' < 'AB'" - value: { bool_value: false } - } - test { - name: "unicode_order_lexical" - description: "Compare the actual code points of the string, instead of decomposing ế into 'e' plus accent modifiers." - expr: "'f' < '\\u1EBF'" - value: { bool_value: true } - } - test { - name: "lt_bytes" - expr: "b'a' < b'b'" - value: { bool_value: true } - } - test { - name: "not_lt_bytes_same" - expr: "b'abc' < b'abc'" - value: { bool_value: false } - } - test { - name: "not_lt_bytes_width" - expr: "b'á' < b'b'" - value: { bool_value: false } - } - test { - name: "lt_bool_false_first" - expr: "false < true" - value: { bool_value: true } - } - test { - name: "not_lt_bool_same" - expr: "true < true" - value: { bool_value: false } - } - test { - name: "not_lt_bool_true_first" - expr: "true < false" - value: { bool_value: false } - } - test { - name: "lt_list_unsupported" - expr: "[0] < [1]" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "lt_map_unsupported" - expr: "{0:'a'} < {1:'b'}" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "lt_null_unsupported" - description: "Ensure _<_ doesn't have a binding for null" - expr: "null < null" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "lt_mixed_types_error" - expr: "'foo' < 1024" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "lt_dyn_int_uint" - expr: "dyn(1) < 2u" - value: { bool_value: true } - } - test { - name: "lt_dyn_int_double" - expr: "dyn(1) < 2.0" - value: { bool_value: true } - } - test { - name: "lt_dyn_uint_int" - expr: "dyn(1u) < 2" - value: { bool_value: true } - } - test { - name: "lt_dyn_uint_double" - expr: "dyn(1u) < 2.0" - value: { bool_value: true } - } - test { - name: "lt_dyn_double_int" - expr: "dyn(1.0) < 2" - value: { bool_value: true } - } - test { - name: "lt_dyn_double_uint" - expr: "dyn(1.0) < 2u" - value: { bool_value: true } - } - test { - name: "not_lt_dyn_int_uint" - expr: "dyn(1) < 1u" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_int_double" - expr: "dyn(1) < 1.0" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_uint_int" - expr: "dyn(1u) < 1" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_uint_double" - expr: "dyn(1u) < 1.0" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_double_int" - expr: "dyn(1.0) < 1" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_double_uint" - expr: "dyn(1.0) < 1u" - value: { bool_value: false } - } - test { - name: "lt_dyn_int_big_uint" - expr: "dyn(1) < 9223372036854775808u" - value: { bool_value: true } - } - test { - name: "lt_dyn_small_int_uint" - expr: "dyn(-1) < 0u" - value: { bool_value: true } - } - test { - name: "not_lt_dyn_int_big_lossy_double" - expr: "dyn(9223372036854775807) < 9223372036854775808.0" - value: { bool_value: false } - } - test { - name: "lt_dyn_int_big_lossy_double" - expr: "dyn(9223372036854775807) < 9223372036854777857.0" - value: { bool_value: true } - } - test { - name: "not_lt_dyn_int_small_double" - expr: "dyn(9223372036854775807) < -9223372036854777857.0" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_int_small_lossy_double" - expr: "dyn(-9223372036854775808) < -9223372036854775809.0" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_uint_small_int" - expr: "dyn(1u) < -9223372036854775808" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_big_uint_int" - expr: "dyn(9223372036854775808u) < 1" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_uint_small_double" - expr: "dyn(18446744073709551615u) < -1.0" - value: { bool_value: false } - } - test { - name: "lt_dyn_uint_big_double" - expr: "dyn(18446744073709551615u) < 18446744073709590000.0" - value: { bool_value: true } - } - test { - name: "not_lt_dyn_big_double_uint" - expr: "dyn(18446744073709553665.0) < 18446744073709551615u" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_big_double_int" - expr: "dyn(9223372036854775808.0) < 9223372036854775807" - value: { bool_value: false } - } - test { - name: "not_lt_dyn_small_double_int" - expr: "dyn(-9223372036854775809.0) < -9223372036854775808" - value: { bool_value: false } - } - -} -section { - name: "gt_literal" - description: "Literals comparison on _>_" - test { - name: "gt_int" - expr: "42 > -42" - value: { bool_value: true } - } - test { - name: "not_gt_int" - expr: "0 > 0" - value: { bool_value: false } - } - test { - name: "gt_uint" - expr: "48u > 46u" - value: { bool_value: true } - } - test { - name: "not_gt_uint" - expr: "0u > 999u" - value: { bool_value: false } - } - test { - name: "gt_double" - expr: "1e+1 > 1e+0" - value: { bool_value: true } - } - test { - name: "not_gt_double" - expr: ".99 > 9.9e-1" - value: { bool_value: false } - } - test { - name: "not_gt_double_neg_zero" - expr: "-0.0 > 0.0" - value: { bool_value: false } - } - test { - name: "not_gt_double_zero_neg_zero" - expr: "0.0 > -0.0" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_double_neg_zero_int" - expr: "dyn(-0.0) > 0" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_int_double_neg_zero" - expr: "dyn(0) > -0.0" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_double_neg_zero_uint" - expr: "dyn(-0.0) > 0u" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_uint_double_neg_zero" - expr: "dyn(0u) > -0.0" - value: { bool_value: false } - } - test { - name: "not_gt_double_nan" - expr: "0.0/0.0 > 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_gt_double_nan_left" - expr: "0.0/0.0 > 1.0" - value: { bool_value: false } - } - test { - name: "not_gt_double_nan_right" - expr: "1.0 > 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_double_nan_int" - expr: "dyn(0.0/0.0) > 1" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_int_double_nan" - expr: "dyn(1) > 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_double_nan_uint" - expr: "dyn(0.0/0.0) > 1u" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_uint_double_nan" - expr: "dyn(1u) > 0.0/0.0" - value: { bool_value: false } - } - test { - name: "gt_string_case" - expr: "'abc' > 'aBc'" - value: { bool_value: true } - } - test { - name: "gt_string_to_empty" - expr: "'A' > ''" - value: { bool_value: true } - } - test { - name: "not_gt_string_empty_to_empty" - expr: "'' > ''" - value: { bool_value: false } - } - test { - name: "gt_string_unicode" - expr: "'α' > 'omega'" - value: { bool_value: true } - } - test { - name: "gt_bytes_one" - expr: "b'\x01' > b'\x00'" - value: { bool_value: true } - } - test { - name: "gt_bytes_one_to_empty" - expr: "b'\x00' > b''" - value: { bool_value: true } - } - test { - name: "not_gt_bytes_sorting" - expr: "b'\x00\x01' > b'\x01'" - value: { bool_value: false } - } - test { - name: "gt_bool_true_false" - expr: "true > false" - value: { bool_value: true } - } - test { - name: "not_gt_bool_false_true" - expr: "false > true" - value: { bool_value: false } - } - test { - name: "not_gt_bool_same" - expr: "true > true" - value: { bool_value: false } - } - test { - name: "gt_null_unsupported" - expr: "null > null" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "gt_list_unsupported" - expr: "[1] > [0]" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "gt_map_unsupported" - expr: "{1:'b'} > {0:'a'}" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "gt_mixed_types_error" - expr: "'foo' > 1024" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "gt_dyn_int_uint" - expr: "dyn(2) > 1u" - value: { bool_value: true } - } - test { - name: "gt_dyn_int_double" - expr: "dyn(2) > 1.0" - value: { bool_value: true } - } - test { - name: "gt_dyn_uint_int" - expr: "dyn(2u) > 1" - value: { bool_value: true } - } - test { - name: "gt_dyn_uint_double" - expr: "dyn(2u) > 1.0" - value: { bool_value: true } - } - test { - name: "gt_dyn_double_int" - expr: "dyn(2.0) > 1" - value: { bool_value: true } - } - test { - name: "gt_dyn_double_uint" - expr: "dyn(2.0) > 1u" - value: { bool_value: true } - } - test { - name: "not_gt_dyn_int_uint" - expr: "dyn(1) > 1u" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_int_double" - expr: "dyn(1) > 1.0" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_uint_int" - expr: "dyn(1u) > 1" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_uint_double" - expr: "dyn(1u) > 1.0" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_double_int" - expr: "dyn(1.0) > 1" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_double_uint" - expr: "dyn(1.0) > 1u" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_int_big_uint" - expr: "dyn(1) > 9223372036854775808u" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_small_int_uint" - expr: "dyn(-1) > 0u" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_int_big_double" - expr: "dyn(9223372036854775807) > 9223372036854775808.0" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_int_small_lossy_double" - description: "The conversion of the int to double is lossy and the numbers end up being equal" - expr: "dyn(-9223372036854775808) > -9223372036854775809.0" - value: { bool_value: false } - } - test { - name: "gt_dyn_int_small_lossy_double_greater" - expr: "dyn(-9223372036854775808) > -9223372036854777857.0" - value: { bool_value: true } - } - test { - name: "gt_dyn_uint_small_int" - expr: "dyn(1u) > -1" - value: { bool_value: true } - } - test { - name: "gt_dyn_big_uint_int" - expr: "dyn(9223372036854775808u) > 1" - value: { bool_value: true } - } - test { - name: "gt_dyn_uint_small_double" - expr: "dyn(9223372036854775807u) > -1.0" - value: { bool_value: true } - } - test { - name: "not_gt_dyn_uint_big_double" - expr: "dyn(18446744073709551615u) > 18446744073709590000.0" - value: { bool_value: false } - } - test { - name: "gt_dyn_big_double_uint" - expr: "dyn(18446744073709553665.0) > 18446744073709551615u" - value: { bool_value: true } - } - test { - name: "not_gt_dyn_big_double_int" - expr: "dyn(9223372036854775808.0) > 9223372036854775807" - value: { bool_value: false } - } - test { - name: "not_gt_dyn_small_double_int" - expr: "dyn(-9223372036854775809.0) > -9223372036854775808" - value: { bool_value: false } - } -} -section { - name: "lte_literal" - description: "Literals comparison on _<=_" - test { - name: "lte_int_lt" - expr: "0 <= 1" - value: { bool_value: true } - } - test { - name: "lte_int_eq" - expr: "1 <= 1" - value: { bool_value: true } - } - test { - name: "not_lte_int_gt" - expr: "1 <= -1" - value: { bool_value: false } - } - test { - name: "lte_uint_lt" - expr: "0u <= 1u" - value: { bool_value: true } - } - test { - name: "lte_uint_eq" - expr: "1u <= 1u" - value: { bool_value: true } - } - test { - name: "not_lte_uint_gt" - expr: "1u <= 0u" - value: { bool_value: false } - } - test { - name: "lte_double_lt" - expr: "0.0 <= 0.1e-31" - value: { bool_value: true } - } - test { - name: "lte_double_eq" - expr: "0.0 <= 0e-1" - value: { bool_value: true } - } - test { - name: "not_lte_double_gt" - expr: "1.0 <= 0.99" - value: { bool_value: false } - } - test { - name: "lte_double_neg_zero" - expr: "-0.0 <= 0.0" - value: { bool_value: true } - } - test { - name: "lte_double_zero_neg_zero" - expr: "0.0 <= -0.0" - value: { bool_value: true } - } - test { - name: "lte_dyn_double_neg_zero_int" - expr: "dyn(-0.0) <= 0" - value: { bool_value: true } - } - test { - name: "lte_dyn_int_double_neg_zero" - expr: "dyn(0) <= -0.0" - value: { bool_value: true } - } - test { - name: "lte_dyn_double_neg_zero_uint" - expr: "dyn(-0.0) <= 0u" - value: { bool_value: true } - } - test { - name: "lte_dyn_uint_double_neg_zero" - expr: "dyn(0u) <= -0.0" - value: { bool_value: true } - } - test { - name: "not_lte_double_nan" - expr: "0.0/0.0 <= 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_lte_double_nan_left" - expr: "0.0/0.0 <= 1.0" - value: { bool_value: false } - } - test { - name: "not_lte_double_nan_right" - expr: "1.0 <= 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_double_nan_int" - expr: "dyn(0.0/0.0) <= 1" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_int_double_nan" - expr: "dyn(1) <= 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_double_nan_uint" - expr: "dyn(0.0/0.0) <= 1u" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_uint_double_nan" - expr: "dyn(1u) <= 0.0/0.0" - value: { bool_value: false } - } - test { - name: "lte_string_empty" - expr: "'' <= ''" - value: { bool_value: true } - } - test { - name: "lte_string_from_empty" - expr: "'' <= 'a'" - value: { bool_value: true } - } - test { - name: "not_lte_string_to_empty" - expr: "'a' <= ''" - value: { bool_value: false } - } - test { - name: "lte_string_lexicographical" - expr: "'aBc' <= 'abc'" - value: { bool_value: true } - } - test { - name: "lte_string_unicode_eq" - expr: "'α' <= 'α'" - value: { bool_value: true } - } - test { - name: "lte_string_unicode_lt" - expr: "'a' <= 'α'" - value: { bool_value: true } - } - test { - name: "not_lte_string_unicode" - expr: "'α' <= 'a'" - value: { bool_value: false } - } - test { - name: "lte_bytes_empty" - expr: "b'' <= b'\x00'" - value: { bool_value: true } - } - test { - name: "not_lte_bytes_length" - expr: "b'\x01\x00' <= b'\x01'" - value: { bool_value: false } - } - test { - name: "lte_bool_false_true" - expr: "false <= true" - value: { bool_value: true } - } - test { - name: "lte_bool_false_false" - expr: "false <= false" - value: { bool_value: true } - } - test { - name: "lte_bool_true_false" - expr: "true <= false" - value: { bool_value: false } - } - test { - name: "lte_null_unsupported" - expr: "null <= null" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "lte_list_unsupported" - expr: "[0] <= [0]" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "lte_map_unsupported" - expr: "{0:'a'} <= {1:'b'}" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "lte_mixed_types_error" - expr: "'foo' <= 1024" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "lte_dyn_int_uint" - expr: "dyn(1) <= 2u" - value: { bool_value: true } - } - test { - name: "lte_dyn_int_double" - expr: "dyn(1) <= 2.0" - value: { bool_value: true } - } - test { - name: "lte_dyn_uint_int" - expr: "dyn(1u) <= 2" - value: { bool_value: true } - } - test { - name: "lte_dyn_uint_double" - expr: "dyn(1u) <= 2.0" - value: { bool_value: true } - } - test { - name: "lte_dyn_double_int" - expr: "dyn(1.0) <= 2" - value: { bool_value: true } - } - test { - name: "lte_dyn_double_uint" - expr: "dyn(1.0) <= 2u" - value: { bool_value: true } - } - test { - name: "not_lte_dyn_int_uint" - expr: "dyn(2) <= 1u" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_int_double" - expr: "dyn(2) <= 1.0" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_uint_int" - expr: "dyn(2u) <= 1" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_uint_double" - expr: "dyn(2u) <= 1.0" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_double_int" - expr: "dyn(2.0) <= 1" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_double_uint" - expr: "dyn(2.0) <= 1u" - value: { bool_value: false } - } - test { - name: "lte_dyn_int_big_uint" - expr: "dyn(1) <= 9223372036854775808u" - value: { bool_value: true } - } - test { - name: "lte_dyn_small_int_uint" - expr: "dyn(-1) <= 0u" - value: { bool_value: true } - } - test { - name: "lte_dyn_int_big_double" - expr: "dyn(9223372036854775807) <= 9223372036854775808.0" - value: { bool_value: true } - } - test { - name: "lte_dyn_int_small_lossy_double" - description: "The conversion of the int to double is lossy and the numbers end up being equal" - expr: "dyn(-9223372036854775808) <= -9223372036854775809.0" - value: { bool_value: true } - } - test { - name: "not_lte_dyn_int_small_lossy_double_less" - expr: "dyn(-9223372036854775808) <= -9223372036854777857.0" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_uint_small_int" - expr: "dyn(1u) <= -9223372036854775808" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_big_uint_int" - expr: "dyn(9223372036854775808u) <= 1" - value: { bool_value: false } - } - test { - name: "not_lte_dyn_uint_small_double" - expr: "dyn(18446744073709551615u) <= -1.0" - value: { bool_value: false } - } - test { - name: "lte_dyn_uint_big_double" - expr: "dyn(18446744073709551615u) <= 18446744073709590000.0" - value: { bool_value: true } - } - test { - name: "not_lte_dyn_big_double_uint" - expr: "dyn(18446744073709553665.0) <= 18446744073709551615u" - value: { bool_value: false } - } - test { - name: "lte_dyn_big_double_int" - expr: "dyn(9223372036854775808.0) <= 9223372036854775807" - value: { bool_value: true } - } - test { - name: "lte_dyn_small_double_int" - expr: "dyn(-9223372036854775809.0) <= -9223372036854775808" - value: { bool_value: true } - } -} -section { - name: "gte_literal" - description: "Literals comparison on _>=_" - test { - name: "gte_int_gt" - expr: "0 >= -1" - value: { bool_value: true } - } - test { - name: "gte_int_eq" - expr: "999 >= 999" - value: { bool_value: true } - } - test { - name: "not_gte_int_lt" - expr: "999 >= 1000" - value: { bool_value: false } - } - test { - name: "gte_uint_gt" - expr: "1u >= 0u" - value: { bool_value: true } - } - test { - name: "gte_uint_eq" - expr: "0u >= 0u" - value: { bool_value: true } - } - test { - name: "not_gte_uint_lt" - expr: "1u >= 10u" - value: { bool_value: false } - } - test { - name: "gte_double_gt" - expr: "1e+1 >= 1e+0" - value: { bool_value: true } - } - test { - name: "gte_double_eq" - expr: "9.80665 >= 9.80665e+0" - value: { bool_value: true } - } - test { - name: "not_gte_double_lt" - expr: "0.9999 >= 1.0" - value: { bool_value: false } - } - test { - name: "gte_double_neg_zero" - expr: "-0.0 >= 0.0" - value: { bool_value: true } - } - test { - name: "gte_double_zero_neg_zero" - expr: "0.0 >= -0.0" - value: { bool_value: true } - } - test { - name: "gte_dyn_double_neg_zero_int" - expr: "dyn(-0.0) >= 0" - value: { bool_value: true } - } - test { - name: "gte_dyn_int_double_neg_zero" - expr: "dyn(0) >= -0.0" - value: { bool_value: true } - } - test { - name: "gte_dyn_double_neg_zero_uint" - expr: "dyn(-0.0) >= 0u" - value: { bool_value: true } - } - test { - name: "gte_dyn_uint_double_neg_zero" - expr: "dyn(0u) >= -0.0" - value: { bool_value: true } - } - test { - name: "not_gte_double_nan" - expr: "0.0/0.0 >= 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_gte_double_nan_left" - expr: "0.0/0.0 >= 1.0" - value: { bool_value: false } - } - test { - name: "not_gte_double_nan_right" - expr: "1.0 >= 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_double_nan_int" - expr: "dyn(0.0/0.0) >= 1" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_int_double_nan" - expr: "dyn(1) >= 0.0/0.0" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_double_nan_uint" - expr: "dyn(0.0/0.0) >= 1u" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_uint_double_nan" - expr: "dyn(1u) >= 0.0/0.0" - value: { bool_value: false } - } - test { - name: "gte_string_empty" - expr: "'' >= ''" - value: { bool_value: true } - } - test { - name: "gte_string_to_empty" - expr: "'a' >= ''" - value: { bool_value: true } - } - test { - name: "gte_string_empty_to_nonempty" - expr: "'' >= 'a'" - value: { bool_value: false } - } - test { - name: "gte_string_length" - expr: "'abcd' >= 'abc'" - value: { bool_value: true } - } - test { - name: "not_gte_string_lexicographical" - expr: "'abc' >= 'abd'" - value: { bool_value: false } - } - test { - name: "gte_string_unicode_eq" - expr: "'τ' >= 'τ'" - value: { bool_value: true } - } - test { - name: "gte_string_unicode_gt" - expr: "'τ' >= 't'" - value: { bool_value: true } - } - test { - name: "not_get_string_unicode" - expr: "'t' >= 'τ'" - value: { bool_value: false } - } - test { - name: "gte_bytes_to_empty" - expr: "b'\x00' >= b''" - value: { bool_value: true } - } - test { - name: "not_gte_bytes_empty_to_nonempty" - expr: "b'' >= b'\x00'" - value: { bool_value: false } - } - test { - name: "gte_bytes_samelength" - expr: "b'\x00\x01' >= b'\x01\x00'" - value: { bool_value: false } - } - test { - name: "gte_bool_gt" - expr: "true >= false" - value: { bool_value: true } - } - test { - name: "gte_bool_eq" - expr: "true >= true" - value: { bool_value: true } - } - test { - name: "not_gte_bool_lt" - expr: "false >= true" - value: { bool_value: false } - } - test { - name: "gte_null_unsupported" - expr: "null >= null" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "gte_list_unsupported" - expr: "['y'] >= ['x']" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "gte_map_unsupported" - expr: "{1:'b'} >= {0:'a'}" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "gte_mixed_types_error" - expr: "'foo' >= 1.0" - disable_check: true - eval_error: { - errors: { message: "no such overload" } - } - } - test { - name: "gte_dyn_int_uint" - expr: "dyn(2) >= 1u" - value: { bool_value: true } - } - test { - name: "gte_dyn_int_double" - expr: "dyn(2) >= 1.0" - value: { bool_value: true } - } - test { - name: "gte_dyn_uint_int" - expr: "dyn(2u) >= 1" - value: { bool_value: true } - } - test { - name: "gte_dyn_uint_double" - expr: "dyn(2u) >= 1.0" - value: { bool_value: true } - } - test { - name: "gte_dyn_double_int" - expr: "dyn(2.0) >= 1" - value: { bool_value: true } - } - test { - name: "gte_dyn_double_uint" - expr: "dyn(2.0) >= 1u" - value: { bool_value: true } - } - test { - name: "not_gte_dyn_int_uint" - expr: "dyn(0) >= 1u" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_int_double" - expr: "dyn(0) >= 1.0" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_uint_int" - expr: "dyn(0u) >= 1" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_uint_double" - expr: "dyn(0u) >= 1.0" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_double_int" - expr: "dyn(0.0) >= 1" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_double_uint" - expr: "dyn(0.0) >= 1u" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_int_big_uint" - expr: "dyn(1) >= 9223372036854775808u" - value: { bool_value: false } - } - test { - name: "not_gte_dyn_small_int_uint" - expr: "dyn(-1) >= 0u" - value: { bool_value: false } - } - test { - name: "gte_dyn_int_big_lossy_double" - expr: "dyn(9223372036854775807) >= 9223372036854775808.0" - value: { bool_value: true } - } - test { - name: "not_gte_dyn_int_big_double" - expr: "dyn(9223372036854775807) >= 9223372036854777857.0" - value: { bool_value: false } - } - test { - name: "gte_dyn_int_small_lossy_double_equal" - description: "The conversion of the int to double is lossy and the numbers end up being equal" - expr: "dyn(-9223372036854775808) >= -9223372036854775809.0" - value: { bool_value: true } - } - test { - name: "gte_dyn_int_small_lossy_double_greater" - expr: "dyn(-9223372036854775808) >= -9223372036854777857.0" - value: { bool_value: true } - } - test { - name: "gte_dyn_uint_small_int" - expr: "dyn(1u) >= -1" - value: { bool_value: true } - } - test { - name: "gte_dyn_big_uint_int" - expr: "dyn(9223372036854775808u) >= 1" - value: { bool_value: true } - } - test { - name: "gte_dyn_uint_small_double" - expr: "dyn(9223372036854775807u) >= -1.0" - value: { bool_value: true } - } - test { - name: "not_gte_dyn_uint_big_double" - expr: "dyn(18446744073709551615u) >= 18446744073709553665.0" - value: { bool_value: false } - } - test { - name: "gte_dyn_big_double_uint" - expr: "dyn(18446744073709553665.0) >= 18446744073709551615u" - value: { bool_value: true } - } - test { - name: "gte_dyn_big_double_int" - expr: "dyn(9223372036854775808.0) >= 9223372036854775807" - value: { bool_value: true } - } - test { - name: "gte_dyn_small_double_int" - expr: "dyn(-9223372036854775809.0) >= -9223372036854775808" - value: { bool_value: true } - } -} -section { - name: "in_list_literal" - description: "Set membership tests using list literals and the 'in' operator" - test { - name: "elem_not_in_empty_list" - expr: "'empty' in []" - value { bool_value: false } - } - test { - name: "elem_in_list" - expr: "'elem' in ['elem', 'elemA', 'elemB']" - value { bool_value: true } - } - test { - name: "elem_not_in_list" - expr: "'not' in ['elem1', 'elem2', 'elem3']" - value { bool_value: false } - } - test { - name: "elem_in_mixed_type_list" - description: "Set membership tests should succeed if the 'elem' exists in a mixed element type list." - expr: "'elem' in [1, 'elem', 2]" - value { bool_value: true } - } - test { - name: "elem_in_mixed_type_list_cross_type" - description: "Set membership tests should return false due to the introduction of heterogeneous-equality. Set membership via 'in' is equivalent to the macro exists() behavior." - expr: "'elem' in [1u, 'str', 2, b'bytes']" - value: { bool_value: false } - } - test { - name: "nan_not_in_list" - expr: "0.0/0.0 in [0.0/0.0]" - value: { bool_value: false } - } - test { - name: "nested_list_nan_not_in_list" - expr: "[0.0/0.0] in [[0.0/0.0]]" - value: { bool_value: false } - } - test { - name: "nested_map_nan_not_in_list" - expr: "{'a': 0.0/0.0} in [{'a': 0.0/0.0}]" - value: { bool_value: false } - } - test { - name: "neg_zero_in_list_double" - expr: "-0.0 in [0.0]" - value: { bool_value: true } - } - test { - name: "neg_zero_in_list_int" - expr: "-0.0 in [0, 1.0]" - value: { bool_value: true } - } - test { - name: "neg_zero_in_list_uint" - expr: "-0.0 in [0u, 1.0]" - value: { bool_value: true } - } - test { - name: "int_zero_in_list_neg_zero" - expr: "0 in [-0.0, 1]" - value: { bool_value: true } - } - test { - name: "uint_zero_in_list_neg_zero" - expr: "0u in [-0.0, 1u]" - value: { bool_value: true } - } - test { - name: "nested_list_neg_zero_in_list" - expr: "[-0.0] in [[0.0]]" - value: { bool_value: true } - } - test { - name: "nested_map_neg_zero_in_list" - expr: "{'a': -0.0} in [{'a': 0.0}]" - value: { bool_value: true } - } -} -section { - name: "in_map_literal" - description: "Set membership tests using map literals and the 'in' operator" - test { - name: "key_not_in_empty_map" - expr: "'empty' in {}" - value { bool_value: false } - } - test { - name: "key_in_map" - expr: "'key' in {'key':'1', 'other':'2'}" - value { bool_value: true } - } - test { - name: "key_not_in_map" - expr: "'key' in {'lock':1, 'gate':2}" - value { bool_value: false } - } - test { - name: "key_in_mixed_key_type_map" - description: "Map keys are of mixed type, but since the key is present the result is true." - expr: "'key' in {3:3.0, 'key':2u}" - value { bool_value: true } - } - test { - name: "key_in_mixed_key_type_map_cross_type" - expr: "'key' in {1u:'str', 2:b'bytes'}" - value: { bool_value: false } - } - test { - name: "nan_not_in_map" - expr: "dyn(0.0/0.0) in {1: 'a', 2u: 'b'}" - value: { bool_value: false } - } - test { - name: "neg_zero_in_map_int_key" - expr: "dyn(-0.0) in {0: 'a', 1u: 'b'}" - value: { bool_value: true } - } - test { - name: "neg_zero_in_map_uint_key" - expr: "dyn(-0.0) in {0u: 'a', 1: 'b'}" - value: { bool_value: true } - } -} -section { - name: "bound" - description: "Comparing bound variables with literals or other variables" - test { - name: "bytes_gt_left_false" - expr: "x > b'\x00'" - value: { bool_value: false } - type_env: { - name: "x" - ident: { type: { primitive: BYTES } } - } - bindings: { - key: "x" - value: { value: { bytes_value: "\x00" } } - } - } - test { - name: "int_lte_right_true" - expr: "123 <= x" - value: { bool_value: true } - type_env: { - name: "x" - ident: { type: { primitive: INT64 } } - } - bindings: { - key: "x" - value: { value: { int64_value: 124 } } - } - } - test { - name: "bool_lt_right_true" - expr: "false < x" - value: { bool_value: true } - type_env: { - name: "x" - ident: { type: { primitive: BOOL } } - } - bindings: { - key: "x" - value: { value: { bool_value: true } } - } - } - test { - name: "double_ne_left_false" - expr: "x != 9.8" - value: { bool_value: false } - type_env: { - name: "x" - ident: { type: { primitive: DOUBLE } } - } - bindings: { - key: "x" - value: { value: { double_value: 9.8 } } - } - } - test { - name: "map_ne_right_false" - expr: "{'a':'b','c':'d'} != x" - value: { bool_value: false } - type_env: { - name: "x" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: STRING } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - map_value { - entries { - key: { string_value: "c" } - value: { string_value: "d" } - } - entries { - key: { string_value: "a" } - value: { string_value: "b" } - } - } - } - } - } - } - test { - name: "null_eq_left_true" - description: "A comparison _==_ against null only binds if the type is determined to be null or we skip the type checking" - expr: "x == null" - value: { bool_value: true } - type_env: { - name: "x" - ident: { type: { null: NULL_VALUE } } - } - bindings: { - key: "x" - value: { value: { null_value: NULL_VALUE } } - } - } - test { - name: "list_eq_right_false" - expr: "[1, 2] == x" - value: { bool_value: false } - type_env: { - name: "x" - ident: { - type: { - list_type: { - elem_type: { primitive: INT64 } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - list_value { - values: { int64_value: 2 } - values: { int64_value: 1 } - } - } - } - } - } - test { - name: "string_gte_right_true" - expr: "'abcd' >= x" - value: { bool_value: true } - type_env: { - name: "x" - ident: { - type: { primitive: STRING } - } - } - bindings: { - key: "x" - value: { value: { string_value: "abc" } } - } - } - test { - name: "uint_eq_right_false" - expr: "999u == x" - value: { bool_value: false } - type_env: { - name: "x" - ident: { - type: { primitive: UINT64 } - } - } - bindings: { - key: "x" - value: { value: { uint64_value: 1000 } } - } - } - test { - name: "null_lt_right_no_such_overload" - description: "There is no _<_ operation for null, even if both operands are null" - expr: "null < x" - eval_error: { - errors: { message: "no such overload" } - } - disable_check: true - bindings: { - key: "x" - value: { value: { null_value: NULL_VALUE } } - } - } - test { - name: "double_nan_eq_self_false" - expr: "x == x" - value: { bool_value: false } - type_env: { - name: "x" - ident: { type: { primitive: DOUBLE } } - } - bindings: { - key: "x" - value: { value: { double_value: nan } } - } - } - test { - name: "double_nan_ne_self_true" - expr: "x != x" - value: { bool_value: true } - type_env: { - name: "x" - ident: { type: { primitive: DOUBLE } } - } - bindings: { - key: "x" - value: { value: { double_value: nan } } - } - } - test { - name: "list_of_bound_nan_eq_false" - expr: "[x] == [x]" - value: { bool_value: false } - type_env: { - name: "x" - ident: { type: { primitive: DOUBLE } } - } - bindings: { - key: "x" - value: { value: { double_value: nan } } - } - } - test { - name: "list_of_bound_nan_ne_true" - expr: "[x] != [x]" - value: { bool_value: true } - type_env: { - name: "x" - ident: { type: { primitive: DOUBLE } } - } - bindings: { - key: "x" - value: { value: { double_value: nan } } - } - } - test { - name: "bound_list_nan_eq_self_false" - expr: "x == x" - value: { bool_value: false } - type_env: { - name: "x" - ident: { - type: { - list_type: { - elem_type: { primitive: DOUBLE } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - list_value { - values: { double_value: nan } - } - } - } - } - } - test { - name: "bound_list_nan_ne_self_true" - expr: "x != x" - value: { bool_value: true } - type_env: { - name: "x" - ident: { - type: { - list_type: { - elem_type: { primitive: DOUBLE } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - list_value { - values: { double_value: nan } - } - } - } - } - } - test { - name: "bound_map_nan_eq_self_false" - expr: "x == x" - value: { bool_value: false } - type_env: { - name: "x" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: DOUBLE } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - map_value { - entries { - key: { string_value: "a" } - value: { double_value: nan } - } - } - } - } - } - } - test { - name: "bound_map_nan_ne_self_true" - expr: "x != x" - value: { bool_value: true } - type_env: { - name: "x" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: DOUBLE } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - map_value { - entries { - key: { string_value: "a" } - value: { double_value: nan } - } - } - } - } - } - } -} diff --git a/tests/simple/testdata/conversions.textproto b/tests/simple/testdata/conversions.textproto deleted file mode 100644 index 0e4d4b24..00000000 --- a/tests/simple/testdata/conversions.textproto +++ /dev/null @@ -1,622 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "conversions" -description: "Tests for type conversions." -section { - name: "bytes" - description: "Conversions to bytes." - test { - name: "string_empty" - expr: "bytes('')" - value: { bytes_value: "" } - } - test { - name: "string" - expr: "bytes('abc')" - value: { bytes_value: "abc" } - } - test { - name: "string_unicode" - expr: "bytes('ÿ')" - value: { bytes_value: "\303\277" } - } - test { - name: "string_unicode_vs_literal" - expr: "bytes('\\377') == b'\\377'" - value: { bool_value: false } - } -} -section { - name: "double" - description: "Conversions to double." - test { - name: "int_zero" - expr: "double(0)" - value: { double_value: 0.0 } - } - test { - name: "int_pos" - expr: "double(1000000000000)" - value: { double_value: 1e12 } - } - test { - name: "int_neg" - expr: "double(-1000000000000000)" - value: { double_value: -1e15 } - } - test { - name: "int_min_exact" - description: "Smallest contiguous representable int (-2^53)." - expr: "double(-9007199254740992)" - value { double_value: -9.007199254740992e15 } - } - test { - name: "int_max_exact" - description: "Largest contiguous representable int (2^53)." - expr: "double(9007199254740992)" - value { double_value: 9.007199254740992e15 } - } - test { - name: "int_range" - description: "Largest signed 64-bit. Rounds to nearest double." - expr: "double(9223372036854775807)" - value: { double_value: 9.223372036854775807e18 } - } - test { - name: "uint_zero" - expr: "double(0u)" - value: { double_value: 0.0 } - } - test { - name: "uint_pos" - expr: "double(123u)" - value: { double_value: 123.0 } - } - test { - name: "uint_max_exact" - description: "Largest contiguous representable int (2^53)." - expr: "double(9007199254740992u)" - value { double_value: 9.007199254740992e15 } - } - test { - name: "uint_range" - description: "Largest unsigned 64-bit." - expr: "double(18446744073709551615u)" - value: { double_value: 1.8446744073709551615e19 } - } - test { - name: "string_zero" - expr: "double('0')" - value: { double_value: 0.0 } - } - test { - name: "string_zero_dec" - expr: "double('0.0')" - value: { double_value: 0.0 } - } - test { - name: "string_neg_zero" - expr: "double('-0.0')" - value: { double_value: -0.0 } - } - test { - name: "string_no_dec" - expr: "double('123')" - value: { double_value: 123.0 } - } - test { - name: "string_pos" - expr: "double('123.456')" - value: { double_value: 123.456 } - } - test { - name: "string_neg" - expr: "double('-987.654')" - value: { double_value: -987.654 } - } - test { - name: "string_exp_pos_pos" - expr: "double('6.02214e23')" - value: { double_value: 6.02214e23 } - } - test { - name: "string_exp_pos_neg" - expr: "double('1.38e-23')" - value: { double_value: 1.38e-23 } - } - test { - name: "string_exp_neg_pos" - expr: "double('-84.32e7')" - value: { double_value: -8.432e8 } - } - test { - name: "string_exp_neg_neg" - expr: "double('-5.43e-21')" - value: { double_value: -5.43e-21 } - } -} -section { - name: "dyn" - description: "Tests for dyn annotation." - test { - name: "dyn_heterogeneous_list" - description: "No need to disable type checking." - expr: "type(dyn([1, 'one']))" - value: { type_value: "list" } - } -} -section { - name: "int" - description: "Conversions to int." - test { - name: "uint" - expr: "int(42u)" - value: { int64_value: 42 } - } - test { - name: "uint_zero" - expr: "int(0u)" - value: { int64_value: 0 } - } - test { - name: "uint_max_exact" - expr: "int(9223372036854775807u)" - value { int64_value: 9223372036854775807 } - } - test { - name: "uint_range" - expr: "int(18446744073709551615u)" - eval_error { - errors { message: "range error" } - } - } - test { - name: "double_round_neg" - expr: "int(-123.456)" - value: { int64_value: -123 } - } - test { - name: "double_truncate" - expr: "int(1.9)" - value: { int64_value: 1 } - } - test { - name: "double_truncate_neg" - expr: "int(-7.9)" - value: { int64_value: -7 } - } - test { - name: "double_half_pos" - expr: "int(11.5)" - value: { int64_value: 11 } - } - test { - name: "double_half_neg" - expr: "int(-3.5)" - value: { int64_value: -3 } - } - test { - name: "double_big_exact" - description: "Beyond exact range (2^53), but no loss of precision (2^55)." - expr: "int(double(36028797018963968))" - value { int64_value: 36028797018963968 } - } - test { - name: "double_big_precision" - description: "Beyond exact range (2^53), but loses precision (2^55 + 1)." - expr: "int(double(36028797018963969))" - value { int64_value: 36028797018963968 } - } - test { - name: "double_int_max_range" - description: "The double(2^63-1) cast produces a floating point value outside the int range" - expr: "int(9223372036854775807.0)" - eval_error { - errors: { message: "range" } - } - } - test { - name: "double_int_min_range" - description: "The double(-2^63) cast produces a floating point value outside the int range" - expr: "int(-9223372036854775808.0)" - eval_error { - errors: { message: "range" } - } - } - test { - name: "double_range" - expr: "int(1e99)" - eval_error { - errors: { message: "range" } - } - } - test { - name: "string" - expr: "int('987')" - value: { int64_value: 987 } - } - test { - name: "timestamp" - expr: "int(timestamp('2004-09-16T23:59:59Z'))" - value: { int64_value: 1095379199 } - } -} -section { - name: "string" - description: "Conversions to string." - test { - name: "int" - expr: "string(123)" - value: { string_value: "123" } - } - test { - name: "int_neg" - expr: "string(-456)" - value: { string_value: "-456" } - } - test { - name: "uint" - expr: "string(9876u)" - value: { string_value: "9876" } - } - test { - name: "double" - expr: "string(123.456)" - value: { string_value: "123.456" } - } - test { - name: "double_hard" - expr: "string(-4.5e-3)" - value: { string_value: "-0.0045" } - } - test { - name: "bytes" - expr: "string(b'abc')" - value: { string_value: "abc" } - } - test { - name: "bytes_unicode" - expr: "string(b'\\303\\277')" - value: { string_value: "ÿ" } - } - test { - name: "bytes_invalid" - expr: "string(b'\\000\\xff')" - eval_error { - errors { message: "invalid UTF-8" } - } - } -} -section { - name: "type" - description: "Type reflection tests." - test { - name: "bool" - expr: "type(true)" - value: { type_value: "bool" } - } - test { - name: "bool_denotation" - expr: "bool" - value: { type_value: "bool" } - } - test { - name: "dyn_no_denotation" - expr: "dyn" - disable_check: true - eval_error { - errors { message: "unknown variable" } - } - } - test { - name: "int" - expr: "type(0)" - value: { type_value: "int" } - } - test { - name: "int_denotation" - expr: "int" - value: { type_value: "int" } - } - test { - name: "eq_same" - expr: "type(true) == type(false)" - value: { bool_value: true } - } - test { - name: "uint" - expr: "type(64u)" - value: { type_value: "uint" } - } - test { - name: "uint_denotation" - expr: "uint" - value: { type_value: "uint" } - } - test { - name: "double" - expr: "type(3.14)" - value: { type_value: "double" } - } - test { - name: "double_denotation" - expr: "double" - value: { type_value: "double" } - } - test { - name: "null_type" - expr: "type(null)" - value: { type_value: "null_type" } - } - test { - name: "null_type_denotation" - expr: "null_type" - value: { type_value: "null_type" } - } - test { - name: "string" - expr: "type('foo')" - value: { type_value: "string" } - } - test { - name: "string_denotation" - expr: "string" - value: { type_value: "string" } - } - test { - name: "bytes" - expr: "type(b'\\xff')" - value: { type_value: "bytes" } - } - test { - name: "bytes_denotation" - expr: "bytes" - value: { type_value: "bytes" } - } - test { - name: "list" - expr: "type([1, 2, 3])" - value: { type_value: "list" } - } - test { - name: "list_denotation" - expr: "list" - value: { type_value: "list" } - } - test { - name: "lists_monomorphic" - expr: "type([1, 2, 3]) == type(['one', 'two', 'three'])" - value: { bool_value: true } - } - test { - name: "map" - expr: "type({4: 16})" - value: { type_value: "map" } - } - test { - name: "map_denotation" - expr: "map" - value: { type_value: "map" } - } - test { - name: "map_monomorphic" - expr: "type({'one': 1}) == type({1: 'one'})" - value: { bool_value: true } - } - test { - name: "eq_diff" - expr: "type(7) == type(7u)" - value: { bool_value: false } - } - test { - name: "neq_same" - expr: "type(0.0) != type(-0.0)" - value: { bool_value: false } - } - test { - name: "neq_diff" - expr: "type(0.0) != type(0)" - value: { bool_value: true } - } - test { - name: "meta" - expr: "type(type(7)) == type(type(7u))" - value: { bool_value: true } - } - test { - name: "type" - expr: "type(int)" - value: { type_value: "type" } - } - test { - name: "type_denotation" - expr: "type" - value: { type_value: "type" } - } - test { - name: "type_type" - expr: "type(type)" - value: { type_value: "type" } - } -} -section { - name: "uint" - description: "Conversions to uint." - test { - name: "int" - expr: "uint(1729)" - value: { uint64_value: 1729 } - } - test { - name: "int_max" - expr: "uint(9223372036854775807)" - value { uint64_value: 9223372036854775807 } - } - test { - name: "int_neg" - expr: "uint(-1)" - eval_error { - errors { message: "range" } - } - } - test { - name: "double" - expr: "uint(3.14159265)" - value: { uint64_value: 3 } - } - test { - name: "double_truncate" - expr: "uint(1.9)" - value: { uint64_value: 1 } - } - test { - name: "double_half" - expr: "uint(25.5)" - value: { uint64_value: 25 } - } - test { - name: "double_big_exact" - description: "Beyond exact range (2^53), but no loss of precision (2^55)." - expr: "uint(double(36028797018963968u))" - value { uint64_value: 36028797018963968 } - } - test { - name: "double_big_precision" - description: "Beyond exact range (2^53), but loses precision (2^55 + 1)." - expr: "uint(double(36028797018963969u))" - value { uint64_value: 36028797018963968 } - } - test { - name: "double_uint_max_range" - description: "The exact conversion of uint max as a double does not round trip." - expr: "int(18446744073709551615.0)" - eval_error { - errors: { message: "range" } - } - } - test { - name: "double_range_beyond_uint" - expr: "uint(6.022e23)" - eval_error { - errors { message: "range" } - } - } - test { - name: "string" - expr: "uint('300')" - value: { uint64_value: 300 } - } -} -section { - name: "bool" - description: "Conversions to bool" - test { - name: "string_1" - expr: "bool('1')" - value: { bool_value: true } - } - test { - name: "string_t" - expr: "bool('t')" - value: { bool_value: true } - } - test { - name: "string_true_lowercase" - expr: "bool('true')" - value: { bool_value: true } - } - test { - name: "string_true_uppercase" - expr: "bool('TRUE')" - value: { bool_value: true } - } - test { - name: "string_true_pascalcase" - expr: "bool('True')" - value: { bool_value: true } - } - test { - name: "string_0" - expr: "bool('0')" - value: { bool_value: false } - } - test { - name: "string_f" - expr: "bool('f')" - value: { bool_value: false } - } - test { - name: "string_false_lowercase" - expr: "bool('false')" - value: { bool_value: false } - } - test { - name: "string_false_uppercase" - expr: "bool('FALSE')" - value: { bool_value: false } - } - test { - name: "string_false_pascalcase" - expr: "bool('False')" - value: { bool_value: false } - } - test { - name: "string_true_badcase" - expr: "bool('TrUe')" - eval_error { - errors { message: "Type conversion error" } - } - } - test { - name: "string_false_badcase" - expr: "bool('FaLsE')" - eval_error { - errors { message: "Type conversion error" } - } - } -} -section { - name: "identity" - description: "Identity functions" - test { - name: "bool" - expr: "bool(true)" - value: { bool_value: true } - } - test { - name: "int" - expr: "int(1)" - value: { int64_value: 1 } - } - test { - name: "uint" - expr: "uint(1u)" - value: { uint64_value: 1 } - } - test { - name: "double" - expr: "double(5.5)" - value: { double_value: 5.5 } - } - test { - name: "string" - expr: "string('hello')" - value: { string_value: "hello" } - } - test { - name: "bytes" - expr: "bytes(b'abc')" - value: { bytes_value: "abc" } - } - test { - name: "duration" - expr: "duration(duration('100s')) == duration('100s')" - value: { bool_value: true } - } - test { - name: "timestamp" - expr: "timestamp(timestamp(1000000000)) == timestamp(1000000000)" - value: { bool_value: true } - } -} diff --git a/tests/simple/testdata/dynamic.textproto b/tests/simple/testdata/dynamic.textproto deleted file mode 100644 index 75346a4a..00000000 --- a/tests/simple/testdata/dynamic.textproto +++ /dev/null @@ -1,2289 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "dynamic" -description: "Tests for 'dynamic' proto behavior, including JSON, wrapper, and Any messages." -section { - name: "int32" - description: "Tests for int32 conversion." - test { - name: "literal" - expr: "google.protobuf.Int32Value{value: -123}" - value { int64_value: -123 } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.Int32Value{value: -123}.value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_zero" - expr: "google.protobuf.Int32Value{}" - value { int64_value: 0 } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.Int32Value" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Int32Value] { value: 2000000 } - } - } - } - } - value { int64_value: 2000000 } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int32_wrapper: 432}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int32_wrapper { value: 432 } } - } - } - } - test { - name: "field_assign_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int32_wrapper: 0}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int32_wrapper {} } - } - } - } - test { - name: "field_assign_proto2_max" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int32_wrapper: 2147483647}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int32_wrapper { value: 2147483647 } } - } - } - } - test { - name: "field_assign_proto2_min" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int32_wrapper: -2147483648}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int32_wrapper { value: -2147483648 } } - } - } - } - test { - name: "field_assign_proto2_range" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int32_wrapper: 12345678900}" - eval_error { - errors { message: "range error" } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int32_wrapper: 642}.single_int32_wrapper" - value { int64_value: 642 } - } - test { - name: "field_read_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int32_wrapper: 0}.single_int32_wrapper" - value { int64_value: 0 } - } - test { - name: "field_read_proto2_unset" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_int32_wrapper" - value { null_value: NULL_VALUE } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32_wrapper: -975}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int32_wrapper { value: -975 } } - } - } - } - test { - name: "field_assign_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32_wrapper: 0}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int32_wrapper {} } - } - } - } - test { - name: "field_assign_proto3_max" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32_wrapper: 2147483647}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int32_wrapper { value: 2147483647 } } - } - } - } - test { - name: "field_assign_proto3_min" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32_wrapper: -2147483648}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int32_wrapper { value: -2147483648 } } - } - } - } - test { - name: "field_assign_proto3_range" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32_wrapper: -998877665544332211}" - eval_error { - errors { message: "range error" } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32_wrapper: 642}.single_int32_wrapper" - value { int64_value: 642 } - } - test { - name: "field_read_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32_wrapper: 0}.single_int32_wrapper" - value { int64_value: 0 } - } - test { - name: "field_read_proto3_unset" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_int32_wrapper" - value { null_value: NULL_VALUE } - } -} -section { - name: "int64" - description: "Tests for int64 conversion." - test { - name: "literal" - expr: "google.protobuf.Int64Value{value: -123}" - value { int64_value: -123 } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.Int64Value{value: -123}.value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_zero" - expr: "google.protobuf.Int64Value{}" - value { int64_value: 0 } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.Int64Value" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Int64Value] { value: 2000000 } - } - } - } - } - value { int64_value: 2000000 } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int64_wrapper: 432}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int64_wrapper { value: 432 } } - } - } - } - test { - name: "field_assign_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int64_wrapper: 0}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int64_wrapper {} } - } - } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64_wrapper: -975}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int64_wrapper { value: -975 } } - } - } - } - test { - name: "field_assign_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64_wrapper: 0}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int64_wrapper {} } - } - } - } -} -section { - name: "uint32" - description: "Tests for uint32 conversion." - test { - name: "literal" - expr: "google.protobuf.UInt32Value{value: 123u}" - value { uint64_value: 123 } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.UInt32Value{value: 123u}.value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_zero" - expr: "google.protobuf.UInt32Value{}" - value { uint64_value: 0 } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.UInt32Value" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.UInt32Value] { value: 2000000 } - } - } - } - } - value { uint64_value: 2000000 } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint32_wrapper: 432u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_uint32_wrapper { value: 432 } } - } - } - } - test { - name: "field_assign_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint32_wrapper: 0u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_uint32_wrapper {} } - } - } - } - test { - name: "field_assign_proto2_max" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint32_wrapper: 4294967295u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_uint32_wrapper { value: 4294967295 } } - } - } - } - test { - name: "field_assign_proto2_range" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint32_wrapper: 6111222333u}" - eval_error { - errors { message: "range error" } - } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint32_wrapper: 975u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_uint32_wrapper { value: 975 } } - } - } - } - test { - name: "field_assign_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint32_wrapper: 0u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_uint32_wrapper {} } - } - } - } - test { - name: "field_assign_proto3_max" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint32_wrapper: 4294967295u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_uint32_wrapper { value: 4294967295 } } - } - } - } - test { - name: "field_assign_proto3_range" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint32_wrapper: 6111222333u}" - eval_error { - errors { message: "range error" } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint32_wrapper: 258u}.single_uint32_wrapper" - value { uint64_value: 258 } - } - test { - name: "field_read_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint32_wrapper: 0u}.single_uint32_wrapper" - value { uint64_value: 0 } - } - test { - name: "field_read_proto2_unset" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_uint32_wrapper" - value { null_value: NULL_VALUE } - } -} -section { - name: "uint64" - description: "Tests for uint64 conversion." - test { - name: "literal" - expr: "google.protobuf.UInt64Value{value: 123u}" - value { uint64_value: 123 } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.UInt64Value{value: 123u}.value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_zero" - expr: "google.protobuf.UInt64Value{}" - value { uint64_value: 0 } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.UInt64Value" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.UInt64Value] { value: 2000000 } - } - } - } - } - value { uint64_value: 2000000 } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint64_wrapper: 432u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_uint64_wrapper { value: 432 } } - } - } - } - test { - name: "field_assign_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint64_wrapper: 0u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_uint64_wrapper {} } - } - } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint64_wrapper: 975u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_uint64_wrapper { value: 975 } } - } - } - } - test { - name: "field_assign_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint64_wrapper: 0u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_uint64_wrapper {} } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint64_wrapper: 5123123123u}.single_uint64_wrapper" - value { uint64_value: 5123123123 } - } - test { - name: "field_read_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint64_wrapper: 0u}.single_uint64_wrapper" - value { uint64_value: 0 } - } - test { - name: "field_read_proto2_unset" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_uint64_wrapper" - value { null_value: NULL_VALUE } - } -} -section { - name: "float" - description: "Tests for float conversion." - test { - name: "literal" - expr: "google.protobuf.FloatValue{value: -1.5e3}" - value { double_value: -1500.0 } - } - test { - name: "literal_not_double" - description: "Use a number with no exact representation to make sure we actually narrow to a float." - expr: "google.protobuf.FloatValue{value: 1.333} == 1.333" - value { bool_value: false } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.FloatValue{value: 3.1416}.value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_zero" - expr: "google.protobuf.FloatValue{}" - value { double_value: 0.0 } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.FloatValue" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.FloatValue] { value: -1.25e6 } - } - } - } - } - value { double_value: -1250000.0 } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_float_wrapper: 86.75}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_float_wrapper { value: 86.75 } } - } - } - } - test { - name: "field_assign_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_float_wrapper: 0.0}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_float_wrapper {} } - } - } - } - test { - name: "field_assign_proto2_subnorm" - description: "Subnormal single floats range from ~1e-38 to ~1e-45." - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_float_wrapper: 1e-40}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_float_wrapper { value: 1e-40 } } - } - } - } - test { - name: "field_assign_proto2_round_to_zero" - description: "Subnormal single floats range from ~1e-38 to ~1e-45." - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_float_wrapper: 1e-50}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_float_wrapper {} } - } - } - } - test { - name: "field_assign_proto2_range" - description: "Single float max is about 3.4e38" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_float_wrapper: 1.4e55}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_float_wrapper { value: inf } } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_float_wrapper: -12.375}.single_float_wrapper" - value { double_value: -12.375 } - } - test { - name: "field_read_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_float_wrapper: 0.0}.single_float_wrapper" - value { double_value: 0.0 } - } - test { - name: "field_read_proto2_unset" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_float_wrapper" - value { null_value: NULL_VALUE } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_float_wrapper: -9.75}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_float_wrapper { value: -9.75 } } - } - } - } - test { - name: "field_assign_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_float_wrapper: 0.0}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_float_wrapper {} } - } - } - } - test { - name: "field_assign_proto3_subnorm" - description: "Subnormal single floats range from ~1e-38 to ~1e-45." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_float_wrapper: 1e-40}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_float_wrapper { value: 1e-40 } } - } - } - } - test { - name: "field_assign_proto3_round_to_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_float_wrapper: -9.9e-100}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_float_wrapper { value: -0 } } - } - } - } - test { - name: "field_assign_proto3_range" - description: "Single float min is about -3.4e38" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_float_wrapper: -9.9e100}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_float_wrapper { value: -inf } } - } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_float_wrapper: 64.25}.single_float_wrapper" - value { double_value: 64.25 } - } - test { - name: "field_read_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_float_wrapper: 0.0}.single_float_wrapper" - value { double_value: 0.0 } - } - test { - name: "field_read_proto3_unset" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_float_wrapper" - value { null_value: NULL_VALUE } - } -} -section { - name: "double" - description: "Tests for double conversion." - test { - name: "literal" - expr: "google.protobuf.DoubleValue{value: -1.5e3}" - value { double_value: -1500.0 } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.DoubleValue{value: 3.1416}.value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_zero" - expr: "google.protobuf.DoubleValue{}" - value { double_value: 0.0 } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.DoubleValue" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.DoubleValue] { value: -1.25e6 } - } - } - } - } - value { double_value: -1250000.0 } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_double_wrapper: 86.75}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_double_wrapper { value: 86.75 } } - } - } - } - test { - name: "field_assign_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_double_wrapper: 0.0}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_double_wrapper {} } - } - } - } - test { - name: "field_assign_proto2_range" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_double_wrapper: 1.4e55}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_double_wrapper { value: 1.4e55 } } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_double_wrapper: -12.375}.single_double_wrapper" - value { double_value: -12.375 } - } - test { - name: "field_read_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int32_wrapper: 0}.single_int32_wrapper" - value { int64_value: 0 } - } - test { - name: "field_read_proto2_unset" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_double_wrapper" - value { null_value: NULL_VALUE } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_double_wrapper: -9.75}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_double_wrapper { value: -9.75 } } - } - } - } - test { - name: "field_assign_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_double_wrapper: 0.0}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_double_wrapper {} } - } - } - } - test { - name: "field_assign_proto3_range" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_double_wrapper: -9.9e100}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_double_wrapper { value: -9.9e100 } } - } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_double_wrapper: 64.25}.single_double_wrapper" - value { double_value: 64.25 } - } - test { - name: "field_read_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_double_wrapper: 0.0}.single_double_wrapper" - value { double_value: 0.0 } - } - test { - name: "field_read_proto3_unset" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_double_wrapper" - value { null_value: NULL_VALUE } - } -} -section { - name: "bool" - description: "Tests for bool conversion." - test { - name: "literal" - expr: "google.protobuf.BoolValue{value: true}" - value { bool_value: true } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.BoolValue{value: true}.value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_empty" - expr: "google.protobuf.BoolValue{}" - value { bool_value: false } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.BoolValue" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.BoolValue] { value: true } - } - } - } - } - value { bool_value: true } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_bool_wrapper: true}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_bool_wrapper { value: true } } - } - } - } - test { - name: "field_assign_proto2_false" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_bool_wrapper: false}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_bool_wrapper {} } - } - } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bool_wrapper: true}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_bool_wrapper { value: true } } - } - } - } - test { - name: "field_assign_proto3_false" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bool_wrapper: false}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_bool_wrapper {} } - } - } - } -} -section { - name: "string" - description: "Tests for string conversion." - test { - name: "literal" - expr: "google.protobuf.StringValue{value: 'foo'}" - value { string_value: "foo" } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.StringValue{value: 'foo'}.value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_empty" - expr: "google.protobuf.StringValue{}" - value { string_value: "" } - } - test { - name: "literal_unicode" - expr: "google.protobuf.StringValue{value: 'flambé'}" - value { string_value: "flambé" } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.StringValue" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.StringValue] { value: "bar" } - } - } - } - } - value { string_value: "bar" } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_string_wrapper: 'baz'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_string_wrapper { value: "baz" } } - } - } - } - test { - name: "field_assign_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_string_wrapper: ''}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_string_wrapper {} } - } - } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_string_wrapper: 'bletch'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_string_wrapper { value: "bletch" } } - } - } - } - test { - name: "field_assign_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_string_wrapper: ''}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_string_wrapper {} } - } - } - } -} -section { - name: "bytes" - description: "Tests for bytes conversion." - test { - name: "literal" - expr: "google.protobuf.BytesValue{value: b'foo\\123'}" - value { bytes_value: "foo\123" } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.BytesValue{value: b'foo'}.value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_empty" - expr: "google.protobuf.BytesValue{}" - value { bytes_value: "" } - } - test { - name: "literal_unicode" - expr: "google.protobuf.BytesValue{value: b'flambé'}" - value { bytes_value: "flambé" } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.BytesValue" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.BytesValue] { value: "bar" } - } - } - } - } - value { bytes_value: "bar" } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_bytes_wrapper: b'baz'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_bytes_wrapper { value: "baz" } } - } - } - } - test { - name: "field_assign_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_bytes_wrapper: b''}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_bytes_wrapper {} } - } - } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bytes_wrapper: b'bletch'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_bytes_wrapper { value: "bletch" } } - } - } - } - test { - name: "field_assign_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bytes_wrapper: b''}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_bytes_wrapper {} } - } - } - } -} -section { - name: "list" - description: "Tests for list conversion." - test { - name: "literal" - expr: "google.protobuf.ListValue{values: [3.0, 'foo', null]}" - value { - list_value { - values { double_value: 3.0 } - values { string_value: "foo" } - values { null_value: NULL_VALUE } - } - } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.ListValue{values: [3.0, 'foo', null]}.values" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_empty" - expr: "google.protobuf.ListValue{values: []}" - value { list_value {} } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.ListValue" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.ListValue] { - values { string_value: "bar" } - values { - list_value { - values { string_value: "a" } - values { string_value: "b" } - } - } - } - } - } - } - } - value { - list_value { - values { string_value: "bar" } - values { - list_value { - values { string_value: "a" } - values { string_value: "b" } - } - } - } - } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{list_value: [1.0, 'one']}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - list_value { - values: { number_value: 1.0 } - values: { string_value: "one" } - } - } - } - } - } - test { - name: "field_assign_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{list_value: []}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { list_value {} } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{list_value: [1.0, 'one']}.list_value" - value { - list_value { - values { double_value: 1.0 } - values { string_value: "one" } - } - } - } - test { - name: "field_read_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{list_value: []}.list_value" - value { list_value {} } - } - test { - name: "field_read_proto2_unset" - description: "Not a wrapper type, so doesn't convert to null." - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.list_value" - value { list_value {} } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{list_value: [1.0, 'one']}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - list_value { - values: { number_value: 1.0 } - values: { string_value: "one" } - } - } - } - } - } - test { - name: "field_assign_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{list_value: []}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { list_value {} } - } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{list_value: [1.0, 'one']}.list_value" - value { - list_value { - values { double_value: 1.0 } - values { string_value: "one" } - } - } - } - test { - name: "field_read_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{list_value: []}.list_value" - value { list_value {} } - } - test { - name: "field_read_proto3_unset" - description: "Not a wrapper type, so doesn't convert to null." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.list_value" - value { list_value {} } - } -} -section { - name: "struct" - description: "Tests for struct conversion." - test { - name: "literal" - expr: "google.protobuf.Struct{fields: {'uno': 1.0, 'dos': 2.0}}" - value { - map_value { - entries { - key { string_value: "uno" } - value { double_value: 1.0 } - } - entries { - key { string_value: "dos" } - value { double_value: 2.0 } - } - } - } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.Struct{fields: {'uno': 1.0, 'dos': 2.0}}.fields" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_empty" - expr: "google.protobuf.Struct{fields: {}}" - value { map_value {} } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.Struct" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Struct] { - fields { - key: "first" - value { string_value: "Abraham" } - } - fields { - key: "last" - value { string_value: "Lincoln" } - } - } - } - } - } - } - value { - map_value { - entries { - key { string_value: "first" } - value { string_value: "Abraham" } - } - entries { - key { string_value: "last" } - value { string_value: "Lincoln" } - } - } - } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_struct: {'un': 1.0, 'deux': 2.0}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_struct { - fields { - key: "un" - value { number_value: 1.0 } - } - fields { - key: "deux" - value { number_value: 2.0 } - } - } - } - } - } - } - test { - name: "field_assign_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_struct: {}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_struct {} } - } - } - } - test { - name: "field_assign_proto2_bad" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_struct: {1: 'uno'}}" - disable_check: true - eval_error { - errors { message: "bad key type" } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_struct: {'one': 1.0}}.single_struct" - value { - map_value { - entries { - key { string_value: "one" } - value { double_value: 1.0 } - } - } - } - } - test { - name: "field_read_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_struct: {}}.single_struct" - value { map_value {} } - } - test { - name: "field_read_proto2_unset" - description: "Not a wrapper type, so doesn't convert to null." - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_struct" - value { map_value {} } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_struct: {'un': 1.0, 'deux': 2.0}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_struct { - fields { - key: "un" - value { number_value: 1.0 } - } - fields { - key: "deux" - value { number_value: 2.0 } - } - } - } - } - } - } - test { - name: "field_assign_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_struct: {}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_struct {} } - } - } - } - test { - name: "field_assign_proto3_bad" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_struct: {1: 'uno'}}" - disable_check: true - eval_error { - errors { message: "bad key type" } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_struct: {'one': 1.0}}.single_struct" - value { - map_value { - entries { - key { string_value: "one" } - value { double_value: 1.0 } - } - } - } - } - test { - name: "field_read_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_struct: {}}.single_struct" - value { map_value {} } - } - test { - name: "field_read_proto3_unset" - description: "Not a wrapper type, so doesn't convert to null." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_struct" - value { map_value {} } - } -} -section { - name: "value_null" - description: "Tests for null conversions." - test { - name: "literal" - container: "google.protobuf" - expr: "Value{null_value: NullValue.NULL_VALUE}" - value { null_value: NULL_VALUE } - } - test { - name: "literal_no_field_access" - container: "google.protobuf" - expr: "Value{null_value: NullValue.NULL_VALUE}.null_value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_unset" - expr: "google.protobuf.Value{}" - value { null_value: NULL_VALUE } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.Value" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Value] { null_value: NULL_VALUE } - } - } - } - } - value { null_value: NULL_VALUE } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: null}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_value { null_value: NULL_VALUE } } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: null}.single_value" - value { null_value: NULL_VALUE } - } - test { - name: "field_read_proto2_unset" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_value" - value { null_value: NULL_VALUE } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: null}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_value { null_value: NULL_VALUE } } - } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: null}.single_value" - value { null_value: NULL_VALUE } - } - test { - name: "field_read_proto3_unset" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_value" - value { null_value: NULL_VALUE } - } -} -section { - name: "value_number" - description: "Tests for number conversions in Value." - test { - name: "literal" - expr: "google.protobuf.Value{number_value: 12.5}" - value { double_value: 12.5 } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.Value{number_value: 12.5}.number_value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_zero" - expr: "google.protobuf.Value{number_value: 0.0}" - value { double_value: 0.0 } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.Value" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Value] { number_value: -26.375 } - } - } - } - } - value { double_value: -26.375 } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: 7e23}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_value { number_value: 7e23 } } - } - } - } - test { - name: "field_assign_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: 0.0}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_value { number_value: 0.0 } } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: 7e23}.single_value" - value { double_value: 7e23 } - } - test { - name: "field_read_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: 0.0}.single_value" - value { double_value: 0.0 } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: 7e23}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_value { number_value: 7e23 } } - } - } - } - test { - name: "field_assign_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: 0.0}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_value { number_value: 0.0 } } - } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: 7e23}.single_value" - value { double_value: 7e23 } - } - test { - name: "field_read_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: 0.0}.single_value" - value { double_value: 0.0 } - } -} -section { - name: "value_string" - description: "Tests for string conversions in Value." - test { - name: "literal" - expr: "google.protobuf.Value{string_value: 'foo'}" - value { string_value: "foo" } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.Value{string_value: 'foo'}.string_value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_empty" - expr: "google.protobuf.Value{string_value: ''}" - value { string_value: "" } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.Value" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Value] { string_value: "bar" } - } - } - } - } - value { string_value: "bar" } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: 'baz'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_value { string_value: "baz" } } - } - } - } - test { - name: "field_assign_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: ''}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_value { string_value: "" } } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: 'bletch'}.single_value" - value { string_value: "bletch" } - } - test { - name: "field_read_proto2_zero" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: ''}.single_value" - value { string_value: "" } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: 'baz'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_value { string_value: "baz" } } - } - } - } - test { - name: "field_assign_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: ''}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_value { string_value: "" } } - } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: 'bletch'}.single_value" - value { string_value: "bletch" } - } - test { - name: "field_read_proto3_zero" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: ''}.single_value" - value { string_value: "" } - } -} -section { - name: "value_bool" - description: "Tests for boolean conversions in Value." - test { - name: "literal" - expr: "google.protobuf.Value{bool_value: true}" - value { bool_value: true } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.Value{bool_value: true}.bool_value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_false" - expr: "google.protobuf.Value{bool_value: false}" - value { bool_value: false } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.Value" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Value] { bool_value: true } - } - } - } - } - value { bool_value: true } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: true}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_value { bool_value: true } } - } - } - } - test { - name: "field_assign_proto2_false" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: false}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_value { bool_value: false } } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: true}.single_value" - value { bool_value: true } - } - test { - name: "field_read_proto2_false" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: false}.single_value" - value { bool_value: false } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: true}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_value { bool_value: true } } - } - } - } - test { - name: "field_assign_proto3_false" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: false}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_value { bool_value: false } } - } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: true}.single_value" - value { bool_value: true } - } - test { - name: "field_read_proto3_false" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: false}.single_value" - value { bool_value: false } - } -} -section { - name: "value_struct" - description: "Tests for struct conversions in Value." - test { - name: "literal" - expr: "google.protobuf.Value{struct_value: {'a': 1.0, 'b': 'two'}}" - value { - map_value { - entries { - key { string_value: "a" } - value { double_value: 1.0 } - } - entries { - key { string_value: "b" } - value { string_value: "two" } - } - } - } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.Value{struct_value: {'a': 1.0, 'b': 'two'}}.struct_value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_empty" - expr: "google.protobuf.Value{struct_value: {}}" - value { map_value: {} } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.Value" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Value] { - struct_value { - fields { - key: "x" - value { null_value: NULL_VALUE } - } - fields { - key: "y" - value { bool_value: false } - } - } - } - } - } - } - } - value { - map_value { - entries { - key { string_value: "x" } - value { null_value: NULL_VALUE } - } - entries { - key { string_value: "y" } - value { bool_value: false } - } - } - } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: {'un': 1.0, 'deux': 2.0}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_value { - struct_value { - fields { - key: "un" - value { number_value: 1.0 } - } - fields { - key: "deux" - value { number_value: 2.0 } - } - } - } - } - } - } - } - test { - name: "field_assign_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: {}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_value { struct_value: {} } } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: {'i': true}}.single_value" - value { - map_value { - entries { - key { string_value: "i" } - value { bool_value: true } - } - } - } - } - test { - name: "field_read_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: {}}.single_value" - value { map_value: {} } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: {'un': 1.0, 'deux': 2.0}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_value { - struct_value { - fields { - key: "un" - value { number_value: 1.0 } - } - fields { - key: "deux" - value { number_value: 2.0 } - } - } - } - } - } - } - } - test { - name: "field_assign_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: {}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_value { struct_value: {} } } - } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: {'i': true}}.single_value" - value { - map_value { - entries { - key { string_value: "i" } - value { bool_value: true } - } - } - } - } - test { - name: "field_read_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: {}}.single_value" - value { map_value: {} } - } -} -section { - name: "value_list" - description: "Tests for list conversions in Value." - test { - name: "literal" - expr: "google.protobuf.Value{list_value: ['a', 3.0]}" - value { - list_value { - values { string_value: "a" } - values { double_value: 3.0 } - } - } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.Value{list_value: []}.list_value" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_empty" - expr: "google.protobuf.Value{list_value: []}" - value { list_value: {} } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.Value" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Value] { - list_value { - values { number_value: 1.0 } - values { bool_value: true } - values { string_value: "hi" } - } - } - } - } - } - } - value { - list_value { - values { double_value: 1.0 } - values { bool_value: true } - values { string_value: "hi" } - } - } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: ['un', 1.0]}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_value { - list_value { - values { string_value: "un" } - values { number_value: 1.0 } - } - } - } - } - } - } - test { - name: "field_assign_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: []}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_value { list_value: {} } } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: ['i', true]}.single_value" - value { - list_value { - values { string_value: "i" } - values { bool_value: true } - } - } - } - test { - name: "field_read_proto2_empty" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: []}.single_value" - value { list_value: {} } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: ['un', 1.0]}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_value { - list_value { - values { string_value: "un" } - values { number_value: 1.0 } - } - } - } - } - } - } - test { - name: "field_assign_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: []}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_value { list_value: {} } } - } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: ['i', true]}.single_value" - value { - list_value { - values { string_value: "i" } - values { bool_value: true } - } - } - } - test { - name: "field_read_proto3_empty" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: []}.single_value" - value { list_value: {} } - } -} -section { - name: "any" - description: "Tests for Any conversion." - test { - name: "literal" - expr: "google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\x08\\x96\\x01'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int32: 150 } - } - } - } - test { - name: "literal_no_field_access" - expr: "google.protobuf.Any{type_url: 'type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes', value: b'\\x08\\x96\\x01'}.type_url" - disable_check: true - eval_error { - errors { message: "no_matching_overload" } - } - } - test { - name: "literal_empty" - expr: "google.protobuf.Any{}" - eval_error { - errors { message: "conversion" } - } - } - test { - name: "var" - expr: "x" - type_env { - name: "x" - ident { type { message_type: "google.protobuf.Any" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Any] { - type_url: "type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes" - value: "\x08\x96\x01" - } - } - } - } - } - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int32: 150 } - } - } - } - test { - name: "field_assign_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_any: TestAllTypes{single_int32: 150}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_any { - type_url: "type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes" - value: "\x08\x96\x01" - } - } - } - } - } - test { - name: "field_read_proto2" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_any: TestAllTypes{single_int32: 150}}.single_any" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int32: 150 } - } - } - } - test { - name: "field_assign_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: TestAllTypes{single_int32: 150}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_any { - type_url: "type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes" - value: "\x08\x96\x01" - } - } - } - } - } - test { - name: "field_read_proto3" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: TestAllTypes{single_int32: 150}}.single_any" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int32: 150 } - } - } - } -} -section { - name: "complex" - description: "Tests combining various dynamic conversions." - test { - name: "any_list_map" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: [{'almost': 'done'}]}.single_any" - value { - list_value { - values { - map_value { - entries { - key { string_value: "almost" } - value { string_value: "done" } - } - } - } - } - } - } -} diff --git a/tests/simple/testdata/encoders_ext.textproto b/tests/simple/testdata/encoders_ext.textproto deleted file mode 100644 index 07cf11d9..00000000 --- a/tests/simple/testdata/encoders_ext.textproto +++ /dev/null @@ -1,44 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "encoders_ext" -description: "Tests for the encoders extension library." -section: { - name: "encode" - test: { - name: "hello" - expr: "base64.encode(b'hello')" - value: { - string_value: "aGVsbG8=" - } - } -} - -section: { - name: "decode" - test: { - name: "hello" - expr: "base64.decode('aGVsbG8=')" - value: { - bytes_value: "hello" - } - } - test: { - name: "hello_without_padding" - expr: "base64.decode('aGVsbG8')" - value: { - bytes_value: "hello" - } - } -} - -section: { - name: "round_trip" - test: { - name: "hello" - expr: "base64.decode(base64.encode(b'Hello World!'))" - value: { - bytes_value: "Hello World!" - } - } -} diff --git a/tests/simple/testdata/enums.textproto b/tests/simple/testdata/enums.textproto deleted file mode 100644 index 0341183f..00000000 --- a/tests/simple/testdata/enums.textproto +++ /dev/null @@ -1,391 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "enums" -description: "Tests for enum types." -section { - name: "legacy_proto2" - description: "Legacy semantics where all enums are ints, proto2." - test { - name: "literal_global" - container: "cel.expr.conformance.proto2" - expr: "GlobalEnum.GAZ" - value { int64_value: 2 } - } - test { - name: "literal_nested" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes.NestedEnum.BAR" - value { int64_value: 1 } - } - test { - name: "literal_zero" - container: "cel.expr.conformance.proto2" - expr: "GlobalEnum.GOO" - value { int64_value: 0 } - } - test { - name: "comparison" - container: "cel.expr.conformance.proto2" - expr: "GlobalEnum.GAR == 1" - value { bool_value: true } - } - test { - name: "arithmetic" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes.NestedEnum.BAR + 3" - value { int64_value: 4 } - } - test { - name: "type_global" - container: "cel.expr.conformance.proto2" - expr: "type(GlobalEnum.GOO)" - value { type_value: "int" } - } - test { - name: "type_nested" - container: "cel.expr.conformance.proto2" - expr: "type(TestAllTypes.NestedEnum.BAZ)" - value { type_value: "int" } - } - test { - name: "select_default" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.standalone_enum" - value { int64_value: 0 } - } - test { - name: "field_type" - container: "cel.expr.conformance.proto2" - expr: "type(TestAllTypes{}.standalone_enum)" - value { type_value: "int" } - } - test { - name: "assign_standalone_name" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{standalone_enum: TestAllTypes.NestedEnum.BAZ}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - standalone_enum: BAZ - } - } - } - } - test { - name: "assign_standalone_int" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{standalone_enum: 1}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - standalone_enum: BAR - } - } - } - } - test { - name: "assign_standalone_int_too_big" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{standalone_enum: 5000000000}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "assign_standalone_int_too_neg" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{standalone_enum: -7000000000}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "access_repeated_enum" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.repeated_nested_enum" - value { - list_value {} - } - } - test { - name: "assign_repeated_enum" - container: "cel.expr.conformance.proto2" - expr: - "TestAllTypes{" - " repeated_nested_enum: [" - " TestAllTypes.NestedEnum.FOO," - " TestAllTypes.NestedEnum.BAR]}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - repeated_nested_enum: FOO - repeated_nested_enum: BAR - } - } - } - } - test { - name: "list_enum_as_list_int" - container: "cel.expr.conformance.proto2" - expr: - "0 in " - "TestAllTypes{" - " repeated_nested_enum: [" - " TestAllTypes.NestedEnum.FOO," - " TestAllTypes.NestedEnum.BAR]}" - ".repeated_nested_enum" - value: { bool_value: true } - } - test { - name: "enum_as_int" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{standalone_enum: TestAllTypes.NestedEnum.FOO}.standalone_enum in [0]" - value: { bool_value: true } - } -} -section { - name: "legacy_proto3" - description: "Legacy semantics where all enums are ints, proto3" - test { - name: "literal_global" - container: "cel.expr.conformance.proto3" - expr: "GlobalEnum.GAZ" - value { int64_value: 2 } - } - test { - name: "literal_nested" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes.NestedEnum.BAR" - value { int64_value: 1 } - } - test { - name: "literal_zero" - container: "cel.expr.conformance.proto3" - expr: "GlobalEnum.GOO" - value { int64_value: 0 } - } - test { - name: "comparison" - container: "cel.expr.conformance.proto3" - expr: "GlobalEnum.GAR == 1" - value { bool_value: true } - } - test { - name: "arithmetic" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes.NestedEnum.BAR + 3" - value { int64_value: 4 } - } - test { - name: "type_global" - container: "cel.expr.conformance.proto3" - expr: "type(GlobalEnum.GOO)" - value { type_value: "int" } - } - test { - name: "type_nested" - container: "cel.expr.conformance.proto3" - expr: "type(TestAllTypes.NestedEnum.BAZ)" - value { type_value: "int" } - } - test { - name: "select_default" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.standalone_enum" - value { int64_value: 0 } - } - test { - name: "select" - container: "cel.expr.conformance.proto3" - expr: "x.standalone_enum" - type_env { - name: "x" - ident { - type { message_type: "cel.expr.conformance.proto3.TestAllTypes" } - } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - standalone_enum: 2 - } - } - } - } - } - value { int64_value: 2 } - } - test { - name: "select_big" - container: "cel.expr.conformance.proto3" - expr: "x.standalone_enum" - type_env { - name: "x" - ident { - type { message_type: "cel.expr.conformance.proto3.TestAllTypes" } - } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - standalone_enum: 108 - } - } - } - } - } - value { int64_value: 108 } - } - test { - name: "select_neg" - container: "cel.expr.conformance.proto3" - expr: "x.standalone_enum" - type_env { - name: "x" - ident { - type { message_type: "cel.expr.conformance.proto3.TestAllTypes" } - } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - standalone_enum: -3 - } - } - } - } - } - value { int64_value: -3 } - } - test { - name: "field_type" - container: "cel.expr.conformance.proto3" - expr: "type(TestAllTypes{}.standalone_enum)" - value { type_value: "int" } - } - test { - name: "assign_standalone_name" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{standalone_enum: TestAllTypes.NestedEnum.BAZ}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - standalone_enum: BAZ - } - } - } - } - test { - name: "assign_standalone_int" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{standalone_enum: 1}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - standalone_enum: BAR - } - } - } - } - test { - name: "assign_standalone_int_big" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{standalone_enum: 99}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - standalone_enum: 99 - } - } - } - } - test { - name: "assign_standalone_int_neg" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{standalone_enum: -1}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - standalone_enum: -1 - } - } - } - } - test { - name: "assign_standalone_int_too_big" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{standalone_enum: 5000000000}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "assign_standalone_int_too_neg" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{standalone_enum: -7000000000}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "access_repeated_enum" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.repeated_nested_enum" - value { - list_value {} - } - } - test { - name: "assign_repeated_enum" - container: "cel.expr.conformance.proto2" - expr: - "TestAllTypes{" - " repeated_nested_enum: [" - " TestAllTypes.NestedEnum.FOO," - " TestAllTypes.NestedEnum.BAR]}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - repeated_nested_enum: FOO - repeated_nested_enum: BAR - } - } - } - } - test { - name: "list_enum_as_list_int" - container: "cel.expr.conformance.proto2" - expr: - "0 in " - "TestAllTypes{" - " repeated_nested_enum: [" - " TestAllTypes.NestedEnum.FOO," - " TestAllTypes.NestedEnum.BAR]}" - ".repeated_nested_enum" - value: { bool_value: true } - } - test { - name: "enum_as_int" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{standalone_enum: TestAllTypes.NestedEnum.FOO}.standalone_enum in [0]" - value: { bool_value: true } - } -} diff --git a/tests/simple/testdata/fields.textproto b/tests/simple/testdata/fields.textproto deleted file mode 100644 index 66eb5d41..00000000 --- a/tests/simple/testdata/fields.textproto +++ /dev/null @@ -1,674 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "fields" -description: "Tests for field access in maps." -section { - name: "map_fields" - description: "select an element in a map" - test { - name: "map_key_int64" - expr: "{0:1,2:2,5:true}[5]" - value: { bool_value: true } - } - test { - name: "map_key_uint64" - expr: "{0u:1u,2u:'happy',5u:3u}[2u]" - value: { string_value: "happy" } - } - test { - name: "map_key_string" - expr: "{'name':100u}['name']" - value: { uint64_value: 100 } - } - test { - name: "map_key_bool" - expr: "{true:5}[true]" - value: { int64_value: 5 } - } - test { - name: "map_key_mixed_type" - expr: "{true:1,2:2,5u:3}[true]" - value: { int64_value: 1 } - } - test { - name: "map_key_mixed_numbers_double_key" - expr: "{1u: 1.0, 2: 2.0, 3u: 3.0}[3.0]" - value: { double_value: 3.0 } - } - test { - name: "map_key_mixed_numbers_lossy_double_key" - expr: "{1u: 1.0, 2: 2.0, 3u: 3.0}[3.1]" - eval_error: { - errors: { message: "no such key" } - } - } - test { - name: "map_key_mixed_numbers_uint_key" - expr: "{1u: 1.0, 2: 2.0, 3u: 3.0}[2u]" - value: { double_value: 2.0 } - } - test { - name: "map_key_mixed_numbers_int_key" - expr: "{1u: 1.0, 2: 2.0, 3u: 3.0}[1]" - value: { double_value: 1.0 } - } - test { - name: "map_field_access" - expr: "x.name" - type_env: { - name: "x" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: INT64 } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - map_value: { - entries { - key: { string_value: "name" } - value: { int64_value: 1024 } - } - } - } - } - } - value: { int64_value: 1024 } - } - test { - name: "map_no_such_key" - expr: "{0:1,2:2,5:3}[1]" - eval_error: { - errors: { message: "no such key" } - } - } - test { - name: "map_no_such_key_or_false" - expr: "dyn({0:1,2:2,5:3}[1]) || false" - eval_error: { - errors: { message: "no such key" } - } - } - test { - name: "map_no_such_key_or_true" - expr: "dyn({0:1,2:2,5:3}[1]) || true" - value: { bool_value: true } - } - test { - name: "map_no_such_key_and_false" - expr: "dyn({0:1,2:2,5:3}[1]) && false" - value: { bool_value: false } - } - test { - name: "map_no_such_key_and_true" - expr: "dyn({0:1,2:2,5:3}[1]) && true" - eval_error: { - errors: { message: "no such key" } - } - } - test { - name: "map_bad_key_type" - expr: "{0:1,2:2,5:3}[dyn(b'')]" - eval_error: { - errors: { message: "no such key" } - } - } - test { - name: "map_bad_key_type_or_false" - expr: "dyn({0:1,2:2,5:3}[dyn(b'')]) || false" - eval_error: { - errors: { message: "no such key" } - } - } - test { - name: "map_bad_key_type_or_true" - expr: "dyn({0:1,2:2,5:3}[dyn(b'')]) || true" - value: { bool_value: true } - } - test { - name: "map_bad_key_type_and_false" - expr: "dyn({0:1,2:2,5:3}[dyn(b'')]) && false" - value: { bool_value: false } - } - test { - name: "map_bad_key_type_and_true" - expr: "dyn({0:1,2:2,5:3}[dyn(b'')]) && true" - eval_error: { - errors: { message: "no such key" } - } - } - test { - name: "map_field_select_no_such_key" - expr: "x.name" - type_env: { - name: "x" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: STRING } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - map_value: { - entries { - key: { string_value: "holiday" } - value: { string_value: "field" } - } - } - } - } - } - eval_error: { - errors: { message: "no such key: 'name'" } - } - } - test { - name: "map_field_select_no_such_key_or_false" - expr: "dyn(x.name) || false" - type_env: { - name: "x" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: STRING } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - map_value: { - entries { - key: { string_value: "holiday" } - value: { string_value: "field" } - } - } - } - } - } - eval_error: { - errors: { message: "no such key: 'name'" } - } - } - test { - name: "map_field_select_no_such_key_or_true" - expr: "dyn(x.name) || true" - type_env: { - name: "x" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: STRING } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - map_value: { - entries { - key: { string_value: "holiday" } - value: { string_value: "field" } - } - } - } - } - } - value: { bool_value: true } - } - test { - name: "map_field_select_no_such_key_and_false" - expr: "dyn(x.name) && false" - type_env: { - name: "x" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: STRING } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - map_value: { - entries { - key: { string_value: "holiday" } - value: { string_value: "field" } - } - } - } - } - } - value: { bool_value: false } - } - test { - name: "map_field_select_no_such_key_and_true" - expr: "dyn(x.name) && true" - type_env: { - name: "x" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: STRING } - } - } - } - } - bindings: { - key: "x" - value: { - value: { - map_value: { - entries { - key: { string_value: "holiday" } - value: { string_value: "field" } - } - } - } - } - } - eval_error: { - errors: { message: "no such key: 'name'" } - } - } - test { - name: "map_value_null" - expr: "{true:null}[true]" - value: { null_value: NULL_VALUE } - } - test { - name: "map_value_bool" - expr: "{27:false}[27]" - value: { bool_value: false } - } - test { - name: "map_value_string" - expr: "{'n':'x'}['n']" - value: { string_value: "x" } - } - test { - name: "map_value_float" - expr: "{3:15.15}[3]" - value: { double_value: 15.15 } - } - test { - name: "map_value_uint64" - expr: "{0u:1u,2u:2u,5u:3u}[0u]" - value: { uint64_value: 1 } - } - test { - name: "map_value_int64" - expr: "{true:1,false:2}[true]" - value: { int64_value: 1 } - } - test { - name: "map_value_bytes" - expr: "{0:b''}[0]" - value: { bytes_value: "" } - } - test { - name: "map_value_list" - expr: "{0u:[1]}[0u]" - value: { - list_value: { - values: { int64_value: 1 } - } - } - } - test { - name: "map_value_map" - expr: "{'map': {'k': 'v'}}['map']" - value: { - map_value { - entries { - key: { string_value: "k" } - value: { string_value: "v" } - } - } - } - } - test { - name: "map_value_mix_type" - expr: "{'map': {'k': 'v'}, 'list': [1]}['map']" - value: { - map_value { - entries { - key: { string_value: "k" } - value: { string_value: "v" } - } - } - } - } -} -section { - name: "map_has" - description: "Has macro for map entries." - test { - name: "has" - expr: "has({'a': 1, 'b': 2}.a)" - value: { bool_value: true } - } - test { - name: "has_not" - expr: "has({'a': 1, 'b': 2}.c)" - value: { bool_value: false } - } - test { - name: "has_empty" - expr: "has({}.a)" - value: { bool_value: false } - } -} -section { - name: "quoted_map_fields" - description: "Field accesses using the quote syntax" - test { - name: "field_access_slash" - expr: "{'/api/v1': true, '/api/v2': false}.`/api/v1`" - value: { bool_value: true } - } - test { - name: "field_access_dash" - expr: "{'content-type': 'application/json', 'content-length': 145}.`content-type` == 'application/json'" - value: { bool_value: true } - } - test { - name: "field_access_dot" - expr: "{'foo.txt': 32, 'bar.csv': 1024}.`foo.txt`" - value: { int64_value: 32 } - } - test { - name: "has_field_slash" - expr: "has({'/api/v1': true, '/api/v2': false}.`/api/v3`)" - value: { bool_value: false } - } - test { - name: "has_field_dash" - expr: "has({'content-type': 'application/json', 'content-length': 145}.`content-type`)" - value: { bool_value: true } - } - test { - name: "has_field_dot" - expr: "has({'foo.txt': 32, 'bar.csv': 1024}.`foo.txt`)" - value: { bool_value: true } - } -} -section { - name: "qualified_identifier_resolution" - description: "Tests for qualified identifier resolution." - test { - name: "qualified_ident" - expr: "a.b.c" - type_env: { - name: "a.b.c" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "a.b.c" - value: { value: { string_value: "yeah" } } - } - value: { string_value: "yeah" } - } - test { - name: "map_field_select" - expr: "a.b.c" - type_env: { - name: "a.b" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: STRING } - } - } - } - } - bindings: { - key: "a.b" - value: { - value: { - map_value: { - entries { - key: { string_value: "c" } - value: { string_value: "yeah" } - } - } - } - } - } - value: { string_value: "yeah" } - } - test { - name: "qualified_identifier_resolution_unchecked" - description: "namespace resolution should try to find the longest prefix for the evaluator." - expr: "a.b.c" - type_env: { - name: "a.b.c" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "a.b.c" - value: { value: { string_value: "yeah" } } - } - type_env: { - name: "a.b" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: STRING } - } - } - } - } - bindings: { - key: "a.b" - value: { - value: { - map_value: { - entries { - key: { string_value: "c" } - value: { string_value: "oops" } - } - } - } - } - } - disable_check: true ## when check is disabled, the evaluator should evaluate it in the correct order - value: { string_value: "yeah" } - } - test { - name: "list_field_select_unsupported" - expr: "a.b.pancakes" - disable_check: true - type_env: { - name: "a.b" - ident: { - type: { - list_type: { - elem_type: { primitive: STRING } - } - } - } - } - bindings: { - key: "a.b" - value: { - value: { - list_value: { - values: { string_value: "pancakes" } - } - } - } - } - eval_error: { - errors: { - message: "type 'list_type: > ' does not support field selection" - } - } - } - test { - name: "int64_field_select_unsupported" - expr: "a.pancakes" - disable_check: true - type_env: { - name: "a" - ident: { - type: { - primitive: INT64 - } - } - } - bindings: { - key: "a" - value: { - value: { - int64_value: 15 - } - } - } - eval_error: { - errors: { - message: "type 'int64_type' does not support field selection" - } - } - } - test { - name: "ident_with_longest_prefix_check" - description: "namespace resolution should try to find the longest prefix for the checker." - expr: "a.b.c" - type_env: { - name: "a.b.c" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "a.b.c" - value: { value: { string_value: "yeah" } } - } - type_env: { - name: "a.b" - ident: { - type: { - map_type: { - key_type: { primitive: STRING } - value_type: { primitive: STRING } - } - } - } - } - bindings: { - key: "a.b" - value: { - value: { - map_value: { - entries { - key: { string_value: "c" } - value: { string_value: "oops" } - } - } - } - } - } - value: { string_value: "yeah" } - } - test { - name: "map_key_float" - description: "map should not support float as the key." - expr: "{3.3:15.15, 1.0: 5}[1.0]" - disable_check: true # need to make it fail in the evaluation phase - eval_error: { - errors: { message: "unsupported key type" } - } - ## Current behavior - ## value: { int64_value: 5 } - } - test { - name: "map_key_null" - description: "map should not support null as the key." - expr: "{null:false}[null]" - disable_check: true # need to make it fail in the evaluation phase - eval_error: { - errors: { message: "unsupported key type" } - } - ## Current behavior - ## value: { bool_value: false } - } - test { - name: "map_value_repeat_key" - description: "map should not support repeated key." - expr: "{true:1,false:2,true:3}[true]" - eval_error: { - errors: { message: "Failed with repeated key" } - } - ## Current behavior: - ## value: { int64_value: 1 } - } - test { - name: "map_value_repeat_key_heterogeneous" - description: "map should not support repeated key." - expr: "{0: 1, 0u: 2}[0.0]" - eval_error: { - errors: { message: "Failed with repeated key" } - } - ## Current behavior: - ## value: { int64_value: 1 } - } -} -section { - name: "in" - description: "Tests for 'in' operator for maps." - test { - name: "empty" - expr: "7 in {}" - value: { bool_value: false } - } - test { - name: "singleton" - expr: "true in {true: 1}" - value: { bool_value: true } - } - test { - name: "present" - expr: "'George' in {'John': 'smart', 'Paul': 'cute', 'George': 'quiet', 'Ringo': 'funny'}" - value: { bool_value: true } - } - test { - name: "absent" - expr: "'spider' in {'ant': 6, 'fly': 6, 'centipede': 100}" - value: { bool_value: false } - } - test { - name: "mixed_numbers_and_keys_present" - expr: "3.0 in {1: 1, 2: 2, 3u: 3} && 2u in {1u: 1, 2: 2} && 1 in {1u: 1, 2: 2}" - value: { bool_value: true } - } - test { - name: "mixed_numbers_and_keys_absent" - expr: "3.1 in {1: 1, 2: 2, 3u: 3}" - value: { bool_value: false } - } -} diff --git a/tests/simple/testdata/fp_math.textproto b/tests/simple/testdata/fp_math.textproto deleted file mode 100644 index 72474bc7..00000000 --- a/tests/simple/testdata/fp_math.textproto +++ /dev/null @@ -1,167 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "fp_math" -description: "Tests for floating-point math." -section { - name: "fp_math" - description: "Simple tests for floating point." - test { - name: "add_positive_positive" - expr: "4.25 + 15.25" - value: { double_value: 19.5 } - } - test { - name: "add_positive_negative" - expr: "17.75 + (-7.75)" - value: { double_value: 10 } - } - test { - name: "add_negative_negative" - expr: "-4.125 + (-2.125)" - value: { double_value: -6.25 } - } - test { - name: "sub_positive_positive" - expr: "42.0 - 12.0" - value: { double_value: 30 } - } - test { - name: "sub_positive_negative" - expr: "42.875 - (-22.0)" - value: { double_value: 64.875 } - } - test { - name: "sub_negative_negative" - expr: "-4.875 - (-0.125)" - value: { double_value: -4.75 } - } - test { - name: "multiply_positive_positive" - expr: "42.5 * 0.2" - value: { double_value: 8.5 } - } - test { - name: "multiply_positive_negative" - expr: "40.75 * (-2.25)" - value: { double_value: -91.6875 } - } - test { - name: "multiply_negative_negative" - expr: "-3.0 * (-2.5)" - value: { double_value: 7.5 } - } - test { - name: "divide_positive_positive" - expr: "0.0625 / 0.002" - value: { double_value: 31.25 } - } - test { - name: "divide_positive_negative" - expr: "-2.0 / 2.0" - value: { double_value: -1 } - } - test { - name: "divide_negative_negative" - expr: "-8.875 / (-0.0625)" - value: { double_value: 142 } - } - test { - name: "mod_not_support" - expr: "47.5 % 5.5" - disable_check: true - eval_error: { - errors: { message:"found no matching overload for '_%_' applied to '(double, double)'" } - } - } - test { - name: "negative" - expr: "-(4.5)" - value: { double_value: -4.5 } - } - test { - name: "double_negative" - expr: "-(-1.25)" - value: { double_value: 1.25 } - } - test { - name: "negative_zero" - expr: "-(0.0)" - value: { double_value: -0.0 } - } - test { - name: "divide_zero" - expr: "15.75 / 0.0" - value: { double_value: Infinity } - } - test { - name: "multiply_zero" - expr: "15.36 * 0.0" - value: { double_value: 0 } - } - test { - name: "add_left_identity" - expr: "0.0 + 1.75" - value: { double_value: 1.75} - } - test { - name: "add_right_identity" - expr: " 2.5 + 0.0" - value: { double_value: 2.5 } - } - test { - name: "add_commutative" - expr: "7.5 + 1.5 == 1.5 + 7.5" - value: { bool_value: true } - } - test { - name: "add_associative" - expr: "5.625 + (15.75 + 2.0) == (5.625 + 15.75) + 2.0" - value: { bool_value: true } - } - test { - name: "mul_left_identity" - expr: "1.0 * 45.25" - value: { double_value: 45.25 } - } - test { - name: "mul_right_identity" - expr: "-25.25 * 1.0" - value: { double_value: -25.25 } - } - test { - name: "mul_commutative" - expr: "1.5 * 25.875 == 25.875 * 1.5" - value: { bool_value: true } - } - test { - name: "mul_associative" - expr: "1.5 * (23.625 * 0.75) == (1.5 * 23.625) * 0.75" - value: { bool_value: true } - } - test { - name: "add_mul_distribute" - expr: "5.75 * (1.5 + 2.5) == 5.75 * 1.5 + 5.75 * 2.5" - ## overflow or underflow may cause this not equal. - value: { bool_value: true } - } - test { - name: "fp_overflow_positive" - description: "DBL_MAX(2^1023) times two" - expr: "2.0 * 8.988466e+307 " - value: {double_value: inf} - } - test { - name: "fp_overflow_negative" - description: "-DBL_MAX(-2^1023) times two" - expr: "2.0 * -8.988466e+307 " - value: {double_value: -inf} - } - test { - name: "fp_underflow" - description: "DBL_MIN(2^-1074) divided by two" - expr: "1e-324 / 2.0" - ## Expect it to be the closest number to the exact result. - value: {double_value: 0} - } -} diff --git a/tests/simple/testdata/integer_math.textproto b/tests/simple/testdata/integer_math.textproto deleted file mode 100644 index c0d4f514..00000000 --- a/tests/simple/testdata/integer_math.textproto +++ /dev/null @@ -1,386 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "integer_math" -description: "Tests for int and uint math." -section { - name: "int64_math" - description: "Simple tests for int64." - test { - name: "add_positive_positive" - expr: "40 + 2" - value: { int64_value: 42 } - } - test { - name: "add_positive_negative" - expr: "42 + (-7)" - value: { int64_value: 35 } - } - test { - name: "add_negative_negative" - expr: "-4 + (-2)" - value: { int64_value: -6 } - } - test { - name: "sub_positive_positive" - expr: "42 - 12" - value: { int64_value: 30 } - } - test { - name: "sub_positive_negative" - expr: "42 - (-22)" - value: { int64_value: 64 } - } - test { - name: "sub_negative_negative" - expr: "-42 - (-12)" - value: { int64_value: -30 } - } - test { - name: "multiply_positive_positive" - expr: "42 * 2" - value: { int64_value: 84 } - } - test { - name: "multiply_positive_negative" - expr: "40 * (-2)" - value: { int64_value: -80 } - } - test { - name: "multiply_negative_negative" - expr: "-30 * (-2)" - value: { int64_value: 60 } - } - test { - name: "divide_positive_positive" - expr: "42 / 2" - value: { int64_value: 21 } - } - test { - name: "divide_positive_negative" - expr: "-20 / 2" - value: { int64_value: -10 } - } - test { - name: "divide_negative_negative" - expr: "-80 / (-2)" - value: { int64_value: 40 } - } - test { - name: "mod_positive_positive" - expr: "47 % 5" - value: { int64_value: 2 } - } - test { - name: "mod_positive_negative" - expr: "43 % (-5)" - value: { int64_value: 3 } - } - test { - name: "mod_negative_negative" - expr: "-42 % (-5)" - value: { int64_value: -2 } - } - test { - name: "mod_negative_positive" - expr: "-3 % 5" - value: { int64_value: -3 } - } - test { - name: "unary_minus_pos" - expr: "-(42)" - value: { int64_value: -42 } - } - test { - name: "unary_minus_neg" - expr: "-(-42)" - value: { int64_value: 42 } - } - test { - name: "unary_minus_no_overload" - expr: "-(42u)" - disable_check: true - eval_error: { - errors: { message:"no_such_overload" } - } - } - test { - name: "unary_minus_not_bool" - expr: "-false" - disable_check: true - eval_error: { - errors: { message:"no_such_overload" } - } - } - test { - name: "mod_zero" - expr: "34 % 0" - eval_error: { - errors: { message:"modulus by zero" } - } - } - test { - name: "negative_zero" - expr: "-(0)" - value: { int64_value: 0 } - } - test { - name: "double_negative" - expr: "-(-42)" - value: { int64_value: 42 } - } - test { - name: "divide_zero" - expr: "15 / 0" - eval_error: { - errors: { message:"divide by zero" } - } - } - test { - name: "multiply_zero" - expr: "15 * 0" - value: { int64_value: 0 } - } - test { - name: "add_left_identity" - expr: "0 + 17" - value: { int64_value: 17} - } - test { - name: "add_right_identity" - expr: " 29 + 0" - value: { int64_value: 29 } - } - test { - name: "add_commutative" - expr: "75 + 15 == 15 + 75" - value: { bool_value: true } - } - test { - name: "add_associative" - expr: "5 + (15 + 20) == (5 + 15) + 20" - value: { bool_value: true } - } - test { - name: "mul_left_identity" - expr: "1 * 45" - value: { int64_value: 45 } - } - test { - name: "mul_right_identity" - expr: "-25 * 1" - value: { int64_value: -25 } - } - test { - name: "mul_commutative" - expr: "15 * 25 == 25 * 15" - value: { bool_value: true } - } - test { - name: "mul_associative" - expr: "15 * (23 * 88) == (15 * 23) * 88" - value: { bool_value: true } - } - test { - name: "add_mul_distribute" - expr: "5 * (15 + 25) == 5 * 15 + 5 * 25" - value: { bool_value: true } - } - test { - name: "int64_overflow_positive" - description: "LLONG_MAX plus one." - expr: "9223372036854775807 + 1" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "int64_overflow_negative" - description: "LLONG_MIN minus one." - expr: "-9223372036854775808 - 1" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "int64_overflow_add_negative" - description: "negative overflow via addition" - expr: "-9223372036854775808 + (-1)" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "int64_overflow_sub_positive" - description: "positive overflow via subtraction" - expr: "1 - (-9223372036854775807)" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "int64_min_negate" - description: "Negated LLONG_MIN is not representable." - expr: "-(-9223372036854775808)" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "int64_min_negate_mul" - description: "Negate LLONG_MIN via multiplication" - expr: "(-9223372036854775808) * -1" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "int64_min_negate_div" - description: "Negate LLONG_MIN via division." - expr: "(-9223372036854775808)/-1" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "int64_overflow_mul_positive" - description: "Overflow via multiplication." - expr: "5000000000 * 5000000000" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "int64_overflow_mul_negative" - description: "Overflow via multiplication." - expr: "(-5000000000) * 5000000000" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "uint64_overflow_positive" - description: "ULLONG_MAX plus one." - expr: "18446744073709551615u + 1u" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "uint64_overflow_negative" - description: "zero minus one." - expr: "0u - 1u" - eval_error: { - errors: { message: "return error for overflow" } - } - } - test { - name: "uint64_overflow_mul_positive" - description: "Overflow via multiplication." - expr: "5000000000u * 5000000000u" - eval_error: { - errors: { message: "return error for overflow" } - } - } -} -section { - name: "uint64_math" - description: "Simple tests for uint64." - test { - name: "add" - expr: "42u + 2u" - value: { uint64_value: 44 } - } - test { - name: "sub" - expr: "42u - 12u" - value: { uint64_value: 30 } - } - test { - name: "multiply" - expr: "40u * 2u" - value: { uint64_value: 80 } - } - test { - name: "divide" - expr: "60u / 2u" - value: { uint64_value: 30 } - } - test { - name: "mod" - expr: "42u % 5u" - value: { uint64_value: 2 } - } - test { - name: "negative_no_overload" - expr: "-(5u)" - disable_check: true - eval_error: { - errors: { message:"no such overload" } - } - } - test { - name: "mod_zero" - expr: "34u % 0u" - eval_error: { - errors: { message:"modulus by zero" } - } - } - test { - name: "divide_zero" - expr: "15u / 0u" - eval_error: { - errors: { message:"divide by zero" } - } - } - test { - name: "multiply_zero" - expr: "15u * 0u" - value: { uint64_value: 0 } - } - test { - name: "add_left_identity" - expr: "0u + 17u" - value: { uint64_value: 17} - } - test { - name: "add_right_identity" - expr: " 29u + 0u" - value: { uint64_value: 29 } - } - test { - name: "add_commutative" - expr: "75u + 15u == 15u + 75u" - value: { bool_value: true } - } - test { - name: "add_associative" - expr: "5u + (15u + 20u) == (5u + 15u) + 20u" - value: { bool_value: true } - } - test { - name: "mul_left_identity" - expr: "1u * 45u" - value: { uint64_value: 45 } - } - test { - name: "mul_right_identity" - expr: "25u * 1u" - value: { uint64_value: 25 } - } - test { - name: "mul_commutative" - expr: "15u * 25u == 25u * 15u" - value: { bool_value: true } - } - test { - name: "mul_associative" - expr: "15u * (23u * 88u) == (15u * 23u) * 88u" - value: { bool_value: true } - } - test { - name: "add_mul_distribute" - expr: "5u * (15u + 25u) == 5u * 15u + 5u * 25u" - value: { bool_value: true } - } -} diff --git a/tests/simple/testdata/lists.textproto b/tests/simple/testdata/lists.textproto deleted file mode 100644 index 2148118a..00000000 --- a/tests/simple/testdata/lists.textproto +++ /dev/null @@ -1,245 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "lists" -description: "Tests for list operations." -section { - name: "concatenation" - description: "Tests for list concatenation." - test { - name: "list_append" - expr: "[0, 1, 2] + [3, 4, 5] == [0, 1, 2, 3, 4, 5]" - value: { bool_value: true } - } - test { - name: "list_not_commutative" - expr: "[0, 1, 2] + [3, 4, 5] == [3, 4, 5, 0, 1, 2]" - value: { bool_value: false } - } - test { - name: "list_repeat" - expr: "[2] + [2]" - value: { - list_value { - values: { int64_value: 2 } - values: { int64_value: 2 } - } - } - } - test { - name: "empty_empty" - expr: "[] + []" - value: { list_value { } } - } - test { - name: "left_unit" - expr: "[] + [3, 4]" - value: { - list_value { - values { int64_value: 3 } - values { int64_value: 4 } - } - } - } - test { - name: "right_unit" - expr: "[1, 2] + []" - value { - list_value { - values { int64_value: 1 } - values { int64_value: 2 } - } - } - } -} -section { - name: "index" - description: "List indexing tests." - test { - name: "zero_based" - expr: "[7, 8, 9][0]" - value: { int64_value: 7 } - } - test { - name: "zero_based_double" - expr: "[7, 8, 9][dyn(0.0)]" - value: { int64_value: 7 } - } - test { - name: "zero_based_double_error" - expr: "[7, 8, 9][dyn(0.1)]" - eval_error { - errors { message: "invalid_argument" } - } - } - test { - name: "zero_based_uint" - expr: "[7, 8, 9][dyn(0u)]" - value: { int64_value: 7 } - } - test { - name: "singleton" - expr: "['foo'][0]" - value: { string_value: "foo" } - } - test { - name: "middle" - expr: "[0, 1, 1, 2, 3, 5, 8, 13][4]" - value: { int64_value: 3 } - } - test { - name: "last" - expr: "['George', 'John', 'Paul', 'Ringo'][3]" - value: { string_value: "Ringo" } - } - test { - name: "index_out_of_bounds" - expr: "[1, 2, 3][3]" - eval_error { - errors { message: "invalid_argument" } - } - } - test { - name: "index_out_of_bounds_or_false" - expr: "dyn([1, 2, 3][3]) || false" - eval_error { - errors { message: "invalid_argument" } - } - } - test { - name: "index_out_of_bounds_or_true" - expr: "dyn([1, 2, 3][3]) || true" - value: { bool_value: true } - } - test { - name: "index_out_of_bounds_and_false" - expr: "dyn([1, 2, 3][3]) && false" - value: { bool_value: false } - } - test { - name: "index_out_of_bounds_and_true" - expr: "dyn([1, 2, 3][3]) && true" - eval_error { - errors { message: "invalid_argument" } - } - } - test { - name: "bad_index_type" - expr: "[1, 2, 3][dyn('')]" - eval_error { - errors { message: "invalid_argument" } - } - } - test { - name: "bad_index_type_or_false" - expr: "dyn([1, 2, 3][dyn('')]) || false" - eval_error { - errors { message: "invalid_argument" } - } - } - test { - name: "bad_index_type_or_true" - expr: "dyn([1, 2, 3][dyn('')]) || true" - value: { bool_value: true } - } - test { - name: "bad_index_type_and_false" - expr: "dyn([1, 2, 3][dyn('')]) && false" - value: { bool_value: false } - } - test { - name: "bad_index_type_and_true" - expr: "dyn([1, 2, 3][dyn('')]) && true" - eval_error { - errors { message: "invalid_argument" } - } - } -} -section { - name: "in" - description: "List membership tests." - test { - name: "empty" - expr: "7 in []" - value: { bool_value: false } - } - test { - name: "singleton" - expr: "4u in [4u]" - value: { bool_value: true } - } - test { - name: "first" - expr: "'alpha' in ['alpha', 'beta', 'gamma']" - value: { bool_value: true } - } - test { - name: "middle" - expr: "3 in [5, 4, 3, 2, 1]" - value: { bool_value: true } - } - test { - name: "last" - expr: "20u in [4u, 6u, 8u, 12u, 20u]" - value: { bool_value: true } - } - test { - name: "double_in_ints" - expr: "dyn(3.0) in [5, 4, 3, 2, 1]" - value: { bool_value: true } - } - test { - name: "uint_in_ints" - expr: "dyn(3u) in [5, 4, 3, 2, 1]" - value: { bool_value: true } - } - test { - name: "int_in_doubles" - expr: "dyn(3) in [5.0, 4.0, 3.0, 2.0, 1.0]" - value: { bool_value: true } - } - test { - name: "uint_in_doubles" - expr: "dyn(3u) in [5.0, 4.0, 3.0, 2.0, 1.0]" - value: { bool_value: true } - } - test { - name: "int_in_uints" - expr: "dyn(3) in [5u, 4u, 3u, 2u, 1u]" - value: { bool_value: true } - } - test { - name: "double_in_uints" - expr: "dyn(3.0) in [5u, 4u, 3u, 2u, 1u]" - value: { bool_value: true } - } - test { - name: "missing" - expr: "'hawaiian' in ['meat', 'veggie', 'margarita', 'cheese']" - value: { bool_value: false } - } -} -section { - name: "size" - description: "List and map size tests." - test { - name: "list_empty" - expr: "size([])" - value: { int64_value: 0 } - } - test { - name: "list" - expr: "size([1, 2, 3])" - value: { int64_value: 3 } - } - test { - name: "map_empty" - expr: "size({})" - value: { int64_value: 0 } - } - test { - name: "map" - expr: "size({1: 'one', 2: 'two', 3: 'three'})" - value: { int64_value: 3 } - } -} diff --git a/tests/simple/testdata/lists_ext.textproto b/tests/simple/testdata/lists_ext.textproto deleted file mode 100644 index f983a607..00000000 --- a/tests/simple/testdata/lists_ext.textproto +++ /dev/null @@ -1,293 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "lists_ext" -description: "Tests for the lists extension library." -section: { - name: "slice" - description: "slice: since version 0" - test: { - name: "sublist" - expr: "[1, 2, 3, 4].slice(1, 3) == [2, 3]" - } - test: { - name: "full" - expr: "[1, 2, 3, 4].slice(0, 4) == [1, 2, 3, 4]" - } - test: { - name: "empty_start" - expr: "[1, 2, 3, 4].slice(0, 0) == []" - } - test: { - name: "empty_middle" - expr: "[1, 2, 3, 4].slice(2, 2) == []" - } - test: { - name: "empty_end" - expr: "[1, 2, 3, 4].slice(4, 4) == []" - } - test: { - name: "start_greater_than_end" - expr: "[1, 2, 3, 4].slice(3, 1)" - eval_error: { - errors: { - message: "invalid_argument" - } - } - } - test: { - name: "end_greater_than_length" - expr: "[1, 2, 3, 4].slice(1, 5)" - eval_error: { - errors: { - message: "invalid_argument" - } - } - } - test: { - name: "negative_start_index" - expr: "[1, 2, 3, 4].slice(-1, 2)" - eval_error: { - errors: { - message: "invalid_argument" - } - } - } - test: { - name: "negative_end_index" - expr: "[1, 2, 3, 4].slice(1, -1)" - eval_error: { - errors: { - message: "invalid_argument" - } - } - } -} -section: { - name: "flatten" - description: "flatten: since version 1" - test: { - name: "default_depth" - expr: "[1, [2, 3], [4]].flatten() == [1, 2, 3, 4]" - } - test: { - name: "default_depth_nested" - expr: "[1, [2, [3, 4]]].flatten() == [1, 2, [3, 4]]" - } - test: { - name: "empty_sublists" - expr: "[1, 2, [], [], [3, 4]].flatten() == [1, 2, 3, 4]" - } - test: { - name: "depth_two" - expr: "[1, [2, [3, [4]]]].flatten(2) == [1, 2, 3, [4]]" - } - test: { - name: "depth_zero" - expr: "[1, [2, 3]].flatten(0) == [1, [2, 3]]" - } - test: { - name: "empty_list" - expr: "dyn([]).flatten() == []" - } - test: { - name: "already_flat" - expr: "dyn([1, 2, 3]).flatten() == [1, 2, 3]" - } - test: { - name: "negative_depth" - expr: "[1, [2, 3]].flatten(-1)" - eval_error: { - errors: { - message: "invalid_argument" - } - } - } -} -section: { - name: "distinct" - description: "distinct: since version 2" - test: { - name: "ints" - expr: "[1, 2, 2, 3, 3, 3].distinct() == [1, 2, 3]" - } - test: { - name: "strings" - expr: "[\"b\", \"b\", \"c\", \"a\", \"c\"].distinct() == [\"b\", \"c\", \"a\"]" - } - test: { - name: "heterogeneous" - expr: "[1, \"b\", 2, \"b\"].distinct() == [1, \"b\", 2]" - } - test: { - name: "empty" - expr: "[].distinct() == []" - } - test: { - name: "single_element" - expr: "[1].distinct() == [1]" - } - test: { - name: "uints" - expr: "[2u, 5u, 100u, 1u, 1u, 5u].distinct() == [2u, 5u, 100u, 1u]" - } - test: { - name: "bools" - expr: "[false, true, true, false].distinct() == [false, true]" - } -} -section: { - name: "range" - description: "lists.range: since version 2" - test: { - name: "positive" - expr: "lists.range(5) == [0, 1, 2, 3, 4]" - } - test: { - name: "zero" - expr: "lists.range(0) == []" - } - test: { - name: "single" - expr: "lists.range(1) == [0]" - } - test: { - name: "negative_error" - expr: "lists.range(-1)" - eval_error: { - errors: { - message: "invalid_argument" - } - } - } - test: { - name: "limit_exceeded_error" - # Assumed to be overridable, but check that a reasonable limit is in place - # by default. - expr: "lists.range(1000001)" - eval_error: { - errors: { - message: "invalid_argument" - } - } - } -} -section: { - name: "reverse" - description: "reverse: since version 2" - test: { - name: "integers" - expr: "[5, 3, 1, 2].reverse() == [2, 1, 3, 5]" - } - test: { - name: "strings" - expr: "[\"are\", \"you\", \"as\", \"bored\"].reverse() == [\"bored\", \"as\", \"you\", \"are\"]" - } - test: { - name: "empty" - expr: "[].reverse() == []" - } - test: { - name: "single" - expr: "[1].reverse() == [1]" - } - test: { - name: "double_reverse" - expr: "[false, true, true].reverse().reverse() == [false, true, true]" - } -} -section: { - name: "sort" - description: "sort: since version 2" - test: { - name: "integers" - expr: "[3, 2, 1].sort() == [1, 2, 3]" - } - test: { - name: "uints" - expr: "[42u, 3u, 1337u].sort() == [3u, 42u, 1337u]" - } - test: { - name: "doubles" - expr: "[1.0, -1.5, 2.0].sort() == [-1.5, 1.0, 2.0]" - } - test: { - name: "strings" - expr: "[\"b\", \"c\", \"a\"].sort() == [\"a\", \"b\", \"c\"]" - } - test: { - name: "bytes" - expr: "[b\"d\", b\"a\", b\"aa\"].sort() == [b\"a\", b\"aa\", b\"d\"]" - } - test: { - name: "bools" - expr: "[true, false, true].sort() == [false, true, true]" - } - test: { - name: "durations" - expr: "[duration('1m'), duration('2s'), duration('3h')].sort() == [duration('2s'), duration('1m'), duration('3h')]" - } - test: { - name: "timestamps" - expr: "[timestamp('2024-01-03T00:00:00Z'), timestamp('2024-01-01T00:00:00Z')].sort() == [timestamp('2024-01-01T00:00:00Z'), timestamp('2024-01-03T00:00:00Z')]" - } - test: { - name: "empty" - expr: "[].sort() == []" - } - test: { - name: "single" - expr: "[1].sort() == [1]" - } - test: { - name: "mixed_types_error" - expr: "[1, \"b\"].sort()" - eval_error: { - errors: { - message: "invalid_argument" - } - } - } - test: { - name: "incomparable_type_error" - expr: "dyn([[1, 2, 3]]).sort()" - eval_error: { - errors: { - message: "invalid_argument" - } - } - } -} -section: { - name: "sortBy" - description: "sortBy: since version 2" - test: { - name: "number_key" - expr: "[-3, 1, -5, -2, 4].sortBy(e, -(e * e)) == [-5, 4, -3, -2, 1]" - } - test: { - name: "identity_key" - expr: "[1, 2, 3].sortBy(e, -e) == [3, 2, 1]" - } - test: { - name: "string_key" - expr: "[\"a\", \"c\", \"b\", \"first\"].sortBy(e, e == \"first\" ? \"\" : e) == [\"first\", \"a\", \"b\", \"c\"]" - } - test: { - name: "empty" - expr: "[].sortBy(e, e) == []" - } - test: { - name: "single" - expr: "[\"a\"].sortBy(e, e) == [\"a\"]" - } - test: { - name: "mixed_key_types_error" - expr: "[[1], [\"a\"]].sortBy(e, e[0])" - eval_error: { - errors: { - message: "invalid_argument" - } - } - } -} diff --git a/tests/simple/testdata/logic.textproto b/tests/simple/testdata/logic.textproto deleted file mode 100644 index 384e5ce0..00000000 --- a/tests/simple/testdata/logic.textproto +++ /dev/null @@ -1,198 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: google.api.expr.test.v1.SimpleTestFile - -name: "logic" -description: "Tests for logical special operators." -section { - name: "conditional" - description: "Tests for the conditional operator." - test { - name: "true_case" - expr: "true ? 1 : 2" - value: { int64_value: 1 } - } - test { - name: "false_case" - expr: "false ? 'foo' : 'bar'" - value: { string_value: "bar" } - } - test { - name: "error_case" - expr: "2 / 0 > 4 ? 'baz' : 'quux'" - eval_error: { - errors: { message: "division by zero" } - } - } - test { - name: "mixed_type" - expr: "true ? 'cows' : 17" - disable_check: true - value: { string_value: "cows" } - } - test { - name: "bad_type" - expr: "'cows' ? false : 17" - disable_check: true - eval_error: { - errors: { message: "no matching overload" } - } - } -} -section { - name: "AND" - description: "Tests for logical AND." - test { - name: "all_true" - expr: "true && true" - value: { bool_value: true } - } - test { - name: "all_false" - expr: "false && false" - value: { bool_value: false } - } - test { - name: "false_left" - expr: "false && true" - value: { bool_value: false } - } - test { - name: "false_right" - expr: "true && false" - value: { bool_value: false } - } - test { - name: "short_circuit_type_left" - expr: "false && 32" - disable_check: true - value: { bool_value: false } - } - test { - name: "short_circuit_type_right" - expr: "'horses' && false" - disable_check: true - value: { bool_value: false } - } - test { - name: "short_circuit_error_left" - expr: "false && (2 / 0 > 3 ? false : true)" - value: { bool_value: false } - } - test { - name: "short_circuit_error_right" - expr: "(2 / 0 > 3 ? false : true) && false" - value: { bool_value: false } - } - test { - name: "error_right" - expr: "true && 1/0 != 0" - eval_error: { - errors: { message: "no matching overload" } - } - } - test { - name: "error_left" - expr: "1/0 != 0 && true" - eval_error: { - errors: { message: "no matching overload" } - } - } - test { - name: "no_overload" - expr: "'less filling' && 'tastes great'" - disable_check: true - eval_error: { - errors: { message: "no matching overload" } - } - } -} -section { - name: "OR" - description: "Tests for logical OR" - test { - name: "all_true" - expr: "true || true" - value: { bool_value: true } - } - test { - name: "all_false" - expr: "false || false" - value: { bool_value: false } - } - test { - name: "false_left" - expr: "false || true" - value: { bool_value: true } - } - test { - name: "false_right" - expr: "true || false" - value: { bool_value: true } - } - test { - name: "short_circuit_type_left" - expr: "true || 32" - disable_check: true - value: { bool_value: true } - } - test { - name: "short_circuit_type_right" - expr: "'horses' || true" - disable_check: true - value: { bool_value: true } - } - test { - name: "short_circuit_error_left" - expr: "true || (2 / 0 > 3 ? false : true)" - value: { bool_value: true } - } - test { - name: "short_circuit_error_right" - expr: "(2 / 0 > 3 ? false : true) || true" - value: { bool_value: true } - } - test { - name: "error_right" - expr: "false || 1/0 != 0" - eval_error: { - errors: { message: "no matching overload" } - } - } - test { - name: "error_left" - expr: "1/0 != 0 || false" - eval_error: { - errors: { message: "no matching overload" } - } - } - test { - name: "no_overload" - expr: "'less filling' || 'tastes great'" - disable_check: true - eval_error: { - errors: { message: "no matching overload" } - } - } -} -section { - name: "NOT" - description: "Tests for logical NOT." - test { - name: "not_true" - expr: "!true" - value: { bool_value: false } - } - test { - name: "not_false" - expr: "!false" - value: { bool_value: true } - } - test { - name: "no_overload" - expr: "!0" - disable_check: true - eval_error: { - errors: { message: "no matching overload" } - } - } -} diff --git a/tests/simple/testdata/macros.textproto b/tests/simple/testdata/macros.textproto deleted file mode 100644 index 26a201fa..00000000 --- a/tests/simple/testdata/macros.textproto +++ /dev/null @@ -1,289 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: google.api.expr.test.v1.SimpleTestFile - -name: "macros" -description: "Tests for CEL macros." -section { - name: "exists" - description: "Tests for the .exists() macro, which is equivalent to joining the evaluated elements with logical-OR." - test { - name: "list_elem_all_true" - expr: "[1, 2, 3].exists(e, e > 0)" - value: { bool_value: true } - } - test { - name: "list_elem_some_true" - expr: "[1, 2, 3].exists(e, e == 2)" - value: { bool_value: true } - } - test { - name: "list_elem_none_true" - expr: "[1, 2, 3].exists(e, e > 3)" - value: { bool_value: false } - } - test { - name: "list_elem_type_shortcircuit" - description: "Exists filter is true for the last element." - expr: "[1, 'foo', 3].exists(e, e != '1')" - value: { bool_value: true } - } - test { - name: "list_elem_type_exhaustive" - description: "Exists filter is never true, but heterogenous equality ensure the result is false." - expr: "[1, 'foo', 3].exists(e, e == '10')" - value: { bool_value: false } - } - test { - name: "list_elem_exists_error" - expr: "[1, 2, 3].exists(e, e / 0 == 17)" - eval_error: { - errors: { message: "divide by zero" } - } - } - test { - name: "list_empty" - expr: "[].exists(e, e == 2)" - value: { bool_value: false } - } - test { - name: "map_key" - expr: "{'key1':1, 'key2':2}.exists(k, k == 'key2')" - value: { bool_value: true } - } - test { - name: "not_map_key" - expr: "!{'key1':1, 'key2':2}.exists(k, k == 'key3')" - value: { bool_value: true } - } - test { - name: "map_key_type_shortcircuit" - description: "Exists filter is true for the second key" - expr: "{'key':1, 1:21}.exists(k, k != 2)" - value: { bool_value: true } - } - test { - name: "map_key_type_exhaustive" - description: "Exists filter is never true, but heterogeneous equality ensures the result is false." - expr: "!{'key':1, 1:42}.exists(k, k == 2)" - value: { bool_value: true } - } -} -section { - name: "all" - description: "Tests for the .all() macro, which is equivalent to joining the evaluated elements with logical-AND." - test { - name: "list_elem_all_true" - expr: "[1, 2, 3].all(e, e > 0)" - value: { bool_value: true } - } - test { - name: "list_elem_some_true" - expr: "[1, 2, 3].all(e, e == 2)" - value: { bool_value: false } - } - test { - name: "list_elem_none_true" - expr: "[1, 2, 3].all(e, e == 17)" - value: { bool_value: false } - } - test { - name: "list_elem_type_shortcircuit" - expr: "[1, 'foo', 3].all(e, e == 1)" - value: { bool_value: false } - } - test { - name: "list_elem_type_exhaustive" - expr: "[1, 'foo', 3].all(e, e % 2 == 1)" - eval_error: { - errors: { message: "no_such_overload" } - } - } - test { - name: "list_elem_error_shortcircuit" - expr: "[1, 2, 3].all(e, 6 / (2 - e) == 6)" - value: { bool_value: false } - } - test { - name: "list_elem_error_exhaustive" - expr: "[1, 2, 3].all(e, e / 0 != 17)" - eval_error: { - errors: { message: "divide by zero" } - } - } - test { - name: "list_empty" - expr: "[].all(e, e > 0)" - value: { bool_value: true } - } - test { - name: "map_key" - expr: "{'key1':1, 'key2':2}.all(k, k == 'key2')" - value: { bool_value: false } - } -} -section { - name: "exists_one" - description: "Tests for exists_one() macro. An expression 'L.exists_one(I, E)' is equivalent to 'size(L.filter(I, E)) == 1'." - test { - name: "list_empty" - expr: "[].exists_one(a, a == 7)" - value: { bool_value: false } - } - test { - name: "list_one_true" - expr: "[7].exists_one(a, a == 7)" - value: { bool_value: true } - } - test { - name: "list_one_false" - expr: "[8].exists_one(a, a == 7)" - value: { bool_value: false } - } - test { - name: "list_none" - expr: "[1, 2, 3].exists_one(x, x > 20)" - value: { bool_value: false } - } - test { - name: "list_one" - expr: "[6, 7, 8].exists_one(foo, foo % 5 == 2)" - value: { bool_value: true } - } - test { - name: "list_many" - expr: "[0, 1, 2, 3, 4].exists_one(n, n % 2 == 1)" - value: { bool_value: false } - } - test { - name: "list_all" - expr: "['foal', 'foo', 'four'].exists_one(n, n.startsWith('fo'))" - value: { bool_value: false } - } - test { - name: "list_no_shortcircuit" - description: "Errors invalidate everything, even if already false." - expr: "[3, 2, 1, 0].exists_one(n, 12 / n > 1)" - eval_error { - errors: { message: "divide by zero" } - } - } - test { - name: "map_one" - expr: "{6: 'six', 7: 'seven', 8: 'eight'}.exists_one(foo, foo % 5 == 2)" - value: { bool_value: true } - } -} -section { - name: "map" - description: "Tests for map() macro." - test { - name: "list_empty" - expr: "[].map(n, n / 2)" - value: { list_value: {} } - } - test { - name: "list_one" - expr: "[3].map(n, n * n)" - value: { list_value { - values: { int64_value: 9 } - } - } - } - test { - name: "list_many" - expr: "[2, 4, 6].map(n, n / 2)" - value: { list_value { - values: { int64_value: 1 } - values: { int64_value: 2 } - values: { int64_value: 3 } - } - } - } - test { - name: "list_error" - expr: "[2, 1, 0].map(n, 4 / n)" - eval_error { - errors: { message: "divide by zero" } - } - } - test { - name: "map_extract_keys" - expr: "{'John': 'smart'}.map(key, key) == ['John']" - value: { bool_value: true } - } -} -section { - name: "filter" - description: "Tests for filter() macro." - test { - name: "list_empty" - expr: "[].filter(n, n % 2 == 0)" - value: { list_value {} } - } - test { - name: "list_one_true" - expr: "[2].filter(n, n == 2)" - value: { list_value { - values: { int64_value: 2 } - } - } - } - test { - name: "list_one_false" - expr: "[1].filter(n, n > 3)" - value: { list_value {} } - } - test { - name: "list_none" - expr: "[1, 2, 3].filter(e, e > 3)" - value: { list_value {} } - } - test { - name: "list_some" - expr: "[0, 1, 2, 3, 4].filter(x, x % 2 == 1)" - value: { list_value { - values: { int64_value: 1 } - values: { int64_value: 3 } - } - } - } - test { - name: "list_all" - expr: "[1, 2, 3].filter(n, n > 0)" - value: { list_value { - values: { int64_value: 1 } - values: { int64_value: 2 } - values: { int64_value: 3 } - } - } - } - test { - name: "list_no_shortcircuit" - expr: "[3, 2, 1, 0].filter(n, 12 / n > 4)" - eval_error { - errors: { message: "divide by zero" } - } - } - test { - name: "map_filter_keys" - expr: "{'John': 'smart', 'Paul': 'cute', 'George': 'quiet', 'Ringo': 'funny'}.filter(key, key == 'Ringo') == ['Ringo']" - value: { bool_value: true } - } -} -section { - name: "nested" - description: "Tests with nested macros." - test { - name: "filter_all" - expr: "['signer'].filter(signer, ['artifact'].all(artifact, true))" - value: { list_value { - values: { string_value: "signer" } - } - } - } - test { - name: "all_all" - expr: "['signer'].all(signer, ['artifact'].all(artifact, true))" - value: { bool_value: true } - } -} diff --git a/tests/simple/testdata/macros2.textproto b/tests/simple/testdata/macros2.textproto deleted file mode 100644 index a3f93011..00000000 --- a/tests/simple/testdata/macros2.textproto +++ /dev/null @@ -1,354 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: google.api.expr.test.v1.SimpleTestFile - -name: "macros2" -description: "Tests for CEL comprehensions v2" -section { - name: "exists" - description: "Tests for the .exists() macro, which is equivalent to joining the evaluated elements with logical-OR." - test { - name: "list_elem_all_true" - expr: "[1, 2, 3].exists(i, v, i > -1 && v > 0)" - value: { bool_value: true } - } - test { - name: "list_elem_some_true" - expr: "[1, 2, 3].exists(i, v, i == 1 && v == 2)" - value: { bool_value: true } - } - test { - name: "list_elem_none_true" - expr: "[1, 2, 3].exists(i, v, i > 2 && v > 3)" - value: { bool_value: false } - } - test { - name: "list_elem_type_shortcircuit" - expr: "[1, 'foo', 3].exists(i, v, i == 1 && v != '1')" - value: { bool_value: true } - } - test { - name: "list_elem_type_exhaustive" - expr: "[1, 'foo', 3].exists(i, v, i == 3 || v == '10')" - value: { bool_value: false } - } - test { - name: "list_elem_exists_error" - expr: "[1, 2, 3].exists(i, v, v / i == 17)" - eval_error: { - errors: { message: "divide by zero" } - } - } - test { - name: "list_empty" - expr: "[].exists(i, v, i == 0 || v == 2)" - value: { bool_value: false } - } - test { - name: "map_key" - expr: "{'key1':1, 'key2':2}.exists(k, v, k == 'key2' && v == 2)" - value: { bool_value: true } - } - test { - name: "not_map_key" - expr: "!{'key1':1, 'key2':2}.exists(k, v, k == 'key3' || v == 3)" - value: { bool_value: true } - } - test { - name: "map_key_type_shortcircuit" - expr: "{'key':1, 1:21}.exists(k, v, k != 2 && v != 22)" - value: { bool_value: true } - } - test { - name: "map_key_type_exhaustive" - expr: "!{'key':1, 1:42}.exists(k, v, k == 2 && v == 43)" - value: { bool_value: true } - } -} -section { - name: "all" - description: "Tests for the .all() macro, which is equivalent to joining the evaluated elements with logical-AND." - test { - name: "list_elem_all_true" - expr: "[1, 2, 3].all(i, v, i > -1 && v > 0)" - value: { bool_value: true } - } - test { - name: "list_elem_some_true" - expr: "[1, 2, 3].all(i, v, i == 1 && v == 2)" - value: { bool_value: false } - } - test { - name: "list_elem_none_true" - expr: "[1, 2, 3].all(i, v, i == 3 || v == 4)" - value: { bool_value: false } - } - test { - name: "list_elem_type_shortcircuit" - expr: "[1, 'foo', 3].all(i, v, i == 0 || v == 1)" - value: { bool_value: false } - } - test { - name: "list_elem_type_exhaustive" - expr: "[0, 'foo', 3].all(i, v, v % 2 == i)" - value: { bool_value: false } - } - test { - name: "list_elem_type_error_exhaustive" - expr: "[0, 'foo', 5].all(i, v, v % 3 == i)" - eval_error: { - errors: { message: "no_such_overload" } - } - } - test { - name: "list_elem_error_shortcircuit" - expr: "[1, 2, 3].all(i, v, 6 / (2 - v) == i)" - value: { bool_value: false } - } - test { - name: "list_elem_error_exhaustive" - expr: "[1, 2, 3].all(i, v, v / i != 17)" - eval_error: { - errors: { message: "divide by zero" } - } - } - test { - name: "list_empty" - expr: "[].all(i, v, i > -1 || v > 0)" - value: { bool_value: true } - } - test { - name: "map_key" - expr: "{'key1':1, 'key2':2}.all(k, v, k == 'key2' && v == 2)" - value: { bool_value: false } - } -} -section { - name: "existsOne" - description: "Tests for existsOne() macro. An expression 'L.existsOne(I, E)' is equivalent to 'size(L.filter(I, E)) == 1'." - test { - name: "list_empty" - expr: "[].existsOne(i, v, i == 3 || v == 7)" - value: { bool_value: false } - } - test { - name: "list_one_true" - expr: "[7].existsOne(i, v, i == 0 && v == 7)" - value: { bool_value: true } - } - test { - name: "list_one_false" - expr: "[8].existsOne(i, v, i == 0 && v == 7)" - value: { bool_value: false } - } - test { - name: "list_none" - expr: "[1, 2, 3].existsOne(i, v, i > 2 || v > 3)" - value: { bool_value: false } - } - test { - name: "list_one" - expr: "[5, 7, 8].existsOne(i, v, v % 5 == i)" - value: { bool_value: true } - } - test { - name: "list_many" - expr: "[0, 1, 2, 3, 4].existsOne(i, v, v % 2 == i)" - value: { bool_value: false } - } - test { - name: "list_all" - expr: "['foal', 'foo', 'four'].existsOne(i, v, i > -1 && v.startsWith('fo'))" - value: { bool_value: false } - } - test { - name: "list_no_shortcircuit" - expr: "[3, 2, 1, 0].existsOne(i, v, v / i > 1)" - eval_error { - errors: { message: "divide by zero" } - } - } - test { - name: "map_one" - expr: "{6: 'six', 7: 'seven', 8: 'eight'}.existsOne(k, v, k % 5 == 2 && v == 'seven')" - value: { bool_value: true } - } -} -section { - name: "transformList" - description: "Tests for transformList() macro." - test { - name: "empty" - expr: "[].transformList(i, v, i / v)" - value: { list_value: {} } - } - test { - name: "empty_filter" - expr: "[].transformList(i, v, i > v, i / v)" - value: { list_value: {} } - } - test { - name: "one" - expr: "[3].transformList(i, v, v * v + i)" - value: { list_value { - values: { int64_value: 9 } - } - } - } - test { - name: "one_filter" - expr: "[3].transformList(i, v, i == 0 && v == 3, v * v + i)" - value: { list_value { - values: { int64_value: 9 } - } - } - } - test { - name: "many" - expr: "[2, 4, 6].transformList(i, v, v / 2 + i)" - value: { list_value { - values: { int64_value: 1 } - values: { int64_value: 3 } - values: { int64_value: 5 } - } - } - } - test { - name: "many_filter" - expr: "[2, 4, 6].transformList(i, v, i != 1 && v != 4, v / 2 + i)" - value: { list_value { - values: { int64_value: 1 } - values: { int64_value: 5 } - } - } - } - test { - name: "error" - expr: "[2, 1, 0].transformList(i, v, v / i)" - eval_error { - errors: { message: "divide by zero" } - } - } - test { - name: "error_filter" - expr: "[2, 1, 0].transformList(i, v, v / i > 0, v)" - eval_error { - errors: { message: "divide by zero" } - } - } -} -section { - name: "transformMap" - description: "Tests for transformMap() macro." - test { - name: "empty" - expr: "{}.transformMap(k, v, k + v)" - value: { map_value: {} } - } - test { - name: "empty_filter" - expr: "{}.transformMap(k, v, k == 'foo' && v == 'bar', k + v)" - value: { map_value: {} } - } - test { - name: "one" - expr: "{'foo': 'bar'}.transformMap(k, v, k + v)" - value: { - map_value: { - entries: { - key: { - string_value: "foo" - } - value: { - string_value: "foobar" - } - } - } - } - } - test { - name: "one_filter" - expr: "{'foo': 'bar'}.transformMap(k, v, k == 'foo' && v == 'bar', k + v)" - value: { - map_value: { - entries: { - key: { - string_value: "foo" - } - value: { - string_value: "foobar" - } - } - } - } - } - test { - name: "many" - expr: "{'foo': 'bar', 'baz': 'bux', 'hello': 'world'}.transformMap(k, v, k + v)" - value: { - map_value: { - entries: { - key: { - string_value: "foo" - } - value: { - string_value: "foobar" - } - } - entries: { - key: { - string_value: "baz" - } - value: { - string_value: "bazbux" - } - } - entries: { - key: { - string_value: "hello" - } - value: { - string_value: "helloworld" - } - } - } - } - } - test { - name: "many_filter" - expr: "{'foo': 'bar', 'baz': 'bux', 'hello': 'world'}.transformMap(k, v, k != 'baz' && v != 'bux', k + v)" - value: { - map_value: { - entries: { - key: { - string_value: "foo" - } - value: { - string_value: "foobar" - } - } - entries: { - key: { - string_value: "hello" - } - value: { - string_value: "helloworld" - } - } - } - } - } - test { - name: "error" - expr: "{'foo': 2, 'bar': 1, 'baz': 0}.transformMap(k, v, 4 / v)" - eval_error { - errors: { message: "divide by zero" } - } - } - test { - name: "error_filter" - expr: "{'foo': 2, 'bar': 1, 'baz': 0}.transformMap(k, v, k == 'baz' && 4 / v == 0, v)" - eval_error { - errors: { message: "divide by zero" } - } - } -} \ No newline at end of file diff --git a/tests/simple/testdata/math_ext.textproto b/tests/simple/testdata/math_ext.textproto deleted file mode 100644 index 333d9bd6..00000000 --- a/tests/simple/testdata/math_ext.textproto +++ /dev/null @@ -1,1266 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: google.api.expr.test.v1.SimpleTestFile - -name: "math_ext" -description: "Tests for the math extension library." -section: { - name: "greatest_int_result" - test: { - name: "unary_negative" - expr: "math.greatest(-5)" - value: { - int64_value: -5 - } - } - test: { - name: "unary_positive" - expr: "math.greatest(5)" - value: { - int64_value: 5 - } - } - test: { - name: "binary_same_args" - expr: "math.greatest(1, 1)" - value: { - int64_value: 1 - } - } - test: { - name: "binary_with_decimal" - expr: "math.greatest(1, 1.0) == 1" - } - test: { - name: "binary_with_uint" - expr: "math.greatest(1, 1u) == 1" - } - test: { - name: "binary_first_arg_greater" - expr: "math.greatest(3, -3)" - value: { - int64_value: 3 - } - } - test: { - name: "binary_second_arg_greater" - expr: "math.greatest(-7, 5)" - value: { - int64_value: 5 - } - } - test: { - name: "binary_first_arg_int_max" - expr: "math.greatest(9223372036854775807, 1)" - value: { - int64_value: 9223372036854775807 - } - } - test: { - name: "binary_second_arg_int_max" - expr: "math.greatest(1, 9223372036854775807)" - value: { - int64_value: 9223372036854775807 - } - } - test: { - name: "binary_first_arg_int_min" - expr: "math.greatest(-9223372036854775808, 1)" - value: { - int64_value: 1 - } - } - test: { - name: "binary_second_arg_int_min" - expr: "math.greatest(1, -9223372036854775808)" - value: { - int64_value: 1 - } - } - test: { - name: "ternary_same_args" - expr: "math.greatest(1, 1, 1) == 1" - } - test: { - name: "ternary_with_decimal" - expr: "math.greatest(1, 1.0, 1.0) == 1" - } - test: { - name: "ternary_with_uint" - expr: "math.greatest(1, 1u, 1u) == 1" - } - test: { - name: "ternary_first_arg_greatest" - expr: "math.greatest(10, 1, 3) == 10" - } - test: { - name: "ternary_third_arg_greatest" - expr: "math.greatest(1, 3, 10) == 10" - } - test: { - name: "ternary_with_negatives" - expr: "math.greatest(-1, -2, -3) == -1" - } - test: { - name: "ternary_int_max" - expr: "math.greatest(9223372036854775807, 1, 5) == 9223372036854775807" - } - test: { - name: "ternary_int_min" - expr: "math.greatest(-9223372036854775807, -1, -5) == -1" - } - test: { - name: "quaternary_mixed" - expr: "math.greatest(5.4, 10, 3u, -5.0, 9223372036854775807) == 9223372036854775807" - } - test: { - name: "quaternary_mixed_array" - expr: "math.greatest([5.4, 10, 3u, -5.0, 3.5]) == 10" - } - test: { - name: "quaternary_mixed_dyn_array" - expr: "math.greatest([dyn(5.4), dyn(10), dyn(3u), dyn(-5.0), dyn(3.5)]) == 10" - } -} - -section: { - name: "greatest_double_result" - test: { - name: "unary_negative" - expr: "math.greatest(-5.0)" - value: { - double_value: -5.0 - } - } - test: { - name: "unary_positive" - expr: "math.greatest(5.0)" - value: { - double_value: 5.0 - } - } - test: { - name: "binary_same_args" - expr: "math.greatest(1.0, 1.0)" - value: { - double_value: 1.0 - } - } - test: { - name: "binary_with_int" - expr: "math.greatest(1.0, 1) == 1.0" - } - test: { - name: "binary_with_uint" - expr: "math.greatest(1.0, 1u) == 1.0" - } - test: { - name: "binary_first_arg_greater" - expr: "math.greatest(5.0, -7.0)" - value: { - double_value: 5.0 - } - } - test: { - name: "binary_second_arg_greater" - expr: "math.greatest(-3.0, 3.0)" - value: { - double_value: 3.0 - } - } - test: { - name: "binary_first_arg_double_max" - expr: "math.greatest(1.797693e308, 1)" - value: { - double_value: 1.797693e308 - } - } - test: { - name: "binary_second_arg_double_max" - expr: "math.greatest(1, 1.797693e308)" - value: { - double_value: 1.797693e308 - } - } - test: { - name: "binary_first_arg_double_min" - expr: "math.greatest(-1.797693e308, 1.5)" - value: { - double_value: 1.5 - } - } - test: { - name: "binary_second_arg_double_min" - expr: "math.greatest(1.5, -1.797693e308)" - value: { - double_value: 1.5 - } - } - test: { - name: "ternary_same_args" - expr: "math.greatest(1.0, 1.0, 1.0) == 1.0" - } - test: { - name: "ternary_with_int" - expr: "math.greatest(1.0, 1, 1) == 1.0" - } - test: { - name: "ternary_with_uint" - expr: "math.greatest(1.0, 1u, 1u) == 1.0" - } - test: { - name: "ternary_first_arg_greatest" - expr: "math.greatest(10.5, 1.5, 3.5) == 10.5" - } - test: { - name: "ternary_third_arg_greatest" - expr: "math.greatest(1.5, 3.5, 10.5) == 10.5" - } - test: { - name: "ternary_with_negatives" - expr: "math.greatest(-1.5, -2.5, -3.5) == -1.5" - } - test: { - name: "ternary_double_max" - expr: "math.greatest(1.797693e308, 1, 5) == 1.797693e308" - } - test: { - name: "ternary_double_min" - expr: "math.greatest(-1.797693e308, -1, -5) == -1" - } - test: { - name: "quaternary_mixed" - expr: "math.greatest(5.4, 10, 3u, -5.0, 1.797693e308) == 1.797693e308" - } - test: { - name: "quaternary_mixed_array" - expr: "math.greatest([5.4, 10.5, 3u, -5.0, 3.5]) == 10.5" - } - test: { - name: "quaternary_mixed_dyn_array" - expr: "math.greatest([dyn(5.4), dyn(10.5), dyn(3u), dyn(-5.0), dyn(3.5)]) == 10.5" - } -} - -section: { - name: "greatest_uint_result" - test: { - name: "unary" - expr: "math.greatest(5u)" - value: { - uint64_value: 5 - } - } - test: { - name: "binary_same_args" - expr: "math.greatest(1u, 1u)" - value: { - uint64_value: 1 - } - } - test: { - name: "binary_with_decimal" - expr: "math.greatest(1u, 1.0) == 1" - } - test: { - name: "binary_with_int" - expr: "math.greatest(1u, 1) == 1u" - } - test: { - name: "binary_first_arg_greater" - expr: "math.greatest(5u, -7)" - value: { - uint64_value: 5 - } - } - test: { - name: "binary_second_arg_greater" - expr: "math.greatest(-3, 3u)" - value: { - uint64_value: 3 - } - } - test: { - name: "binary_first_arg_uint_max" - expr: "math.greatest(18446744073709551615u, 1u)" - value: { - uint64_value: 18446744073709551615 - } - } - test: { - name: "binary_second_arg_uint_max" - expr: "math.greatest(1u, 18446744073709551615u)" - value: { - uint64_value: 18446744073709551615 - } - } - test: { - name: "ternary_same_args" - expr: "math.greatest(1u, 1u, 1u) == 1u" - } - test: { - name: "ternary_with_decimal" - expr: "math.greatest(1u, 1.0, 1.0) == 1u" - } - test: { - name: "ternary_with_int" - expr: "math.greatest(1u, 1, 1) == 1u" - } - test: { - name: "ternary_first_arg_greatest" - expr: "math.greatest(10u, 1u, 3u) == 10u" - } - test: { - name: "ternary_third_arg_greatest" - expr: "math.greatest(1u, 3u, 10u) == 10u" - } - test: { - name: "ternary_int_max" - expr: "math.greatest(18446744073709551615u, 1u, 5u) == 18446744073709551615u" - } - test: { - name: "quaternary_mixed" - expr: "math.greatest(5.4, 10, 3u, -5.0, 18446744073709551615u) == 18446744073709551615u" - } - test: { - name: "quaternary_mixed_array" - expr: "math.greatest([5.4, 10u, 3u, -5.0, 3.5]) == 10u" - } - test: { - name: "quaternary_mixed_dyn_array" - expr: "math.greatest([dyn(5.4), dyn(10u), dyn(3u), dyn(-5.0), dyn(3.5)]) == 10u" - } -} - -section: { - name: "least_int_result" - test: { - name: "unary_negative" - expr: "math.least(-5)" - value: { - int64_value: -5 - } - } - test: { - name: "unary_positive" - expr: "math.least(5)" - value: { - int64_value: 5 - } - } - test: { - name: "binary_same_args" - expr: "math.least(1, 1)" - value: { - int64_value: 1 - } - } - test: { - name: "binary_with_decimal" - expr: "math.least(1, 1.0) == 1" - } - test: { - name: "binary_with_uint" - expr: "math.least(1, 1u) == 1" - } - test: { - name: "binary_first_arg_least" - expr: "math.least(-3, 3)" - value: { - int64_value: -3 - } - } - test: { - name: "binary_second_arg_least" - expr: "math.least(5, -7)" - value: { - int64_value: -7 - } - } - test: { - name: "binary_first_arg_int_max" - expr: "math.least(9223372036854775807, 1)" - value: { - int64_value: 1 - } - } - test: { - name: "binary_second_arg_int_max" - expr: "math.least(1, 9223372036854775807)" - value: { - int64_value: 1 - } - } - test: { - name: "binary_first_arg_int_min" - expr: "math.least(-9223372036854775808, 1)" - value: { - int64_value: -9223372036854775808 - } - } - test: { - name: "binary_second_arg_int_min" - expr: "math.least(1, -9223372036854775808)" - value: { - int64_value: -9223372036854775808 - } - } - test: { - name: "ternary_same_args" - expr: "math.least(1, 1, 1) == 1" - } - test: { - name: "ternary_with_decimal" - expr: "math.least(1, 1.0, 1.0) == 1" - } - test: { - name: "ternary_with_uint" - expr: "math.least(1, 1u, 1u) == 1" - } - test: { - name: "ternary_first_arg_least" - expr: "math.least(0, 1, 3) == 0" - } - test: { - name: "ternary_third_arg_least" - expr: "math.least(1, 3, 0) == 0" - } - test: { - name: "ternary_with_negatives" - expr: "math.least(-1, -2, -3) == -3" - } - test: { - name: "ternary_int_max" - expr: "math.least(9223372036854775807, 1, 5) == 1" - } - test: { - name: "ternary_int_min" - expr: "math.least(-9223372036854775808, -1, -5) == -9223372036854775808" - } - test: { - name: "quaternary_mixed" - expr: "math.least(5.4, 10, 3u, -5.0, 9223372036854775807) == -5.0" - } - test: { - name: "quaternary_mixed_array" - expr: "math.least([5.4, 10, 3u, -5.0, 3.5]) == -5.0" - } - test: { - name: "quaternary_mixed_dyn_array" - expr: "math.least([dyn(5.4), dyn(10), dyn(3u), dyn(-5.0), dyn(3.5)]) == -5.0" - } -} - -section: { - name: "least_double_result" - test: { - name: "unary_negative" - expr: "math.least(-5.5)" - value: { - double_value: -5.5 - } - } - test: { - name: "unary_positive" - expr: "math.least(5.5)" - value: { - double_value: 5.5 - } - } - test: { - name: "binary_same_args" - expr: "math.least(1.5, 1.5)" - value: { - double_value: 1.5 - } - } - test: { - name: "binary_with_int" - expr: "math.least(1.0, 1) == 1" - } - test: { - name: "binary_with_uint" - expr: "math.least(1, 1u) == 1" - } - test: { - name: "binary_first_arg_least" - expr: "math.least(-3.5, 3.5)" - value: { - double_value: -3.5 - } - } - test: { - name: "binary_second_arg_least" - expr: "math.least(5.5, -7.5)" - value: { - double_value: -7.5 - } - } - test: { - name: "binary_first_arg_double_max" - expr: "math.least(1.797693e308, 1.5)" - value: { - double_value: 1.5 - } - } - test: { - name: "binary_second_arg_double_max" - expr: "math.least(1.5, 1.797693e308)" - value: { - double_value: 1.5 - } - } - test: { - name: "binary_first_arg_double_min" - expr: "math.least(-1.797693e308, 1.5)" - value: { - double_value: -1.797693e308 - } - } - test: { - name: "binary_second_arg_double_min" - expr: "math.least(1.5, -1.797693e308)" - value: { - double_value: -1.797693e308 - } - } - test: { - name: "ternary_same_args" - expr: "math.least(1.5, 1.5, 1.5) == 1.5" - } - test: { - name: "ternary_with_int" - expr: "math.least(1.0, 1, 1) == 1.0" - } - test: { - name: "ternary_with_uint" - expr: "math.least(1.0, 1u, 1u) == 1" - } - test: { - name: "ternary_first_arg_least" - expr: "math.least(0.5, 1.5, 3.5) == 0.5" - } - test: { - name: "ternary_third_arg_least" - expr: "math.least(1.5, 3.5, 0.5) == 0.5" - } - test: { - name: "ternary_with_negatives" - expr: "math.least(-1.5, -2.5, -3.5) == -3.5" - } - test: { - name: "ternary_double_max" - expr: "math.least(1.797693e308, 1, 5) == 1" - } - test: { - name: "ternary_double_min" - expr: "math.least(-1.797693e308, -1, -5) == -1.797693e308" - } - test: { - name: "quaternary_mixed" - expr: "math.least(5.4, 10, 3u, -5.0, 1.797693e308) == -5.0" - } - test: { - name: "quaternary_mixed_array" - expr: "math.least([5.4, 10.5, 3u, -5.0, 3.5]) == -5.0" - } - test: { - name: "quaternary_mixed_dyn_array" - expr: "math.least([dyn(5.4), dyn(10.5), dyn(3u), dyn(-5.0), dyn(3.5)]) == -5.0" - } -} - -section: { - name: "least_uint_result" - test: { - name: "unary" - expr: "math.least(5u)" - value: { - uint64_value: 5 - } - } - test: { - name: "binary_same_args" - expr: "math.least(1u, 1u)" - value: { - uint64_value: 1 - } - } - test: { - name: "binary_with_decimal" - expr: "math.least(1u, 1.0) == 1u" - } - test: { - name: "binary_with_int" - expr: "math.least(1u, 1) == 1u" - } - test: { - name: "binary_first_arg_least" - expr: "math.least(1u, 3u)" - value: { - uint64_value: 1 - } - } - test: { - name: "binary_second_arg_least" - expr: "math.least(5u, 2u)" - value: { - uint64_value: 2 - } - } - test: { - name: "binary_first_arg_uint_max" - expr: "math.least(18446744073709551615u, 1u)" - value: { - uint64_value: 1 - } - } - test: { - name: "binary_second_arg_uint_max" - expr: "math.least(1u, 18446744073709551615u)" - value: { - uint64_value: 1 - } - } - test: { - name: "ternary_same_args" - expr: "math.least(1u, 1u, 1u) == 1u" - } - test: { - name: "ternary_with_decimal" - expr: "math.least(1u, 1.0, 1.0) == 1u" - } - test: { - name: "ternary_with_int" - expr: "math.least(1u, 1, 1) == 1u" - } - test: { - name: "ternary_first_arg_least" - expr: "math.least(1u, 10u, 3u) == 1u" - } - test: { - name: "ternary_third_arg_least" - expr: "math.least(10u, 3u, 1u) == 1u" - } - test: { - name: "ternary_uint_max" - expr: "math.least(18446744073709551615u, 1u, 5u) == 1u" - } - test: { - name: "quaternary_mixed" - expr: "math.least(5.4, 10, 3u, 1u, 18446744073709551615u) == 1u" - } - test: { - name: "quaternary_mixed_array" - expr: "math.least([5.4, 10u, 3u, 1u, 3.5]) == 1u" - } - test: { - name: "quaternary_mixed_dyn_array" - expr: "math.least([dyn(5.4), dyn(10u), dyn(3u), dyn(1u), dyn(3.5)]) == 1u" - } -} - -section: { - name: "ceil" - test: { - name: "negative" - expr: "math.ceil(-1.2)" - value: { - double_value: -1.0 - } - } - test: { - name: "positive" - expr: "math.ceil(1.2)" - value: { - double_value: 2.0 - } - } - test: { - name: "dyn_error" - expr: "math.ceil(dyn(1))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "floor" - test: { - name: "negative" - expr: "math.floor(-1.2)" - value: { - double_value: -2.0 - } - } - test: { - name: "positive" - expr: "math.floor(1.2)" - value: { - double_value: 1.0 - } - } - test: { - name: "dyn_error" - expr: "math.floor(dyn(1))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "round" - test: { - name: "negative_down" - expr: "math.round(-1.6)" - value: { - double_value: -2.0 - } - } - test: { - name: "negative_up" - expr: "math.round(-1.4)" - value: { - double_value: -1.0 - } - } - test: { - name: "negative_mid" - expr: "math.round(-1.5)" - value: { - double_value: -2.0 - } - } - test: { - name: "positive_down" - expr: "math.round(1.2)" - value: { - double_value: 1.0 - } - } - test: { - name: "positive_up" - expr: "math.round(1.5)" - value: { - double_value: 2.0 - } - } - test: { - name: "nan" - expr: "math.isNaN(math.round(0.0/0.0))" - } - test: { - name: "dyn_error" - expr: "math.round(dyn(1))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "trunc" - test: { - name: "negative" - expr: "math.trunc(-1.2)" - value: { - double_value: -1.0 - } - } - test: { - name: "positive" - expr: "math.trunc(1.2)" - value: { - double_value: 1.0 - } - } - test: { - name: "nan" - expr: "math.isNaN(math.trunc(0.0/0.0))" - } - test: { - name: "dyn_error" - expr: "math.trunc(dyn(1))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "abs" - test: { - name: "uint" - expr: "math.abs(1u)" - value: { - uint64_value: 1 - } - } - test: { - name: "positive_int" - expr: "math.abs(1)" - value: { - int64_value: 1 - } - } - test: { - name: "negative_int" - expr: "math.abs(-11)" - value: { - int64_value: 11 - } - } - test: { - name: "positive_double" - expr: "math.abs(1.5)" - value: { - double_value: 1.5 - } - } - test: { - name: "negative_double" - expr: "math.abs(-11.5)" - value: { - double_value: 11.5 - } - } - test: { - name: "int_overflow" - expr: "math.abs(-9223372036854775808)" - eval_error: { - errors: { - message: "overflow" - } - } - } -} - -section: { - name: "sign" - test: { - name: "positive_uint" - expr: "math.sign(100u)" - value: { - uint64_value: 1 - } - } - test: { - name: "zero_uint" - expr: "math.sign(0u)" - value: { - uint64_value: 0 - } - } - test: { - name: "positive_int" - expr: "math.sign(100)" - value: { - int64_value: 1 - } - } - test: { - name: "negative_int" - expr: "math.sign(-11)" - value: { - int64_value: -1 - } - } - test: { - name: "zero_int" - expr: "math.sign(0)" - value: { - int64_value: 0 - } - } - test: { - name: "positive_double" - expr: "math.sign(100.5)" - value: { - double_value: 1.0 - } - } - test: { - name: "negative_double" - expr: "math.sign(-32.0)" - value: { - double_value: -1.0 - } - } - test: { - name: "zero_double" - expr: "math.sign(0.0)" - value: { - double_value: 0.0 - } - } - test: { - name: "dyn_error" - expr: "math.sign(dyn(true))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "isNaN" - test: { - name: "true" - expr: "math.isNaN(0.0/0.0)" - } - test: { - name: "false" - expr: "!math.isNaN(1.0/0.0)" - } - test: { - name: "dyn_error" - expr: "math.isNaN(dyn(true))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "isInf" - test: { - name: "true" - expr: "math.isInf(1.0/0.0)" - } - test: { - name: "false" - expr: "!math.isInf(0.0/0.0)" - } - test: { - name: "dyn_error" - expr: "math.isInf(dyn(true))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "isFinite" - test: { - name: "true" - expr: "math.isFinite(1.0/1.5)" - } - test: { - name: "false_nan" - expr: "!math.isFinite(0.0/0.0)" - } - test: { - name: "false_inf" - expr: "!math.isFinite(-1.0/0.0)" - } - test: { - name: "dyn_error" - expr: "math.isFinite(dyn(true))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "bit_and" - test: { - name: "int_int_non_intersect" - expr: "math.bitAnd(1, 2)" - value: { - int64_value: 0 - } - } - test: { - name: "int_int_intersect" - expr: "math.bitAnd(1, 3)" - value: { - int64_value: 1 - } - } - test: { - name: "int_int_intersect_neg" - expr: "math.bitAnd(1, -1)" - value: { - int64_value: 1 - } - } - test: { - name: "uint_uint_non_intersect" - expr: "math.bitAnd(1u, 2u)" - value: { - uint64_value: 0 - } - } - test: { - name: "uint_uint_intersect" - expr: "math.bitAnd(1u, 3u)" - value: { - uint64_value: 1 - } - } - test: { - name: "int_dyn_error" - expr: "math.bitAnd(2u, dyn(''))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "bit_or" - test: { - name: "int_int_positive" - expr: "math.bitOr(1, 2)" - value: { - int64_value: 3 - } - } - test: { - name: "int_int_positive_negative" - expr: "math.bitOr(4, -2)" - value: { - int64_value: -2 - } - } - test: { - name: "uint_uint" - expr: "math.bitOr(1u, 4u)" - value: { - uint64_value: 5 - } - } - test: { - name: "dyn_int_error" - expr: "math.bitOr(dyn(1.2), 1)" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "bit_xor" - test: { - name: "int_int_positive" - expr: "math.bitXor(1, 3)" - value: { - int64_value: 2 - } - } - test: { - name: "int_int_positive_negative" - expr: "math.bitXor(4, -2)" - value: { - int64_value: -6 - } - } - test: { - name: "uint_uint" - expr: "math.bitXor(1u, 3u)" - value: { - uint64_value: 2 - } - } - test: { - name: "dyn_dyn_error" - expr: "math.bitXor(dyn([]), dyn([1]))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "bit_not" - test: { - name: "int_positive" - expr: "math.bitNot(1)" - value: { - int64_value: -2 - } - } - test: { - name: "int_negative" - expr: "math.bitNot(-1)" - value: { - int64_value: 0 - } - } - test: { - name: "int_zero" - expr: "math.bitNot(0)" - value: { - int64_value: -1 - } - } - test: { - name: "uint_positive" - expr: "math.bitNot(1u)" - value: { - uint64_value: 18446744073709551614 - } - } - test: { - name: "uint_zero" - expr: "math.bitNot(0u)" - value: { - uint64_value: 18446744073709551615 - } - } - test: { - name: "dyn_error" - expr: "math.bitNot(dyn(''))" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "bit_shift_left" - test: { - name: "int", - expr: "math.bitShiftLeft(1, 2)" - value: { - int64_value: 4 - } - } - test: { - name: "int_large_shift", - expr: "math.bitShiftLeft(1, 200)" - value: { - int64_value: 0 - } - } - test: { - name: "int_negative_large_shift", - expr: "math.bitShiftLeft(-1, 200)" - value: { - int64_value: 0 - } - } - test: { - name: "uint", - expr: "math.bitShiftLeft(1u, 2)" - value: { - uint64_value: 4 - } - } - test: { - name: "uint_large_shift", - expr: "math.bitShiftLeft(1u, 200)" - value: { - uint64_value: 0 - } - } - test: { - name: "bad_shift", - expr: "math.bitShiftLeft(1u, -1)" - eval_error: { - errors: { - message: "negative offset" - } - } - } - test: { - name: "dyn_int_error" - expr: "math.bitShiftLeft(dyn(4.3), 1)" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} - -section: { - name: "bit_shift_right" - test: { - name: "int", - expr: "math.bitShiftRight(1024, 2)" - value: { - int64_value: 256 - } - } - test: { - name: "int_large_shift", - expr: "math.bitShiftRight(1024, 64)" - value: { - int64_value: 0 - } - } - test: { - name: "int_negative", - expr: "math.bitShiftRight(-1024, 3)" - value: { - int64_value: 2305843009213693824 - } - } - test: { - name: "int_negative_large_shift", - expr: "math.bitShiftRight(-1024, 64)" - value: { - int64_value: 0 - } - } - test: { - name: "uint", - expr: "math.bitShiftRight(1024u, 2)" - value: { - uint64_value: 256 - } - } - test: { - name: "uint_large_shift", - expr: "math.bitShiftRight(1024u, 200)" - value: { - uint64_value: 0 - } - } - test: { - name: "bad_shift", - expr: "math.bitShiftRight(1u, -1)" - eval_error: { - errors: { - message: "negative offset" - } - } - } - test: { - name: "dyn_int_error" - expr: "math.bitShiftRight(dyn(b'123'), 1)" - eval_error: { - errors: { - message: "no such overload" - } - } - } -} diff --git a/tests/simple/testdata/namespace.textproto b/tests/simple/testdata/namespace.textproto deleted file mode 100644 index 4cacd1a9..00000000 --- a/tests/simple/testdata/namespace.textproto +++ /dev/null @@ -1,262 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: google.api.expr.test.v1.SimpleTestFile - -name: "namespace" -description: "Uses of qualified identifiers and namespaces." -section { - name: "qualified" - description: "Qualified variable lookups." - test { - name: "self_eval_qualified_lookup" - expr: "x.y" - value: { bool_value: true } - type_env: { - name: "x.y" - ident: { type: { primitive: BOOL } } - } - bindings: { - key: "x.y" - value: { value: { bool_value: true } } - } - } -} -section { - name: "namespace" - description: "Namespaced identifiers." - test { - name: "self_eval_container_lookup" - expr: "y" - container: "x" - type_env: { - name: "x.y" - ident: { type: { primitive: BOOL } } - } - type_env: { - name: "y" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "x.y" - value: { value: { bool_value: true } } - } - bindings: { - key: "y" - value: { value: { string_value: "false" } } - } - value: { bool_value: true } - } - test { - name: "self_eval_container_lookup_unchecked" - expr: "y" - container: "x" - type_env: { - name: "x.y" - ident: { type: { primitive: BOOL } } - } - type_env: { - name: "y" - ident: { type: { primitive: BOOL } } - } - bindings: { - key: "x.y" - value: { value: { bool_value: true } } - } - bindings: { - key: "y" - value: { value: { bool_value: false } } - } - disable_check: true ## ensure unchecked ASTs resolve the same as checked ASTs - value: { bool_value: true } - } -} -section { - name: "namespace_shadowing" - description: "Variable shadowing in comprehensions" - test { - name: "basic" - expr: "y" - container: "com.example" - type_env: { - name: "com.example.y" - ident: { type: { primitive: BOOL } } - } - type_env: { - name: "y" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "com.example.y" - value: { value: { bool_value: true } } - } - bindings: { - key: "y" - value: { value: { string_value: "string" } } - } - value: { bool_value: true } - } - test { - name: "disambiguation" - expr: ".y" - container: "com.example" - type_env: { - name: "com.example.y" - ident: { type: { primitive: STRING } } - } - type_env: { - name: "y" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "com.example.y" - value: { value: { string_value: "com.example.y" } } - } - bindings: { - key: "y" - value: { value: { string_value: "y" } } - } - value: { string_value: "y" } - } - test { - name: "comprehension_shadowing" - expr: "[0].exists(y, y == 0)" - container: "com.example" - type_env: { - name: "com.example.y" - ident: { type: { primitive: INT64 } } - } - bindings: { - key: "com.example.y" - value: { value: { int64_value: 42 } } - } - value: { bool_value: true } - } - test { - name: "comprehension_shadowing_disambiguation" - expr: "['compre'].exists(y, .y == 'y')" - container: "com.example" - type_env: { - name: "y" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "y" - value: { value: { string_value: "y" } } - } - value: { bool_value: true } - } - test { - name: "comprehension_shadowing_parse_only" - expr: "[0].exists(y, y == 0)" - container: "com.example" - type_env: { - name: "com.example.y" - ident: { type: { primitive: INT64 } } - } - bindings: { - key: "com.example.y" - value: { value: { int64_value: 42 } } - } - disable_check: true - value: { bool_value: true } - } - test { - name: "comprehension_shadowing_selector" - expr: "[{'z': 0}].exists(y, y.z == 0)" - type_env: { - name: "y.z" - ident: { type: { primitive: INT64 } } - } - bindings: { - key: "y.z" - value: { value: { int64_value: 42 } } - } - value: { bool_value: true } - } - test { - name: "comprehension_shadowing_selector_parse_only" - expr: "[{'z': 0}].exists(y, y.z == 0)" - type_env: { - name: "y.z" - ident: { type: { primitive: INT64 } } - } - bindings: { - key: "y.z" - value: { value: { int64_value: 42 } } - } - disable_check: true - value: { bool_value: true } - } - test { - name: "comprehension_shadowing_namespaced_selector" - expr: "[{'z': 0}].exists(y, y.z == 0)" - container: "com.example" - type_env: { - name: "com.example.y.z" - ident: { type: { primitive: INT64 } } - } - bindings: { - key: "com.example.y.z" - value: { value: { int64_value: 42 } } - } - value: { bool_value: true } - } - test { - name: "comprehension_shadowing_namespaced_selector_parse_only" - expr: "[{'z': 0}].exists(y, y.z == 0)" - container: "com.example" - type_env: { - name: "com.example.y.z" - ident: { type: { primitive: INT64 } } - } - bindings: { - key: "com.example.y.z" - value: { value: { int64_value: 42 } } - } - disable_check: true - value: { bool_value: true } - } - test { - name: "comprehension_shadowing_namespaced_selector_disambiguation" - expr: "[{'z': 'compre'}].exists(y, .y.z == 'y.z')" - container: "com.example" - type_env: { - name: "com.example.y.z" - ident: { type: { primitive: STRING } } - } - type_env: { - name: "y.z" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "com.example.y.z" - value: { value: { string_value: "com.example.y.z" } } - } - bindings: { - key: "y.z" - value: { value: { string_value: "y.z" } } - } - value: { bool_value: true } - } - test { - name: "comprehension_shadowing_nesting" - expr: "[1].exists(y, [0].exists(y, y == 0))" - container: "com.example" - type_env: { - name: "com.example.y" - ident: { type: { primitive: INT64 } } - } - type_env: { - name: "y" - ident: { type: { primitive: INT64 } } - } - bindings: { - key: "com.example.y" - value: { value: { int64_value: 42 } } - } - bindings: { - key: "y" - value: { value: { int64_value: 42 } } - } - value: { bool_value: true } - } -} diff --git a/tests/simple/testdata/network_ext.textproto b/tests/simple/testdata/network_ext.textproto deleted file mode 100644 index 8b5bbccc..00000000 --- a/tests/simple/testdata/network_ext.textproto +++ /dev/null @@ -1,420 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "network_ext" -description: "Conformance tests for IP address extensions in CEL" -section { - name: "ip_type" - description: "Tests for parsing and validating IP addresses" - test { - name: "parse_ipv4" - description: "Successfully parse a standard IPv4 address" - expr: "string(ip('192.168.0.1'))" - value: { string_value: "192.168.0.1" } - } - test { - name: "parse_invalid_ipv4" - description: "Fail to parse an invalid IPv4 address" - expr: "ip('192.168.0.1.0')" - eval_error: { - errors: { - message: "IP Address '192.168.0.1.0' parse error during conversion from string" - } - } - } - test { - name: "is_ip_valid_ipv4" - description: "isIP returns true for valid IPv4" - expr: "isIP('192.168.0.1')" - value: { bool_value: true } - } - test { - name: "is_ip_invalid_ipv4" - description: "isIP returns false for invalid IPv4" - expr: "isIP('192.168.0.1.0')" - value: { bool_value: false } - } - test { - name: "ip_is_canonical_valid_ipv4" - description: "ip.isCanonical returns true for valid IPv4" - expr: "ip.isCanonical('127.0.0.1')" - value: { bool_value: true } - } - test { - name: "ip_is_canonical_invalid_ipv4" - description: "ip.isCanonical errors on invalid address string" - expr: "ip.isCanonical('127.0.0.1.0')" - eval_error: { - errors: { - message: "IP Address '127.0.0.1.0' parse error during conversion from string" - } - } - } - test { - name: "ip_is_canonical_non_canonical_ipv6" - description: "IPv6 with uppercase letters is not canonical" - expr: "ip.isCanonical('2001:DB8::68')" - value: { bool_value: false } - } - test { - name: "parse_ipv6" - expr: "string(ip('2001:db8::68'))" - value: { string_value: "2001:db8::68" } - } - test { - name: "parse_invalid_ipv6" - expr: "ip('2001:db8:::68')" - eval_error: { - errors: { - message: "IP Address '2001:db8:::68' parse error" - } - } - } - test { - name: "parse_invalid_ipv6_with_zone" - expr: "ip('fe80::1%en0')" - eval_error: { - errors: { - message: "IP Address with zone value is not allowed" - } - } - } - test { - name: "parse_invalid_ipv4_in_ipv6" - expr: "ip('::ffff:192.168.0.1')" - eval_error: { - errors: { - message: "IPv4-mapped IPv6 address is not allowed" - } - } - } - test { - name: "ip_to_string" - description: "Converting an IP address back to a string" - expr: "string(ip('192.168.0.1'))" - value: { string_value: "192.168.0.1" } - } - test { - name: "ip_type" - description: "Check the type of the IP object" - expr: "type(ip('192.168.0.1')) == net.IP" - value: { bool_value: true } - } - test { - name: "is_ip_cidr_compile_error" - description: "isIP should not accept a CIDR type" - expr: "isIP(cidr('192.168.0.0/24'))" - disable_check: false - eval_error: { - errors: { - message: "found no matching overload for 'isIP' applied to '(net.CIDR)'" - } - } - } -} -section { - name: "ipv4" - description: "Tests for properties and methods of IPv4 addresses" - test { - name: "ipv4_family" - expr: "ip('192.168.0.1').family()" - value: { int64_value: 4 } - } - test { - name: "ipv4_is_unspecified_true" - expr: "ip('0.0.0.0').isUnspecified()" - value: { bool_value: true } - } - test { - name: "ipv4_is_unspecified_false" - expr: "ip('127.0.0.1').isUnspecified()" - value: { bool_value: false } - } - test { - name: "ipv4_is_loopback_true" - expr: "ip('127.0.0.1').isLoopback()" - value: { bool_value: true } - } - test { - name: "ipv4_is_loopback_false" - expr: "ip('1.2.3.4').isLoopback()" - value: { bool_value: false } - } - test { - name: "ipv4_is_global_unicast_true" - expr: "ip('192.168.0.1').isGlobalUnicast()" - value: { bool_value: true } - } - test { - name: "ipv4_is_global_unicast_false" - expr: "ip('255.255.255.255').isGlobalUnicast()" - value: { bool_value: false } - } - test { - name: "is_link_local_multicast_true" - expr: "ip('224.0.0.1').isLinkLocalMulticast()" - value: { bool_value: true } - } - test { - name: "is_link_local_multicast_false" - expr: "ip('224.0.1.1').isLinkLocalMulticast()" - value: { bool_value: false } - } - test { - name: "is_link_local_unicast_true" - expr: "ip('169.254.169.254').isLinkLocalUnicast()" - value: { bool_value: true } - } - test { - name: "is_link_local_unicast_false" - expr: "ip('192.168.0.1').isLinkLocalUnicast()" - value: { bool_value: false } - } - test { - name: "ipv4_equals" - expr: "ip('127.0.0.1') == ip('127.0.0.1')" - value: { bool_value: true } - } - test { - name: "ipv4_not_equals" - expr: "ip('127.0.0.1') == ip('10.0.0.1')" - value: { bool_value: false } - } - test { - name: "invalid_ipv4_equals_ipv6" - expr: "ip('::ffff:c0a8:1') == ip('192.168.0.1')" - eval_error: { - errors: { - message: "IPv4-mapped IPv6 address is not allowed" - } - } - } - test { - name: "ipv4_not_equals_ipv6" - expr: "ip('192.168.0.1') == ip('2001:db8::1')" - value: { bool_value: false } - } -} -section { - name: "ipv6" - description: "Tests for properties and methods of IPv6 addresses" - test { - name: "family" - expr: "ip('2001:db8::68').family()" - value: { int64_value: 6 } - } - test { - name: "is_unspecified_true" - expr: "ip('::').isUnspecified()" - value: { bool_value: true } - } - test { - name: "is_loopback_true" - expr: "ip('::1').isLoopback()" - value: { bool_value: true } - } - test { - name: "is_global_unicast_true" - expr: "ip('2001:db8::abcd').isGlobalUnicast()" - value: { bool_value: true } - } - test { - name: "is_global_unicast_false" - expr: "ip('ff00::1').isGlobalUnicast()" - value: { bool_value: false } - } - test { - name: "is_link_local_multicast_true" - expr: "ip('ff02::1').isLinkLocalMulticast()" - value: { bool_value: true } - } - test { - name: "is_link_local_multicast_false" - expr: "ip('fd00::1').isLinkLocalMulticast()" - value: { bool_value: false } - } - test { - name: "is_link_local_unicast_true" - expr: "ip('fe80::1').isLinkLocalUnicast()" - value: { bool_value: true } - } - test { - name: "is_link_local_unicast_false" - expr: "ip('fd80::1').isLinkLocalUnicast()" - value: { bool_value: false } - } - test { - name: "ipv6_equals" - expr: "ip('2001:db8::1') == ip('2001:DB8::1')" - value: { bool_value: true } - } - test { - name: "ipv6_not_equals" - expr: "ip('::') == ip('::ffff')" - value: { bool_value: false } - } -} - -section { - name: "cidr" - description: "Tests for CIDR parsing and range checking" - test { - name: "parse_cidr_ipv4" - expr: "type(cidr('192.168.0.0/24')) == net.CIDR" - value: { bool_value: true } - } - test { - name: "parse_invalid_cidr_ipv4" - expr: "cidr('192.168.0.0/')" - eval_error: { - errors: { - message: "network address parse error during conversion from string" - } - } - } - test { - name: "parse_invalid_cidr_with_zone" - expr: "cidr('fe80::1%en0/24')" - eval_error: { - errors: { - message: "CIDR with zone value is not allowed" - } - } - } - test { - name: "parse_invalid_cidr_ipv4_in_ipv6" - expr: "cidr('::ffff:192.168.0.1/24')" - eval_error: { - errors: { - message: "IPv4-mapped IPv6 address is not allowed" - } - } - } - test { - name: "cidr_equals" - expr: "cidr('127.0.0.1/24') == cidr('127.0.0.1/24')" - value: { bool_value: true } - } - test { - name: "cidr_not_equals" - expr: "cidr('192.0.0.1/32') == cidr('10.0.0.1/8')" - value: { bool_value: false } - } - test { - name: "cidr_not_equals_ipv4_ipv6" - expr: "cidr('2001:db8::/32') == cidr('10.0.0.1/32')" - value: { bool_value: false } - } - test { - name: "cidr_contains_ip_ipv4_object" - expr: "cidr('192.168.0.0/24').containsIP(ip('192.168.0.1'))" - value: { bool_value: true } - } - test { - name: "cidr_does_not_contain_ip_ipv4_object" - expr: "cidr('192.168.0.0/24').containsIP(ip('192.168.1.1'))" - value: { bool_value: false } - } - test { - name: "cidr_contains_ip_ipv4_string" - expr: "cidr('192.168.0.0/24').containsIP('192.168.0.1')" - value: { bool_value: true } - } - test { - name: "cidr_does_not_contain_ip_ipv4_string" - expr: "cidr('192.168.0.0/24').containsIP('192.168.1.1')" - value: { bool_value: false } - } - test { - name: "cidr_contains_cidr_ipv4_object" - expr: "cidr('192.168.0.0/24').containsCIDR(cidr('192.168.0.0/25'))" - value: { bool_value: true } - } - test { - name: "cidr_contains_cidr_ipv4_object_32" - expr: "cidr('192.168.0.0/24').containsCIDR(cidr('192.168.0.1/32'))" - value: { bool_value: true } - } - test { - name: "cidr_not_contains_cidr_ipv4_object" - expr: "cidr('192.168.0.0/24').containsCIDR(cidr('192.168.0.0/23'))" - value: { bool_value: false } - } - test { - name: "cidr_contains_cidr_ipv4_string" - expr: "cidr('192.168.0.0/24').containsCIDR('192.168.0.0/25')" - value: { bool_value: true } - } - test { - name: "cidr_contains_cidr" - expr: "cidr('10.0.0.0/8').containsCIDR(cidr('10.0.0.0/8'))" - value: { bool_value: true } - } - test { - name: "cidr_contains_cidr_ipv4_exact" - expr: "cidr('10.0.0.0/8').containsCIDR('10.0.0.0/8')" - value: { bool_value: true } - } - test { - name: "cidr_ipv6_not_contains_ip_ipv4_object" - expr: "cidr('2001:db8::/32').containsIP(ip('192.168.1.1'))" - value: { bool_value: false } - } - test { - name: "cidr_ipv4_not_contains_ip_ipv6_object" - expr: "cidr('192.168.1.1/32').containsIP(ip('2001:db8::1'))" - value: { bool_value: false } - } - test { - name: "cidr_get_ip_ipv4" - expr: "cidr('192.168.0.0/24').ip() == ip('192.168.0.0')" - value: { bool_value: true } - } - test { - name: "cidr_masked_ipv4" - expr: "cidr('192.168.0.1/24').masked() == cidr('192.168.0.0/24')" - value: { bool_value: true } - } - test { - name: "cidr_prefix_length_ipv4" - expr: "cidr('192.168.0.0/24').prefixLength()" - value: { int64_value: 24 } - } - test { - name: "parse_cidr_ipv6" - expr: "string(cidr('2001:db8::/32'))" - value: { string_value: "2001:db8::/32" } - } - test { - name: "cidr_contains_ip_ipv6_object" - expr: "cidr('2001:db8::/32').containsIP(ip('2001:db8::1'))" - value: { bool_value: true } - } - test { - name: "cidr_contains_cidr_ipv6_object" - expr: "cidr('2001:db8::/32').containsCIDR(cidr('2001:db8::/33'))" - value: { bool_value: true } - } - test { - name: "cidr_get_ip_ipv6" - expr: "cidr('2001:db8::/32').ip() == ip('2001:db8::')" - value: { bool_value: true } - } - test { - name: "cidr_prefix_length_ipv6" - expr: "cidr('2001:db8::/32').prefixLength()" - value: { int64_value: 32 } - } - test { - name: "cidr_to_string" - description: "Converting a CIDR back to a string" - expr: "string(cidr('192.168.0.0/24'))" - value: { string_value: "192.168.0.0/24" } - } - test { - name: "cidr_type" - description: "Check the type of the CIDR object" - expr: "type(cidr('192.168.0.0/24')) == net.CIDR" - value: { bool_value: true } - } -} diff --git a/tests/simple/testdata/optionals.textproto b/tests/simple/testdata/optionals.textproto deleted file mode 100644 index 6fcb8ca0..00000000 --- a/tests/simple/testdata/optionals.textproto +++ /dev/null @@ -1,601 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "optionals" -description: "Tests for optionals." -section: { - name: "optionals" - test { - name: "null" - expr: "optional.of(null).hasValue()" - value: { bool_value: true } - } - test { - name: "null_non_zero_value" - expr: "optional.ofNonZeroValue(null).hasValue()" - value: { bool_value: false } - } - test { - name: "none_or_none_or_value" - expr: "optional.none().or(optional.none()).orValue(42)" - value: { int64_value: 42 } - } - test { - name: "none_optMap_hasValue" - expr: "optional.none().optMap(y, y + 1).hasValue()" - value: { bool_value: false } - } - test { - name: "empty_map_optFlatMap_hasValue" - expr: "{}.?key.optFlatMap(k, k.?subkey).hasValue()" - value: { bool_value: false } - } - test { - name: "map_empty_submap_optFlatMap_hasValue" - expr: "{'key': {}}.?key.optFlatMap(k, k.?subkey).hasValue()" - value: { bool_value: false } - } - test { - name: "map_null_entry_hasValue" - expr: "{'null_key': dyn(null)}.?null_key.hasValue()" - value: { bool_value: true } - } - test { - name: "map_null_entry_no_such_key" - expr: "{'null_key': dyn(null)}.?null_key.invalid.hasValue()" - eval_error: { - errors: { message: "no such key" } - } - } - test { - name: "map_absent_key_absent_field_none" - expr: "{true: dyn(0)}[?false].absent.hasValue()" - value: { bool_value: false } - } - test { - name: "map_present_key_invalid_field" - expr: "{true: dyn(0)}[?true].absent.hasValue()" - eval_error: { - errors: { message: "no such key" } - } - } - test { - name: "map_undefined_entry_hasValue" - expr: "{}.?null_key.invalid.hasValue()" - value: { bool_value: false } - } - test { - name: "map_submap_subkey_optFlatMap_value" - expr: "{'key': {'subkey': 'subvalue'}}.?key.optFlatMap(k, k.?subkey).value()" - value: { string_value: "subvalue" } - } - test { - name: "map_submap_optFlatMap_value" - expr: "{'key': {'subkey': ''}}.?key.optFlatMap(k, k.?subkey).value()" - value: { string_value: "" } - } - test { - name: "map_optindex_optFlatMap_optional_ofNonZeroValue_hasValue" - expr: "{'key': {'subkey': ''}}.?key.optFlatMap(k, optional.ofNonZeroValue(k.subkey)).hasValue()" - value: { bool_value: false } - } - test { - name: "optional_of_optMap_value" - expr: "optional.of(42).optMap(y, y + 1).value()" - value: { int64_value: 43 } - } - test { - name: "optional_ofNonZeroValue_or_optional_value" - expr: "optional.ofNonZeroValue(42).or(optional.of(20)).value() == 42" - value: { bool_value: true } - } - test { - name: "ternary_optional_hasValue" - expr: "(has({}.x) ? optional.of({}.x) : optional.none()).hasValue()" - value: { bool_value: false } - } - test { - name: "map_optindex_hasValue" - expr: "{}.?x.hasValue()" - value: { bool_value: false } - } - test { - name: "has_map_optindex" - expr: "has({}.?x.y)" - value: { bool_value: false } - } - test { - name: "has_map_optindex_field" - expr: "has({'x': {'y': 'z'}}.?x.y)" - value: { bool_value: true } - } - test { - name: "type" - expr: "type(optional.none()) == optional_type" - value: { bool_value: true } - } - test { - name: "optional_chaining_1" - expr: "optional.ofNonZeroValue('').or(optional.of({'c': {'dashed-index': 'goodbye'}}.c['dashed-index'])).orValue('default value')" - value: { string_value: "goodbye" } - } - test { - name: "optional_chaining_2" - expr: "{'c': {'dashed-index': 'goodbye'}}.c[?'dashed-index'].orValue('default value')" - value: { string_value: "goodbye" } - } - test { - name: "optional_chaining_3" - expr: "{'c': {}}.c[?'missing-index'].orValue('default value')" - value: { string_value: "default value" } - } - test { - name: "optional_chaining_4" - expr: "optional.of({'c': {'index': 'goodbye'}}).c.index.orValue('default value')" - value: { string_value: "goodbye" } - } - test { - name: "optional_chaining_5" - expr: "optional.of({'c': {}}).c.missing.or(optional.none()[0]).orValue('default value')" - value: { string_value: "default value" } - } - test { - name: "optional_chaining_6" - expr: "optional.of({'c': {}}).c.missing.or(optional.of(['list-value'])[0]).orValue('default value')" - value: { string_value: "list-value" } - } - test { - name: "optional_chaining_7" - expr: "optional.of({'c': {'index': 'goodbye'}}).c['index'].orValue('default value')" - value: { string_value: "goodbye" } - } - test { - name: "optional_chaining_8" - expr: "optional.of({'c': {}}).c['missing'].orValue('default value')" - value: { string_value: "default value" } - } - test { - name: "optional_chaining_9" - expr: "has(optional.of({'c': {'entry': 'hello world'}}).c) && !has(optional.of({'c': {'entry': 'hello world'}}).c.missing)" - value: { bool_value: true } - } - test { - name: "optional_chaining_10" - expr: "optional.ofNonZeroValue({'c': {'dashed-index': 'goodbye'}}.a.z).orValue({'c': {'dashed-index': 'goodbye'}}.c['dashed-index'])" - eval_error: { - errors: { message: "no such key" } - } - } - test { - name: "optional_chaining_11" - expr: "{'c': {'dashed-index': 'goodbye'}}.?c.missing.or({'c': {'dashed-index': 'goodbye'}}.?c['dashed-index']).orValue('').size()" - value: { int64_value: 7 } - } - test { - name: "optional_chaining_12" - expr: "{?'nested_map': optional.ofNonZeroValue({?'map': {'c': {'dashed-index': 'goodbye'}}.?c})}" - value: { - map_value: { - entries { - key: { string_value: "nested_map" } - value: { - map_value: { - entries { - key: { string_value: "map" } - value: { - map_value: { - entries { - key: { string_value: "dashed-index" } - value: { string_value: "goodbye" } - } - } - } - } - } - } - } - } - } - } - test { - name: "optional_chaining_13" - expr: "{?'nested_map': optional.ofNonZeroValue({?'map': {}.?c}), 'singleton': true}" - value: { - map_value: { - entries { - key: { string_value: "singleton" } - value: { bool_value: true } - } - } - } - } - test { - name: "optional_chaining_14" - expr: "[?{}.?c, ?optional.of(42), ?optional.none()]" - value: { list_value: { values: { int64_value: 42 } } } - } - test { - name: "optional_chaining_15" - expr: "[?optional.ofNonZeroValue({'c': []}.?c.orValue(dyn({})))]" - value: { list_value: {} } - } - test { - name: "optional_chaining_16" - expr: "optional.ofNonZeroValue({?'nested_map': optional.ofNonZeroValue({?'map': optional.of({}).?c})}).hasValue()" - value: { bool_value: false } - } - test { - name: "has_optional_ofNonZeroValue_struct_optional_ofNonZeroValue_map_optindex_field" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{?single_double_wrapper: optional.ofNonZeroValue(0.0)}.single_double_wrapper)" - value: { bool_value: false } - } - test { - name: "optional_ofNonZeroValue_struct_optional_ofNonZeroValue_map_optindex_field" - container: "cel.expr.conformance.proto2" - expr: "optional.ofNonZeroValue(TestAllTypes{?single_double_wrapper: optional.ofNonZeroValue(0.0)}).hasValue()" - value: { bool_value: false } - } - test { - name: "struct_map_optindex_field" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{?map_string_string: {'nested': {}}[?'nested']}.map_string_string" - value: { map_value: {} } - } - test { - name: "struct_optional_ofNonZeroValue_map_optindex_field" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{?map_string_string: optional.ofNonZeroValue({'nested': {}}[?'nested'].orValue({}))}.map_string_string" - value: { map_value: {} } - } - test { - name: "struct_map_optindex_field_nested" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{?map_string_string: {'nested': {'hello': 'world'}}[?'nested']}.map_string_string" - value: { - map_value: { - entries { - key: { string_value: "hello" } - value: { string_value: "world" } - } - } - } - } - test { - name: "struct_list_optindex_field" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{repeated_string: ['greetings', ?{'nested': {'hello': 'world'}}.nested.?hello]}.repeated_string" - value: { - list_value: { - values { - string_value: "greetings" - } - values { - string_value: "world" - } - } - } - } - test { - name: "optional_empty_map_optindex_hasValue" - expr: "optional.of({}).?c.hasValue()" - value: { - bool_value: false - } - } - test { - name: "empty_struct_optindex_hasValue" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.?repeated_string.hasValue()" - value: { - bool_value: false - } - } - test { - name: "optional_empty_struct_optindex_hasValue" - container: "cel.expr.conformance.proto2" - expr: "optional.of(TestAllTypes{}).?repeated_string.hasValue()" - value: { - bool_value: false - } - } - test { - name: "optional_none_optselect_hasValue" - expr: "optional.none().?repeated_string.hasValue()" - value: { - bool_value: false - } - } - test { - name: "struct_optindex_value" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{repeated_string: ['foo']}.?repeated_string.value()" - value: { - list_value: { - values { - string_value: "foo" - } - } - } - } - test { - name: "optional_struct_optindex_value" - container: "cel.expr.conformance.proto2" - expr: "optional.of(TestAllTypes{repeated_string: ['foo']}).?repeated_string.value()" - value: { - list_value: { - values { - string_value: "foo" - } - } - } - } - test { - name: "optional_struct_optindex_index_value" - container: "cel.expr.conformance.proto2" - expr: "optional.of(TestAllTypes{repeated_string: ['foo']}).?repeated_string[0].value()" - value: { - string_value: "foo" - } - } - test { - name: "empty_list_optindex_hasValue" - expr: "[][?0].hasValue()" - value: { - bool_value: false - } - } - test { - name: "optional_empty_list_optindex_hasValue" - expr: "optional.of([])[?0].hasValue()" - value: { - bool_value: false - } - } - test { - name: "optional_none_optindex_hasValue" - expr: "optional.none()[?0].hasValue()" - value: { - bool_value: false - } - } - test { - name: "list_optindex_value" - expr: "['foo'][?0].value()" - value: { - string_value: "foo" - } - } - test { - name: "optional_list_optindex_value" - expr: "optional.of(['foo'])[?0].value()" - value: { - string_value: "foo" - } - } - test { - name: "map_key_mixed_type_optindex_value" - expr: "{true: 1, 2: 2, 5u: 3}[?true].value()" - value: { int64_value: 1 } - } - test { - name: "map_key_mixed_numbers_double_key_optindex_value" - expr: "{1u: 1.0, 2: 2.0, 3u: 3.0}[?3.0].value()" - value: { double_value: 3.0 } - } - test { - name: "map_key_mixed_numbers_uint_key_optindex_value" - expr: "{1u: 1.0, 2: 2.0, 3u: 3.0}[?2u].value()" - value: { double_value: 2.0 } - } - test { - name: "map_key_mixed_numbers_int_key_optindex_value" - expr: "{1u: 1.0, 2: 2.0, 3u: 3.0}[?1].value()" - value: { double_value: 1.0 } - } - test { - name: "optional_eq_none_none" - expr: "optional.none() == optional.none()" - value: { bool_value: true } - } - test { - name: "optional_eq_none_int" - expr: "optional.none() == optional.of(1)" - value: { bool_value: false } - } - test { - name: "optional_eq_int_none" - expr: "optional.of(1) == optional.none()" - value: { bool_value: false } - } - test { - name: "optional_eq_int_int" - expr: "optional.of(1) == optional.of(1)" - value: { bool_value: true } - } - test { - name: "optional_ne_none_none" - expr: "optional.none() != optional.none()" - value: { bool_value: false } - } - test { - name: "optional_ne_none_int" - expr: "optional.none() != optional.of(1)" - value: { bool_value: true } - } - test { - name: "optional_ne_int_none" - expr: "optional.of(1) != optional.none()" - value: { bool_value: true } - } - test { - name: "optional_ne_int_int" - expr: "optional.of(1) != optional.of(1)" - value: { bool_value: false } - } - test { - name: "optional_eq_int_double" - expr: "optional.of(1) == optional.of(dyn(1.0))" - value: { bool_value: true } - } - test { - name: "optional_eq_int_uint" - expr: "optional.of(1) == optional.of(dyn(1u))" - value: { bool_value: true } - } - test { - name: "optional_eq_neg_zero_pos_zero" - expr: "optional.of(-0.0) == optional.of(0.0)" - value: { bool_value: true } - } - test { - name: "optional_eq_nan_nan" - expr: "optional.of(0.0/0.0) == optional.of(0.0/0.0)" - value: { bool_value: false } - } - test { - name: "optional_ne_nan_nan" - expr: "optional.of(0.0/0.0) != optional.of(0.0/0.0)" - value: { bool_value: true } - } - test { - name: "optional_eq_list_int_double" - expr: "optional.of([1]) == optional.of([dyn(1.0)])" - value: { bool_value: true } - } - test { - name: "map_optional_has" - expr: "has({'foo': optional.none()}.foo)" - value: { bool_value: true } - } - test { - name: "map_optional_select_has" - expr: "has({'foo': optional.none()}.foo.bar)" - value: { bool_value: false } - } - test { - name: "map_optional_of_select_has" - expr: "has({'foo': optional.of({'bar': 1})}.foo.bar)" - value: { bool_value: true } - } - test { - name: "map_optional_entry_has" - expr: "has({?'foo': optional.none()}.foo)" - value: { bool_value: false } - } - test { - name: "map_optional_none_select" - expr: "{'a': optional.none()}.a.b == optional.none()" - value: { bool_value: true } - } - test { - name: "map_optional_of_select" - expr: "{'a': optional.of({'b': 1})}.a.b == optional.of(1)" - value: { bool_value: true } - } - test { - name: "map_optional_none_optselect" - expr: "{'a': optional.none()}.?a == optional.of(optional.none())" - value: { bool_value: true } - } - test { - name: "map_optional_of_optselect" - expr: "{'a': optional.of(1)}.?a == optional.of(optional.of(1))" - value: { bool_value: true } - } - test { - name: "optional_map_optional_none_optselect" - expr: "optional.of({'a': optional.none()}).?a == optional.of(optional.none())" - value: { bool_value: true } - } - test { - name: "optional_map_optional_of_optselect" - expr: "optional.of({'a': optional.of(1)}).?a == optional.of(optional.of(1))" - value: { bool_value: true } - } - test { - name: "optional_map_optional_none_select" - expr: "optional.of({'a': optional.none()}).a == optional.of(optional.none())" - value: { bool_value: true } - } - test { - name: "optional_map_optional_of_select" - expr: "optional.of({'a': optional.of(1)}).a == optional.of(optional.of(1))" - value: { bool_value: true } - } - test { - name: "map_optional_none_optindex" - expr: "{'a': optional.none()}[?'a'] == optional.of(optional.none())" - value: { bool_value: true } - } - test { - name: "map_optional_of_optindex" - expr: "{'a': optional.of(1)}[?'a'] == optional.of(optional.of(1))" - value: { bool_value: true } - } - test { - name: "optional_map_optional_none_optindex" - expr: "optional.of({'a': optional.none()})[?'a'] == optional.of(optional.none())" - value: { bool_value: true } - } - test { - name: "optional_map_optional_of_optindex" - expr: "optional.of({'a': optional.of(1)})[?'a'] == optional.of(optional.of(1))" - value: { bool_value: true } - } - test { - name: "optional_map_optional_none_index" - expr: "optional.of({'a': optional.none()})['a'] == optional.of(optional.none())" - value: { bool_value: true } - } - test { - name: "optional_map_optional_of_index" - expr: "optional.of({'a': optional.of(1)})['a'] == optional.of(optional.of(1))" - value: { bool_value: true } - } - test { - name: "list_optional_none_optindex" - expr: "[optional.none()][?0] == optional.of(optional.none())" - value: { bool_value: true } - } - test { - name: "list_optional_of_optindex" - expr: "[optional.of(1)][?0] == optional.of(optional.of(1))" - value: { bool_value: true } - } - test { - name: "optional_list_optional_none_optindex" - expr: "optional.of([optional.none()])[?0] == optional.of(optional.none())" - value: { bool_value: true } - } - test { - name: "optional_list_optional_of_optindex" - expr: "optional.of([optional.of(1)])[?0] == optional.of(optional.of(1))" - value: { bool_value: true } - } - test { - name: "optional_list_optional_none_index" - expr: "optional.of([optional.none()])[0] == optional.of(optional.none())" - value: { bool_value: true } - } - test { - name: "optional_list_optional_of_index" - expr: "optional.of([optional.of(1)])[0] == optional.of(optional.of(1))" - value: { bool_value: true } - } - test { - name: "map_optional_entry_nested_none" - expr: "{?'a': {'a': optional.none()}.?a}.a == optional.none()" - value: { bool_value: true } - } - test { - name: "list_optional_element_nested_none" - expr: "[?{'a': optional.none()}.?a] == [optional.none()]" - value: { bool_value: true } - } - test { - name: "list_optional_elements_nested" - expr: "[?optional.of(optional.none()), ?optional.none(), ?optional.of(optional.of(1))] == [optional.none(), optional.of(1)]" - value: { bool_value: true } - } -} diff --git a/tests/simple/testdata/parse.textproto b/tests/simple/testdata/parse.textproto deleted file mode 100644 index 6b140009..00000000 --- a/tests/simple/testdata/parse.textproto +++ /dev/null @@ -1,1414 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "parse" -description: "End-to-end parsing tests." -section { - name: "nest" - description: "Deep parse trees which all implementations must support." - test { - name: "list_index" - description: "Member = Member '[' Expr ']'. Nested indices are supported up to 12 times." - expr: "a[a[a[a[a[a[a[a[a[a[a[a[0]]]]]]]]]]]]" - type_env { - name: "a" - ident { type { list_type { elem_type { primitive: INT64 } } } } - } - bindings { - key: "a" - value { value { list_value { values { int64_value: 0 } } } } - } - value { int64_value: 0 } - } - test { - name: "message_literal" - description: "Member = Member '{' [FieldInits] '}'. Nested messages supported up to 12 levels deep." - container: "cel.expr.conformance.proto3" - expr: "NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{payload: TestAllTypes{single_int64: 137}}}}}}}}}}}}.payload.single_int64" - value { int64_value: 0 } - } - test { - name: "funcall" - description: "Primary = ['.'] IDENT ['(' [ExprList] ')']. Nested function calls supported up to 12 levels deep." - expr: "int(uint(int(uint(int(uint(int(uint(int(uint(int(uint(7))))))))))))" - value { int64_value: 7 } - } - test { - name: "list_literal" - description: "Primary = '[' [ExprList] ']'. Nested list literals up to 12 levels deep." - expr: "size([[[[[[[[[[[[0]]]]]]]]]]]])" - value { int64_value: 1 } - } - test { - name: "map_literal" - description: "Primary = '{' [MapInits] '}'. Nested map literals up to 12 levels deep." - expr: "size({0: {0: {0: {0: {0: {0: {0: {0: {0: {0: {0: {0: 'foo'}}}}}}}}}}}})" - value { int64_value: 1 } - } - test { - name: "parens" - description: "Primary = '(' Expr ')'" - expr: "((((((((((((((((((((((((((((((((7))))))))))))))))))))))))))))))))" - value { int64_value: 7 } - } -} -section { - name: "repeat" - description: "Repetitive parse trees which all implementations must support." - test { - name: "conditional" - description: "Expr = ConditionalOr ['?' ConditionalOr ':' Expr]. Chained ternary operators up to 24 levels." - expr: "true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : false" - value { bool_value: true } - } - test { - name: "or" - description: "ConditionalOr = [ConditionalOr '||'] ConditionalAnd. Logical OR statements with 32 conditions." - expr: "false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || true" - value { bool_value: true } - } - test { - name: "and" - description: "ConditionalAnd = [ConditionalAnd '&&'] Relation. Logical AND statements with 32 conditions." - expr: "true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && false" - value { bool_value: false } - } - test { - name: "add_sub" - description: "Addition = [Addition ('+' | '-')] Multiplication. Addition operators are supported up to 24 times consecutively." - expr: "3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3" - value { int64_value: 3 } - } - test { - name: "mul_div" - description: "Multiplication = [Multiplication ('*' | '/' | '%')] Unary. Multiplication operators are supported up to 24 times consecutively." - expr: "4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4" - value { int64_value: 4 } - } - test { - name: "not" - description: "Unary = '!' {'!'} Member" - expr: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!true" - value { bool_value: true } - } - test { - name: "unary_neg" - description: "Unary = '-' {'-'} Member" - expr: "--------------------------------19" - value { int64_value: 19 } - } - test { - name: "select" - description: "Member = Member '.' IDENT ['(' [ExprList] ')']. Selection is supported up to 12 times consecutively." - container: "cel.expr.conformance.proto3" - expr: "NestedTestAllTypes{}.child.child.child.child.child.child.child.child.child.child.payload.single_int32" - value { int64_value: 0 } - } - test { - name: "index" - description: "Member = Member '[' Expr ']'. Indexing is supported up to 12 times consecutively." - expr: "[[[[[[[[[[[['foo']]]]]]]]]]]][0][0][0][0][0][0][0][0][0][0][0][0]" - value { string_value: "foo" } - } - test { - name: "list_literal" - description: "Primary = '[' [ExprList] ']'. List literals with up to 32 elements." - expr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31][17]" - value { int64_value: 17 } - } - test { - name: "map_literal" - description: "Primary = '{' [MapInits] '}'. Map literals with up to 32 entries." - expr: "{0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty-one', 22: 'twenty-two', 23: 'twenty-three', 24: 'twenty-four', 25: 'twenty-five', 26: 'twenty-six', 27: 'twenty-seven', 28: 'twenty-eight', 29: 'twenty-nine', 30: 'thirty', 31: 'thirty-one'}[17]" - value { string_value: "seventeen" } - } - test { - name: "message_literal" - description: "Member = Member '{' [FieldInits] '}'. Message literals with up to 32 fields." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32: 5, single_int64: 10, single_uint32: 15u, single_uint64: 20u, single_sint32: 25, single_sint64: 30, single_fixed32: 35u, single_fixed64: 40u, single_float: 45.0, single_double: 50.0, single_bool: true, single_string: 'sixty', single_bytes: b'sixty-five', single_value: 70.0, single_int64_wrapper: 75, single_int32_wrapper: 80, single_double_wrapper: 85.0, single_float_wrapper: 90.0, single_uint64_wrapper: 95u, single_uint32_wrapper: 100u, single_string_wrapper: 'one hundred five', single_bool_wrapper: true, repeated_int32: [115], repeated_int64: [120], repeated_uint32: [125u], repeated_uint64: [130u], repeated_sint32: [135], repeated_sint64: [140], repeated_fixed32: [145u], repeated_fixed64: [150u], repeated_sfixed32: [155], repeated_float: [160.0]}.single_sint64" - value { int64_value: 30 } - } -} - -# txtpbfmt: off -section { - name: "string_literals" - description: "Check that string literals are properly parsed" - test { - name: "single_quoted" - expr: "'hello'" - value: { string_value: "hello" } - } - test { - name: "double_quoted" - expr: '"hello"' - value: { string_value: "hello" } - } - test { - name: "triple_single_quoted" - expr: "'''hello'''" - value: { string_value: "hello" } - } - test { - name: "triple_double_quoted" - expr: '"""hello"""' - value: { string_value: "hello" } - } - test { - name: "single_quoted_escaped_punctuation" - # ' \\ \? \" \' \` ' - expr: "' \\\\ \\? \\\" \\\' \\` '" - value: { string_value: " \\ ? \" \' ` " } - } - test { - name: "double_quoted_escaped_punctuation" - expr: '" \\\\ \\? \\\" \\\' \\` "' - value: { string_value: " \\ ? \" \' ` " } - } - test { - name: "triple_single_quoted_escaped_punctuation" - expr: "''' \\\\ \\? \\\" \\\' \\` '''" - value: { string_value: " \\ ? \" \' ` " } - } - test { - name: "triple_double_quoted_escaped_punctuation" - expr: '""" \\\\ \\? \\\" \\\' \\` """' - value: { string_value: " \\ ? \" \' ` " } - } - test { - name: "triple_single_quoted_unescaped_punctuation" - expr: "''' ? \" \' ` '''" - value: { string_value: " ? \" \' ` " } - } - test { - name: "triple_double_quoted_unescaped_punctuation" - expr: '""" ? \" \' ` """' - value: { string_value: " ? \" \' ` " } - } - - test { - name: "single_quoted_escaped_special_control_characters" - expr: "' \\a \\b \\f \\t \\v '" - value: { string_value: " \a \b \f \t \v " } - } - test { - name: "double_quoted_escaped_special_control_characters" - expr: '" \\a \\b \\f \\t \\v "' - value: { string_value: " \a \b \f \t \v " } - } - test { - name: "single_quoted_unescaped_special_control_characters" - expr: "' \a \b \f \t \v '" - value: { string_value: " \a \b \f \t \v " } - } - test { - name: "double_quoted_unescaped_special_control_characters" - expr: '" \a \b \f \t \v "' - value: { string_value: " \a \b \f \t \v " } - } - - test { - name: "triple_single_quoted_escaped_special_control_characters" - expr: "''' \\a \\b \\f \\t \\v '''" - value: { string_value: " \a \b \f \t \v " } - } - test { - name: "triple_double_quoted_escaped_special_control_characters" - expr: '""" \\a \\b \\f \\t \\v """' - value: { string_value: " \a \b \f \t \v " } - } - test { - name: "triple_single_quoted_unescaped_special_control_characters" - expr: "''' \a \b \f \t \v '''" - value: { string_value: " \a \b \f \t \v " } - } - test { - name: "triple_double_quoted_unescaped_special_control_characters" - expr: '""" \a \b \f \t \v """' - value: { string_value: " \a \b \f \t \v " } - } - - test { - name: "single_quoted_escaped_line_feed" - expr: "' \\n '" - value: { string_value: " \n " } - } - test { - name: "double_quoted_escaped_line_feed" - expr: '" \\n "' - value: { string_value: " \n " } - } - - test { - name: "triple_single_quoted_escaped_line_feed" - expr: "''' \\n '''" - value: { string_value: " \n " } - } - test { - name: "triple_double_quoted_escaped_line_feed" - expr: '""" \\n """' - value: { string_value: " \n " } - } - test { - name: "triple_single_quoted_unescaped_line_feed" - expr: "''' \n '''" - value: { string_value: " \n " } - } - test { - name: "triple_double_quoted_unescaped_line_feed" - expr: '""" \n """' - value: { string_value: " \n " } - } - - test { - name: "single_quoted_escaped_carriage_return" - expr: "' \\r '" - value: { string_value: " \r " } - } - test { - name: "double_quoted_escaped_carriage_return" - expr: '" \\r "' - value: { string_value: " \r " } - } - - test { - name: "triple_single_quoted_escaped_carriage_return" - expr: "''' \\r '''" - value: { string_value: " \r " } - } - test { - name: "triple_double_quoted_escaped_carriage_return" - expr: '""" \\r """' - value: { string_value: " \r " } - } - - # See https://github.com/cel-expr/cel-spec/issues/490 - # test { - # name: "triple_single_quoted_unescaped_carriage_return" - # expr: "''' \r '''" - # value: { string_value: " \r " } - # } - # test { - # name: "triple_double_quoted_unescaped_carriage_return" - # expr: '""" \r """' - # value: { string_value: " \r " } - # } - - test { - name: "single_quoted_escaped_windows_line_end" - expr: "' \\r\\n '" - value: { string_value: " \r\n " } - } - test { - name: "double_quoted_escaped_windows_line_end" - expr: '" \\r\\n "' - value: { string_value: " \r\n " } - } - - test { - name: "triple_single_quoted_escaped_windows_line_end" - expr: "''' \\r\\n '''" - value: { string_value: " \r\n " } - } - test { - name: "triple_double_quoted_escaped_windows_line_end" - expr: '""" \\r\\n """' - value: { string_value: " \r\n " } - } - - # See https://github.com/cel-expr/cel-spec/issues/490 - # test { - # name: "triple_single_quoted_unescaped_windows_line_end" - # expr: "''' \r\n '''" - # value: { string_value: " \r\n " } - # } - # test { - # name: "triple_double_quoted_unescaped_windows_line_end" - # expr: '""" \r\n """' - # value: { string_value: " \r\n " } - # } - - test { - name: "single_quoted_escaped_all_control_characters" - expr: "' \\x01 \\x02 \\x03 \\x04 \\x05 \\x06 \\x07 \\x08 \\x09 \\x0B \\x0C \\x0E \\x0F \\x10 \\x11 \\x12 \\x13 \\x14 \\x15 \\x16 \\x17 \\x18 \\x19 \\x1A \\x1B \\x1C \\x1D \\x1E \\x1f \\x7F '" - value: { string_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "double_quoted_escaped_all_control_characters" - expr: '" \\x01 \\x02 \\x03 \\x04 \\x05 \\x06 \\x07 \\x08 \\x09 \\x0B \\x0C \\x0E \\x0F \\x10 \\x11 \\x12 \\x13 \\x14 \\x15 \\x16 \\x17 \\x18 \\x19 \\x1A \\x1B \\x1C \\x1D \\x1E \\x1f \\x7F "' - value: { string_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "single_quoted_unescaped_all_control_characters" - expr: "' \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F '" - value: { string_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "double_quoted_unescaped_all_control_characters" - expr: '" \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F "' - value: { string_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - - test { - name: "triple_single_quoted_escaped_all_control_characters" - expr: "''' \\x01 \\x02 \\x03 \\x04 \\x05 \\x06 \\x07 \\x08 \\x09 \\x0B \\x0C \\x0E \\x0F \\x10 \\x11 \\x12 \\x13 \\x14 \\x15 \\x16 \\x17 \\x18 \\x19 \\x1A \\x1B \\x1C \\x1D \\x1E \\x1f \\x7F '''" - value: { string_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "triple_double_quoted_escaped_all_control_characters" - expr: '""" \\x01 \\x02 \\x03 \\x04 \\x05 \\x06 \\x07 \\x08 \\x09 \\x0B \\x0C \\x0E \\x0F \\x10 \\x11 \\x12 \\x13 \\x14 \\x15 \\x16 \\x17 \\x18 \\x19 \\x1A \\x1B \\x1C \\x1D \\x1E \\x1f \\x7F """' - value: { string_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "triple_single_quoted_unescaped_all_control_characters" - expr: "''' \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F '''" - value: { string_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "triple_double_quoted_unescaped_all_control_characters" - expr: '""" \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F """' - value: { string_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - - test { - name: "single_quoted_octal_escapes" - expr: "' \\000 \\012 \\177 '" - value: { string_value: " \x00 \x0A \x7F " } - } - test { - name: "double_quoted_octal_escapes" - expr: '" \\000 \\012 \\177 "' - value: { string_value: " \x00 \x0A \x7F " } - } - test { - name: "triple_single_quoted_octal_escapes" - expr: "''' \\000 \\012 \\177 '''" - value: { string_value: " \x00 \x0A \x7F " } - } - test { - name: "triple_double_quoted_octal_escapes" - expr: '""" \\000 \\012 \\177 """' - value: { string_value: " \x00 \x0A \x7F " } - } - - test { - name: "single_quoted_lower_x_escapes" - expr: "' \\x00 \\x0A \\x7F '" - value: { string_value: " \x00 \x0A \x7F " } - } - test { - name: "double_quoted_lower_x_escapes" - expr: '" \\x00 \\x0A \\x7F "' - value: { string_value: " \x00 \x0A \x7F " } - } - test { - name: "triple_single_quoted_lower_x_escapes" - expr: "''' \\x00 \\x0A \\x7F '''" - value: { string_value: " \x00 \x0A \x7F " } - } - test { - name: "triple_double_quoted_lower_x_escapes" - expr: '""" \\x00 \\x0A \\x7F """' - value: { string_value: " \x00 \x0A \x7F " } - } - - test { - name: "single_quoted_upper_x_escapes" - expr: "' \\X00 \\X0A \\X7F '" - value: { string_value: " \x00 \x0A \x7F " } - } - test { - name: "double_quoted_upper_x_escapes" - expr: '" \\X00 \\X0A \\X7F "' - value: { string_value: " \x00 \x0A \x7F " } - } - test { - name: "triple_single_quoted_upper_x_escapes" - expr: "''' \\X00 \\X0A \\X7F '''" - value: { string_value: " \x00 \x0A \x7F " } - } - test { - name: "triple_double_quoted_upper_x_escapes" - expr: '""" \\X00 \\X0A \\X7F """' - value: { string_value: " \x00 \x0A \x7F " } - } - - test { - name: "single_quoted_lower_u_escapes" - expr: "' \\u0000 \\u000A \\u007F \\u0100 \\uFFFB '" - value: { string_value: " \x00 \x0A \x7F \u0100 \uFFFB " } - } - test { - name: "double_quoted_lower_u_escapes" - expr: '" \\u0000 \\u000A \\u007F \\u0100 \\uFFFB "' - value: { string_value: " \x00 \x0A \x7F \u0100 \uFFFB " } - } - test { - name: "triple_single_quoted_lower_u_escapes" - expr: "''' \\u0000 \\u000A \\u007F \\u0100 \\uFFFB '''" - value: { string_value: " \x00 \x0A \x7F \u0100 \uFFFB " } - } - test { - name: "triple_double_quoted_lower_u_escapes" - expr: '""" \\u0000 \\u000A \\u007F \\u0100 \\uFFFB """' - value: { string_value: " \x00 \x0A \x7F \u0100 \uFFFB " } - } - - test { - name: "single_quoted_upper_u_escapes" - expr: "' \\U00000000 \\U0000000A \\U0000007F \\U00000100 \\U0000FFFB \\U00010000 \\U0001F62C '" - value: { string_value: " \x00 \x0A \x7F \U00000100 \U0000FFFB \U00010000 \U0001F62C " } - } - test { - name: "double_quoted_upper_u_escapes" - expr: '" \\U00000000 \\U0000000A \\U0000007F \\U00000100 \\U0000FFFB \\U00010000 \\U0001F62C "' - value: { string_value: " \x00 \x0A \x7F \U00000100 \U0000FFFB \U00010000 \U0001F62C " } - } - test { - name: "triple_single_quoted_upper_u_escapes" - expr: "''' \\U00000000 \\U0000000A \\U0000007F \\U00000100 \\U0000FFFB \\U00010000 \\U0001F62C '''" - value: { string_value: " \x00 \x0A \x7F \U00000100 \U0000FFFB \U00010000 \U0001F62C " } - } - test { - name: "triple_double_quoted_upper_u_escapes" - expr: '""" \\U00000000 \\U0000000A \\U0000007F \\U00000100 \\U0000FFFB \\U00010000 \\U0001F62C """' - value: { string_value: " \x00 \x0A \x7F \U00000100 \U0000FFFB \U00010000 \U0001F62C " } - } - - test { - name: "mixed_case_hex_single_quoted_escapes" - expr: "' \\x4a \\x4B \\X4c \\X4D \\u01aB \\U000001aB '" - value: { string_value: " \x4a \x4B \x4c \x4D \u01aB \U000001aB " } - } - test { - name: "mixed_case_hex_double_quoted_escapes" - expr: '" \\x4a \\x4B \\X4c \\X4D \\u01aB \\U000001aB "' - value: { string_value: " \x4a \x4B \x4c \x4D \u01aB \U000001aB " } - } - test { - name: "mixed_case_hex_triple_single_quoted_escapes" - expr: "''' \\x4a \\x4B \\X4c \\X4D \\u01aB \\U000001aB '''" - value: { string_value: " \x4a \x4B \x4c \x4D \u01aB \U000001aB " } - } - test { - name: "mixed_case_hex_triple_double_quoted_escapes" - expr: '""" \\x4a \\x4B \\X4c \\X4D \\u01aB \\U000001aB """' - value: { string_value: " \x4a \x4B \x4c \x4D \u01aB \U000001aB " } - } - - test { - name: "unassigned_code_point_single_quoted_escapes" - expr: "' \\U00088888 '" - value: { string_value: " \U00088888 " } - } - test { - name: "unassigned_code_point_double_quoted_escapes" - expr: '" \\U00088888 "' - value: { string_value: " \U00088888 " } - } - test { - name: "unassigned_code_point_triple_single_quoted_escapes" - expr: "''' \\U00088888 '''" - value: { string_value: " \U00088888 " } - } - test { - name: "unassigned_code_point_triple_double_quoted_escapes" - expr: '""" \\U00088888 """' - value: { string_value: " \U00088888 " } - } - - test { - name: "unassigned_code_point_single_quoted_unescaped" - expr: "' \U00088888 '" - value: { string_value: " \U00088888 " } - } - test { - name: "unassigned_code_point_double_quoted_unescaped" - expr: '" \U00088888 "' - value: { string_value: " \U00088888 " } - } - test { - name: "unassigned_code_point_triple_single_quoted_unescaped" - expr: "''' \U00088888 '''" - value: { string_value: " \U00088888 " } - } - test { - name: "unassigned_code_point_triple_double_quoted_unescaped" - expr: '""" \U00088888 """' - value: { string_value: " \U00088888 " } - } - - test { - name: "raw_single_quoted_escapes" - expr: "r' \\\\ \\\? \\\" \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 '" - value: { string_value: " \\\\ \\\? \\\" \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "raw_double_quoted_escapes" - expr: 'r" \\\\ \\\? \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 "' - value: { string_value: " \\\\ \\\? \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "raw_triple_single_quoted_escapes" - expr: "r''' \\\\ \\\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 '''" - value: { string_value: " \\\\ \\\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "raw_triple_double_quoted_escapes" - expr: 'r""" \\\\ \\\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 """' - value: { string_value: " \\\\ \\\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - - test { - name: "upper_raw_single_quoted_escapes" - expr: "R' \\\\ \\\? \\\" \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 '" - value: { string_value: " \\\\ \\\? \\\" \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "upper_raw_double_quoted_escapes" - expr: 'R" \\\\ \\\? \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 "' - value: { string_value: " \\\\ \\\? \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "upper_raw_triple_single_quoted_escapes" - expr: "R''' \\\\ \\\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 '''" - value: { string_value: " \\\\ \\\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "upper_raw_triple_double_quoted_escapes" - expr: 'R""" \\\\ \\\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 """' - value: { string_value: " \\\\ \\\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } -} -section { - name: "bytes_literals" - description: "Check that bytes literals are properly parsed" - test { - name: "single_quoted" - expr: "b'hello'" - value: { bytes_value: "hello" } - } - test { - name: "double_quoted" - expr: 'b"hello"' - value: { bytes_value: "hello" } - } - test { - name: "triple_single_quoted" - expr: "b'''hello'''" - value: { bytes_value: "hello" } - } - test { - name: "triple_double_quoted" - expr: 'b"""hello"""' - value: { bytes_value: "hello" } - } - - test { - name: "single_quoted_escaped_punctuation" - expr: "b' \\\\ \\? \\\" \\\' \\` '" - value: { bytes_value: " \\ ? \" \' ` " } - } - test { - name: "double_quoted_escaped_punctuation" - expr: 'b" \\\\ \\? \\\" \\\' \\` "' - value: { bytes_value: " \\ ? \" \' ` " } - } - test { - name: "triple_single_quoted_escaped_punctuation" - expr: "b''' \\\\ \\? \\\" \\\' \\` '''" - value: { bytes_value: " \\ ? \" \' ` " } - } - test { - name: "triple_double_quoted_escaped_punctuation" - expr: 'b""" \\\\ \\? \\\" \\\' \\` """' - value: { bytes_value: " \\ ? \" \' ` " } - } - test { - name: "triple_single_quoted_unescaped_punctuation" - expr: "b''' ? \" \' ` '''" - value: { bytes_value: " ? \" \' ` " } - } - test { - name: "triple_double_quoted_unescaped_punctuation" - expr: 'b""" ? \" \' ` """' - value: { bytes_value: " ? \" \' ` " } - } - - test { - name: "single_quoted_escaped_special_control_characters" - expr: "b' \\a \\b \\f \\t \\v '" - value: { bytes_value: " \a \b \f \t \v " } - } - test { - name: "double_quoted_escaped_special_control_characters" - expr: 'b" \\a \\b \\f \\t \\v "' - value: { bytes_value: " \a \b \f \t \v " } - } - test { - name: "single_quoted_unescaped_special_control_characters" - expr: "b' \a \b \f \t \v '" - value: { bytes_value: " \a \b \f \t \v " } - } - test { - name: "double_quoted_unescaped_special_control_characters" - expr: 'b" \a \b \f \t \v "' - value: { bytes_value: " \a \b \f \t \v " } - } - - test { - name: "triple_single_quoted_escaped_special_control_characters" - expr: "b''' \\a \\b \\f \\t \\v '''" - value: { bytes_value: " \a \b \f \t \v " } - } - test { - name: "triple_double_quoted_escaped_special_control_characters" - expr: 'b""" \\a \\b \\f \\t \\v """' - value: { bytes_value: " \a \b \f \t \v " } - } - test { - name: "triple_single_quoted_unescaped_special_control_characters" - expr: "b''' \a \b \f \t \v '''" - value: { bytes_value: " \a \b \f \t \v " } - } - test { - name: "triple_double_quoted_unescaped_special_control_characters" - expr: 'b""" \a \b \f \t \v """' - value: { bytes_value: " \a \b \f \t \v " } - } - - test { - name: "single_quoted_escaped_line_feed" - expr: "b' \\n '" - value: { bytes_value: " \n " } - } - test { - name: "double_quoted_escaped_line_feed" - expr: 'b" \\n "' - value: { bytes_value: " \n " } - } - - test { - name: "triple_single_quoted_escaped_line_feed" - expr: "b''' \\n '''" - value: { bytes_value: " \n " } - } - test { - name: "triple_double_quoted_escaped_line_feed" - expr: 'b""" \\n """' - value: { bytes_value: " \n " } - } - test { - name: "triple_single_quoted_unescaped_line_feed" - expr: "b''' \n '''" - value: { bytes_value: " \n " } - } - test { - name: "triple_double_quoted_unescaped_line_feed" - expr: 'b""" \n """' - value: { bytes_value: " \n " } - } - - test { - name: "single_quoted_escaped_carriage_return" - expr: "b' \\r '" - value: { bytes_value: " \r " } - } - test { - name: "double_quoted_escaped_carriage_return" - expr: 'b" \\r "' - value: { bytes_value: " \r " } - } - - test { - name: "triple_single_quoted_escaped_carriage_return" - expr: "b''' \\r '''" - value: { bytes_value: " \r " } - } - test { - name: "triple_double_quoted_escaped_carriage_return" - expr: 'b""" \\r """' - value: { bytes_value: " \r " } - } - - # See https://github.com/cel-expr/cel-spec/issues/490 - # test { - # name: "triple_single_quoted_unescaped_carriage_return" - # expr: "b''' \r '''" - # value: { bytes_value: " \r " } - # } - # test { - # name: "triple_double_quoted_unescaped_carriage_return" - # expr: 'b""" \r """' - # value: { bytes_value: " \r " } - # } - - test { - name: "single_quoted_escaped_windows_line_end" - expr: "b' \\r\\n '" - value: { bytes_value: " \r\n " } - } - test { - name: "double_quoted_escaped_windows_line_end" - expr: 'b" \\r\\n "' - value: { bytes_value: " \r\n " } - } - - test { - name: "triple_single_quoted_escaped_windows_line_end" - expr: "b''' \\r\\n '''" - value: { bytes_value: " \r\n " } - } - test { - name: "triple_double_quoted_escaped_windows_line_end" - expr: 'b""" \\r\\n """' - value: { bytes_value: " \r\n " } - } - - # See https://github.com/cel-expr/cel-spec/issues/490 - # test { - # name: "triple_single_quoted_unescaped_windows_line_end" - # expr: "b''' \r\n '''" - # value: { bytes_value: " \r\n " } - # } - # test { - # name: "triple_double_quoted_unescaped_windows_line_end" - # expr: 'b""" \r\n """' - # value: { bytes_value: " \r\n " } - # } - - test { - name: "single_quoted_escaped_all_control_characters" - expr: "b' \\x01 \\x02 \\x03 \\x04 \\x05 \\x06 \\x07 \\x08 \\x09 \\x0B \\x0C \\x0E \\x0F \\x10 \\x11 \\x12 \\x13 \\x14 \\x15 \\x16 \\x17 \\x18 \\x19 \\x1A \\x1B \\x1C \\x1D \\x1E \\x1f \\x7F '" - value: { bytes_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "double_quoted_escaped_all_control_characters" - expr: 'b" \\x01 \\x02 \\x03 \\x04 \\x05 \\x06 \\x07 \\x08 \\x09 \\x0B \\x0C \\x0E \\x0F \\x10 \\x11 \\x12 \\x13 \\x14 \\x15 \\x16 \\x17 \\x18 \\x19 \\x1A \\x1B \\x1C \\x1D \\x1E \\x1f \\x7F "' - value: { bytes_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "single_quoted_unescaped_all_control_characters" - expr: "b' \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F '" - value: { bytes_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "double_quoted_unescaped_all_control_characters" - expr: 'b" \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F "' - value: { bytes_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - - test { - name: "triple_single_quoted_escaped_all_control_characters" - expr: "b''' \\x01 \\x02 \\x03 \\x04 \\x05 \\x06 \\x07 \\x08 \\x09 \\x0B \\x0C \\x0E \\x0F \\x10 \\x11 \\x12 \\x13 \\x14 \\x15 \\x16 \\x17 \\x18 \\x19 \\x1A \\x1B \\x1C \\x1D \\x1E \\x1f \\x7F '''" - value: { bytes_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "triple_double_quoted_escaped_all_control_characters" - expr: 'b""" \\x01 \\x02 \\x03 \\x04 \\x05 \\x06 \\x07 \\x08 \\x09 \\x0B \\x0C \\x0E \\x0F \\x10 \\x11 \\x12 \\x13 \\x14 \\x15 \\x16 \\x17 \\x18 \\x19 \\x1A \\x1B \\x1C \\x1D \\x1E \\x1f \\x7F """' - value: { bytes_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "triple_single_quoted_unescaped_all_control_characters" - expr: "b''' \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F '''" - value: { bytes_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - test { - name: "triple_double_quoted_unescaped_all_control_characters" - expr: 'b""" \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F """' - value: { bytes_value: " \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x09 \x0B \x0C \x0E \x0F \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1A \x1B \x1C \x1D \x1E \x1f \x7F " } - } - - test { - name: "single_quoted_octal_escapes" - expr: "b' \\000 \\012 \\177 \\377 '" - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - test { - name: "double_quoted_octal_escapes" - expr: 'b" \\000 \\012 \\177 \\377 "' - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - test { - name: "triple_single_quoted_octal_escapes" - expr: "b''' \\000 \\012 \\177 \\377 '''" - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - test { - name: "triple_double_quoted_octal_escapes" - expr: 'b""" \\000 \\012 \\177 \\377 """' - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - - test { - name: "single_quoted_lower_x_escapes" - expr: "b' \\x00 \\x0A \\x7F \\xFF '" - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - test { - name: "double_quoted_lower_x_escapes" - expr: 'b" \\x00 \\x0A \\x7F \\xFF "' - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - test { - name: "triple_single_quoted_lower_x_escapes" - expr: "b''' \\x00 \\x0A \\x7F \\xFF '''" - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - test { - name: "triple_double_quoted_lower_x_escapes" - expr: 'b""" \\x00 \\x0A \\x7F \\xFF """' - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - - test { - name: "single_quoted_upper_x_escapes" - expr: "b' \\X00 \\X0A \\X7F \\XFF '" - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - test { - name: "double_quoted_upper_x_escapes" - expr: 'b" \\X00 \\X0A \\X7F \\XFF "' - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - test { - name: "triple_single_quoted_upper_x_escapes" - expr: "b''' \\X00 \\X0A \\X7F \\XFF '''" - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - test { - name: "triple_double_quoted_upper_x_escapes" - expr: 'b""" \\X00 \\X0A \\X7F \\XFF """' - value: { bytes_value: " \x00 \x0A \x7F \xFF " } - } - - test { - name: "mixed_case_hex_single_quoted_escapes" - expr: "B' \\x4a \\x4B \\X4c \\X4D '" - value: { bytes_value: " \x4a \x4B \x4c \x4D " } - } - test { - name: "mixed_case_hex_double_quoted_escapes" - expr: 'B" \\x4a \\x4B \\X4c \\X4D "' - value: { bytes_value: " \x4a \x4B \x4c \x4D " } - } - test { - name: "mixed_case_hex_triple_single_quoted_escapes" - expr: "B''' \\x4a \\x4B \\X4c \\X4D '''" - value: { bytes_value: " \x4a \x4B \x4c \x4D " } - } - test { - name: "mixed_case_hex_triple_double_quoted_escapes" - expr: 'B""" \\x4a \\x4B \\X4c \\X4D """' - value: { bytes_value: " \x4a \x4B \x4c \x4D " } - } - - test { - name: "raw_single_quoted_escapes" - expr: "br' \\\\ \\? \\\" \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 '" - value: { bytes_value: " \\\\ \\? \\\" \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "raw_double_quoted_escapes" - expr: 'br" \\\\ \\? \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 "' - value: { bytes_value: " \\\\ \\? \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "raw_triple_single_quoted_escapes" - expr: "br''' \\\\ \\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 '''" - value: { bytes_value: " \\\\ \\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "raw_triple_double_quoted_escapes" - expr: 'br""" \\\\ \\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 """' - value: { bytes_value: " \\\\ \\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - - test { - name: "upper_raw_single_quoted_escapes" - expr: "bR' \\\\ \\? \\\" \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 '" - value: { bytes_value: " \\\\ \\? \\\" \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "upper_raw_double_quoted_escapes" - expr: 'bR" \\\\ \\? \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 "' - value: { bytes_value: " \\\\ \\? \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "upper_raw_triple_single_quoted_escapes" - expr: "bR''' \\\\ \\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 '''" - value: { bytes_value: " \\\\ \\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } - test { - name: "upper_raw_triple_double_quoted_escapes" - expr: 'bR""" \\\\ \\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 """' - value: { bytes_value: " \\\\ \\? \\\" \\\' \\` \\a \\b \\f \\t \\v \\n \\r \\000 \\x00 \\X00 \\u0000 \\U00000000 " } - } -} -# txtpbfmt: on - -section { - name: "whitespace" - description: "Check that whitespace is ignored by the grammar." - test { - name: "spaces" - description: "Check that spaces are ignored." - expr: "[ . cel. expr .conformance. proto3. TestAllTypes { single_int64 : int ( 17 ) } . single_int64 ] [ 0 ] == ( 18 - 1 ) && ! false ? 1 : 2" - value { int64_value: 1 } - } - test { - name: "tabs" - description: "Check that tabs (`\\t`) are ignored." - expr: "[\t.\tcel.\texpr\t.conformance.\tproto3.\tTestAllTypes\t{\tsingle_int64\t:\tint\t(\t17\t)\t}\t.\tsingle_int64\t]\t[\t0\t]\t==\t(\t18\t-\t1\t)\t&&\t!\tfalse\t?\t1\t:\t2" - value { int64_value: 1 } - } - test { - name: "new_lines" - description: "Check that new lines (`\\n`) are ignored." - expr: "[\n.\ncel.\nexpr\n.conformance.\nproto3.\nTestAllTypes\n{\nsingle_int64\n:\nint\n(\n17\n)\n}\n.\nsingle_int64\n]\n[\n0\n]\n==\n(\n18\n-\n1\n)\n&&\n!\nfalse\n?\n1\n:\n2" - value { int64_value: 1 } - } - test { - name: "new_pages" - description: "Check that new pages (`\\f`) are ignored." - expr: "[\f.\fcel.\fexpr\f.conformance.\fproto3.\fTestAllTypes\f{\fsingle_int64\f:\fint\f(\f17\f)\f}\f.\fsingle_int64\f]\f[\f0\f]\f==\f(\f18\f-\f1\f)\f&&\f!\ffalse\f?\f1\f:\f2" - value { int64_value: 1 } - } - test { - name: "carriage_returns" - description: "Check that carriage returns (`\\r`) are ignored." - expr: "[\r.\rcel.\rexpr\r.conformance.\rproto3.\rTestAllTypes\r{\rsingle_int64\r:\rint\r(\r17\r)\r}\r.\rsingle_int64\r]\r[\r0\r]\r==\r(\r18\r-\r1\r)\r&&\r!\rfalse\r?\r1\r:\r2" - value { int64_value: 1 } - } -} -section { - name: "comments" - description: "Check that comments are ignored by the grammar. Note that carriage returns alone cannot terminate comments." - test { - name: "new_line_terminated" - description: "Check that new-line-terminated comments are ignored." - expr: "[// @\n.// @\ncel.// @\nexpr// @\n.conformance.// @\nproto3.// @\nTestAllTypes// @\n{// @\nsingle_int64// @\n:// @\nint// @\n(// @\n17// @\n)// @\n}// @\n.// @\nsingle_int64// @\n]// @\n[// @\n0// @\n]// @\n==// @\n(// @\n18// @\n-// @\n1// @\n)// @\n&&// @\n!// @\nfalse// @\n?// @\n1// @\n:// @\n2" - value { int64_value: 1 } - } -} -section { - name: "selectors" - description: "Check that reserved identifiers are permitted as selectors as long as they are not language keywords" - test { - name: "as" - description: "Check that `as` can be used as a selector." - expr: "{ 'as': 1 }.as" - value { int64_value: 1 } - } - test { - name: "break" - description: "Check that `break` can be used as a selector." - expr: "{ 'break': 1 }.break" - value { int64_value: 1 } - } - test { - name: "const" - description: "Check that `const` can be used as a selector." - expr: "{ 'const': 1 }.const" - value { int64_value: 1 } - } - test { - name: "continue" - description: "Check that `continue` can be used as a selector." - expr: "{ 'continue': 1 }.continue" - value { int64_value: 1 } - } - test { - name: "else" - description: "Check that `else` can be used as a selector." - expr: "{ 'else': 1 }.else" - value { int64_value: 1 } - } - test { - name: "for" - description: "Check that `for` can be used as a selector." - expr: "{ 'for': 1 }.for" - value { int64_value: 1 } - } - test { - name: "function" - description: "Check that `function` can be used as a selector." - expr: "{ 'function': 1 }.function" - value { int64_value: 1 } - } - test { - name: "if" - description: "Check that `if` can be used as a selector." - expr: "{ 'if': 1 }.if" - value { int64_value: 1 } - } - test { - name: "import" - description: "Check that `import` can be used as a selector." - expr: "{ 'import': 1 }.import" - value { int64_value: 1 } - } - test { - name: "let" - description: "Check that `let` can be used as a selector." - expr: "{ 'let': 1 }.let" - value { int64_value: 1 } - } - test { - name: "loop" - description: "Check that `loop` can be used as a selector." - expr: "{ 'loop': 1 }.loop" - value { int64_value: 1 } - } - test { - name: "package" - description: "Check that `package` can be used as a selector." - expr: "{ 'package': 1 }.package" - value { int64_value: 1 } - } - test { - name: "namespace" - description: "Check that `namespace` can be used as a selector." - expr: "{ 'namespace': 1 }.namespace" - value { int64_value: 1 } - } - test { - name: "return" - description: "Check that `return` can be used as a selector." - expr: "{ 'return': 1 }.return" - value { int64_value: 1 } - } - test { - name: "var" - description: "Check that `var` can be used as a selector." - expr: "{ 'var': 1 }.var" - value { int64_value: 1 } - } - test { - name: "void" - description: "Check that `void` can be used as a selector." - expr: "{ 'void': 1 }.void" - value { int64_value: 1 } - } - test { - name: "while" - description: "Check that `while` can be used as a selector." - expr: "{ 'while': 1 }.while" - value { int64_value: 1 } - } -} -section { - name: "receiver_function_names" - description: "Check that reserved identifiers are permitted as receiver function names as long as they are not language keywords" - test { - name: "as" - description: "Check that `as` can be used as a receiver function." - expr: "a.as() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "break" - description: "Check that `break` can be used as a receiver function." - expr: "a.break() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "const" - description: "Check that `const` can be used as a receiver function." - expr: "a.const() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "continue" - description: "Check that `continue` can be used as a receiver function." - expr: "a.continue() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "else" - description: "Check that `else` can be used as a receiver function." - expr: "a.else() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "for" - description: "Check that `for` can be used as a receiver function." - expr: "a.for() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "function" - description: "Check that `function` can be used as a receiver function." - expr: "a.function() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "if" - description: "Check that `if` can be used as a receiver function." - expr: "a.if() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "import" - description: "Check that `import` can be used as a receiver function." - expr: "a.import() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "let" - description: "Check that `let` can be used as a receiver function." - expr: "a.let() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "loop" - description: "Check that `loop` can be used as a receiver function." - expr: "a.loop() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "package" - description: "Check that `package` can be used as a receiver function." - expr: "a.package() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "namespace" - description: "Check that `namespace` can be used as a receiver function." - expr: "a.namespace() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "return" - description: "Check that `return` can be used as a receiver function." - expr: "a.return() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "var" - description: "Check that `var` can be used as a receiver function." - expr: "a.var() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "void" - description: "Check that `void` can be used as a receiver function." - expr: "a.void() || true" - disable_check: true - value { bool_value: true } - } - test { - name: "while" - description: "Check that `while` can be used as a receiver function." - expr: "a.while() || true" - disable_check: true - value { bool_value: true } - } -} -section { - name: "struct_field_names" - description: "Check that reserved identifiers are permitted as struct field names as long as they are not language keywords" - test { - name: "as" - description: "Check that `as` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ as: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { as: true } - } - } - } - test { - name: "break" - description: "Check that `break` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ break: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { break: true } - } - } - } - test { - name: "const" - description: "Check that `const` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ const: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { const: true } - } - } - } - test { - name: "continue" - description: "Check that `continue` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ continue: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { continue: true } - } - } - } - test { - name: "else" - description: "Check that `else` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ else: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { else: true } - } - } - } - test { - name: "for" - description: "Check that `for` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ for: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { for: true } - } - } - } - test { - name: "function" - description: "Check that `function` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ function: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { function: true } - } - } - } - test { - name: "if" - description: "Check that `if` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ if: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { if: true } - } - } - } - test { - name: "import" - description: "Check that `import` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ import: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { import: true } - } - } - } - test { - name: "let" - description: "Check that `let` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ let: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { let: true } - } - } - } - test { - name: "loop" - description: "Check that `loop` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ loop: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { loop: true } - } - } - } - test { - name: "package" - description: "Check that `package` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ package: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { package: true } - } - } - } - test { - name: "namespace" - description: "Check that `namespace` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ namespace: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { namespace: true } - } - } - } - test { - name: "return" - description: "Check that `return` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ return: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { return: true } - } - } - } - test { - name: "var" - description: "Check that `var` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ var: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { var: true } - } - } - } - test { - name: "void" - description: "Check that `void` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ void: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { void: true } - } - } - } - test { - name: "while" - description: "Check that `while` can be used as a struct field name." - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{ while: true }" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { while: true } - } - } - } -} diff --git a/tests/simple/testdata/plumbing.textproto b/tests/simple/testdata/plumbing.textproto deleted file mode 100644 index 7b347aa1..00000000 --- a/tests/simple/testdata/plumbing.textproto +++ /dev/null @@ -1,74 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: google.api.expr.test.v1.SimpleTestFile - -name: "plumbing" -description: "Check that the ConformanceService server can accept all arguments and return all responses." -section { - name: "min" - description: "Minimal programs." - test { - name: "min_program" - description: "Smallest functionality: expr in, result out." - expr: "17" - value: { int64_value: 17 } - } -} -section { - name: "eval_results" - description: "All evaluation result kinds." - test { - name: "error_result" - description: "Check that error results go through." - expr: "1 / 0" - eval_error: { - errors: { message: "foo" } - } - } - test { - name: "eval_map_results" - description: "Check that map literals results are order independent." - expr: '{"k1":"v1","k":"v"}' - value: { - map_value { - entries { - key: { string_value: "k" } - value: { string_value: "v" } - } - entries { - key: { string_value: "k1" } - value: { string_value: "v1" } - } - } - } - } -} -section { - name: "check_inputs" - description: "All inputs to Check phase." - test { - name: "skip_check" - description: "Make sure we can skip type checking." - expr: "[17, 'pancakes']" - disable_check: true - value: { - list_value { - values: { int64_value: 17 } - values: { string_value: "pancakes" } - } - } - } -} -section { - name: "eval_inputs" - description: "All inputs to Eval phase." - test { - name: "one_ignored_value_arg" - description: "Check that value bindings can be given, even if ignored." - expr: "'foo'" - bindings: { - key: "x" - value: { value: { int64_value: 17 } } - } - value: { string_value: "foo" } - } -} diff --git a/tests/simple/testdata/proto2.textproto b/tests/simple/testdata/proto2.textproto deleted file mode 100644 index c3cd1187..00000000 --- a/tests/simple/testdata/proto2.textproto +++ /dev/null @@ -1,1290 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "proto2" -description: "Protocol buffer version 2 tests. See notes for the available set of protos for tests." - -section { - name: "literal_singular" - description: "Literals with singular fields set." - - test { - name: "int64_nocontainer" - expr: "cel.expr.conformance.proto2.TestAllTypes{single_int64: 17}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int64: 17 } - } - } - } - - test { - name: "int32" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int32: -34}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int32: -34 } - } - } - } - - test { - name: "int32_eq_uint" - container: "google.protobuf" - expr: "Int32Value{value: 34} == dyn(UInt64Value{value: 34u})" - value { bool_value: true } - } - - test { - name: "not_int32_eq_uint" - container: "google.protobuf" - expr: "Int32Value{value: 34} == dyn(UInt64Value{value: 18446744073709551615u})" - value { bool_value: false } - } - - test { - name: "int32_eq_double" - container: "google.protobuf" - expr: "Int32Value{value: 34} == dyn(DoubleValue{value: 34.0})" - value { bool_value: true } - } - - test { - name: "not_int32_eq_double" - container: "google.protobuf" - expr: "Int32Value{value: 34} == dyn(DoubleValue{value: -9223372036854775809.0})" - value { bool_value: false } - } - - test { - name: "int64" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int64: 17}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int64: 17 } - } - } - } - - test { - name: "uint32" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint32: 1u}" - value { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_uint32: 1 } - } - } - } - - test { - name: "uint32_eq_int" - container: "google.protobuf" - expr: "UInt32Value{value: 34u} == dyn(Int64Value{value: 34})" - value { bool_value: true } - } - - test { - name: "not_uint32_eq_int" - container: "google.protobuf" - expr: "UInt32Value{value: 34u} == dyn(Int64Value{value: -1})" - value { bool_value: false } - } - - test { - name: "uint32_eq_double" - container: "google.protobuf" - expr: "UInt32Value{value: 34u} == dyn(DoubleValue{value: 34.0})" - value { bool_value: true } - } - - test { - name: "not_uint32_eq_double" - container: "google.protobuf" - expr: "UInt32Value{value: 34u} == dyn(DoubleValue{value: 18446744073709551616.0})" - value { bool_value: false } - } - - test { - name: "uint64" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint64: 9999u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_uint64: 9999 } - } - } - } - - test { - name: "sint32" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_sint32: -3}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_sint32: -3 } - } - } - } - - test { - name: "sint64" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_sint64: 255}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_sint64: 255 } - } - } - } - - test { - name: "fixed32" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_fixed32: 43u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_fixed32: 43 } - } - } - } - - test { - name: "fixed64" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_fixed64: 1880u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_fixed64: 1880 } - } - } - } - - test { - name: "sfixed32" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_sfixed32: -404}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_sfixed32: -404 } - } - } - } - - test { - name: "sfixed64" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_sfixed64: -1}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_sfixed64: -1 } - } - } - } - - test { - name: "float" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_float: 3.1416}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_float: 3.1416 } - } - } - } - - test { - name: "float_eq_int" - container: "google.protobuf" - expr: "FloatValue{value: 3.0} == dyn(Int64Value{value: 3})" - value { bool_value: true } - } - - test { - name: "not_float_eq_int" - container: "google.protobuf" - expr: "FloatValue{value: -1.14} == dyn(Int64Value{value: -1})" - value { bool_value: false } - } - - test { - name: "float_eq_uint" - container: "google.protobuf" - expr: "FloatValue{value: 34.0} == dyn(UInt64Value{value: 34u})" - value { bool_value: true } - } - - test { - name: "not_float_eq_uint" - container: "google.protobuf" - expr: "FloatValue{value: -1.0} == dyn(UInt64Value{value: 18446744073709551615u})" - value { bool_value: false } - } - - test { - name: "double" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_double: 6.022e23}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_double: 6.022e23 } - } - } - } - - test { - name: "bool" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_bool: true}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_bool: true } - } - } - } - - test { - name: "string" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_string: 'foo'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_string: "foo" } - } - } - } - - test { - name: "bytes" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_bytes: b'\\377'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_bytes: "\377" } - } - } - } -} - -section { - name: "literal_wellknown" - description: "Literals with well-known fields set." - - test { - name: "any" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_any: TestAllTypes{single_int32: 1}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_any { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_int32: 1 - } - } - } - } - } - } - - test { - name: "duration" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_duration: duration('123s')}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_duration { - seconds: 123 - } - } - } - } - } - - test { - name: "timestamp" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_timestamp: timestamp('2009-02-13T23:31:30Z')}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_timestamp { - seconds: 1234567890 - } - } - } - } - } - - test { - name: "struct" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_struct: {'one': 1, 'two': 2}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_struct { - fields { - key: "one" - value { number_value: 1.0 } - } - fields { - key: "two" - value { number_value: 2.0 } - } - } - } - } - } - } - - test { - name: "value" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: 'foo'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_value { - string_value: "foo" - } - } - } - } - } - - test { - name: "int64_wrapper" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int64_wrapper: -321}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_int64_wrapper { - value: -321 - } - } - } - } - } - - test { - name: "int32_wrapper" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_int32_wrapper: -456}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_int32_wrapper { - value: -456 - } - } - } - } - } - - test { - name: "double_wrapper" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_double_wrapper: 2.71828}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_double_wrapper { - value: 2.71828 - } - } - } - } - } - - test { - name: "float_wrapper" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_float_wrapper: 2.99792e8}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_float_wrapper { - value: 2.99792e8 - } - } - } - } - } - - test { - name: "uint64_wrapper" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint64_wrapper: 8675309u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_uint64_wrapper { - value: 8675309 - } - } - } - } - } - - test { - name: "uint32_wrapper" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_uint32_wrapper: 987u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_uint32_wrapper { - value: 987 - } - } - } - } - } - - test { - name: "string_wrapper" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_string_wrapper: 'hubba'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_string_wrapper { - value: "hubba" - } - } - } - } - } - - test { - name: "bool_wrapper" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_bool_wrapper: true}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_bool_wrapper { - value: true - } - } - } - } - } - - test { - name: "bytes_wrapper" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_bytes_wrapper: b'\\301\\103'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { - single_bytes_wrapper { - value: "\301\103" - } - } - } - } - } - -} - -section { - name: "singular_bind" - description: "Binding the singular fields." - - test { - name: "int32" - expr: "x.single_int32" - type_env: { - name: "x" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "x" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int32: 17 } - } - } - } - } - value: { int64_value: 17 } - } - - test { - name: "int64" - expr: "x.single_int64" - type_env: { - name: "x" - ident { type { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "x" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes] { single_int64: -99 } - } - } - } - } - value: { int64_value: -99 } - } -} - -section { - name: "empty_field" - description: "Tests on empty fields." - - test { - name: "scalar_with_default" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_int32" - value: { int64_value: -32 } - } - - test { - name: "scalar_no_default" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_fixed32" - value: { uint64_value: 0 } - } - - test { - name: "nested_message" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_nested_message" - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes.NestedMessage] {} - } - } - } - - test { - name: "nested_message_subfield" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_nested_message.bb" - value: { int64_value: 0 } - } - - test { - name: "wkt" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.single_int64_wrapper" - value: { null_value: NULL_VALUE } - } - - test { - name: "repeated_scalar" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.repeated_int64" - value: { list_value: {} } - } - - test { - name: "repeated_enum" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.repeated_nested_enum" - value: { list_value: {} } - } - - test { - name: "repeated_nested" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.repeated_nested_message" - value: { list_value: {} } - } - - test { - name: "map" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{}.map_string_string" - value: { map_value: {} } - } -} -section { - name: "has" - description: "Tests for the has() macro on proto2 messages." - test { - name: "undefined" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{}.no_such_field)" - disable_check: true - eval_error: { - errors: { message: "no_such_field" } - } - } - test { - name: "repeated_none_implicit" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{}.repeated_int32)" - value { bool_value: false } - } - test { - name: "repeated_none_explicit" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{repeated_int32: []}.repeated_int32)" - value { bool_value: false } - } - test { - name: "repeated_one" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{repeated_int32: [1]}.repeated_int32)" - value { bool_value: true } - } - test { - name: "repeated_many" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{repeated_int32: [1, 2, 3]}.repeated_int32)" - value { bool_value: true } - } - test { - name: "map_none_implicit" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{}.map_string_string)" - value { bool_value: false } - } - test { - name: "map_none_explicit" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{map_string_string: {}}.map_string_string)" - value { bool_value: false } - } - test { - name: "map_one_default" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{map_string_string: {'MT': ''}}.map_string_string)" - value { bool_value: true } - } - test { - name: "map_one" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{map_string_string: {'one': 'uno'}}.map_string_string)" - value { bool_value: true } - } - test { - name: "map_many" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{map_string_string: {'one': 'uno', 'two': 'dos'}}.map_string_string)" - value { bool_value: true } - } - test { - name: "required" - container: "cel.expr.conformance.proto2" - expr: "has(TestRequired{required_int32: 4}.required_int32)" - value { bool_value: true } - } - test { - name: "optional_unset_no_default" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{}.single_sint32)" - value { bool_value: false } - } - test { - name: "optional_set_no_default" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{single_sint32: -4}.single_sint32)" - value { bool_value: true } - } - test { - name: "optional_unset_with_default" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{}.single_int32)" - value { bool_value: false } - } - test { - name: "optional_set_with_default" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{single_int32: 16}.single_int32)" - value { bool_value: true } - } - test { - name: "optional_set_to_default" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{single_int32: -32}.single_int32)" - value { bool_value: true } - } - test { - name: "optional_message_unset" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{}.standalone_message)" - value { bool_value: false } - } - test { - name: "optional_message_set" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{standalone_message: TestAllTypes.NestedMessage{}}.standalone_message)" - value { bool_value: true } - } - test { - name: "optional_enum_unset" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{}.standalone_enum)" - value { bool_value: false } - } - test { - name: "optional_enum_set" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{standalone_enum: TestAllTypes.NestedEnum.BAR}.standalone_enum)" - value { bool_value: true } - } - test { - name: "optional_enum_set_zero" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{standalone_enum: TestAllTypes.NestedEnum.FOO}.standalone_enum)" - value { bool_value: true } - } - test { - name: "oneof_unset" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{}.single_nested_message)" - value { bool_value: false } - } - test { - name: "oneof_other_set" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{single_nested_enum: TestAllTypes.NestedEnum.BAZ}.single_nested_message)" - value { bool_value: false } - } - test { - name: "oneof_set" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{single_nested_message: TestAllTypes.NestedMessage{}}.single_nested_message)" - value { bool_value: true } - } - test { - name: "oneof_set_default" - container: "cel.expr.conformance.proto2" - expr: "has(TestAllTypes{single_nested_enum: TestAllTypes.NestedEnum.FOO}.single_nested_enum)" - value { bool_value: true } - } -} -section { - name: "set_null" - test { - name: "single_message" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_nested_message: null} == TestAllTypes{}" - value: { bool_value: true } - } - test { - name: "single_any" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_any: null}.single_any" - value { null_value: NULL_VALUE } - } - test { - name: "single_value" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_value: null}.single_value" - value { null_value: NULL_VALUE } - } - test { - name: "single_duration" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_duration: null} == TestAllTypes{}" - value: { bool_value: true } - } - test { - name: "single_timestamp" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_timestamp: null} == TestAllTypes{}" - value: { bool_value: true } - } - test { - name: "repeated_field_timestamp_null_pruned" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{repeated_timestamp: [timestamp(1), null]}.repeated_timestamp == [timestamp(1)]" - value: { bool_value: true } - } - test { - name: "repeated_field_duration_null_pruned" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{repeated_duration: [duration('1s'), null]}.repeated_duration == [duration('1s')]" - value: { bool_value: true } - } - test { - name: "repeated_field_wrapper_null_pruned" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{repeated_int32_wrapper: [1, null]}.repeated_int32_wrapper == [1]" - value: { bool_value: true } - } - test { - name: "repeated_field_anytype_null_retained" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{repeated_any: [1, null]}.repeated_any == [1, null]" - value: { bool_value: true } - } - test { - name: "repeated_field_jsontype_null_retained" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{repeated_value: [google.protobuf.Value{bool_value: true}, null]}.repeated_value == [true, null]" - value: { bool_value: true } - } - test { - name: "map_timestamp_null_pruned" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{map_bool_timestamp: {true: null, false: timestamp(1)}}.map_bool_timestamp == {false: timestamp(1)}" - value: { bool_value: true } - } - test { - name: "map_duration_null_pruned" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{map_bool_duration: {true: null, false: duration('1s')}}.map_bool_duration == {false: duration('1s')}" - value: { bool_value: true } - } - test { - name: "map_wrapper_null_pruned" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{map_bool_int32_wrapper: {true: null, false: 1}}.map_bool_int32_wrapper == {false: 1}" - value: { bool_value: true } - } - test { - name: "map_anytype_null_retained" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{map_bool_any: {true: null, false: 1}}.map_bool_any == {true: null, false: 1}" - value: { bool_value: true } - } - test { - name: "map_jsontype_null_retained" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{map_bool_value: {true: null, false: google.protobuf.Value{bool_value: true}}}.map_bool_value == {true: null, false: true}" - value: { bool_value: true } - } - - test { - name: "single_scalar" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_bool: null} == TestAllTypes{}" - disable_check: true - eval_error: { - errors: { message: "unsupported field type" } - } - } - test { - name: "repeated" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{repeated_int32: null} == TestAllTypes{}" - disable_check: true - eval_error: { - errors: { message: "unsupported field type" } - } - } - test { - name: "map" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{map_string_string: null} == TestAllTypes{}" - disable_check: true - eval_error: { - errors: { message: "unsupported field type" } - } - } - test { - name: "list_value" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{list_value: null} == TestAllTypes{}" - disable_check: true - eval_error: { - errors: { message: "unsupported field type" } - } - } - test { - name: "single_struct" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{single_struct: null} == TestAllTypes{}" - disable_check: true - eval_error: { - errors: { message: "unsupported field type" } - } - } -} -section { - name: "quoted_fields" - test { - name: "set_field_with_quoted_name" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{`in`: true} == TestAllTypes{}" - value: { bool_value: false } - } - test { - name: "get_field_with_quoted_name" - container: "cel.expr.conformance.proto2" - expr: "TestAllTypes{`in`: true}.`in`" - value: { bool_value: true } - } -} -section: { - name: "extensions_has" - description: "Tests for presence checks on proto2 extension fields." - test: { - name: "package_scoped_int32" - expr: "has(msg.`cel.expr.conformance.proto2.int32_ext`)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.int32_ext]: 42 - } - } - } - } - } - } - test: { - name: "package_scoped_nested_ext" - expr: "has(msg.`cel.expr.conformance.proto2.nested_ext`)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.nested_ext]: {} - } - } - } - } - } - } - test: { - name: "package_scoped_test_all_types_ext" - expr: "has(msg.`cel.expr.conformance.proto2.test_all_types_ext`)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.test_all_types_ext]: {} - } - } - } - } - } - } - test: { - name: "package_scoped_test_all_types_nested_enum_ext" - expr: "has(msg.`cel.expr.conformance.proto2.nested_enum_ext`)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.nested_enum_ext]: BAR - } - } - } - } - } - } - test: { - name: "package_scoped_repeated_test_all_types" - expr: "has(msg.`cel.expr.conformance.proto2.repeated_test_all_types`)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.repeated_test_all_types]: [ { single_int64: 1 }, { single_bool: true } ] - } - } - } - } - } - } - test: { - name: "message_scoped_int64" - expr: "has(msg.`cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.int64_ext`)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.int64_ext]: 42 - } - } - } - } - } - } - test: { - name: "message_scoped_nested_ext" - expr: "has(msg.`cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_nested_ext`)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_nested_ext]: {} - } - } - } - } - } - } - test: { - name: "message_scoped_nested_enum_ext" - expr: "has(msg.`cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.nested_enum_ext`)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.nested_enum_ext]: BAR - } - } - } - } - } - } - test: { - name: "message_scoped_repeated_test_all_types" - expr: "has(msg.`cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_repeated_test_all_types`)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_repeated_test_all_types]: [ { single_int64: 1 }, { single_bool: true } ] - } - } - } - } - } - } -} -section { - name: "extensions_get" - description: "Tests for accessing proto2 extension fields." - test: { - name: "package_scoped_int32" - expr: "msg.`cel.expr.conformance.proto2.int32_ext` == 42" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.int32_ext]: 42 - } - } - } - } - } - } - test: { - name: "package_scoped_nested_ext" - expr: "msg.`cel.expr.conformance.proto2.nested_ext` == cel.expr.conformance.proto2.TestAllTypes{}" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.nested_ext]: {} - } - } - } - } - } - } - test: { - name: "package_scoped_test_all_types_ext" - expr: "msg.`cel.expr.conformance.proto2.test_all_types_ext` == cel.expr.conformance.proto2.TestAllTypes{}" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.test_all_types_ext]: {} - } - } - } - } - } - } - test: { - name: "package_scoped_test_all_types_nested_enum_ext" - expr: "msg.`cel.expr.conformance.proto2.nested_enum_ext` == cel.expr.conformance.proto2.TestAllTypes.NestedEnum.BAR" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.nested_enum_ext]: BAR - } - } - } - } - } - } - test: { - name: "package_scoped_repeated_test_all_types" - expr: "msg.`cel.expr.conformance.proto2.repeated_test_all_types` == [cel.expr.conformance.proto2.TestAllTypes{single_int64: 1}, cel.expr.conformance.proto2.TestAllTypes{single_bool: true}]" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.repeated_test_all_types]: [ { single_int64: 1 }, { single_bool: true } ] - } - } - } - } - } - } - test: { - name: "message_scoped_int64" - expr: "msg.`cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.int64_ext` == 42" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.int64_ext]: 42 - } - } - } - } - } - } - test: { - name: "message_scoped_nested_ext" - expr: "msg.`cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_nested_ext` == cel.expr.conformance.proto2.TestAllTypes{}" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_nested_ext]: {} - } - } - } - } - } - } - test: { - name: "message_scoped_nested_enum_ext" - expr: "msg.`cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.nested_enum_ext` == cel.expr.conformance.proto2.TestAllTypes.NestedEnum.BAR" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.nested_enum_ext]: BAR - } - } - } - } - } - } - test: { - name: "message_scoped_repeated_test_all_types" - expr: "msg.`cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_repeated_test_all_types` == [cel.expr.conformance.proto2.TestAllTypes{single_int64: 1}, cel.expr.conformance.proto2.TestAllTypes{single_bool: true}]" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_repeated_test_all_types]: [ { single_int64: 1 }, { single_bool: true } ] - } - } - } - } - } - } -} diff --git a/tests/simple/testdata/proto2_ext.textproto b/tests/simple/testdata/proto2_ext.textproto deleted file mode 100644 index efd3fa4b..00000000 --- a/tests/simple/testdata/proto2_ext.textproto +++ /dev/null @@ -1,372 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "proto2_ext" -description: "Tests for the proto extension library." -section: { - name: "has_ext" - test: { - name: "package_scoped_int32" - expr: "proto.hasExt(msg, cel.expr.conformance.proto2.int32_ext)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.int32_ext]: 42 - } - } - } - } - } - } - test: { - name: "package_scoped_nested_ext" - expr: "proto.hasExt(msg, cel.expr.conformance.proto2.nested_ext)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.nested_ext]: {} - } - } - } - } - } - } - test: { - name: "package_scoped_test_all_types_ext" - expr: "proto.hasExt(msg, cel.expr.conformance.proto2.test_all_types_ext)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.test_all_types_ext]: {} - } - } - } - } - } - } - test: { - name: "package_scoped_test_all_types_nested_enum_ext" - expr: "proto.hasExt(msg, cel.expr.conformance.proto2.nested_enum_ext)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.nested_enum_ext]: BAR - } - } - } - } - } - } - test: { - name: "package_scoped_repeated_test_all_types" - expr: "proto.hasExt(msg, cel.expr.conformance.proto2.repeated_test_all_types)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.repeated_test_all_types]: [ { single_int64: 1 }, { single_bool: true } ] - } - } - } - } - } - } - test: { - name: "message_scoped_int64" - expr: "proto.hasExt(msg, cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.int64_ext)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.int64_ext]: 42 - } - } - } - } - } - } - test: { - name: "message_scoped_nested_ext" - expr: "proto.hasExt(msg, cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_nested_ext)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_nested_ext]: {} - } - } - } - } - } - } - test: { - name: "message_scoped_nested_enum_ext" - expr: "proto.hasExt(msg, cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.nested_enum_ext)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.nested_enum_ext]: BAR - } - } - } - } - } - } - test: { - name: "message_scoped_repeated_test_all_types" - expr: "proto.hasExt(msg, cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_repeated_test_all_types)" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_repeated_test_all_types]: [ { single_int64: 1 }, { single_bool: true } ] - } - } - } - } - } - } -} - -section: { - name: "get_ext" - test: { - name: "package_scoped_int32" - expr: "proto.getExt(msg, cel.expr.conformance.proto2.int32_ext) == 42" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.int32_ext]: 42 - } - } - } - } - } - } - test: { - name: "package_scoped_nested_ext" - expr: "proto.getExt(msg, cel.expr.conformance.proto2.nested_ext) == cel.expr.conformance.proto2.TestAllTypes{}" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.nested_ext]: {} - } - } - } - } - } - } - test: { - name: "package_scoped_test_all_types_ext" - expr: "proto.getExt(msg, cel.expr.conformance.proto2.test_all_types_ext) == cel.expr.conformance.proto2.TestAllTypes{}" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.test_all_types_ext]: {} - } - } - } - } - } - } - test: { - name: "package_scoped_test_all_types_nested_enum_ext" - expr: "proto.getExt(msg, cel.expr.conformance.proto2.nested_enum_ext) == cel.expr.conformance.proto2.TestAllTypes.NestedEnum.BAR" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.nested_enum_ext]: BAR - } - } - } - } - } - } - test: { - name: "package_scoped_repeated_test_all_types" - expr: "proto.getExt(msg, cel.expr.conformance.proto2.repeated_test_all_types) == [cel.expr.conformance.proto2.TestAllTypes{single_int64: 1}, cel.expr.conformance.proto2.TestAllTypes{single_bool: true}]" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.repeated_test_all_types]: [ { single_int64: 1 }, { single_bool: true } ] - } - } - } - } - } - } - test: { - name: "message_scoped_int64" - expr: "proto.getExt(msg, cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.int64_ext) == 42" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.int64_ext]: 42 - } - } - } - } - } - } - test: { - name: "message_scoped_nested_ext" - expr: "proto.getExt(msg, cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_nested_ext) == cel.expr.conformance.proto2.TestAllTypes{}" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_nested_ext]: {} - } - } - } - } - } - } - test: { - name: "message_scoped_nested_enum_ext" - expr: "proto.getExt(msg, cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.nested_enum_ext) == cel.expr.conformance.proto2.TestAllTypes.NestedEnum.BAR" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.nested_enum_ext]: BAR - } - } - } - } - } - } - test: { - name: "message_scoped_repeated_test_all_types" - expr: "proto.getExt(msg, cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_repeated_test_all_types) == [cel.expr.conformance.proto2.TestAllTypes{single_int64: 1}, cel.expr.conformance.proto2.TestAllTypes{single_bool: true}]" - type_env: { - name: "msg" - ident: { type: { message_type: "cel.expr.conformance.proto2.TestAllTypes" } } - } - bindings: { - key: "msg" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto2.TestAllTypes]: { - [cel.expr.conformance.proto2.Proto2ExtensionScopedMessage.message_scoped_repeated_test_all_types]: [ { single_int64: 1 }, { single_bool: true } ] - } - } - } - } - } - } -} diff --git a/tests/simple/testdata/proto3.textproto b/tests/simple/testdata/proto3.textproto deleted file mode 100644 index 676c6e3b..00000000 --- a/tests/simple/testdata/proto3.textproto +++ /dev/null @@ -1,818 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "proto3" -description: "Protocol buffer version 3 tests. See notes for the available set of protos for tests." - -section { - name: "literal_singular" - description: "Literals with singular fields set." - - test { - name: "int64_nocontainer" - expr: "cel.expr.conformance.proto3.TestAllTypes{single_int64: 17}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int64: 17 } - } - } - } - - test { - name: "int32" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32: -34}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int32: -34 } - } - } - } - - test { - name: "int64" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64: 17}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int64: 17 } - } - } - } - - test { - name: "uint32" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint32: 1u}" - value { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_uint32: 1 } - } - } - } - - test { - name: "uint64" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint64: 9999u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_uint64: 9999 } - } - } - } - - test { - name: "sint32" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_sint32: -3}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_sint32: -3 } - } - } - } - - test { - name: "sint64" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_sint64: 255}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_sint64: 255 } - } - } - } - - test { - name: "fixed32" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_fixed32: 43u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_fixed32: 43 } - } - } - } - - test { - name: "fixed64" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_fixed64: 1880u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_fixed64: 1880 } - } - } - } - - test { - name: "sfixed32" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_sfixed32: -404}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_sfixed32: -404 } - } - } - } - - test { - name: "sfixed64" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_sfixed64: -1}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_sfixed64: -1 } - } - } - } - - test { - name: "float" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_float: 3.1416}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_float: 3.1416 } - } - } - } - - test { - name: "double" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_double: 6.022e23}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_double: 6.022e23 } - } - } - } - - test { - name: "bool" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bool: true}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_bool: true } - } - } - } - - test { - name: "string" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_string: 'foo'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_string: "foo" } - } - } - } - - test { - name: "bytes" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bytes: b'\\377'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_bytes: "\377" } - } - } - } -} - -section { - name: "literal_wellknown" - description: "Literals with well-known fields set." - - test { - name: "any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: TestAllTypes{single_int32: 1}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_any { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int32: 1 - } - } - } - } - } - } - - test { - name: "duration" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_duration: duration('123s')}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_duration { - seconds: 123 - } - } - } - } - } - - test { - name: "timestamp" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_timestamp: timestamp('2009-02-13T23:31:30Z')}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_timestamp { - seconds: 1234567890 - } - } - } - } - } - - test { - name: "struct" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_struct: {'one': 1, 'two': 2}}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_struct { - fields { - key: "one" - value { number_value: 1.0 } - } - fields { - key: "two" - value { number_value: 2.0 } - } - } - } - } - } - } - - test { - name: "value" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: 'foo'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_value { - string_value: "foo" - } - } - } - } - } - - test { - name: "int64_wrapper" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64_wrapper: -321}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64_wrapper { - value: -321 - } - } - } - } - } - - test { - name: "int32_wrapper" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32_wrapper: -456}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int32_wrapper { - value: -456 - } - } - } - } - } - - test { - name: "double_wrapper" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_double_wrapper: 2.71828}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_double_wrapper { - value: 2.71828 - } - } - } - } - } - - test { - name: "float_wrapper" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_float_wrapper: 2.99792e8}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_float_wrapper { - value: 2.99792e8 - } - } - } - } - } - - test { - name: "uint64_wrapper" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint64_wrapper: 8675309u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_uint64_wrapper { - value: 8675309 - } - } - } - } - } - - test { - name: "uint32_wrapper" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint32_wrapper: 987u}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_uint32_wrapper { - value: 987 - } - } - } - } - } - - test { - name: "string_wrapper" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_string_wrapper: 'hubba'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_string_wrapper { - value: "hubba" - } - } - } - } - } - - test { - name: "bool_wrapper" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bool_wrapper: true}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_bool_wrapper { - value: true - } - } - } - } - } - - test { - name: "bytes_wrapper" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bytes_wrapper: b'\\301\\103'}" - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_bytes_wrapper { - value: "\301\103" - } - } - } - } - } - -} - -section { - name: "singular_bind" - description: "Binding the singular fields." - - test { - name: "int32" - expr: "x.single_int32" - type_env: { - name: "x" - ident: { type: { message_type: "cel.expr.conformance.proto3.TestAllTypes" } } - } - bindings: { - key: "x" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int32: 17 } - } - } - } - } - value: { int64_value: 17 } - } - - test { - name: "int64" - expr: "x.single_int64" - type_env: { - name: "x" - ident { type { message_type: "cel.expr.conformance.proto3.TestAllTypes" } } - } - bindings: { - key: "x" - value: { - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { single_int64: -99 } - } - } - } - } - value: { int64_value: -99 } - } -} - -section { - name: "empty_field" - description: "Tests on empty fields." - - test { - name: "scalar" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_fixed32" - value: { uint64_value: 0 } - } - - test { - name: "nested_message" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_nested_message" - value: { - object_value: { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes.NestedMessage] {} - } - } - } - - test { - name: "nested_message_subfield" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_nested_message.bb" - value: { int64_value: 0 } - } - - test { - name: "wkt" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.single_int64_wrapper" - value: { null_value: NULL_VALUE } - } - - test { - name: "repeated_scalar" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.repeated_int64" - value: { list_value: {} } - } - - test { - name: "repeated_enum" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.repeated_nested_enum" - value: { list_value: {} } - } - - test { - name: "repeated_nested" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.repeated_nested_message" - value: { list_value: {} } - } - - test { - name: "map" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.map_string_string" - value: { map_value: {} } - } -} -section { - name: "has" - description: "Tests for the has() macro on proto3 messages." - test { - name: "undefined" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{}.no_such_field)" - disable_check: true - eval_error: { - errors: { message: "no_such_field" } - } - } - test { - name: "repeated_none_implicit" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{}.repeated_int32)" - value { bool_value: false } - } - test { - name: "repeated_none_explicit" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{repeated_int32: []}.repeated_int32)" - value { bool_value: false } - } - test { - name: "repeated_one" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{repeated_int32: [1]}.repeated_int32)" - value { bool_value: true } - } - test { - name: "repeated_many" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{repeated_int32: [1, 2, 3]}.repeated_int32)" - value { bool_value: true } - } - test { - name: "map_none_implicit" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{}.map_string_string)" - value { bool_value: false } - } - test { - name: "map_none_explicit" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{map_string_string: {}}.map_string_string)" - value { bool_value: false } - } - test { - name: "map_one_default" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{map_string_string: {'MT': ''}}.map_string_string)" - value { bool_value: true } - } - test { - name: "map_one" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{map_string_string: {'one': 'uno'}}.map_string_string)" - value { bool_value: true } - } - test { - name: "map_many" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{map_string_string: {'one': 'uno', 'two': 'dos'}}.map_string_string)" - value { bool_value: true } - } - test { - name: "single_unset" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{}.single_int32)" - value { bool_value: false } - } - test { - name: "single_set" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{single_int32: 16}.single_int32)" - value { bool_value: true } - } - test { - name: "single_set_to_default" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{single_int32: 0}.single_int32)" - value { bool_value: false } - } - test { - name: "single_message_unset" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{}.standalone_message)" - value { bool_value: false } - } - test { - name: "single_message_set" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{standalone_message: TestAllTypes.NestedMessage{bb: 123}}.standalone_message)" - value { bool_value: true } - } - test { - name: "single_message_set_to_default" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{standalone_message: TestAllTypes.NestedMessage{}}.standalone_message)" - value { bool_value: true } - } - test { - name: "single_enum_unset" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{}.standalone_enum)" - value { bool_value: false } - } - test { - name: "single_enum_set" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{standalone_enum: TestAllTypes.NestedEnum.BAR}.standalone_enum)" - value { bool_value: true } - } - test { - name: "single_enum_set_zero" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{standalone_enum: TestAllTypes.NestedEnum.FOO}.standalone_enum)" - value { bool_value: false } - } - test { - name: "oneof_unset" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{}.single_nested_message)" - value { bool_value: false } - } - test { - name: "oneof_other_set" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{single_nested_enum: TestAllTypes.NestedEnum.BAZ}.single_nested_message)" - value { bool_value: false } - } - test { - name: "oneof_set" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{single_nested_message: TestAllTypes.NestedMessage{}}.single_nested_message)" - value { bool_value: true } - } - test { - name: "oneof_set_default" - container: "cel.expr.conformance.proto3" - expr: "has(TestAllTypes{single_nested_enum: TestAllTypes.NestedEnum.FOO}.single_nested_enum)" - value { bool_value: true } - } -} -section { - name: "set_null" - test { - name: "single_message" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_nested_message: null} == TestAllTypes{}" - value: { bool_value: true } - } - test { - name: "single_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: null}.single_any" - value { null_value: NULL_VALUE } - } - test { - name: "single_value" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: null}.single_value" - value { null_value: NULL_VALUE } - } - test { - name: "single_duration" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_duration: null} == TestAllTypes{}" - value: { bool_value: true } - } - test { - name: "single_timestamp" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_timestamp: null} == TestAllTypes{}" - value: { bool_value: true } - } - test { - name: "repeated_field_timestamp_null_pruned" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{repeated_timestamp: [timestamp(1), null]}.repeated_timestamp == [timestamp(1)]" - value: { bool_value: true } - } - test { - name: "repeated_field_duration_null_pruned" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{repeated_duration: [duration('1s'), null]}.repeated_duration == [duration('1s')]" - value: { bool_value: true } - } - test { - name: "repeated_field_wrapper_null_pruned" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{repeated_int32_wrapper: [1, null]}.repeated_int32_wrapper == [1]" - value: { bool_value: true } - } - test { - name: "repeated_field_anytype_null_retained" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{repeated_any: [1, null]}.repeated_any == [1, null]" - value: { bool_value: true } - } - test { - name: "repeated_field_jsontype_null_retained" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{repeated_value: [google.protobuf.Value{bool_value: true}, null]}.repeated_value == [true, null]" - value: { bool_value: true } - } - test { - name: "map_timestamp_null_pruned" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{map_bool_timestamp: {true: null, false: timestamp(1)}}.map_bool_timestamp == {false: timestamp(1)}" - value: { bool_value: true } - } - test { - name: "map_duration_null_pruned" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{map_bool_duration: {true: null, false: duration('1s')}}.map_bool_duration == {false: duration('1s')}" - value: { bool_value: true } - } - test { - name: "map_wrapper_null_pruned" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{map_bool_int32_wrapper: {true: null, false: 1}}.map_bool_int32_wrapper == {false: 1}" - value: { bool_value: true } - } - test { - name: "map_anytype_null_retained" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{map_bool_any: {true: null, false: 1}}.map_bool_any == {true: null, false: 1}" - value: { bool_value: true } - } - test { - name: "map_jsontype_null_retained" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{map_bool_value: {true: null, false: google.protobuf.Value{bool_value: true}}}.map_bool_value == {true: null, false: true}" - value: { bool_value: true } - } - test { - name: "single_scalar" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bool: null} == TestAllTypes{}" - disable_check: true - eval_error: { - errors: { message: "unsupported field type" } - } - } - test { - name: "repeated" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{repeated_int32: null} == TestAllTypes{}" - disable_check: true - eval_error: { - errors: { message: "unsupported field type" } - } - } - test { - name: "map" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{map_string_string: null} == TestAllTypes{}" - disable_check: true - eval_error: { - errors: { message: "unsupported field type" } - } - } - test { - name: "list_value" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{list_value: null} == TestAllTypes{}" - disable_check: true - eval_error: { - errors: { message: "unsupported field type" } - } - } - test { - name: "single_struct" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_struct: null} == TestAllTypes{}" - disable_check: true - eval_error: { - errors: { message: "unsupported field type" } - } - } -} -section { - name: "quoted_fields" - test { - name: "set_field" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{`in`: true} == TestAllTypes{}" - value: { bool_value: false } - } - test { - name: "get_field" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{`in`: true}.`in`" - value: { bool_value: true } - } -} diff --git a/tests/simple/testdata/sets_ext.textproto b/tests/simple/testdata/sets_ext.textproto deleted file mode 100644 index dab91e95..00000000 --- a/tests/simple/testdata/sets_ext.textproto +++ /dev/null @@ -1,493 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "sets_ext" -description: "Tests for the sets extension library." - -# sets.contains(list(T), list(T)) -> bool -# Returns whether the first list argument (arg0) contains all elements in the -# second list argument (arg1), i.e., whether arg0 is a superset of arg1. -section: { - name: "contains" - description: "sets.contains: since version 0" - test: { - name: "empty_empty" - expr: "sets.contains([], [])" - } - test: { - name: "nonempty_empty" - expr: "sets.contains([1], [])" - } - test: { - name: "empty_nonempty" - expr: "!sets.contains([], [1])" - } - test: { - name: "single_equal" - expr: "sets.contains([1], [1])" - } - test: { - name: "single_not_equal" - expr: "!sets.contains([1], [2])" - } - test: { - name: "duplicates_in_sublist" - expr: "sets.contains([1], [1, 1])" - } - test: { - name: "duplicates_in_list" - expr: "sets.contains([1, 1], [1])" - } - test: { - name: "subset" - expr: "sets.contains([1, 2, 3, 4], [2, 3])" - } - test: { - name: "not_subset" - expr: "!sets.contains([1, 2], [2, 3])" - } - test: { - name: "superset_not_contained" - expr: "!sets.contains([1], [1, 2])" - } - test: { - name: "heterogeneous_numeric" - expr: "sets.contains([1, 2.0, 3u], [1.0, 2u, 3])" - } - test: { - name: "heterogeneous_numeric_duplicates" - expr: "sets.contains([1, 2], [2u, 2.0])" - } - test: { - name: "heterogeneous_numeric_fractional_false" - expr: "!sets.contains([1], [1.1, 1u])" - } - test: { - name: "numeric_negatives" - expr: "sets.contains([-1, -9223372036854775808], [-1.0, -9223372036854775808])" - } - test: { - name: "numeric_negatives_and_uint_false" - expr: "!sets.contains([18446744073709551615u, 0u, 1], [-1, -9223372036854775808])" - } - test: { - name: "numeric_uint64_max" - expr: "sets.contains([18446744073709551615u, 0u], [18446744073709551615u])" - } - test: { - name: "numeric_uint64_max_false" - expr: "!sets.contains([-1, 9223372036854775807, 18446744073709590000.0], [18446744073709551615u])" - } - test: { - name: "double_nan_false" - expr: "!sets.contains([double('NaN')], [double('NaN')])" - } - test: { - name: "double_inf" - expr: "sets.contains([double('Infinity'), double('-Infinity')], [double('Infinity')])" - } - test: { - name: "double_inf_false" - expr: "!sets.contains([double('Infinity'), 9223372036854775807, 18446744073709551615u], [double('-Infinity')])" - } - test: { - name: "heterogeneous_types_true" - expr: "sets.contains([1, '1'], [1])" - } - test: { - name: "heterogeneous_types_false" - expr: "!sets.contains([1], ['1', 1])" - } - test: { - name: "strings" - expr: "sets.contains(['a', 'b', 'c'], ['b', 'a'])" - } - test: { - name: "strings_false" - expr: "!sets.contains(['a', 'b'], ['b', 'c'])" - } - test: { - name: "bools" - expr: "sets.contains([true, false], [false])" - } - test: { - name: "bytes" - expr: "sets.contains([b'a', b'b'], [b'b'])" - } - test: { - name: "nested_lists" - expr: "sets.contains([[1], [2, 3]], [[2, 3.0]])" - } - test: { - name: "nested_lists_false" - expr: "!sets.contains([[1], [2], [3]], [[2, 3]])" - } - test: { - name: "maps" - expr: "sets.contains([{'a': 'b'}, {'c': 'd'}], [{'a': 'b'}])" - } - test: { - name: "maps_heterogeneous_numeric" - expr: "sets.contains([{1: 1}], [{1: 1u}, {1: 1.0}])" - } - test: { - name: "maps_heterogeneous_keys" - expr: "sets.contains([{'a': 1, 1: 2, 2u: 3, true: 4}, {'b': 5}], [{true: 4, 2u: 3.0, 1: 2u, 'a': 1.0}])" - } - test: { - name: "maps_heterogeneous_keys_false" - expr: "!sets.contains([{'a': 1, 1: 2}], [{'a': 1, '1': 2}])" - } - test: { - name: "maps_false" - expr: "!sets.contains([{'a': 'b'}], [{'a': 'b'}, {'c': 'd'}])" - } - test: { - name: "proto_wrappers" - container: "cel.expr.conformance.proto3" - expr: "sets.contains([TestAllTypes{single_int64_wrapper: 1}.single_int64_wrapper, TestAllTypes{}.single_int64_wrapper], [1, null])" - } - test: { - name: "proto_wrappers_messages" - container: "cel.expr.conformance.proto3" - expr: "sets.contains([google.protobuf.Int64Value{value: 1}, google.protobuf.Int64Value{}], [1u, 0.0])" - } - test: { - name: "proto_wrappers_null_not_default_false" - container: "cel.expr.conformance.proto3" - expr: "!sets.contains([TestAllTypes{}.single_int64_wrapper], [0])" - } - test: { - name: "proto_messages" - container: "cel.expr.conformance.proto3" - expr: "sets.contains([TestAllTypes{single_int64: 1, single_uint64: 2u}, TestAllTypes{single_int64: 3}], [TestAllTypes{single_int64: 1, single_uint64: 2u}])" - } - test: { - name: "proto_messages_false" - container: "cel.expr.conformance.proto3" - expr: "!sets.contains([TestAllTypes{single_int64: 1, single_uint64: 2u}], [TestAllTypes{single_int64: 2, single_uint64: 3u}])" - } -} - -# sets.equivalent(list(T), list(T)) -> bool -# Returns whether the first list argument (arg0) and the second list argument -# (arg1) are set equivalent, i.e., every element in arg0 has an equal element in -# arg1 and every element in arg1 has an equal element in arg0. -section: { - name: "equivalent" - description: "sets.equivalent: since version 0" - test: { - name: "empty_empty" - expr: "sets.equivalent([], [])" - } - test: { - name: "nonempty_empty" - expr: "!sets.equivalent([1], [])" - } - test: { - name: "empty_nonempty" - expr: "!sets.equivalent([], [1])" - } - test: { - name: "single_equal" - expr: "sets.equivalent([1], [1])" - } - test: { - name: "single_not_equal" - expr: "!sets.equivalent([1], [2])" - } - test: { - name: "duplicates_right" - expr: "sets.equivalent([1], [1, 1])" - } - test: { - name: "duplicates_left" - expr: "sets.equivalent([1, 1], [1])" - } - test: { - name: "duplicates_both_reordered" - expr: "sets.equivalent([1, 1, 2], [2, 2, 1])" - } - test: { - name: "strict_superset_left" - expr: "!sets.equivalent([2, 1], [1])" - } - test: { - name: "strict_subset_left" - expr: "!sets.equivalent([1], [1, 2])" - } - test: { - name: "heterogeneous_numeric_single" - expr: "sets.equivalent([1], [1u, 1.0])" - } - test: { - name: "heterogeneous_numeric_reordered" - expr: "sets.equivalent([1, 2, 3], [3u, 2.0, 1])" - } - test: { - name: "heterogeneous_numeric_missing_element" - expr: "!sets.equivalent([1, 2], [2u, 2, 2.0])" - } - test: { - name: "heterogeneous_numeric_fractional_false" - expr: "!sets.equivalent([1, 2], [1u, 2, 2.3])" - } - test: { - name: "numeric_negatives" - expr: "sets.equivalent([-1, -9223372036854775808], [-9223372036854775808, -1.0])" - } - test: { - name: "numeric_negatives_and_uint_false" - expr: "!sets.equivalent([-1, -1.0], [18446744073709551615u])" - } - test: { - name: "numeric_uint64_max" - expr: "sets.equivalent([18446744073709551615u], [18446744073709551615u, 18446744073709551615u])" - } - test: { - name: "numeric_uint64_max_false" - expr: "!sets.equivalent([18446744073709551615u], [-1, 9223372036854775807, 18446744073709590000.0])" - } - test: { - name: "double_nan_false" - expr: "!sets.equivalent([double('NaN')], [double('NaN')])" - } - test: { - name: "double_inf" - expr: "sets.equivalent([double('Infinity'), double('-Infinity')], [double('-Infinity'), double('Infinity')])" - } - test: { - name: "double_inf_false" - expr: "!sets.equivalent([double('Infinity')], [double('-Infinity')])" - } - test: { - name: "strings" - expr: "sets.equivalent(['foo', 'bar'], ['bar', 'foo'])" - } - test: { - name: "strings_false" - expr: "!sets.equivalent(['foo'], ['bar'])" - } - test: { - name: "bools" - expr: "sets.equivalent([false, true], [true, false])" - } - test: { - name: "bools_false" - expr: "!sets.equivalent([true], [false])" - } - test: { - name: "bytes" - expr: "sets.equivalent([b'foo', b'bar'], [b'bar', b'foo'])" - } - test: { - name: "nulls" - expr: "sets.equivalent([null], [null, null])" - } - test: { - name: "durations" - expr: "sets.equivalent([duration('0s'), duration('1s')], [duration('1s'), duration('0s')])" - } - test: { - name: "timestamps" - expr: "sets.equivalent([timestamp('1970-01-01T00:00:00Z'), timestamp('1970-01-01T00:00:01Z')], [timestamp('1970-01-01T00:00:01Z'), timestamp('1970-01-01T00:00:00Z')])" - } - test: { - name: "nested_lists" - expr: "sets.equivalent([[1.0], [2, 3]], [[1], [2, 3.0]])" - } - test: { - name: "nested_lists_order_matters" - expr: "!sets.equivalent([[false, true]], [[true, false]])" - } - test: { - name: "maps" - expr: "sets.equivalent([{'foo': true, 'bar': false}], [{'bar': false, 'foo': true}])" - } - test: { - name: "maps_heterogeneous_numeric" - expr: "sets.equivalent([{1: 1}], [{1: 1u}, {1: 1.0}])" - } - test: { - name: "maps_heterogeneous_keys" - expr: "sets.equivalent([{'a': 1, 1: 2, 2u: 3, true: 4}], [{true: 4, 2u: 3.0, 1: 2u, 'a': 1.0}])" - } - test: { - name: "maps_heterogeneous_keys_false" - expr: "!sets.equivalent([{'a': 1, 1: 2}], [{'a': 1, '1': 2}])" - } - test: { - name: "proto_wrappers" - container: "cel.expr.conformance.proto3" - expr: "sets.equivalent([TestAllTypes{single_int64_wrapper: 1}.single_int64_wrapper, TestAllTypes{}.single_int64_wrapper], [null, 1u, 1.0])" - } - test: { - name: "proto_wrappers_messages" - container: "cel.expr.conformance.proto3" - expr: "sets.equivalent([google.protobuf.Int64Value{value: 1}, google.protobuf.Int64Value{}], [0, 1.0])" - } - test: { - name: "proto_wrappers_null_not_default_false" - container: "cel.expr.conformance.proto3" - expr: "!sets.equivalent([TestAllTypes{}.single_int64_wrapper], [0])" - } - test: { - name: "proto_messages" - container: "cel.expr.conformance.proto3" - expr: "sets.equivalent([TestAllTypes{single_int64: 1, single_uint64: 2u}, TestAllTypes{single_int64: 1, single_uint64: 2u}], [TestAllTypes{single_int64: 1, single_uint64: 2u}])" - } - test: { - name: "proto_messages_false" - container: "cel.expr.conformance.proto3" - expr: "!sets.equivalent([TestAllTypes{single_int64: 1, single_uint64: 2u}], [TestAllTypes{single_int64: 2, single_uint64: 3u}])" - } -} - -# sets.intersects(list(T), list(T)) -> bool -# Returns whether the first list argument (arg0) has at least one element whose -# value is equal to an element in the second list argument (arg1). -section: { - name: "intersects" - description: "sets.intersects: since version 0" - test: { - name: "empty_empty" - expr: "!sets.intersects([], [])" - } - test: { - name: "nonempty_empty" - expr: "!sets.intersects([1], [])" - } - test: { - name: "empty_nonempty" - expr: "!sets.intersects([], [1])" - } - test: { - name: "single_equal" - expr: "sets.intersects([1], [1])" - } - test: { - name: "single_not_equal" - expr: "!sets.intersects([1], [2])" - } - test: { - name: "duplicates_right" - expr: "sets.intersects([1], [1, 1])" - } - test: { - name: "duplicates_left" - expr: "sets.intersects([1, 1], [1])" - } - test: { - name: "overlap" - expr: "sets.intersects([1], [1, 2])" - } - test: { - name: "disjoint" - expr: "!sets.intersects([1, 3], [2, 4])" - } - test: { - name: "heterogeneous_numeric" - expr: "sets.intersects([1], [1.0, 2])" - } - test: { - name: "heterogeneous_numeric_multiple" - expr: "sets.intersects([1, 2], [2u, 2, 2.0])" - } - test: { - name: "heterogeneous_numeric_with_fractional" - expr: "sets.intersects([1, 2], [1u, 2, 2.3])" - } - test: { - name: "heterogeneous_numeric_false" - expr: "!sets.intersects([1], [1.1, 2u])" - } - test: { - name: "numeric_negatives" - expr: "sets.intersects([-1, -9223372036854775808], [-1.0, 1])" - } - test: { - name: "numeric_negatives_and_uint_false" - expr: "!sets.intersects([-1, -9223372036854775808], [18446744073709551615u, 0u, 1])" - } - test: { - name: "numeric_uint64_max" - expr: "sets.intersects([18446744073709551615u], [0u, 18446744073709551615u])" - } - test: { - name: "numeric_uint64_max_false" - expr: "!sets.intersects([18446744073709551615u], [-1, 9223372036854775807, 18446744073709590000.0])" - } - test: { - name: "double_nan_false" - expr: "!sets.intersects([double('NaN')], [double('NaN')])" - } - test: { - name: "double_inf" - expr: "sets.intersects([double('Infinity'), 1.0], [double('Infinity'), double('-Infinity')])" - } - test: { - name: "double_inf_false" - expr: "!sets.intersects([double('Infinity')], [double('-Infinity'), 9223372036854775807, 18446744073709551615u])" - } - test: { - name: "heterogeneous_types_false" - expr: "!sets.intersects([1], ['1', 2])" - } - test: { - name: "strings" - expr: "sets.intersects(['a', 'b'], ['b', 'c'])" - } - test: { - name: "strings_false" - expr: "!sets.intersects(['a', 'b'], ['c', 'd'])" - } - test: { - name: "nested_lists" - expr: "sets.intersects([[1], [2, 3]], [[1, 2], [2, 3.0]])" - } - test: { - name: "maps" - expr: "sets.intersects([{'a': 'b'}, {'a': 'b'}], [{'a': 'b'}])" - } - test: { - name: "maps_heterogeneous_numeric" - expr: "sets.intersects([{1: 1}], [{1: 1u}, {1: 1.0}])" - } - test: { - name: "maps_heterogeneous_keys" - expr: "sets.intersects([{'a': 1, 1: 2, 2u: 3, true: 4}], [{'b': 5}, {true: 4, 2u: 3.0, 1: 2u, 'a': 1.0}])" - } - test: { - name: "maps_heterogeneous_keys_false" - expr: "!sets.intersects([{'a': 1, 1: 2}], [{'a': 1, '1': 2}])" - } - test: { - name: "maps_false" - expr: "!sets.intersects([{'a': 'b'}], [{'c': 'd'}])" - } - test: { - name: "proto_wrappers" - container: "cel.expr.conformance.proto3" - expr: "sets.intersects([TestAllTypes{single_int64_wrapper: 1}.single_int64_wrapper, TestAllTypes{}.single_int64_wrapper], [2, null])" - } - test: { - name: "proto_wrappers_messages" - container: "cel.expr.conformance.proto3" - expr: "sets.intersects([google.protobuf.Int64Value{value: 1}], [2u, 1.0])" - } - test: { - name: "proto_wrappers_null_not_default_false" - container: "cel.expr.conformance.proto3" - expr: "!sets.intersects([TestAllTypes{}.single_int64_wrapper], [0, 0u, 0.0])" - } - test: { - name: "proto_messages" - container: "cel.expr.conformance.proto3" - expr: "sets.intersects([TestAllTypes{single_int64: 1, single_uint64: 2u}], [TestAllTypes{single_int64: 1, single_uint64: 2u}, TestAllTypes{single_int64: 3}])" - } - test: { - name: "proto_messages_false" - container: "cel.expr.conformance.proto3" - expr: "!sets.intersects([TestAllTypes{single_int64: 1, single_uint64: 2u}], [TestAllTypes{single_int64: 2, single_uint64: 3u}])" - } -} diff --git a/tests/simple/testdata/string.textproto b/tests/simple/testdata/string.textproto deleted file mode 100644 index 3571b11f..00000000 --- a/tests/simple/testdata/string.textproto +++ /dev/null @@ -1,288 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: google.api.expr.test.v1.SimpleTestFile - -name: "string" -description: "Tests for string and bytes operations." -section { - name: "size" - description: "Tests for the size() function." - test { - name: "empty" - expr: "size('')" - value: { int64_value: 0 } - } - test { - name: "one_ascii" - expr: "size('A')" - value: { int64_value: 1 } - } - test { - name: "one_unicode" - expr: "size('ÿ')" - value: { int64_value: 1 } - } - test { - name: "ascii" - expr: "size('four')" - value: { int64_value: 4 } - } - test { - name: "unicode" - expr: "size('πέντε')" - value: { int64_value: 5 } - } - test { - name: "bytes_empty" - expr: "size(b'')" - value: { int64_value: 0 } - } - test { - name: "bytes" - expr: "size(b'abc')" - value: { int64_value: 3 } - } -} -section { - name: "starts_with" - description: "Tests for the startsWith() function." - test { - name: "basic_true" - expr: "'foobar'.startsWith('foo')" - value: { bool_value: true } - } - test { - name: "basic_false" - expr: "'foobar'.startsWith('bar')" - value: { bool_value: false } - } - test { - name: "empty_target" - expr: "''.startsWith('foo')" - value: { bool_value: false } - } - test { - name: "empty_arg" - expr: "'foobar'.startsWith('')" - value: { bool_value: true } - } - test { - name: "empty_empty" - expr: "''.startsWith('')" - value: { bool_value: true } - } - test { - name: "unicode" - expr: "'завтра'.startsWith('за')" - value: { bool_value: true } - } - test { - name: "unicode_smp" - expr: "'\U0001F431\U0001F600\U0001F61B'.startsWith('\U0001F431')" - value: { bool_value: true } - } -} -section { - name: "ends_with" - description: "Tests for the endsWith() function." - test { - name: "basic_true" - expr: "'foobar'.endsWith('bar')" - value: { bool_value: true } - } - test { - name: "basic_false" - expr: "'foobar'.endsWith('foo')" - value: { bool_value: false } - } - test { - name: "empty_target" - expr: "''.endsWith('foo')" - value: { bool_value: false } - } - test { - name: "empty_arg" - expr: "'foobar'.endsWith('')" - value: { bool_value: true } - } - test { - name: "empty_empty" - expr: "''.endsWith('')" - value: { bool_value: true } - } - test { - name: "unicode" - expr: "'forté'.endsWith('té')" - value: { bool_value: true } - } - test { - name: "unicode_smp" - expr: "'\U0001F431\U0001F600\U0001F61B'.endsWith('\U0001F61B')" - value: { bool_value: true } - } -} -section { - name: "matches" - description: "Tests for regexp matching. For now, we will only test the subset of regular languages." - test { - name: "basic" - expr: "'hubba'.matches('ubb')" - value: { bool_value: true } - } - test { - name: "empty_target" - expr: "''.matches('foo|bar')" - value: { bool_value: false } - } - test { - name: "empty_arg" - expr: "'cows'.matches('')" - value: { bool_value: true } - } - test { - name: "empty_empty" - expr: "''.matches('')" - value: { bool_value: true } - } - test { - name: "re_concat" - expr: "'abcd'.matches('bc')" - value: { bool_value: true } - } - test { - name: "re_alt" - expr: "'grey'.matches('gr(a|e)y')" - value: { bool_value: true } - } - test { - name: "re_rep" - expr: "'banana'.matches('ba(na)*')" - value: { bool_value: true } - } - test { - name: "unicode" - expr: "'mañana'.matches('a+ñ+a+')" - value: { bool_value: true } - } - test { - name: "unicode_smp" - expr: "'\U0001F431\U0001F600\U0001F600'.matches('(a|\U0001F600){2}')" - value: { bool_value: true } - } -} -section { - name: "concatenation" - description: "Tests for string concatenation." - test { - name: "concat_true" - expr: "'he' + 'llo'" - value: { string_value: "hello" } - } - test { - name: "concat_with_spaces" - expr: "'hello' + ' ' == 'hello'" - value: { bool_value: false } - } - test { - name: "concat_empty_string_beginning" - expr: "'' + 'abc'" - value: { string_value: "abc" } - } - test { - name: "concat_empty_string_end" - expr: "'abc' + ''" - value: { string_value: "abc" } - } - test { - name: "concat_empty_with_empty" - expr: "'' + ''" - value: { string_value: "" } - } - test { - name: "unicode_unicode" - expr: "'¢' + 'ÿ' + 'Ȁ'" - value: { string_value: "¢ÿȀ" } - } - test { - name: "ascii_unicode" - expr: "'r' + 'ô' + 'le'" - value: { string_value: "rôle" } - } - test { - name: "ascii_unicode_unicode_smp" - expr: "'a' + 'ÿ' + '\U0001F431'" - value: { string_value: "aÿ\xf0\x9f\x90\xb1" } - } - test { - name: "empty_unicode" - expr: "'' + 'Ω' + ''" - value: { string_value: "Ω" } - } -} -section { - name: "contains" - description: "Tests for contains." - test { - name: "contains_true" - expr: "'hello'.contains('he')" - value: { bool_value: true } - } - test { - name: "contains_empty" - expr: "'hello'.contains('')" - value: { bool_value: true } - } - test { - name: "contains_false" - expr: "'hello'.contains('ol')" - value: { bool_value: false } - } - test { - name: "contains_multiple" - expr: "'abababc'.contains('ababc')" - value: { bool_value: true } - } - test { - name: "contains_unicode" - expr: "'Straße'.contains('aß')" - value: { bool_value: true } - } - test { - name: "contains_unicode_smp" - expr: "'\U0001F431\U0001F600\U0001F601'.contains('\U0001F600')" - value: { bool_value: true } - } - test { - name: "empty_contains" - expr: "''.contains('something')" - value: { bool_value: false } - } - test { - name: "empty_empty" - expr: "''.contains('')" - value: { bool_value: true } - } -} -section { - name: "bytes_concat" - description: "Tests for bytes concatenation." - test { - name: "concat" - expr: "b'abc' + b'def'" - value: { bytes_value: "abcdef" } - } - test { - name: "left_unit" - expr: "b'' + b'\\xffoo'" - value: { bytes_value: "\377oo" } - } - test { - name: "right_unit" - expr: "b'zxy' + b''" - value: { bytes_value: "zxy" } - } - test { - name: "empty_empty" - expr: "b'' + b''" - value: { bytes_value: "" } - } -} diff --git a/tests/simple/testdata/string_ext.textproto b/tests/simple/testdata/string_ext.textproto deleted file mode 100644 index fb29c06c..00000000 --- a/tests/simple/testdata/string_ext.textproto +++ /dev/null @@ -1,1535 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "string_ext" -description: "Tests for the strings extension library." -section: { - name: "char_at" - test: { - name: "middle_index" - expr: "'tacocat'.charAt(3)" - value: { - string_value: "o" - } - } - test: { - name: "end_index" - expr: "'tacocat'.charAt(7)" - value: { - string_value: "" - } - } - test: { - name: "multiple" - expr: "'©αT'.charAt(0) == '©' && '©αT'.charAt(1) == 'α' && '©αT'.charAt(2) == 'T'" - } -} -section: { - name: "index_of" - test: { - name: "empty_index" - expr: "'tacocat'.indexOf('')" - value: { - int64_value: 0 - } - } - test: { - name: "string_index" - expr: "'tacocat'.indexOf('ac')" - value: { - int64_value: 1 - } - } - test: { - name: "nomatch" - expr: "'tacocat'.indexOf('none') == -1" - } - test: { - name: "empty_index_offset" - expr: "'tacocat'.indexOf('', 3) == 3" - } - test: { - name: "char_index_offset" - expr: "'tacocat'.indexOf('a', 3) == 5" - } - test: { - name: "string_index_offset" - expr: "'tacocat'.indexOf('at', 3) == 5" - } - test: { - name: "unicode_char" - expr: "'ta©o©αT'.indexOf('©') == 2" - } - test: { - name: "unicode_char_index" - expr: "'ta©o©αT'.indexOf('©', 3) == 4" - } - test: { - name: "unicode_string_index" - expr: "'ta©o©αT'.indexOf('©αT', 3) == 4" - } - test: { - name: "unicode_string_nomatch_index" - expr: "'ta©o©αT'.indexOf('©α', 5) == -1" - } - test: { - name: "char_index" - expr: "'ijk'.indexOf('k') == 2" - } - test: { - name: "string_with_space_fullmatch" - expr: "'hello wello'.indexOf('hello wello') == 0" - } - test: { - name: "string_with_space_index" - expr: "'hello wello'.indexOf('ello', 6) == 7" - } - test: { - name: "string_nomatch_index" - expr: "'hello wello'.indexOf('elbo room!!') == -1" - } -} -section: { - name: "last_index_of" - test: { - name: "empty_string" - expr: "''.lastIndexOf('@@') == -1" - } - test: { - name: "empty_argument" - expr: "'tacocat'.lastIndexOf('') == 7" - } - test: { - name: "string" - expr: "'tacocat'.lastIndexOf('at') == 5" - } - test: { - name: "string_nomatch" - expr: "'tacocat'.lastIndexOf('none') == -1" - } - test: { - name: "empty_index" - expr: "'tacocat'.lastIndexOf('', 3) == 3" - } - test: { - name: "char_index" - expr: "'tacocat'.lastIndexOf('a', 3) == 1" - } - test: { - name: "unicode_char" - expr: "'ta©o©αT'.lastIndexOf('©') == 4" - } - test: { - name: "unicode_char_index" - expr: "'ta©o©αT'.lastIndexOf('©', 3) == 2" - } - test: { - name: "unicode_string_index" - expr: "'ta©o©αT'.lastIndexOf('©α', 4) == 4" - } - test: { - name: "string_with_space_string_index" - expr: "'hello wello'.lastIndexOf('ello', 6) == 1" - } - test: { - name: "string_with_space_string_nomatch" - expr: "'hello wello'.lastIndexOf('low') == -1" - } - test: { - name: "string_with_space_string_with_space_nomatch" - expr: "'hello wello'.lastIndexOf('elbo room!!') == -1" - } - test: { - name: "string_with_space_fullmatch" - expr: "'hello wello'.lastIndexOf('hello wello') == 0" - } - test: { - name: "repeated_string" - expr: "'bananananana'.lastIndexOf('nana', 7) == 6" - } -} -section: { - name: "ascii_casing" - test: { - name: "lowerascii" - expr: "'TacoCat'.lowerAscii() == 'tacocat'" - } - test: { - name: "lowerascii_unicode" - expr: "'TacoCÆt'.lowerAscii() == 'tacocÆt'" - } - test: { - name: "lowerascii_unicode_with_space" - expr: "'TacoCÆt Xii'.lowerAscii() == 'tacocÆt xii'" - } - test: { - name: "upperascii" - expr: "'tacoCat'.upperAscii() == 'TACOCAT'" - } - test: { - name: "upperascii_unicode" - expr: "'tacoCαt'.upperAscii() == 'TACOCαT'" - } - test: { - name: "upperascii_unicode_with_space" - expr: "'TacoCÆt Xii'.upperAscii() == 'TACOCÆT XII'" - } -} -section: { - name: "replace" - test: { - name: "no_placeholder" - expr: "'12 days 12 hours'.replace('{0}', '2') == '12 days 12 hours'" - } - test: { - name: "basic" - expr: "'{0} days {0} hours'.replace('{0}', '2') == '2 days 2 hours'" - } - test: { - name: "chained" - expr: "'{0} days {0} hours'.replace('{0}', '2', 1).replace('{0}', '23') == '2 days 23 hours'" - } - test: { - name: "unicode" - expr: "'1 ©αT taco'.replace('αT', 'o©α') == '1 ©o©α taco'" - } -} -section: { - name: "split" - test: { - name: "empty" - expr: "'hello world'.split(' ') == ['hello', 'world']" - } - test: { - name: "zero_limit" - expr: "'hello world events!'.split(' ', 0) == []" - } - test: { - name: "one_limit" - expr: "'hello world events!'.split(' ', 1) == ['hello world events!']" - } - test: { - name: "unicode_negative_limit" - expr: "'o©o©o©o'.split('©', -1) == ['o', 'o', 'o', 'o']" - } -} -section: { - name: "substring" - test: { - name: "start" - expr: "'tacocat'.substring(4) == 'cat'" - } - test: { - name: "start_with_max_length" - expr: "'tacocat'.substring(7) == ''" - } - test: { - name: "start_and_end" - expr: "'tacocat'.substring(0, 4) == 'taco'" - } - test: { - name: "start_and_end_equal_value" - expr: "'tacocat'.substring(4, 4) == ''" - } - test: { - name: "unicode_start_and_end" - expr: "'ta©o©αT'.substring(2, 6) == '©o©α'" - } - test: { - name: "unicode_start_and_end_equal_value" - expr: "'ta©o©αT'.substring(7, 7) == ''" - } -} -section: { - name: "trim" - test: { - name: "blank_spaces_escaped_chars" - expr: "' \\f\\n\\r\\t\\vtext '.trim() == 'text'" - } - test: { - name: "unicode_space_chars_1" - expr: "'\\u0085\\u00a0\\u1680text'.trim() == 'text'" - } - test: { - name: "unicode_space_chars_2" - expr: "'text\\u2000\\u2001\\u2002\\u2003\\u2004\\u2004\\u2006\\u2007\\u2008\\u2009'.trim() == 'text'" - } - test: { - name: "unicode_space_chars_3" - expr: "'\\u200atext\\u2028\\u2029\\u202F\\u205F\\u3000'.trim() == 'text'" - } - test: { - name: "unicode_no_trim" - expr: "'\\u180etext\\u200b\\u200c\\u200d\\u2060\\ufeff'.trim() == '\\u180etext\\u200b\\u200c\\u200d\\u2060\\ufeff'" - } -} -section: { - name: "join" - test: { - name: "empty_separator" - expr: "['x', 'y'].join() == 'xy'" - } - test: { - name: "dash_separator" - expr: "['x', 'y'].join('-') == 'x-y'" - } - test: { - name: "empty_string_empty_separator" - expr: "[].join() == ''" - } - test: { - name: "empty_string_dash_separator" - expr: "[].join('-') == ''" - } -} -section: { - name: "quote" - test: { - name: "multiline" - expr: "strings.quote(\"first\\nsecond\") == \"\\\"first\\\\nsecond\\\"\"" - } - test: { - name: "escaped" - expr: "strings.quote(\"bell\\a\") == \"\\\"bell\\\\a\\\"\"" - } - test: { - name: "backspace" - expr: "strings.quote(\"\\bbackspace\") == \"\\\"\\\\bbackspace\\\"\"" - } - test: { - name: "form_feed" - expr: "strings.quote(\"\\fform feed\") == \"\\\"\\\\fform feed\\\"\"" - } - test: { - name: "carriage_return" - expr: "strings.quote(\"carriage \\r return\") == \"\\\"carriage \\\\r return\\\"\"" - } - test: { - name: "horizontal_tab" - expr: "strings.quote(\"horizontal tab\\t\") == \"\\\"horizontal tab\\\\t\\\"\"" - } - test: { - name: "vertical_tab" - expr: "strings.quote(\"vertical \\v tab\") == \"\\\"vertical \\\\v tab\\\"\"" - } - test: { - name: "double_slash" - expr: "strings.quote(\"double \\\\\\\\ slash\") == \"\\\"double \\\\\\\\\\\\\\\\ slash\\\"\"" - } - test: { - name: "two_escape_sequences" - expr: "strings.quote(\"two escape sequences \\\\a\\\\n\") == \"\\\"two escape sequences \\\\\\\\a\\\\\\\\n\\\"\"" - } - test: { - name: "verbatim" - expr: "strings.quote(\"verbatim\") == \"\\\"verbatim\\\"\"" - } - test: { - name: "ends_with" - expr: "strings.quote(\"ends with \\\\\") == \"\\\"ends with \\\\\\\\\\\"\"" - } - test: { - name: "starts_with" - expr: "strings.quote(\"\\\\ starts with\") == \"\\\"\\\\\\\\ starts with\\\"\"" - } - test: { - name: "printable_unicode" - expr: "strings.quote(\"printable unicode😀\") == \"\\\"printable unicode😀\\\"\"" - } - test: { - name: "mid_string_quote" - expr: "strings.quote(\"mid string \\\" quote\") == \"\\\"mid string \\\\\\\" quote\\\"\"" - } - test: { - name: "single_quote_with_double_quote" - expr: "strings.quote('single-quote with \"double quote\"') == \"\\\"single-quote with \\\\\\\"double quote\\\\\\\"\\\"\"" - } - test: { - name: "size_unicode_char" - expr: "strings.quote(\"size('ÿ')\") == \"\\\"size('ÿ')\\\"\"" - } - test: { - name: "size_unicode_string" - expr: "strings.quote(\"size('πέντε')\") == \"\\\"size('πέντε')\\\"\"" - } - test: { - name: "unicode" - expr: "strings.quote(\"завтра\") == \"\\\"завтра\\\"\"" - } - test: { - name: "unicode_code_points" - expr: "strings.quote(\"\\U0001F431\\U0001F600\\U0001F61B\")" - value: { - string_value: "\"🐱😀😛\"" - } - } - test: { - name: "unicode_2" - expr: "strings.quote(\"ta©o©αT\") == \"\\\"ta©o©αT\\\"\"" - } - test: { - name: "empty_quote" - expr: "strings.quote(\"\")" - value: { - string_value: "\"\"" - } - } -} -section: { - name: "format" - test: { - name: "no-op" - expr: "\"no substitution\".format([])" - value: { - string_value: "no substitution" - } - } - test: { - name: "mid-string substitution" - expr: "\"str is %s and some more\".format([\"filler\"])" - value: { - string_value: "str is filler and some more" - } - } - test: { - name: "percent escaping" - expr: "\"%% and also %%\".format([])" - value: { - string_value: "% and also %" - } - } - test: { - name: "substitution inside escaped percent signs" - expr: "\"%%%s%%\".format([\"text\"])" - value: { - string_value: "%text%" - } - } - test: { - name: "substitution with one escaped percent sign on the right" - expr: "\"%s%%\".format([\"percent on the right\"])" - value: { - string_value: "percent on the right%" - } - } - test: { - name: "substitution with one escaped percent sign on the left" - expr: "\"%%%s\".format([\"percent on the left\"])" - value: { - string_value: "%percent on the left" - } - } - test: { - name: "multiple substitutions" - expr: "\"%d %d %d, %s %s %s, %d %d %d, %s %s %s\".format([1, 2, 3, \"A\", \"B\", \"C\", 4, 5, 6, \"D\", \"E\", \"F\"])" - value: { - string_value: "1 2 3, A B C, 4 5 6, D E F" - } - } - test: { - name: "percent sign escape sequence support" - expr: "\"%%escaped %s%%\".format([\"percent\"])" - value: { - string_value: "%escaped percent%" - } - } - test: { - name: "fixed point formatting clause" - expr: "\"%.3f\".format([1.2345])" - value: { - string_value: "1.234" - } - } - test: { - name: "binary formatting clause" - expr: "\"this is 5 in binary: %b\".format([5])" - value: { - string_value: "this is 5 in binary: 101" - } - } - test: { - name: "uint support for binary formatting" - expr: "\"unsigned 64 in binary: %b\".format([uint(64)])" - value: { - string_value: "unsigned 64 in binary: 1000000" - } - } - test: { - name: "bool support for binary formatting" - expr: "\"bit set from bool: %b\".format([true])" - value: { - string_value: "bit set from bool: 1" - } - } - test: { - name: "octal formatting clause" - expr: "\"%o\".format([11])" - value: { - string_value: "13" - } - } - test: { - name: "uint support for octal formatting clause" - expr: "\"this is an unsigned octal: %o\".format([uint(65535)])" - value: { - string_value: "this is an unsigned octal: 177777" - } - } - test: { - name: "lowercase hexadecimal formatting clause" - expr: "\"%x is 20 in hexadecimal\".format([30])" - value: { - string_value: "1e is 20 in hexadecimal" - } - } - test: { - name: "uppercase hexadecimal formatting clause" - expr: "\"%X is 20 in hexadecimal\".format([30])" - value: { - string_value: "1E is 20 in hexadecimal" - } - } - test: { - name: "unsigned support for hexadecimal formatting clause" - expr: "\"%X is 6000 in hexadecimal\".format([uint(6000)])" - value: { - string_value: "1770 is 6000 in hexadecimal" - } - } - test: { - name: "string support with hexadecimal formatting clause" - expr: "\"%x\".format([\"Hello world!\"])" - value: { - string_value: "48656c6c6f20776f726c6421" - } - } - test: { - name: "string support with uppercase hexadecimal formatting clause" - expr: "\"%X\".format([\"Hello world!\"])" - value: { - string_value: "48656C6C6F20776F726C6421" - } - } - test: { - name: "byte support with hexadecimal formatting clause" - expr: "\"%x\".format([b\"byte string\"])" - value: { - string_value: "6279746520737472696e67" - } - } - test: { - name: "byte support with uppercase hexadecimal formatting clause" - expr: "\"%X\".format([b\"byte string\"])" - value: { - string_value: "6279746520737472696E67" - } - } - test: { - name: "scientific notation formatting clause" - expr: "\"%.6e\".format([1052.032911275])" - value: { - string_value: "1.052033e+03" - } - } - test: { - name: "default precision for fixed-point clause" - expr: "\"%f\".format([2.71828])" - value: { - string_value: "2.718280" - } - } - test: { - name: "default precision for fixed-point clause with int" - expr: "\"%f\".format([2])" - value: { - string_value: "2.000000" - } - } - test: { - name: "default precision for fixed-point clause with uint" - expr: "\"%f\".format([3u])" - value: { - string_value: "3.000000" - } - } - test: { - name: "default precision for scientific notation" - expr: "\"%e\".format([2.71828])" - value: { - string_value: "2.718280e+00" - } - } - test: { - name: "default precision for scientific notation with int" - expr: "\"%e\".format([2])" - value: { - string_value: "2.000000e+00" - } - } - test: { - name: "default precision for scientific notation with uint" - expr: "\"%e\".format([3u])" - value: { - string_value: "3.000000e+00" - } - } - test: { - name: "NaN support for scientific notation" - expr: "\"%e\".format([double(\"NaN\")])" - value: { - string_value: "NaN" - } - } - test: { - name: "positive infinity support for scientific notation" - expr: "\"%e\".format([double(\"Infinity\")])" - value: { - string_value: "Infinity" - } - } - test: { - name: "negative infinity support for scientific notation" - expr: "\"%e\".format([double(\"-Infinity\")])" - value: { - string_value: "-Infinity" - } - } - test: { - name: "NaN support for decimal" - expr: "\"%d\".format([double(\"NaN\")])" - value: { - string_value: "NaN" - } - } - test: { - name: "positive infinity support for decimal" - expr: "\"%d\".format([double(\"Infinity\")])" - value: { - string_value: "Infinity" - } - } - test: { - name: "negative infinity support for decimal" - expr: "\"%d\".format([double(\"-Infinity\")])" - value: { - string_value: "-Infinity" - } - } - test: { - name: "NaN support for fixed-point" - expr: "\"%f\".format([double(\"NaN\")])" - value: { - string_value: "NaN" - } - } - test: { - name: "positive infinity support for fixed-point" - expr: "\"%f\".format([double(\"Infinity\")])" - value: { - string_value: "Infinity" - } - } - test: { - name: "negative infinity support for fixed-point" - expr: "\"%f\".format([double(\"-Infinity\")])" - value: { - string_value: "-Infinity" - } - } - test: { - name: "uint support for decimal clause" - expr: "\"%d\".format([uint(64)])" - value: { - string_value: "64" - } - } - test: { - name: "null support for string" - expr: "\"%s\".format([null])" - value: { - string_value: "null" - } - } - test: { - name: "int support for string" - expr: "\"%s\".format([999999999999])" - value: { - string_value: "999999999999" - } - } - test: { - name: "bytes support for string" - expr: "\"%s\".format([b\"xyz\"])" - value: { - string_value: "xyz" - } - } - test: { - name: "type() support for string" - expr: "\"%s\".format([type(\"test string\")])" - value: { - string_value: "string" - } - } - test: { - name: "timestamp support for string" - expr: "\"%s\".format([timestamp(\"2023-02-03T23:31:20+00:00\")])" - value: { - string_value: "2023-02-03T23:31:20Z" - } - } - test: { - name: "duration support for string" - expr: "\"%s\".format([duration(\"1h45m47s\")])" - value: { - string_value: "6347s" - } - } - test: { - name: "list support for string" - expr: "\"%s\".format([[\"abc\", 3.14, null, [9, 8, 7, 6], timestamp(\"2023-02-03T23:31:20Z\")]])" - value: { - string_value: "[abc, 3.14, null, [9, 8, 7, 6], 2023-02-03T23:31:20Z]" - } - } - test: { - name: "map support for string" - expr: "\"%s\".format([{\"key1\": b\"xyz\", \"key5\": null, \"key2\": duration(\"2h\"), \"key4\": true, \"key3\": 2.71828}])" - value: { - string_value: "{key1: xyz, key2: 7200s, key3: 2.71828, key4: true, key5: null}" - } - } - test: { - name: "map support (all key types)" - expr: "\"%s\".format([{1: \"value1\", uint(2): \"value2\", true: double(\"NaN\")}])" - value: { - string_value: "{1: value1, 2: value2, true: NaN}" - } - } - test: { - name: "boolean support for %s" - expr: "\"%s, %s\".format([true, false])" - value: { - string_value: "true, false" - } - } - test: { - name: "dyntype support for string formatting clause" - expr: "\"%s\".format([dyn(\"a string\")])" - value: { - string_value: "a string" - } - } - test: { - name: "dyntype support for numbers with string formatting clause" - expr: "\"%s, %s\".format([dyn(32), dyn(56.8)])" - value: { - string_value: "32, 56.8" - } - } - test: { - name: "dyntype support for integer formatting clause" - expr: "\"%d\".format([dyn(128)])" - value: { - string_value: "128" - } - } - test: { - name: "dyntype support for integer formatting clause (unsigned)" - expr: "\"%d\".format([dyn(256u)])" - value: { - string_value: "256" - } - } - test: { - name: "dyntype support for hex formatting clause" - expr: "\"%x\".format([dyn(22)])" - value: { - string_value: "16" - } - } - test: { - name: "dyntype support for hex formatting clause (uppercase)" - expr: "\"%X\".format([dyn(26)])" - value: { - string_value: "1A" - } - } - test: { - name: "dyntype support for unsigned hex formatting clause" - expr: "\"%x\".format([dyn(500u)])" - value: { - string_value: "1f4" - } - } - test: { - name: "dyntype support for fixed-point formatting clause" - expr: "\"%.3f\".format([dyn(4.5)])" - value: { - string_value: "4.500" - } - } - test: { - name: "dyntype support for scientific notation" - expr: "\"%e\".format([dyn(2.71828)])" - value: { - string_value: "2.718280e+00" - } - } - test: { - name: "dyntype NaN/infinity support" - expr: "\"%s\".format([[double(\"NaN\"), double(\"Infinity\"), double(\"-Infinity\")]])" - value: { - string_value: "[NaN, Infinity, -Infinity]" - } - } - test: { - name: "dyntype support for timestamp" - expr: "\"%s\".format([dyn(timestamp(\"2009-11-10T23:00:00Z\"))])" - value: { - string_value: "2009-11-10T23:00:00Z" - } - } - test: { - name: "dyntype support for duration" - expr: "\"%s\".format([dyn(duration(\"8747s\"))])" - value: { - string_value: "8747s" - } - } - test: { - name: "dyntype support for lists" - expr: "\"%s\".format([dyn([6, 4.2, \"a string\"])])" - value: { - string_value: "[6, 4.2, a string]" - } - } - test: { - name: "dyntype support for maps" - expr: "\"%s\".format([{\"strKey\":\"x\", 6:duration(\"422s\"), true:42}])" - value: { - string_value: "{6: 422s, strKey: x, true: 42}" - } - } - test: { - name: "string substitution in a string variable" - expr: "str_var.format([\"filler\"])" - type_env: { - name: "str_var" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "str_var" - value: { value: { string_value: "%s" } } - } - value: { - string_value: "filler" - } - } - test: { - name: "multiple substitutions in a string variable" - expr: "str_var.format([1, 2, 3, \"A\", \"B\", \"C\", 4, 5, 6, \"D\", \"E\", \"F\"])" - type_env: { - name: "str_var" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "str_var" - value: { value: { string_value: "%d %d %d, %s %s %s, %d %d %d, %s %s %s" } } - } - value: { - string_value: "1 2 3, A B C, 4 5 6, D E F" - } - } - test: { - name: "substitution inside escaped percent signs in a string variable" - expr: "str_var.format([\"text\"])" - type_env: { - name: "str_var" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "str_var" - value: { value: { string_value: "%%%s%%" } } - } - value: { - string_value: "%text%" - } - } - test: { - name: "fixed point formatting clause in a string variable" - expr: "str_var.format([1.2345])" - type_env: { - name: "str_var" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "str_var" - value: { value: { string_value: "%.3f" } } - } - value: { - string_value: "1.234" - } - } - test: { - name: "binary formatting clause in a string variable" - expr: "str_var.format([5])" - type_env: { - name: "str_var" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "str_var" - value: { value: { string_value: "%b" } } - } - value: { - string_value: "101" - } - } - test: { - name: "scientific notation formatting clause in a string variable" - expr: "str_var.format([1052.032911275])" - type_env: { - name: "str_var" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "str_var" - value: { value: { string_value: "%.6e" } } - } - value: { - string_value: "1.052033e+03" - } - } - test: { - name: "default precision for fixed-point clause in a string variable" - expr: "str_var.format([2.71828])" - type_env: { - name: "str_var" - ident: { type: { primitive: STRING } } - } - bindings: { - key: "str_var" - value: { value: { string_value: "%f" } } - } - value: { - string_value: "2.718280" - } - } - test: { - name: "format_%f_insignificant_zeroes_removed" - expr: "\"%.0f\".format([123.000000])" - value: { - string_value: "123" - } - } - test: { - name: "format_%f_positive_round_to_whole_number" - expr: "\"%.0f\".format([3.5001])" - value: { - string_value: "4" - } - } - test: { - name: "format_%f_negative_truncate_to_whole_number" - expr: "\"%.0f\".format([3.4999])" - value: { - string_value: "3" - } - } - test: { - name: "format_%f_halfway_round_up_to_nearest_even" - expr: "\"%.0f\".format([1.5])" - value: { - string_value: "2" - } - } - test: { - name: "format_%f_halfway_truncate_to_nearest_even" - expr: "\"%.0f\".format([2.5])" - value: { - string_value: "2" - } - } - test: { - name: "format_%f_positive_round_up" - expr: "\"%.3f\".format([123.4999])" - value: { - string_value: "123.500" - } - } - test: { - name: "format_%f_positive_round_down" - expr: "\"%.3f\".format([123.4994])" - value: { - string_value: "123.499" - } - } - test: { - name: "format_%f_negative_round_up" - expr: "\"%.3f\".format([-123.4999])" - value: { - string_value: "-123.500" - } - } - test: { - name: "format_%f_negative_round_down" - expr: "\"%.3f\".format([-123.4994])" - value: { - string_value: "-123.499" - } - } - test: { - name: "format_%f_zero_padding" - expr: "\"%.5f\".format([-1.2])" - value: { - string_value: "-1.20000" - } - } -} -section: { - name: "format_errors" - test: { - name: "unrecognized formatting clause" - expr: "\"%a\".format([1])" - disable_check: true - eval_error: { - errors: { - message: "could not parse formatting clause: unrecognized formatting clause \"a\"" - } - } - } - test: { - name: "out of bounds arg index" - expr: "\"%d %d %d\".format([0, 1])" - disable_check: true - eval_error: { - errors: { - message: "index 2 out of range" - } - } - } - test: { - name: "string substitution is not allowed with binary clause" - expr: "\"string is %b\".format([\"abc\"])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: only integers and bools can be formatted as binary, was given string" - } - } - } - test: { - name: "duration substitution not allowed with decimal clause" - expr: "\"%d\".format([duration(\"30m2s\")])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: decimal clause can only be used on integers, was given google.protobuf.Duration" - } - } - } - test: { - name: "string substitution not allowed with octal clause" - expr: "\"octal: %o\".format([\"a string\"])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: octal clause can only be used on integers, was given string" - } - } - } - test: { - name: "double substitution not allowed with hex clause" - expr: "\"double is %x\".format([0.5])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: only integers, byte buffers, and strings can be formatted as hex, was given double" - } - } - } - test: { - name: "uppercase not allowed for scientific clause" - expr: "\"double is %E\".format([0.5])" - disable_check: true - eval_error: { - errors: { - message: "could not parse formatting clause: unrecognized formatting clause \"E\"" - } - } - } - test: { - name: "object not allowed" - expr: "\"object is %s\".format([cel.expr.conformance.proto3.TestAllTypes{}])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: string clause can only be used on strings, bools, bytes, ints, doubles, maps, lists, types, durations, and timestamps, was given cel.expr.conformance.proto3.TestAllTypes" - } - } - } - test: { - name: "object inside list" - expr: "\"%s\".format([[1, 2, cel.expr.conformance.proto3.TestAllTypes{}]])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: string clause can only be used on strings, bools, bytes, ints, doubles, maps, lists, types, durations, and timestamps, was given cel.expr.conformance.proto3.TestAllTypes" - } - } - } - test: { - name: "object inside map" - expr: "\"%s\".format([{1: \"a\", 2: cel.expr.conformance.proto3.TestAllTypes{}}])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: string clause can only be used on strings, bools, bytes, ints, doubles, maps, lists, types, durations, and timestamps, was given cel.expr.conformance.proto3.TestAllTypes" - } - } - } - test: { - name: "null not allowed for %d" - expr: "\"null: %d\".format([null])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: decimal clause can only be used on integers, was given null_type" - } - } - } - test: { - name: "null not allowed for %e" - expr: "\"null: %e\".format([null])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: scientific clause can only be used on doubles, was given null_type" - } - } - } - test: { - name: "null not allowed for %f" - expr: "\"null: %f\".format([null])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: fixed-point clause can only be used on doubles, was given null_type" - } - } - } - test: { - name: "null not allowed for %x" - expr: "\"null: %x\".format([null])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: only integers, byte buffers, and strings can be formatted as hex, was given null_type" - } - } - } - test: { - name: "null not allowed for %X" - expr: "\"null: %X\".format([null])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: only integers, byte buffers, and strings can be formatted as hex, was given null_type" - } - } - } - test: { - name: "null not allowed for %b" - expr: "\"null: %b\".format([null])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: only integers and bools can be formatted as binary, was given null_type" - } - } - } - test: { - name: "null not allowed for %o" - expr: "\"null: %o\".format([null])" - disable_check: true - eval_error: { - errors: { - message: "error during formatting: octal clause can only be used on integers, was given null_type" - } - } - } -} -section: { - name: "value_errors" - test: { - name: "charat_out_of_range" - expr: "'tacocat'.charAt(30) == ''" - eval_error: { - errors: { - message: "index out of range: 30" - } - } - } - test: { - name: "indexof_out_of_range" - expr: "'tacocat'.indexOf('a', 30) == -1" - eval_error: { - errors: { - message: "index out of range: 30" - } - } - } - test: { - name: "lastindexof_negative_index" - expr: "'tacocat'.lastIndexOf('a', -1) == -1" - eval_error: { - errors: { - message: "index out of range: -1" - } - } - } - test: { - name: "lastindexof_out_of_range" - expr: "'tacocat'.lastIndexOf('a', 30) == -1" - eval_error: { - errors: { - message: "index out of range: 30" - } - } - } - test: { - name: "substring_out_of_range" - expr: "'tacocat'.substring(40) == 'cat'" - eval_error: { - errors: { - message: "index out of range: 40" - } - } - } - test: { - name: "substring_negative_index" - expr: "'tacocat'.substring(-1) == 'cat'" - eval_error: { - errors: { - message: "index out of range: -1" - } - } - } - test: { - name: "substring_end_index_out_of_range" - expr: "'tacocat'.substring(1, 50) == 'cat'" - eval_error: { - errors: { - message: "index out of range: 50" - } - } - } - test: { - name: "substring_begin_index_out_of_range" - expr: "'tacocat'.substring(49, 50) == 'cat'" - eval_error: { - errors: { - message: "index out of range: 49" - } - } - } - test: { - name: "substring_end_index_greater_than_begin_index" - expr: "'tacocat'.substring(4, 3) == ''" - eval_error: { - errors: { - message: "invalid substring range. start: 4, end: 3" - } - } - } -} -section: { - name: "type_errors" - test: { - name: "charat_invalid_type" - expr: "42.charAt(2) == ''" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "charat_invalid_argument" - expr: "'hello'.charAt(true) == ''" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "indexof_unary_invalid_type" - expr: "24.indexOf('2') == 0" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "indexof_unary_invalid_argument" - expr: "'hello'.indexOf(true) == 1" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "indexof_binary_invalid_argument" - expr: "42.indexOf('4', 0) == 0" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "indexof_binary_invalid_argument_2" - expr: "'42'.indexOf(4, 0) == 0" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "indexof_binary_both_invalid_arguments" - expr: "'42'.indexOf('4', '0') == 0" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "indexof_ternary_invalid_arguments" - expr: "'42'.indexOf('4', 0, 1) == 0" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "split_invalid_type" - expr: "42.split('2') == ['4']" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "replace_invalid_type" - expr: "42.replace(2, 1) == '41'" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "replace_binary_invalid_argument" - expr: "'42'.replace(2, 1) == '41'" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "replace_binary_invalid_argument_2" - expr: "'42'.replace('2', 1) == '41'" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "replace_ternary_invalid_argument" - expr: "42.replace('2', '1', 1) == '41'" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "replace_ternary_invalid_argument_2" - expr: "'42'.replace(2, '1', 1) == '41'" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "replace_ternary_invalid_argument_3" - expr: "'42'.replace('2', 1, 1) == '41'" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "replace_ternary_invalid_argument_4" - expr: "'42'.replace('2', '1', '1') == '41'" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "replace_quaternary_invalid_argument" - expr: "'42'.replace('2', '1', 1, false) == '41'" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "split_invalid_type_empty_arg" - expr: "42.split('') == ['4', '2']" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "split_invalid_argument" - expr: "'42'.split(2) == ['4']" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "split_binary_invalid_type" - expr: "42.split('2', '1') == ['4']" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "split_binary_invalid_argument" - expr: "'42'.split(2, 1) == ['4']" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "split_binary_invalid_argument_2" - expr: "'42'.split('2', '1') == ['4']" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "split_ternary_invalid_argument" - expr: "'42'.split('2', 1, 1) == ['4']" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "substring_ternary_invalid_argument" - expr: "'hello'.substring(1, 2, 3) == ''" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "substring_binary_invalid_type" - expr: "30.substring(true, 3) == ''" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "substring_binary_invalid_argument" - expr: "'tacocat'.substring(true, 3) == ''" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } - test: { - name: "substring_binary_invalid_argument_2" - expr: "'tacocat'.substring(0, false) == ''" - disable_check: true - eval_error: { - errors: { - message: "no such overload" - } - } - } -} -section: { - name: "reverse" - description: "Tests for (string).reverse(). Added in version 3." - test: { - name: "empty" - expr: "''.reverse() == ''" - } - test: { - name: "single_character" - expr: "'☺'.reverse() == '☺'" - } - test: { - name: "multiple" - expr: "'Ta©oCαt'.reverse() == 'tαCo©aT'" - } -} diff --git a/tests/simple/testdata/timestamps.textproto b/tests/simple/testdata/timestamps.textproto deleted file mode 100644 index 8c64132c..00000000 --- a/tests/simple/testdata/timestamps.textproto +++ /dev/null @@ -1,610 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "timestamps" -description: "Timestamp and duration tests." -section { - name: "timestamp_conversions" - description: "Conversions of timestamps to other types." - test { - name: "toInt_timestamp" - expr: "int(timestamp('2009-02-13T23:31:30Z'))" - value: { int64_value: 1234567890 } - } - test { - name: "toString_timestamp" - expr: "string(timestamp('2009-02-13T23:31:30Z'))" - value: { string_value: "2009-02-13T23:31:30Z" } - } - test { - name: "toString_timestamp_nanos" - expr: "string(timestamp('9999-12-31T23:59:59.999999999Z'))" - value: { string_value: "9999-12-31T23:59:59.999999999Z" } - } - test { - name: "toType_timestamp" - expr: "type(timestamp('2009-02-13T23:31:30Z'))" - value: { type_value: "google.protobuf.Timestamp" } - } - test { - name: "type_comparison" - expr: "google.protobuf.Timestamp == type(timestamp('2009-02-13T23:31:30Z'))" - value: { bool_value: true } - } -} -section { - name: "duration_conversions" - description: "Conversions of durations to other types." - test { - name: "toString_duration" - expr: "string(duration('1000000s'))" - value: { string_value: "1000000s" } - } - test { - name: "toString_duration_max" - expr: "string(duration('315576000000s999999999ns'))" - value: { string_value: "315576000000.999999999s" } - } - test { - name: "toString_duration_min" - expr: "string(duration('-315576000000s999999999ns'))" - value: { string_value: "-315576000000.999999999s" } - } - test { - name: "from_string_max" - expr: "duration('315576000000s999999999ns')" - value { - object_value { - [type.googleapis.com/google.protobuf.Duration] { - seconds: 315576000000 - nanos: 999999999 - } - } - } - } - test { - name: "from_string_min" - expr: "duration('-315576000000s999999999ns')" - value { - object_value { - [type.googleapis.com/google.protobuf.Duration] { - seconds: -315576000000 - nanos: -999999999 - } - } - } - } - test { - name: "toType_duration" - expr: "type(duration('1000000s'))" - value: { type_value: "google.protobuf.Duration" } - } - test { - name: "type_comparison" - expr: "google.protobuf.Duration == type(duration('1000000s'))" - value: { bool_value: true } - } -} - -section { - name: "timestamp_selectors" - description: "Timestamp selection operators without timezones" - # 1234567890 -> Fri 2009-02-13 23:31:30 UTC - test { - name: "getDate" - expr: "timestamp('2009-02-13T23:31:30Z').getDate()" - value: { int64_value: 13 } - } - test { - name: "getDayOfMonth" - expr: "timestamp('2009-02-13T23:31:30Z').getDayOfMonth()" - value: { int64_value: 12 } - } - test { - name: "getDayOfWeek" - expr: "timestamp('2009-02-13T23:31:30Z').getDayOfWeek()" - value: { int64_value: 5 } - } - test { - name: "getDayOfYear" - expr: "timestamp('2009-02-13T23:31:30Z').getDayOfYear()" - value: { int64_value: 43 } - } - test { - name: "getFullYear" - expr: "timestamp('2009-02-13T23:31:30Z').getFullYear()" - value: { int64_value: 2009 } - } - test { - name: "getHours" - expr: "timestamp('2009-02-13T23:31:30Z').getHours()" - value: { int64_value: 23 } - } - test { - name: "getMilliseconds" - expr: "timestamp('2009-02-13T23:31:20.123456789Z').getMilliseconds()" - value: { int64_value: 123 } - } - test { - name: "getMinutes" - expr: "timestamp('2009-02-13T23:31:30Z').getMinutes()" - value: { int64_value: 31 } - } - test { - name: "getMonth" - expr: "timestamp('2009-02-13T23:31:30Z').getMonth()" - value: { int64_value: 1 } - } - test { - name: "getSeconds" - expr: "timestamp('2009-02-13T23:31:30Z').getSeconds()" - value: { int64_value: 30 } - } -} -section { - name: "timestamp_selectors_tz" - description: "Timestamp selection operators with timezones" - # 1234567890 -> Fri 2009-02-13 23:31:30 UTC - test { - name: "getDate" - expr: "timestamp('2009-02-13T23:31:30Z').getDate('Australia/Sydney')" - value: { int64_value: 14 } - } - test { - name: "getDayOfMonth_name_pos" - expr: "timestamp('2009-02-13T23:31:30Z').getDayOfMonth('US/Central')" - value: { int64_value: 12 } - } - test { - name: "getDayOfMonth_numerical_pos" - expr: "timestamp('2009-02-13T23:31:30Z').getDayOfMonth('+11:00')" - value: { int64_value: 13 } - } - test { - name: "getDayOfMonth_numerical_neg" - expr: "timestamp('2009-02-13T02:00:00Z').getDayOfMonth('-02:30')" - value: { int64_value: 11 } - } - test { - name: "getDayOfMonth_name_neg" - expr: "timestamp('2009-02-13T02:00:00Z').getDayOfMonth('America/St_Johns')" - value: { int64_value: 11 } - } - test { - name: "getDayOfWeek" - expr: "timestamp('2009-02-13T23:31:30Z').getDayOfWeek('UTC')" - value: { int64_value: 5 } - } - test { - name: "getDayOfYear" - expr: "timestamp('2009-02-13T23:31:30Z').getDayOfYear('US/Central')" - value: { int64_value: 43 } - } - test { - name: "getFullYear" - expr: "timestamp('2009-02-13T23:31:30Z').getFullYear('-09:30')" - value: { int64_value: 2009 } - } - test { - name: "getHours" - expr: "timestamp('2009-02-13T23:31:30Z').getHours('02:00')" - value: { int64_value: 1 } - } - test { - name: "getMinutes" - expr: "timestamp('2009-02-13T23:31:30Z').getMinutes('Asia/Kathmandu')" - value: { int64_value: 16 } - } - test { - name: "getMonth" - expr: "timestamp('2009-02-13T23:31:30Z').getMonth('UTC')" - value: { int64_value: 1 } - } - test { - name: "getSeconds" - expr: "timestamp('2009-02-13T23:31:30Z').getSeconds('-00:00')" - value: { int64_value: 30 } - } -} -section { - name: "timestamp_equality" - description: "Equality operations on timestamps." - test { - name: "eq_same" - expr: "timestamp('2009-02-13T23:31:30Z') == timestamp('2009-02-13T23:31:30Z')" - value: { bool_value: true } - } - test { - name: "eq_diff" - expr: "timestamp('2009-02-13T23:31:29Z') == timestamp('2009-02-13T23:31:30Z')" - value: { bool_value: false } - } - test { - name: "neq_same" - expr: "timestamp('1945-05-07T02:41:00Z') != timestamp('1945-05-07T02:41:00Z')" - value: { bool_value: false } - } - test { - name: "neq_diff" - expr: "timestamp('2000-01-01T00:00:00Z') != timestamp('2001-01-01T00:00:00Z')" - value: { bool_value: true } - } -} -section { - name: "duration_equality" - description: "Equality tests for durations." - test { - name: "eq_same" - expr: "duration('123s') == duration('123s')" - value: { bool_value: true } - } - test { - name: "eq_diff" - expr: "duration('60s') == duration('3600s')" - value: { bool_value: false } - } - test { - name: "neq_same" - expr: "duration('604800s') != duration('604800s')" - value: { bool_value: false } - } - test { - name: "neq_diff" - expr: "duration('86400s') != duration('86164s')" - value: { bool_value: true } - } -} -section { - name: "timestamp_arithmetic" - description: "Arithmetic operations on timestamps and/or durations." - test { - name: "add_duration_to_time" - expr: "timestamp('2009-02-13T23:00:00Z') + duration('240s') == timestamp('2009-02-13T23:04:00Z')" - value: { bool_value: true } - } - test { - name: "add_time_to_duration" - expr: "duration('120s') + timestamp('2009-02-13T23:01:00Z') == timestamp('2009-02-13T23:03:00Z')" - value: { bool_value: true } - } - test { - name: "add_duration_to_duration" - expr: "duration('600s') + duration('50s') == duration('650s')" - value: { bool_value: true } - } - test { - name: "add_time_to_duration_nanos_negative" - expr: "timestamp('0001-01-01T00:00:01.000000001Z') + duration('-999999999ns') == timestamp('0001-01-01T00:00:00.000000002Z')" - value: { bool_value: true } - } - test { - name: "add_time_to_duration_nanos_positive" - expr: "timestamp('0001-01-01T00:00:01.999999999Z') + duration('999999999ns') == timestamp('0001-01-01T00:00:02.999999998Z')" - value: { bool_value: true } - } - test { - name: "subtract_duration_from_time" - expr: "timestamp('2009-02-13T23:10:00Z') - duration('600s') == timestamp('2009-02-13T23:00:00Z')" - value: { bool_value: true } - } - test { - name: "subtract_time_from_time" - expr: "timestamp('2009-02-13T23:31:00Z') - timestamp('2009-02-13T23:29:00Z') == duration('120s')" - value: { bool_value: true } - } - test { - name: "subtract_duration_from_duration" - expr: "duration('900s') - duration('42s') == duration('858s')" - value: { bool_value: true } - } - test { - name: "add_max_duration_to_min_time" - expr: "timestamp('0001-01-01T00:00:00Z') + duration('315537897599s999999999ns') == timestamp('9999-12-31T23:59:59.999999999Z')" - value: { bool_value: true } - } - test { - name: "subtract_max_duration_from_max_time" - expr: "timestamp('9999-12-31T23:59:59.999999999Z') - duration('315537897599s999999999ns') == timestamp('0001-01-01T00:00:00Z')" - value: { bool_value: true } - } - test { - name: "add_duration_to_duration_max" - expr: "duration('315576000000s') + duration('999999999ns') == duration('315576000000s999999999ns')" - value: { bool_value: true } - } - test { - name: "subtract_duration_from_duration_min" - expr: "duration('-315576000000s') - duration('999999999ns') == duration('-315576000000s999999999ns')" - value: { bool_value: true } - } -} -section { - name: "comparisons" - description: "Comparisons on timestamps and/or durations." - test { - name: "leq_timestamp_true" - expr: "timestamp('2009-02-13T23:00:00Z') <= timestamp('2009-02-13T23:00:00Z')" - value: { bool_value: true } - } - test { - name: "leq_timestamp_false" - expr: "timestamp('2009-02-13T23:00:00Z') <= timestamp('2009-02-13T22:59:59Z')" - value: { bool_value: false } - } - test { - name: "leq_duration_true" - expr: "duration('200s') <= duration('200s')" - value: { bool_value: true } - } - test { - name: "leq_duration_false" - expr: "duration('300s') <= duration('200s')" - value: { bool_value: false } - } - test { - name: "less_timestamp_true" - expr: "timestamp('2009-02-13T23:00:00Z') < timestamp('2009-03-13T23:00:00Z')" - value: { bool_value: true } - } - test { - name: "less_duration_true" - expr: "duration('200s') < duration('300s')" - value: { bool_value: true } - } - test { - name: "geq_timestamp_true" - expr: "timestamp('2009-02-13T23:00:00Z') >= timestamp('2009-02-13T23:00:00Z')" - value: { bool_value: true } - } - test { - name: "geq_timestamp_false" - expr: "timestamp('2009-02-13T22:58:00Z') >= timestamp('2009-02-13T23:00:00Z')" - value: { bool_value: false } - } - test { - name: "geq_duration_true" - expr: "duration('200s') >= duration('200s')" - value: { bool_value: true } - } - test { - name: "geq_duration_false" - expr: "duration('120s') >= duration('200s')" - value: { bool_value: false } - } - test { - name: "greater_timestamp_true" - expr: "timestamp('2009-02-13T23:59:00Z') > timestamp('2009-02-13T23:00:00Z')" - value: { bool_value: true } - } - test { - name: "greater_duration_true" - expr: "duration('300s') > duration('200s')" - value: { bool_value: true } - } -} -section { - name: "duration_converters" - description: "Conversion functions on durations. Unlike timestamps, we don't, e.g. select the 'minutes' field - we convert the duration to integer minutes." - test { - name: "get_hours" - expr: "duration('10000s').getHours()" - value: { int64_value: 2 } - } - test { - name: "get_milliseconds" - description: "Obtain the milliseconds component of the duration. Note, this is not the same as converting the duration to milliseconds. This behavior will be deprecated." - expr: "x.getMilliseconds()" - type_env { - name: "x" - ident: { type: { message_type: "google.protobuf.Duration" } } - } - bindings { - key: "x" - value { - value { - object_value { - [type.googleapis.com/google.protobuf.Duration] { - seconds: 123 - nanos: 321456789 - } - } - } - } - } - value: { int64_value: 321 } - } - test { - name: "get_minutes" - expr: "duration('3730s').getMinutes()" - value: { int64_value: 62 } - } - test { - name: "get_seconds" - expr: "duration('3730s').getSeconds()" - value: { int64_value: 3730 } - } -} -section { - name: "timestamp_range" - description: "Tests for out-of-range operations on timestamps." - test { - name: "from_string_under" - expr: "timestamp('0000-01-01T00:00:00Z')" - eval_error { - errors { message: "range" } - } - } - test { - name: "from_int_under" - expr: "timestamp(-62135596801)" - eval_error { - errors { message: "range" } - } - } - test { - name: "from_string_over" - expr: "timestamp('10000-01-01T00:00:00Z')" - eval_error { - errors { message: "range" } - } - } - test { - name: "from_int_over" - expr: "timestamp(253402300800)" - eval_error { - errors { message: "range" } - } - } - test { - name: "add_duration_under" - expr: "timestamp('0001-01-01T00:00:00Z') + duration('-1s')" - eval_error { - errors { message: "range" } - } - } - test { - name: "add_duration_over" - expr: "timestamp('9999-12-31T23:59:59Z') + duration('1s')" - eval_error { - errors { message: "range" } - } - } - test { - name: "add_duration_nanos_over" - expr: "timestamp('9999-12-31T23:59:59.999999999Z') + duration('1ns')" - eval_error { - errors { message: "range" } - } - } - test { - name: "add_duration_nanos_under" - expr: "timestamp('0001-01-01T00:00:00Z') + duration('-1ns')" - eval_error { - errors { message: "range" } - } - } - test { - name: "sub_time_duration_over" - expr: "timestamp('9999-12-31T23:59:59Z') - timestamp('0001-01-01T00:00:00Z')" - value { - object_value { - [type.googleapis.com/google.protobuf.Duration] { - seconds: 315537897599 - } - } - } - } - test { - name: "sub_time_duration_under" - expr: "timestamp('0001-01-01T00:00:00Z') - timestamp('9999-12-31T23:59:59Z')" - value { - object_value { - [type.googleapis.com/google.protobuf.Duration] { - seconds: -315537897599 - } - } - } - } -} -section { - name: "duration_range" - description: "Tests for out-of-range operations on durations." - test { - name: "from_string_under" - expr: "duration('-320000000000s')" - eval_error { - errors { message: "range" } - } - } - test { - name: "from_string_over" - expr: "duration('320000000000s')" - eval_error { - errors { message: "range" } - } - } - test { - name: "from_string_under_boundary" - expr: "duration('-315576000001s')" - eval_error { - errors { message: "range" } - } - } - test { - name: "from_string_over_boundary" - expr: "duration('315576000001s')" - eval_error { - errors { message: "range" } - } - } - test { - name: "from_string_nanos_under_boundary" - expr: "duration('-315576000000s1000000000ns')" - eval_error { - errors { message: "range" } - } - } - test { - name: "from_string_nanos_over_boundary" - expr: "duration('315576000000s1000000000ns')" - eval_error { - errors { message: "range" } - } - } - test { - name: "add_under" - expr: "duration('-200000000000s') + duration('-200000000000s')" - eval_error { - errors { message: "range" } - } - } - test { - name: "add_over" - expr: "duration('200000000000s') + duration('200000000000s')" - eval_error { - errors { message: "range" } - } - } - test { - name: "add_nanos_under" - expr: "duration('-315576000000s999999999ns') + duration('-1ns')" - eval_error { - errors { message: "range" } - } - } - test { - name: "add_nanos_over" - expr: "duration('315576000000s999999999ns') + duration('1ns')" - eval_error { - errors { message: "range" } - } - } - test { - name: "sub_under" - expr: "duration('-200000000000s') - duration('200000000000s')" - eval_error { - errors { message: "range" } - } - } - test { - name: "sub_over" - expr: "duration('200000000000s') - duration('-200000000000s')" - eval_error { - errors { message: "range" } - } - } - test { - name: "sub_nanos_under" - expr: "duration('-315576000000s999999999ns') - duration('1ns')" - eval_error { - errors { message: "range" } - } - } - test { - name: "sub_nanos_over" - expr: "duration('315576000000s999999999ns') - duration('-1ns')" - eval_error { - errors { message: "range" } - } - } -} diff --git a/tests/simple/testdata/type_deduction.textproto b/tests/simple/testdata/type_deduction.textproto deleted file mode 100644 index 345cf6d9..00000000 --- a/tests/simple/testdata/type_deduction.textproto +++ /dev/null @@ -1,1353 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "type_deductions" -description: "Tests for type checker deduced types" - -section { - name: "constant_literals" - test { - name: "bool" - expr: "true" - typed_result { - result { - bool_value: true - } - deduced_type { - primitive: BOOL - } - } - } - test { - name: "int" - expr: "42" - typed_result { - result { - int64_value: 42 - } - deduced_type { - primitive: INT64 - } - } - } - test { - name: "uint" - expr: "42u" - typed_result { - result { - uint64_value: 42 - } - deduced_type { - primitive: UINT64 - } - } - } - test { - name: "double" - expr: "0.1" - typed_result { - result { - double_value: 0.1 - } - deduced_type { - primitive: DOUBLE - } - } - } - test { - name: "string" - expr: "\"test\"" - typed_result { - result { - string_value: "test" - } - deduced_type { - primitive: STRING - } - } - } - test { - name: "bytes" - expr: "b\"test\"" - typed_result { - result { - bytes_value: "test" - } - deduced_type { - primitive: BYTES - } - } - } - test { - name: "null" - expr: "null" - typed_result { - result { - null_value: NULL_VALUE - } - deduced_type { - null: NULL_VALUE - } - } - } -} - -section { - name: "complex_initializers" - test { - name: "list" - expr: "[1]" - typed_result { - result { - list_value { - values { - int64_value: 1 - } - } - } - deduced_type { - list_type { elem_type { primitive: INT64 } } - } - } - } - test { - name: "map" - expr: "{'abc': 123}" - typed_result { - result { - map_value { - entries { - key { string_value: "abc" } - value { int64_value: 123 } - } - } - } - deduced_type { - map_type { - key_type { primitive: STRING } - value_type { primitive: INT64 } - } - } - } - } - test { - name: "struct" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64: 1}" - typed_result { - result { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] { - single_int64: 1 - } - } - } - deduced_type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } -} - -section { - name: "field_access" - test { - name: "int_field" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64: 1}.single_int64" - typed_result { - result { - int64_value: 1 - } - deduced_type { - primitive: INT64 - } - } - } - test { - name: "repeated_int_field" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.repeated_int64" - typed_result { - result { - list_value {} - } - deduced_type { - list_type { elem_type { primitive: INT64 } } - } - } - } - test { - name: "map_bool_int" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.map_bool_int64" - typed_result { - result { - map_value {} - } - deduced_type { - map_type { - key_type { primitive: BOOL } - value_type { primitive: INT64 } - } - } - } - } - test { - name: "enum_field" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.standalone_enum" - typed_result { - result { - int64_value: 0 - } - deduced_type { primitive: INT64 } - } - } - test { - name: "repeated_enum_field" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.repeated_nested_enum" - typed_result { - result { - list_value {} - } - deduced_type { - list_type { elem_type { primitive: INT64 } } - } - } - } - test { - name: "enum_map_field" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{}.map_int32_enum" - typed_result { - result { - map_value {} - } - deduced_type { - map_type { - key_type { primitive: INT64 } - value_type { primitive: INT64 } - } - } - } - } -} - -section { - name: "indexing" - test { - name: "list" - expr: "['foo'][0]" - typed_result { - result { - string_value: "foo" - } - deduced_type { - primitive: STRING - } - } - } - test { - name: "map" - expr: "{'abc': 123}['abc']" - typed_result { - result { - int64_value: 123 - } - deduced_type { - primitive: INT64 - } - } - } -} - -section { - name: "functions" - test { - name: "nested_calls" - expr: "('foo' + 'bar').startsWith('foo')" - typed_result { - result { - bool_value: true - } - deduced_type { - primitive: BOOL - } - } - } - test { - name: "function_result_type" - expr: "fn('abc', 123)" - check_only: true - type_env { - name: "fn" - function { - overloads { - overload_id: "fn_string_int" - result_type { primitive: STRING } - params { primitive: STRING } - params { primitive: INT64 } - } - } - } - typed_result { - deduced_type { - primitive: STRING - } - } - } -} - -# These are somewhat complex expressions for edge cases in type inference. The -# result values are not interesting, but the inferred types are. -section { - name: "flexible_type_parameter_assignment" - test { - name: "list_parameter" - expr: "[[], [[]], [[[]]], [[[[]]]]]" - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - list_type { - elem_type { - list_type { - elem_type { - list_type { - elem_type { - list_type { - elem_type { dyn {} } - } - } - } - } - } - } - } - } - } - } - } - } - test { - name: "list_parameter_order_independent" - expr: "[[[[[]]]], [], [[[]]]]" - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - list_type { - elem_type { - list_type { - elem_type { - list_type { - elem_type { - list_type { - elem_type { dyn {} } - } - } - } - } - } - } - } - } - } - } - } - } - test { - name: "comprehension_type_var_aliasing" - expr: "msg.repeated_nested_message.map(x, x).map(y, y.bb)" - check_only: true - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - typed_result { - deduced_type { - list_type { - elem_type { - primitive: INT64 - } - } - } - } - } - test { - name: "overload_type_var_aliasing" - expr: "([] + msg.repeated_nested_message + [])[0].bb" - check_only: true - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - typed_result { - deduced_type { - primitive: INT64 - } - } - } - test { - name: "unconstrained_type_var_as_dyn" - expr: "([].map(x,x))[0].foo" - check_only: true - typed_result { - deduced_type { - dyn {} - } - } - } - test { - name: "list_parameters_do_not_unify" - expr: "[msg.single_int64_wrapper, msg.single_string_wrapper]" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - dyn {} - } - } - } - } - } - test { - name: "optional_none" - expr: "[optional.none(), optional.of(1)]" - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - abstract_type { - name: "optional_type" - parameter_types { primitive: INT64 } - } - } - } - } - } - } - test { - name: "optional_none_2" - expr: "[optional.of(1), optional.none()]" - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - abstract_type { - name: "optional_type" - parameter_types { primitive: INT64 } - } - } - } - } - } - } - test { - name: "optional_dyn_promotion" - expr: "[optional.of(1), optional.of(dyn(1))]" - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - abstract_type { - name: "optional_type" - parameter_types { dyn {} } - } - } - } - } - } - } - test { - name: "optional_dyn_promotion_2" - expr: "[optional.of(dyn(1)), optional.of(1)]" - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - abstract_type { - name: "optional_type" - parameter_types { dyn {} } - } - } - } - } - } - } - test { - name: "optional_in_ternary" - expr: "true ? optional.of(dyn(1)) : optional.of(1)" - check_only: true - typed_result { - deduced_type { - abstract_type { - name: "optional_type" - parameter_types { dyn {} } - } - } - } - } -} - -# Wrapper types have some special handling. They generally behave like a union -# type e.g. `null | int64` with auto-unboxing, but there are some quirks. -section { - name: "wrappers" - test { - name: "wrapper_promotion" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - expr: "[msg.single_int64_wrapper, msg.single_int64]" - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - wrapper: INT64 - } - } - } - } - } - test { - name: "wrapper_promotion_2" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - expr: "[msg.single_int64, msg.single_int64_wrapper]" - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - wrapper: INT64 - } - } - } - } - } - test { - name: "wrapper_dyn_promotion" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - expr: "[msg.single_int64_wrapper, msg.single_int64, dyn(1)]" - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - dyn {} - } - } - } - } - } - test { - name: "wrapper_dyn_promotion_2" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - expr: "[dyn(1), msg.single_int64_wrapper, msg.single_int64]" - check_only: true - typed_result { - deduced_type { - list_type { - elem_type { - dyn {} - } - } - } - } - } - test { - name: "wrapper_primitive_assignable" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - expr: "msg.single_int64_wrapper + 1" - check_only: true - typed_result { - deduced_type { - primitive: INT64 - } - } - } - test { - name: "wrapper_null_assignable" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - expr: "msg.single_int64_wrapper == null" - check_only: true - typed_result { - deduced_type { - primitive: BOOL - } - } - } - test { - name: "wrapper_ternary_parameter_assignment" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - expr: "false ? msg.single_int64_wrapper : null" - check_only: true - typed_result { - deduced_type { - wrapper: INT64 - } - } - } - test { - name: "wrapper_ternary_parameter_assignment_2" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - expr: "true ? msg.single_int64_wrapper : 42" - check_only: true - typed_result { - deduced_type { - wrapper: INT64 - } - } - } -} - -section { - name: "type_parameters" - test { - name: "multiple_parameters_generality" - check_only: true - expr: "[tuple(1, 2u, 3.0), tuple(dyn(1), dyn(2u), dyn(3.0))][0]" - type_env { - name: "tuple" - function { - overloads { - overload_id: "tuple_T_U_V" - params { type_param: "T" } - params { type_param: "U" } - params { type_param: "V" } - result_type { - abstract_type { - name: "tuple" - parameter_types { type_param: "T" } - parameter_types { type_param: "U" } - parameter_types { type_param: "V" } - } - } - } - } - } - typed_result { - deduced_type { - abstract_type { - name: "tuple" - parameter_types { dyn {} } - parameter_types { dyn {} } - parameter_types { dyn {} } - } - } - } - } - test { - name: "multiple_parameters_generality_2" - check_only: true - expr: "sort(tuple(dyn(1), 2u, 3.0))" - type_env { - name: "tuple" - function { - overloads { - overload_id: "tuple_T_U_V" - params { type_param: "T" } - params { type_param: "U" } - params { type_param: "V" } - result_type { - abstract_type { - name: "tuple" - parameter_types { type_param: "T" } - parameter_types { type_param: "U" } - parameter_types { type_param: "V" } - } - } - } - } - } - type_env { - name: "sort" - function { - overloads { - overload_id: "sort_tuple_T_T_T" - params { - abstract_type { - name: "tuple" - parameter_types { type_param: "T" } - parameter_types { type_param: "T" } - parameter_types { type_param: "T" } - } - } - result_type { - abstract_type { - name: "tuple" - parameter_types { type_param: "T" } - parameter_types { type_param: "T" } - parameter_types { type_param: "T" } - } - } - } - } - } - typed_result { - deduced_type { - abstract_type { - name: "tuple" - parameter_types { dyn {} } - parameter_types { dyn {} } - parameter_types { dyn {} } - } - } - } - } - test { - name: "multiple_parameters_parameterized_ovl" - check_only: true - expr: "tuple(1, 2u, 3.0) == tuple(1, dyn(2u), dyn(3.0))" - type_env { - name: "tuple" - function { - overloads { - overload_id: "tuple_T_U_V" - params { type_param: "T" } - params { type_param: "U" } - params { type_param: "V" } - result_type { - abstract_type { - name: "tuple" - parameter_types { type_param: "T" } - parameter_types { type_param: "U" } - parameter_types { type_param: "V" } - } - } - } - } - } - typed_result { - deduced_type { - primitive: BOOL - } - } - } - test { - name: "multiple_parameters_parameterized_ovl_2" - check_only: true - expr: "tuple(dyn(1), dyn(2u), 3.0) == tuple(1, 2u, 3.0)" - type_env { - name: "tuple" - function { - overloads { - overload_id: "tuple_T_U_V" - params { type_param: "T" } - params { type_param: "U" } - params { type_param: "V" } - result_type { - abstract_type { - name: "tuple" - parameter_types { type_param: "T" } - parameter_types { type_param: "U" } - parameter_types { type_param: "V" } - } - } - } - } - } - typed_result { - deduced_type { - primitive: BOOL - } - } - } -} - -# Messages, some well-known types, and abstract can be assigned from null in the -# CEL type checkers for historical reasons. For backward compatibility, we -# maintain this behavior but it's a bit inconsistent with the intended meaning -# of null (a singleton representing a JSON null literal) in CEL. -section { - name: "legacy_nullable_types" - test { - name: "null_assignable_to_message_parameter_candidate" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - bindings { - key: "msg" - value { - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] {} - } - } - } - } - expr: "[msg, null][0]" - typed_result { - deduced_type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - result { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] {} - } - } - } - } - test { - name: "null_assignable_to_duration_parameter_candidate" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - bindings { - key: "msg" - value { - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] {} - } - } - } - } - expr: "[msg.single_duration, null][0]" - typed_result { - deduced_type { - well_known: DURATION - } - result { - object_value { - [type.googleapis.com/google.protobuf.Duration] {} - } - } - } - } - test { - name: "null_assignable_to_timestamp_parameter_candidate" - type_env { - name: "msg" - ident { - type { - message_type: "cel.expr.conformance.proto3.TestAllTypes" - } - } - } - bindings { - key: "msg" - value { - value { - object_value { - [type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] {} - } - } - } - } - expr: "[msg.single_timestamp, null][0]" - typed_result { - deduced_type { - well_known: TIMESTAMP - } - result { - object_value { - [type.googleapis.com/google.protobuf.Timestamp] {} - } - } - } - } - test { - name: "null_assignable_to_abstract_parameter_candidate" - expr: "[optional.of(1), null][0]" - check_only: true - typed_result { - deduced_type { - abstract_type { - name: "optional_type" - parameter_types { primitive: INT64 } - } - } - } - } -} - -section { - name: "type_parameters_in_type_type" - description: "Tests for type parameter deduction within TypeType (type(T))." - test { - name: "type_param_in_type_type_int" - check_only: true - expr: "cast('hello', int)" - type_env { - name: "cast" - function { - overloads { - overload_id: "cast_val_to_type" - params { dyn {} } - params { - type { - type_param: "T" - } - } - result_type { - type_param: "T" - } - } - } - } - typed_result { - deduced_type { - primitive: INT64 - } - } - } - test { - name: "type_param_in_type_type_string" - check_only: true - expr: "cast(123, string)" - type_env { - name: "cast" - function { - overloads { - overload_id: "cast_val_to_type" - params { dyn {} } - params { - type { - type_param: "T" - } - } - result_type { - type_param: "T" - } - } - } - } - typed_result { - deduced_type { - primitive: STRING - } - } - } - test { - name: "composite_type_param_in_type_type" - check_only: true - expr: "first_elem_type('data', type([1]))" - type_env { - name: "first_elem_type" - function { - overloads { - overload_id: "first_elem_type_list" - params { dyn {} } - params { - type { - list_type { - elem_type { - type_param: "T" - } - } - } - } - result_type { - type_param: "T" - } - } - } - } - typed_result { - deduced_type { - primitive: INT64 - } - } - } - test { - name: "nested_type_param_in_type_type" - check_only: true - expr: "unwrap_type(type(int))" - type_env { - name: "unwrap_type" - function { - overloads { - overload_id: "unwrap_type_t" - params { - type { - type { - type_param: "T" - } - } - } - result_type { - type { - type_param: "T" - } - } - } - } - } - typed_result { - deduced_type { - type { - primitive: INT64 - } - } - } - } - test { - name: "type_map_erasure_comparison" - check_only: true - expr: "type({}) == map" - typed_result { - deduced_type { - primitive: BOOL - } - } - } - test { - name: "type_list_erasure_comparison" - check_only: true - expr: "type([1]) == list" - typed_result { - deduced_type { - primitive: BOOL - } - } - } - test { - name: "type_comparison_different_types_inequality" - expr: "type(1) != type(1u)" - typed_result { - result { - bool_value: true - } - deduced_type { - primitive: BOOL - } - } - } - test { - name: "type_comparison_different_types_equality" - expr: "type(1) == type(1u)" - typed_result { - result { - bool_value: false - } - deduced_type { - primitive: BOOL - } - } - } -} - -section { - name: "empty_range_nested_comprehensions" - description: "An empty iteration range gives the iteration variable a free type " - "variable rather than dyn. Using it as the range of a nested " - "comprehension must resolve it to dyn." - test { - name: "empty_list_range_nested_list_comprehension" - check_only: true - expr: "[].map(x, x.map(y, y))" - typed_result { - deduced_type { - list_type { elem_type { list_type { elem_type { dyn {} } } } } - } - } - } - test { - name: "empty_map_range_nested_comprehension" - check_only: true - expr: "{}.map(k, k.map(y, y))" - typed_result { - deduced_type { - list_type { elem_type { list_type { elem_type { dyn {} } } } } - } - } - } - test { - name: "empty_range_nested_comprehension_before_constraint" - description: "Inner comprehension widens the outer element type to dyn, so the " - "subsequent int comparison is legal." - expr: "[].all(x, x.all(y, y == 1) && x == 1)" - typed_result { - result { bool_value: true } - deduced_type { primitive: BOOL } - } - } - test { - name: "empty_range_nested_comprehension_boolean_map" - description: "Inner comprehension body produces bool, so the expression deduces to " - "list(list(bool)) even though the range variable is widened to dyn." - check_only: true - expr: "[].map(i, i.map(j, j > 1))" - typed_result { - deduced_type { - list_type { elem_type { list_type { elem_type { primitive: BOOL } } } } - } - } - } - test { - name: "empty_range_nested_comprehension_equality" - description: "Inner comprehension widens the outer element type to dyn and deduces " - "list(list(bool)), which is comparable with [[]] (list(list(dyn)))." - expr: "[].map(i, i.map(j, j > 1)) == [[]]" - typed_result { - result { bool_value: false } - deduced_type { primitive: BOOL } - } - } -} - -section { - name: "type_decay" - description: "Tests for type decay / least-upper-bound generalization of type values." - test { - name: "type_list_decay" - expr: "[int, bool, double]" - typed_result { - result { - list_value { - values { - type_value: "int" - } - values { - type_value: "bool" - } - values { - type_value: "double" - } - } - } - deduced_type { - list_type { - elem_type { - type { - dyn {} - } - } - } - } - } - } - test { - name: "type_ternary_decay" - expr: "true ? type(1) : type(1u)" - typed_result { - result { - type_value: "int" - } - deduced_type { - type { - dyn {} - } - } - } - } - test { - name: "type_free_param_list_decay" - description: "Type decay for list literal containing a free type parameter in a type value and a concrete type." - expr: "[type([]), int]" - typed_result { - result { - list_value { - values { - type_value: "list" - } - values { - type_value: "int" - } - } - } - deduced_type { - list_type { - elem_type { - type { - dyn {} - } - } - } - } - } - } - test { - name: "type_free_param_list_decay_order_independent" - description: "Type decay for list literal containing a concrete type and a free type parameter in a type value." - expr: "[int, type([])]" - typed_result { - result { - list_value { - values { - type_value: "int" - } - values { - type_value: "list" - } - } - } - deduced_type { - list_type { - elem_type { - type { - dyn {} - } - } - } - } - } - } - test { - name: "type_nested_list_decay" - description: "Type decay for nested list literal with differing type values." - expr: "[[type(1)], [type(1u)]]" - typed_result { - result { - list_value { - values { - list_value { - values { - type_value: "int" - } - } - } - values { - list_value { - values { - type_value: "uint" - } - } - } - } - } - deduced_type { - list_type { - elem_type { - list_type { - elem_type { - type { - dyn {} - } - } - } - } - } - } - } - } - test { - name: "type_free_param_list_concat" - description: "Type deduction for concatenated lists containing free type parameters in type values." - expr: "([] + [[type(1)]]) + [[type([])]]" - typed_result { - result { - list_value { - values { - list_value { - values { - type_value: "int" - } - } - } - values { - list_value { - values { - type_value: "list" - } - } - } - } - } - deduced_type { - list_type { - elem_type { - list_type { - elem_type { - type { - dyn {} - } - } - } - } - } - } - } - } -} diff --git a/tests/simple/testdata/unknowns.textproto b/tests/simple/testdata/unknowns.textproto deleted file mode 100644 index 1464f833..00000000 --- a/tests/simple/testdata/unknowns.textproto +++ /dev/null @@ -1,5 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: google.api.expr.test.v1.SimpleTestFile - -name: "unknowns" -description: "Tests for evaluation with unknown inputs." diff --git a/tests/simple/testdata/wrappers.textproto b/tests/simple/testdata/wrappers.textproto deleted file mode 100644 index a6b93a5b..00000000 --- a/tests/simple/testdata/wrappers.textproto +++ /dev/null @@ -1,520 +0,0 @@ -# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto -# proto-message: cel.expr.conformance.test.SimpleTestFile - -name: "wrappers" -description: "Conformance tests related to wrapper types." - -# google.protobuf.BoolValue -section { - name: "bool" - test { - name: "to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: google.protobuf.BoolValue{value: true}}.single_any" - value { - bool_value: true - } - } - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.BoolValue{value: true}}.single_value" - value { - bool_value: true - } - } - test { - name: "to_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bool_wrapper: null} == TestAllTypes{}" - value { - bool_value: true - } - } -} - -# google.protobuf.Int32Value -section { - name: "int32" - test { - name: "to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: google.protobuf.Int32Value{value: 1}}.single_any" - value { - int64_value: 1 - } - } - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.Int32Value{value: 1}}.single_value" - value { - double_value: 1 - } - } - test { - name: "to_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int32_wrapper: null} == TestAllTypes{}" - value { - bool_value: true - } - } -} - -# google.protobuf.Int64Value -section { - name: "int64" - test { - name: "to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: google.protobuf.Int64Value{value: 1}}.single_any" - value { - int64_value: 1 - } - } - test { - name: "to_json_number" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.Int64Value{value: 1}}.single_value" - value { - double_value: 1 - } - } - test { - name: "to_json_string" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.Int64Value{value: 9223372036854775807}}.single_value" - value { - string_value: "9223372036854775807" - } - } - test { - name: "to_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_int64_wrapper: null} == TestAllTypes{}" - value { - bool_value: true - } - } -} - -# google.protobuf.UInt32Value -section { - name: "uint32" - test { - name: "to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: google.protobuf.UInt32Value{value: 1u}}.single_any" - value { - uint64_value: 1 - } - } - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.UInt32Value{value: 1u}}.single_value" - value { - double_value: 1 - } - } - test { - name: "to_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint32_wrapper: null} == TestAllTypes{}" - value { - bool_value: true - } - } -} - -# google.protobuf.UInt64Value -section { - name: "uint64" - test { - name: "to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: google.protobuf.UInt64Value{value: 1u}}.single_any" - value { - uint64_value: 1 - } - } - test { - name: "to_json_number" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.UInt64Value{value: 1u}}.single_value" - value { - double_value: 1 - } - } - test { - name: "to_json_string" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.UInt64Value{value: 18446744073709551615u}}.single_value" - value { - string_value: "18446744073709551615" - } - } - test { - name: "to_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_uint64_wrapper: null} == TestAllTypes{}" - value { - bool_value: true - } - } -} - -# google.protobuf.FloatValue -section { - name: "float" - test { - name: "to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: google.protobuf.FloatValue{value: 1.0}}.single_any" - value { - double_value: 1 - } - } - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.FloatValue{value: 1.0}}.single_value" - value { - double_value: 1 - } - } - test { - name: "to_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_float_wrapper: null} == TestAllTypes{}" - value { - bool_value: true - } - } -} - -# google.protobuf.DoubleValue -section { - name: "double" - test { - name: "to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: google.protobuf.DoubleValue{value: 1.0}}.single_any" - value { - double_value: 1 - } - } - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.DoubleValue{value: 1.0}}.single_value" - value { - double_value: 1 - } - } - test { - name: "to_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_double_wrapper: null} == TestAllTypes{}" - value { - bool_value: true - } - } -} - -# google.protobuf.BytesValue -section { - name: "bytes" - test { - name: "to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: google.protobuf.BytesValue{value: b'foo'}}.single_any" - value { - bytes_value: "foo" - } - } - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.BytesValue{value: b'foo'}}.single_value" - value { - string_value: "Zm9v" - } - } - test { - name: "to_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_bytes_wrapper: null} == TestAllTypes{}" - value { - bool_value: true - } - } -} - -# google.protobuf.StringValue -section { - name: "string" - test { - name: "to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: google.protobuf.StringValue{value: 'foo'}}.single_any" - value { - string_value: "foo" - } - } - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.StringValue{value: 'foo'}}.single_value" - value { - string_value: "foo" - } - } - test { - name: "to_null" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_string_wrapper: null} == TestAllTypes{}" - value { - bool_value: true - } - } -} - -# google.protobuf.Value -section { - name: "value" - test { - name: "default_to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: TestAllTypes{}.single_value}.single_any" - value { - null_value: NULL_VALUE - } - } -} - -# google.protobuf.ListValue -section { - name: "list_value" - description: "" - test { - name: "literal_to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: []}.single_any" - value { - list_value {} - } - } -} - -# google.protobuf.Struct -section { - name: "struct" - test { - name: "literal_to_any" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_any: {}}.single_any" - value { - map_value {} - } - } -} - -# google.protobuf.FieldMask -section { - name: "field_mask" - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.FieldMask{paths: ['foo', 'bar']}}.single_value" - value { - string_value: "foo,bar" - } - } -} - -# google.protobuf.Duration -section { - name: "duration" - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: duration('1000000s')}.single_value" - value { - string_value: "1000000s" - } - } - test { - name: "max_value" - expr: "google.protobuf.Duration{seconds: 315576000000, nanos: 999999999}" - value { - object_value { - [type.googleapis.com/google.protobuf.Duration] { - seconds: 315576000000 - nanos: 999999999 - } - } - } - } - test { - name: "min_value" - expr: "google.protobuf.Duration{seconds: -315576000000, nanos: -999999999}" - value { - object_value { - [type.googleapis.com/google.protobuf.Duration] { - seconds: -315576000000 - nanos: -999999999 - } - } - } - } - test { - name: "seconds_over" - expr: "google.protobuf.Duration{seconds: 315576000001}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "seconds_under" - expr: "google.protobuf.Duration{seconds: -315576000001}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "nanos_over" - expr: "google.protobuf.Duration{nanos: 1000000000}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "nanos_under" - expr: "google.protobuf.Duration{nanos: -1000000000}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "positive_seconds_negative_nanos" - expr: "google.protobuf.Duration{seconds: 1, nanos: -1}" - eval_error { - errors { - message: "sign" - } - } - } - test { - name: "negative_seconds_positive_nanos" - expr: "google.protobuf.Duration{seconds: -1, nanos: 1}" - eval_error { - errors { - message: "sign" - } - } - } -} - -# google.protobuf.Timestamp -section { - name: "timestamp" - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: timestamp('9999-12-31T23:59:59.999999999Z')}.single_value" - value { - string_value: "9999-12-31T23:59:59.999999999Z" - } - } - test { - name: "max_value" - expr: "google.protobuf.Timestamp{seconds: 253402300799, nanos: 999999999}" - value { - object_value { - [type.googleapis.com/google.protobuf.Timestamp] { - seconds: 253402300799 - nanos: 999999999 - } - } - } - } - test { - name: "min_value" - expr: "google.protobuf.Timestamp{seconds: -62135596800, nanos: 0}" - value { - object_value { - [type.googleapis.com/google.protobuf.Timestamp] { - seconds: -62135596800 - } - } - } - } - test { - name: "seconds_over" - expr: "google.protobuf.Timestamp{seconds: 253402300800}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "seconds_under" - expr: "google.protobuf.Timestamp{seconds: -62135596801}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "nanos_over" - expr: "google.protobuf.Timestamp{nanos: 1000000000}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "nanos_under" - expr: "google.protobuf.Timestamp{nanos: -1}" - eval_error { - errors { - message: "range" - } - } - } - test { - name: "negative_seconds_negative_nanos" - expr: "google.protobuf.Timestamp{seconds: -1, nanos: -1}" - eval_error { - errors { - message: "range" - } - } - } -} - -# google.protobuf.Empty -section { - name: "empty" - test { - name: "to_json" - container: "cel.expr.conformance.proto3" - expr: "TestAllTypes{single_value: google.protobuf.Empty{}}.single_value" - value { - map_value {} - } - } -}