Files
zen/core/expression/tests/data/standard.csv
T
2025-06-03 09:49:45 +02:00

15 KiB

1expression (string);input (json 5);output (json 5)
2# Boolean
3true and true;;true
4true and false;;false
5false and true;;false
6false and false;;false
7true or true;;true
8true or false;;true
9false or true;;true
10false or false;;false
11not true;;false
12not false;;true
13# Numbers
141 == 1;;true
151 == 2;;false
161 != 2;;true
171 != 1;;false
181 < 2;;true
191 < 1;;false
201 <= 1;;true
212 <= 1;;false
222 > 1;;true
231 > 1;;false
241 >= 1;;true
251 >= 2;;false
26-1 == -1;;true
27-1 == 1;;false
28-1 != 1;;true
29-1 != -1;;false
30-1 < 1;;true
31-1 < -1;;false
32-1 <= -1;;true
331 <= -1;;false
341 > -1;;true
35-1 > -1;;false
36-1 >= -1;;true
37-1 >= 1;;false
381 + 2 == 3;;true
391 + 2 == 4;;false
401 - 2 == -1;;true
411 - 2 == 0;;false
422 * 3 == 6;;true
432 * 3 == 7;;false
446 / 3 == 2;;true
456 / 3 == 2.5;;false
465 % 2 == 1;;true
476 % 2 == 0;;true
48-5 + 5 == 0;;true
49-5 * 5 == -25;;true
50-5 * -5 == 25;;true
51abs(-5) == 5;;true
52abs(5) == 5;;true
532 ^ 3 == 8;;true
542 ^ -1 == 0.5;;true
55max([35]) == 5;;true
56max([-3-5]) == -3;;true
57min([35]) == 3;;true
58min([-3-5]) == -5;;true
593 + 4 * 2;;11
60(3 + 4) * 2;;14
61(10 - 4) / 2;;3
62abs(-5);;5
63sum([12345]);;15
64avg([102030]);;20
65min([582117]);;2
66max([582117]);;11
67floor(4.8);;4
68ceil(4.1);;5
69round(3.5);;4
70rand(100) >= 0 and rand(100) <= 100;;true
71median([42753]);;4
72mode([1223334444]);;4
735 % 2 == 1;;true
7410 % 4 == 2;;true
75true ? 10 == 10 : 20 == 30;;true
76false ? 10 == 10 : 20 == 30;;false
77true ? 10 == 20 : false ? 30 == 40 : true ? 50 == 60 : 70 == 80;;false
78# String
79# Template string
80`simple template`;;'simple template'
81`sum of numbers ${sum([123])}`;;'sum of numbers 6'
82`reference env: ${a}`;{a:'example'};'reference env: example'
83`uppercase inner ${upper('string')}`;;'uppercase inner STRING'
84# String Slice
85string[0:5];{string: 'sample_string'};'sample'
86string[7:12];{string: 'sample_string'};'string'
87string[7:];{string: 'sample_string'};'string'
88string[:5];{string: 'sample_string'};'sample'
89# Array
90len([12345]);; 5
91sum([12345]);; 15
92avg([102030]);; 20
93min([582117]);; 2
94max([582117]);; 11
95contains([12345]3);; true
96contains([12345]6);; false
97count([123452]# == 2);; 2
98filter([12345]# > 3);; [45]
99map([12345]# * 2);; [246810]
100one([12345]# == 3);; true
101one([12345]# == 6);; false
102none([12345]# > 5);; true
103some([12345]# > 3);; true
104flatMap([[12][34][56]]#);; [123456]
105keys([101112]);;[012]
106# Dates
107# Decimal precision
1080.1 + 0.2 == 0.3;; true
1090.1 + 0.2;; 0.3
1100.1 * 0.2 == 0.02;; true
1110.1 * 0.2;; 0.02
1120.3 - 0.1 == 0.2;; true
1130.3 - 0.1;; 0.2
1140.3 / 0.1 == 3.0;; true
1150.3 / 0.1;; 3
116# More complex formulas
117(10 + 5) * 3 / 2 > 15;; true
118(100 - 25) / (5 * 2) < 10;; true
1191000 / (10 - 2) + 50 == 175;; true
120(3 + 4) * (8 - 6) == 14;; true
12110^3 != 999;; true
1221000 / 10^3 <= 1.1;; true
123abs(-20) > 10;; true
124floor(8.9) == 8;; true
125ceil(8.1) == 9;; true
126round(7.6) == 8;; true
12710 % 3 != 0;; true
128-8 + 2^3 == 0;; true
1292 * -(-5) == 10;; true
13020 / (5 / 2) == 8.0;; true
131(4 + 2) * 3 - (5 / 2) + 1 < 18;; true
1325^2 + 3 * 4 - 6 / 2 > 20;; true
1334^3 - 2 * 5 + 7 / 2 == 57.5;; true
134abs(-7 + 4) * (8 - 6^2) < 34;; true
1355 in [1..10];; true
1365 in (1..10);; true
1375 not in [1..10);; false
1385 not in (1..10);; false
139-5 in [-10..-1];; true
140-5 in [-10..-1);; true
141-5 not in [-10..-1];; false
142-5 not in [-10..-1);; false
143-5 in [-5..5];; true
144-5 in (-5..5);; false
145-5 not in [-5..5);; false
146-5 not in (-5..5);; true
14710 > 5;; true
1485 < 10;; true
14910 >= 10;; true
1505 <= 5;; true
151(1 + 2) == 3;; true
152(1 + 2) != 4;; true
153(1 + 2) > 2;; true
154(1 + 2) < 5;; true
155# Date Functions
156dateString(startOf('2023-01-01 15:45:01''day'));;'2023-01-01 00:00:00'
157dateString(endOf('2023-01-01 15:45:01''d'));;'2023-01-01 23:59:59'
158dateString(startOf('2023-01-01 15:45:01''hour'));;'2023-01-01 15:00:00'
159dateString(endOf('2023-01-01 15:45:01''h'));;'2023-01-01 15:59:59'
160dateString(startOf('2023-01-01 15:45:01''minute'));;'2023-01-01 15:45:00'
161dateString(endOf('2023-01-01 15:45:01''m'));;'2023-01-01 15:45:59'
162dateString(startOf('2023-01-04 15:45:01''week'));;'2023-01-02 00:00:00'
163dateString(endOf('2023-01-04 15:45:01''w'));;'2023-01-08 23:59:59'
164dateString(startOf('2023-01-04 15:45:01''month'));;'2023-01-01 00:00:00'
165dateString(endOf('2023-01-04 15:45:01''M'));;'2023-01-31 23:59:59'
166dateString(startOf('2023-01-04 15:45:01''year'));;'2023-01-01 00:00:00'
167dateString(endOf('2023-01-04 15:45:01''y'));;'2023-12-31 23:59:59'
168# Type conversions
169string(123.123);;'123.123'
170string(123);;'123'
171string(true);;'true'
172string(false);;'false'
173string('already string');;'already string'
174number('123.123');;123.123
175number('123');;123
176number(123.123);;123.123
177number(123);;123
178number(true);;1
179number(false);;0
180# Type check
181isNumeric(123.123);;true
182isNumeric(123);;true
183isNumeric('123.123');;true
184isNumeric('123');;true
185isNumeric('string');;false
186isNumeric(true);;false
187# Types
188type('hello');;'string'
189type(123);;'number'
190type(true);;'bool'
191type(null);;'null'
192type([123]);;'array'
193# Object
194sum(values({a: 1b: 2c: 3}));;6
195keys({[`dynamic-${'key'}`]: 123});;['dynamic-key']
196{};;{}
197# Interval iterator
198map([0..3]#);[0123]
199map((0..3]#);[123]
200map([0..3)#);[012]
201map((0..3)#);[12]
202# Nullish coalescing
203null ?? 'hello';;'hello'
204null ?? 123 ?? 321;;123
205null ?? null ?? 321;;321
206false or true ? null ?? 'test' : false;;'test'
207# Array indexing and dot notation
208# Array functions
209len(['a''b''c']);;3
210contains(['a''b''c']'b');;true
211contains(['a''b''c']'d');;false
212some(['a''b''c']# == 'b');;true
213some(['a''b''c']# == 'd');;false
214all(['a''b''c']# in ['a''b''c''d']);;true
215all(['a''b''c']# in ['a''b']);;false
216filter(['a''b''c''d']# in ['a''c']);;['a''c']
217map(['a''b''c']# + '!');;['a!''b!''c!']
218# Array combinations
219map(filter([12345]# > 2)# * 2);;[6810]
220len(filter([12345]# % 2 == 0));;2
221sum(filter([12345]# % 2 == 0));;6
222sum(map(filter([12345]# > 3)# ^ 2));;41
223# Complex array operations
224some(map([123]# * 2)# > 5);;true
225all(map([123]# + 2)# > 2);;true
226contains(map([123]# * 2)6);;true
227contains(values({a: 1b: 2c: 3})2);;true
228# Array with objects
229map([{id: 1name: 'John'}{id: 2name: 'Jane'}]#.id);;[12]
230filter([{id: 1name: 'John'}{id: 2name: 'Jane'}]#.id > 1);;[{id: 2name: 'Jane'}]
231map(filter([{id: 1name: 'John'}{id: 2name: 'Jane'}]#.id > 1)#.name);;['Jane']
232# String concatenation
233'Hello' + ' ' + 'World' + '!';;'Hello World!'
234# String functions
235len('Hello');;5
236upper('Hello');;'HELLO'
237lower('HELLO');;'hello'
238trim(' hello ');;'hello'
239startsWith('Hello World''Hell');;true
240endsWith('Hello World''orld');;true
241contains('Hello World''lo Wo');;true
242matches('123-456-7890''[0-9]{3}-[0-9]{3}-[0-9]{4}');;true
243# String formatting
244`Total: ${sum([123])}`;;'Total: 6'
245# Nested object access
246# Dynamic keys
247# Date arithmetic
248date('2023-10-15') + duration('1d');;1697414400
249date('2023-10-15') - duration('7d');;1696723200
250dateString(date('2023-10-15') + duration('1d'));;'2023-10-16 00:00:00'
251dateString(date('2023-10-15') - duration('7d'));;'2023-10-08 00:00:00'
252# Date comparisons
253date('2023-10-15') > date('2023-10-14');;true
254date('2023-10-15') < date('2023-10-16');;true
255date('2023-10-15') + duration('1d') == date('2023-10-16');;true
256# Date parts
257year(date('2023-10-15'));;2023
258monthOfYear(date('2023-10-15'));;10
259dayOfMonth(date('2023-10-15'));;15
260dayOfWeek(date('2023-10-15'));;7
261weekOfYear(date('2023-10-15'));;41
262# Date formatting
263dateString(date('2023-10-15'));;'2023-10-15 00:00:00'
264dateString(date('2023-10-15') + duration('12h'));;'2023-10-15 12:00:00'
265# Ternary operators
266# Null handling
267# Type conversions
268string(123);;'123'
269string(true);;'true'
270number('123');;123
271number('12.3');;12.3
272number(true);;1
273number(false);;0
274bool(1);;true
275bool(0);;false
276bool('true');;true
277bool('false');;false
278# Complex nested expressions
279len(filter(map([12345]# * 2)# > 5));;3
280sum(map(filter([{id: 1val: 10}{id: 2val: 20}{id: 3val: 30}]#.id > 1)#.val));;50
281# Data transformation
282# Array-based conditions
283# Statistical calculations
284# Closures and the # symbol
285map([123]# * 2);;[246]
286filter([12345]# % 2 == 0);;[24]
287some([123]# > 2);;true
288all([123]# > 0);;true
289count([122333]# == 3);;3
290one([123]# == 2);;true
291none([123]# > 3);;true
292# Nested closures
293filter(map([1234]# * 2)# > 5);;[68]
294map(filter([1234]# % 2 == 0)# * 3);;[612]
295# Range tests
296# Interval iterator
297map([0..5]# * 2);;[0246810]
298filter([0..10]# % 2 == 0);;[0246810]
299# Rounding
300round(7.4);; 7
301round(7.5);; 8
302round(7.6);; 8
303round(-7.4);; -7
304round(-7.5);; -8
305round(-7.6);; -8
306round(0.5);;1
307round(-0.5);;-1
308round(1.5);;2
309round(-1.5);;-2
310round(0.4);;0
311round(-0.4);;0
312round(7.4440);; 7
313round(7.4441);; 7.4
314round(7.4442);; 7.44
315round(7.5550);; 8
316round(7.5551);; 7.6
317round(7.5552);; 7.56
318round(-7.4442);; -7.44
319round(-7.5552);; -7.56
320trunc(7.4);; 7
321trunc(7.5);; 7
322trunc(7.6);; 7
323trunc(-7.4);; -7
324trunc(-7.5);; -7
325trunc(-7.6);; -7
326trunc(7.4440);; 7
327trunc(7.4441);; 7.4
328trunc(7.4442);; 7.44
329trunc(7.9990);; 7
330trunc(7.9991);; 7.9
331trunc(7.9992);; 7.99
332trunc(-7.4442);; -7.44
333trunc(-7.9992);; -7.99
334# Scientific notation - basic parsing
3351e5;;100000
3362e3;;2000
3375e0;;5
3381e-2;;0.01
3392.5e2;;250
3403.14e1;;31.4
3411.23e-3;;0.00123
342-1e3;;-1000
343-2.5e-2;;-0.025
344# Scientific notation - arithmetic operations
3451e2 + 1e1;;110
3462e3 - 5e2;;1500
3473e2 * 2e1;;6000
3481e4 / 2e2;;50
3491e2 + 50;;150
3501e3 - 100;;900
3512e2 * 3;;600
3521e3 / 10;;100
353# Scientific notation - comparisons
3541e3 == 1000;;true
3551e3 != 999;;true
3561e2 > 50;;true
3571e2 < 200;;true
3581e2 >= 100;;true
3591e2 <= 100;;true
3602.5e2 == 250;;true
3611.5e-2 == 0.015;;true
362# Scientific notation - type conversions
363string(1e3);;'1000'
364string(2.5e2);;'250'
365string(1.23e-3);;'0.00123'
366number('1e3');;1000
367number('2.5e2');;250
368number('1.23e-3');;0.00123
369isNumeric('1e3');;true
370isNumeric('2.5e-2');;true
371isNumeric('1.23e-3');;true
372# Scientific notation - array operations
373sum([1e22e23e2]);;600
374max([1e12e13e1]);;30
375min([1e12e13e1]);;10
376avg([1e22e23e2]);;200
377contains([1e22e23e2]200);;true
378map([1e12e13e1]# * 2);;[204060]
379filter([1e12e13e14e1]# > 25);;[3040]
380# Scientific notation - edge cases
3811e+3;;1000
3821e-0;;1
3830e5;;0
3841.0e2;;100
38510e1;;100
3860.1e3;;100
3871.5e+2;;150
3882e-1;;0.2
389# Scientific notation - mixed with regular numbers
3901e2 + 50.5;;150.5
3911000 - 1e2;;900
39215 * 1e2;;1500
3931e3 / 2.5;;400
394# Scientific notation - complex expressions
395(1e2 + 2e2) * 1e1;;3000
3961e3 / (2e1 + 3e1);;20
397abs(-1e2);;100
398floor(1.23e2);;123
399ceil(1.23e2);;123
400round(1.234e2);;123
401# Scientific notation - in functions
4021e1 ^ 2;;100
403# Scientific notation - template strings
404`Value: ${1e3}`;; 'Value: 1000'
405`Scientific: ${2.5e2}`;; 'Scientific: 250'
406`Negative: ${-1e2}`;; 'Negative: -100'