diff --git a/doc/langdef.md b/doc/langdef.md index 8f618e9e..0ab6481a 100644 --- a/doc/langdef.md +++ b/doc/langdef.md @@ -1835,7 +1835,7 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). - + bool @@ -1846,7 +1846,15 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). - + + (bool) -> bool + + + identity + + + + bytes @@ -1856,6 +1864,14 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). type denotation + + + (bytes) -> bytes + + + identity + + (string) -> bytes @@ -1877,7 +1893,7 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). - + double @@ -1887,6 +1903,14 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). type denotation + + + (double) -> double + + + identity + + (int) -> double @@ -1912,9 +1936,17 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). - + duration + + (google.protobuf.Duration) -> google.protobuf.Duration + + + identity + + + (string) -> google.protobuf.Duration @@ -2180,7 +2212,7 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). - + int @@ -2190,6 +2222,14 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). type denotation + + + (int) -> int + + + identity + + (uint) -> int @@ -2333,7 +2373,7 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). - + string @@ -2343,6 +2383,14 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). type denotation + + + (string) -> string + + + identity + + (int) -> string @@ -2392,9 +2440,17 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). - + timestamp + + (google.protobuf.Timestamp) -> google.protobuf.Timestamp + + + identity + + + (string) -> google.protobuf.Timestamp @@ -2433,6 +2489,14 @@ See [cel-go/issues/9](https://github.com/google/cel-go/issues/9). type denotation + + + (uint) -> uint + + + identity + + (int) -> uint diff --git a/tests/simple/testdata/conversions.textproto b/tests/simple/testdata/conversions.textproto index 87820564..75ffdddd 100644 --- a/tests/simple/testdata/conversions.textproto +++ b/tests/simple/testdata/conversions.textproto @@ -505,3 +505,47 @@ section { value: { uint64_value: 300 } } } +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(bytes('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 } + } +}