Files
regorus/tests/interpreter/cases/builtins/aggregates/count.yaml
Anand Krishnamoorthi 31e1c63281 Tests for aggregates builtins
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-02-28 09:38:40 +05:30

59 lines
1.1 KiB
YAML

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cases:
- note: all
data: {}
modules:
- |
package test
x = [
count([]),
count([1]),
count([1, 2, 3]),
count({}),
count({"a":1}),
count({"a":1, "b":2}),
count(set()),
count({1}),
count({1,1}),
count({1,2}),
count(""),
count("abc")
]
# Undefined
r { false }
z = count(r)
query: data.test
want_result:
x: [
0, 1, 3,
0, 1, 2,
0, 1, 1, 2,
0, 3
]
- note: invalid-null
data: {}
modules: ["package test\n x= count(null)"]
query: data.test
error: "`count` requires array/object/set/string argument."
- note: invalid-bool
data: {}
modules: ["package test\n x= count(true)"]
query: data.test
error: "`count` requires array/object/set/string argument."
- note: invalid-number
data: {}
modules: ["package test\n x= count(5)"]
query: data.test
error: "`count` requires array/object/set/string argument."