Skip to content

Commit 7b788df

Browse files
committed
more-tests
Signed-off-by: yaacov <[email protected]>
1 parent 82e2732 commit 7b788df

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

v6/pkg/walkers/semantics/walk_test.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var _ = Describe("Walk", func() {
4242
"spec.rating": 5.0,
4343
"loaned": true,
4444
"date": date,
45-
"tags": []string{"fiction", "bestseller"},
45+
"tags": []interface{}{"fiction", "bestseller"},
4646
"price": 29.99,
4747
"numbers": []interface{}{1.0, 2.0, 3.0},
4848
"booleans": []interface{}{true, false, true},
@@ -67,6 +67,16 @@ var _ = Describe("Walk", func() {
6767
Expect(actual).To(Equal(expected))
6868
},
6969

70+
// Direct identifier evaluation
71+
Entry("string identifier", "title", "A good book"),
72+
Entry("numeric identifier", "spec.pages", 14.0),
73+
Entry("boolean identifier", "loaned", true),
74+
Entry("date identifier", "date", date),
75+
Entry("price identifier", "price", 29.99),
76+
Entry("numeric array identifier", "numbers", []interface{}{1.0, 2.0, 3.0}),
77+
Entry("string array identifier", "tags", []interface{}{"fiction", "bestseller"}),
78+
Entry("boolean array identifier", "booleans", []interface{}{true, false, true}),
79+
7080
// String operations
7181
Entry("equals string", "title = 'A good book'", true),
7282
Entry("not equals string", "author != 'Jane'", true),
@@ -143,6 +153,18 @@ var _ = Describe("Walk", func() {
143153
Entry("boolean array and boolean", "booleans and true", []interface{}{true, false, true}),
144154
Entry("boolean array or boolean", "booleans or false", []interface{}{true, false, true}),
145155

156+
// String array operations
157+
Entry("string array equality", "tags = 'fiction'", []interface{}{true, false}),
158+
Entry("string array inequality", "tags != 'fiction'", []interface{}{false, true}),
159+
Entry("string array like", "tags like 'fic%'", []interface{}{true, false}),
160+
Entry("string array ilike", "tags ilike 'FIC%'", []interface{}{true, false}),
161+
Entry("string array regex equals", "tags ~= '^f.*'", []interface{}{true, false}),
162+
Entry("string array regex not equals", "tags ~! '^b.*'", []interface{}{true, false}),
163+
Entry("any with string array like", "any (tags like '%sell%')", true),
164+
Entry("all with string array like", "all (tags like '%i%')", false),
165+
Entry("literal string array operations", "['fiction', 'nonfiction', 'bestseller'] = 'bestseller'", []interface{}{false, false, true}),
166+
Entry("literal string array like", "['abc', 'def', 'ghi'] like '%e%'", []interface{}{false, true, false}),
167+
146168
// Literal array operations
147169
Entry("literal array addition", "[1, 2, 3] + 4", []interface{}{5.0, 6.0, 7.0}),
148170
Entry("literal array subtraction", "[5, 6, 7] - 2", []interface{}{3.0, 4.0, 5.0}),
@@ -168,6 +190,7 @@ var _ = Describe("Walk", func() {
168190
Entry("len in comparison", "len numbers = 3", true),
169191
Entry("any with complex expression", "any (numbers * 2 > 5)", true),
170192
Entry("all with complex expression", "all ((numbers + 10) > 10)", true),
193+
Entry("any with string array identifier", "any (tags = 'fiction')", true),
171194
)
172195
})
173196

0 commit comments

Comments
 (0)