Files
zen/core/expression/tests/data/standard.csv
T
stefan-gorules 73d5d5c6cb feat: function scope alias (#426)
* feat: function scope alias

* fix types
2026-01-19 10:44:16 +01:00

19 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
5110 / 0;;null
52abs(-5) == 5;;true
53abs(5) == 5;;true
542 ^ 3 == 8;;true
552 ^ -1 == 0.5;;true
56max([35]) == 5;;true
57max([-3-5]) == -3;;true
58min([35]) == 3;;true
59min([-3-5]) == -5;;true
603 + 4 * 2;;11
61(3 + 4) * 2;;14
62(10 - 4) / 2;;3
63abs(-5);;5
64sum([12345]);;15
65avg([102030]);;20
66min([582117]);;2
67max([582117]);;11
68floor(4.8);;4
69ceil(4.1);;5
70round(3.5);;4
71rand(100) >= 0 and rand(100) <= 100;;true
72median([42753]);;4
73mode([1223334444]);;4
745 % 2 == 1;;true
7510 % 4 == 2;;true
76true ? 10 == 10 : 20 == 30;;true
77false ? 10 == 10 : 20 == 30;;false
78true ? 10 == 20 : false ? 30 == 40 : true ? 50 == 60 : 70 == 80;;false
79# String
80# Template string
81`simple template`;;'simple template'
82`sum of numbers ${sum([123])}`;;'sum of numbers 6'
83`reference env: ${a}`;{a:'example'};'reference env: example'
84`uppercase inner ${upper('string')}`;;'uppercase inner STRING'
85# String Slice
86string[0:5];{string: 'sample_string'};'sample'
87string[7:12];{string: 'sample_string'};'string'
88string[7:];{string: 'sample_string'};'string'
89string[:5];{string: 'sample_string'};'sample'
90# Array
91len([12345]);; 5
92sum([12345]);; 15
93avg([102030]);; 20
94min([582117]);; 2
95max([582117]);; 11
96contains([12345]3);; true
97contains([12345]6);; false
98count([123452]# == 2);; 2
99filter([12345]# > 3);; [45]
100map([12345]# * 2);; [246810]
101one([12345]# == 3);; true
102one([12345]# == 6);; false
103none([12345]# > 5);; true
104some([12345]# > 3);; true
105flatMap([[12][34][56]]#);; [123456]
106keys([101112]);;[012]
107# Dates
108# Decimal precision
1090.1 + 0.2 == 0.3;; true
1100.1 + 0.2;; 0.3
1110.1 * 0.2 == 0.02;; true
1120.1 * 0.2;; 0.02
1130.3 - 0.1 == 0.2;; true
1140.3 - 0.1;; 0.2
1150.3 / 0.1 == 3.0;; true
1160.3 / 0.1;; 3
117# More complex formulas
118(10 + 5) * 3 / 2 > 15;; true
119(100 - 25) / (5 * 2) < 10;; true
1201000 / (10 - 2) + 50 == 175;; true
121(3 + 4) * (8 - 6) == 14;; true
12210^3 != 999;; true
1231000 / 10^3 <= 1.1;; true
124abs(-20) > 10;; true
125floor(8.9) == 8;; true
126ceil(8.1) == 9;; true
127round(7.6) == 8;; true
12810 % 3 != 0;; true
129-8 + 2^3 == 0;; true
1302 * -(-5) == 10;; true
13120 / (5 / 2) == 8.0;; true
132(4 + 2) * 3 - (5 / 2) + 1 < 18;; true
1335^2 + 3 * 4 - 6 / 2 > 20;; true
1344^3 - 2 * 5 + 7 / 2 == 57.5;; true
135abs(-7 + 4) * (8 - 6^2) < 34;; true
1365 in [1..10];; true
1375 in (1..10);; true
1385 not in [1..10);; false
1395 not in (1..10);; false
140-5 in [-10..-1];; true
141-5 in [-10..-1);; true
142-5 not in [-10..-1];; false
143-5 not in [-10..-1);; false
144-5 in [-5..5];; true
145-5 in (-5..5);; false
146-5 not in [-5..5);; false
147-5 not in (-5..5);; true
14810 > 5;; true
1495 < 10;; true
15010 >= 10;; true
1515 <= 5;; true
152(1 + 2) == 3;; true
153(1 + 2) != 4;; true
154(1 + 2) > 2;; true
155(1 + 2) < 5;; true
156# Date Functions
157dateString(startOf('2023-01-01 15:45:01''day'));;'2023-01-01 00:00:00'
158dateString(endOf('2023-01-01 15:45:01''d'));;'2023-01-01 23:59:59'
159dateString(startOf('2023-01-01 15:45:01''hour'));;'2023-01-01 15:00:00'
160dateString(endOf('2023-01-01 15:45:01''h'));;'2023-01-01 15:59:59'
161dateString(startOf('2023-01-01 15:45:01''minute'));;'2023-01-01 15:45:00'
162dateString(endOf('2023-01-01 15:45:01''m'));;'2023-01-01 15:45:59'
163dateString(startOf('2023-01-04 15:45:01''week'));;'2023-01-02 00:00:00'
164dateString(endOf('2023-01-04 15:45:01''w'));;'2023-01-08 23:59:59'
165dateString(startOf('2023-01-04 15:45:01''month'));;'2023-01-01 00:00:00'
166dateString(endOf('2023-01-04 15:45:01''M'));;'2023-01-31 23:59:59'
167dateString(startOf('2023-01-04 15:45:01''year'));;'2023-01-01 00:00:00'
168dateString(endOf('2023-01-04 15:45:01''y'));;'2023-12-31 23:59:59'
169# Type conversions
170string(123.123);;'123.123'
171string(123);;'123'
172string(true);;'true'
173string(false);;'false'
174string('already string');;'already string'
175number('123.123');;123.123
176number('123');;123
177number(123.123);;123.123
178number(123);;123
179number(true);;1
180number(false);;0
181# Type check
182isNumeric(123.123);;true
183isNumeric(123);;true
184isNumeric('123.123');;true
185isNumeric('123');;true
186isNumeric('string');;false
187isNumeric(true);;false
188# Types
189type('hello');;'string'
190type(123);;'number'
191type(true);;'bool'
192type(null);;'null'
193type([123]);;'array'
194# Object
195sum(values({a: 1b: 2c: 3}));;6
196keys({[`dynamic-${'key'}`]: 123});;['dynamic-key']
197{};;{}
198# Interval iterator
199map([0..3]#);[0123]
200map((0..3]#);[123]
201map([0..3)#);[012]
202map((0..3)#);[12]
203# Nullish coalescing
204null ?? 'hello';;'hello'
205null ?? 123 ?? 321;;123
206null ?? null ?? 321;;321
207false or true ? null ?? 'test' : false;;'test'
208# Array indexing and dot notation
209# Array functions
210len(['a''b''c']);;3
211contains(['a''b''c']'b');;true
212contains(['a''b''c']'d');;false
213some(['a''b''c']# == 'b');;true
214some(['a''b''c']# == 'd');;false
215all(['a''b''c']# in ['a''b''c''d']);;true
216all(['a''b''c']# in ['a''b']);;false
217filter(['a''b''c''d']# in ['a''c']);;['a''c']
218map(['a''b''c']# + '!');;['a!''b!''c!']
219# Array combinations
220map(filter([12345]# > 2)# * 2);;[6810]
221len(filter([12345]# % 2 == 0));;2
222sum(filter([12345]# % 2 == 0));;6
223sum(map(filter([12345]# > 3)# ^ 2));;41
224# Complex array operations
225some(map([123]# * 2)# > 5);;true
226all(map([123]# + 2)# > 2);;true
227contains(map([123]# * 2)6);;true
228contains(values({a: 1b: 2c: 3})2);;true
229# Array with objects
230map([{id: 1name: 'John'}{id: 2name: 'Jane'}]#.id);;[12]
231filter([{id: 1name: 'John'}{id: 2name: 'Jane'}]#.id > 1);;[{id: 2name: 'Jane'}]
232map(filter([{id: 1name: 'John'}{id: 2name: 'Jane'}]#.id > 1)#.name);;['Jane']
233# String concatenation
234'Hello' + ' ' + 'World' + '!';;'Hello World!'
235# String functions
236len('Hello');;5
237upper('Hello');;'HELLO'
238lower('HELLO');;'hello'
239trim(' hello ');;'hello'
240startsWith('Hello World''Hell');;true
241endsWith('Hello World''orld');;true
242contains('Hello World''lo Wo');;true
243matches('123-456-7890''[0-9]{3}-[0-9]{3}-[0-9]{4}');;true
244# String formatting
245`Total: ${sum([123])}`;;'Total: 6'
246# Nested object access
247# Dynamic keys
248# Date arithmetic
249date('2023-10-15') + duration('1d');;1697414400
250date('2023-10-15') - duration('7d');;1696723200
251dateString(date('2023-10-15') + duration('1d'));;'2023-10-16 00:00:00'
252dateString(date('2023-10-15') - duration('7d'));;'2023-10-08 00:00:00'
253# Date comparisons
254date('2023-10-15') > date('2023-10-14');;true
255date('2023-10-15') < date('2023-10-16');;true
256date('2023-10-15') + duration('1d') == date('2023-10-16');;true
257# Date parts
258year(date('2023-10-15'));;2023
259monthOfYear(date('2023-10-15'));;10
260dayOfMonth(date('2023-10-15'));;15
261dayOfWeek(date('2023-10-15'));;7
262weekOfYear(date('2023-10-15'));;41
263# Date formatting
264dateString(date('2023-10-15'));;'2023-10-15 00:00:00'
265dateString(date('2023-10-15') + duration('12h'));;'2023-10-15 12:00:00'
266# Ternary operators
267# Null handling
268# Type conversions
269string(123);;'123'
270string(true);;'true'
271number('123');;123
272number('12.3');;12.3
273number(true);;1
274number(false);;0
275bool(1);;true
276bool(0);;false
277bool('true');;true
278bool('false');;false
279# Complex nested expressions
280len(filter(map([12345]# * 2)# > 5));;3
281sum(map(filter([{id: 1val: 10}{id: 2val: 20}{id: 3val: 30}]#.id > 1)#.val));;50
282# Data transformation
283# Array-based conditions
284# Statistical calculations
285# Closures and the # symbol
286map([123]# * 2);;[246]
287filter([12345]# % 2 == 0);;[24]
288some([123]# > 2);;true
289all([123]# > 0);;true
290count([122333]# == 3);;3
291one([123]# == 2);;true
292none([123]# > 3);;true
293# Nested closures
294filter(map([1234]# * 2)# > 5);;[68]
295map(filter([1234]# % 2 == 0)# * 3);;[612]
296# Range tests
297# Interval iterator
298map([0..5]# * 2);;[0246810]
299filter([0..10]# % 2 == 0);;[0246810]
300# Rounding
301round(7.4);; 7
302round(7.5);; 8
303round(7.6);; 8
304round(-7.4);; -7
305round(-7.5);; -8
306round(-7.6);; -8
307round(0.5);;1
308round(-0.5);;-1
309round(1.5);;2
310round(-1.5);;-2
311round(0.4);;0
312round(-0.4);;0
313round(7.4440);; 7
314round(7.4441);; 7.4
315round(7.4442);; 7.44
316round(7.5550);; 8
317round(7.5551);; 7.6
318round(7.5552);; 7.56
319round(-7.4442);; -7.44
320round(-7.5552);; -7.56
321trunc(7.4);; 7
322trunc(7.5);; 7
323trunc(7.6);; 7
324trunc(-7.4);; -7
325trunc(-7.5);; -7
326trunc(-7.6);; -7
327trunc(7.4440);; 7
328trunc(7.4441);; 7.4
329trunc(7.4442);; 7.44
330trunc(7.9990);; 7
331trunc(7.9991);; 7.9
332trunc(7.9992);; 7.99
333trunc(-7.4442);; -7.44
334trunc(-7.9992);; -7.99
335# Scientific notation - basic parsing
3361e5;;100000
3372e3;;2000
3385e0;;5
3391e-2;;0.01
3402.5e2;;250
3413.14e1;;31.4
3421.23e-3;;0.00123
343-1e3;;-1000
344-2.5e-2;;-0.025
345# Scientific notation - arithmetic operations
3461e2 + 1e1;;110
3472e3 - 5e2;;1500
3483e2 * 2e1;;6000
3491e4 / 2e2;;50
3501e2 + 50;;150
3511e3 - 100;;900
3522e2 * 3;;600
3531e3 / 10;;100
354# Scientific notation - comparisons
3551e3 == 1000;;true
3561e3 != 999;;true
3571e2 > 50;;true
3581e2 < 200;;true
3591e2 >= 100;;true
3601e2 <= 100;;true
3612.5e2 == 250;;true
3621.5e-2 == 0.015;;true
363# Scientific notation - type conversions
364string(1e3);;'1000'
365string(2.5e2);;'250'
366string(1.23e-3);;'0.00123'
367number('1e3');;1000
368number('2.5e2');;250
369number('1.23e-3');;0.00123
370isNumeric('1e3');;true
371isNumeric('2.5e-2');;true
372isNumeric('1.23e-3');;true
373# Scientific notation - array operations
374sum([1e22e23e2]);;600
375max([1e12e13e1]);;30
376min([1e12e13e1]);;10
377avg([1e22e23e2]);;200
378contains([1e22e23e2]200);;true
379map([1e12e13e1]# * 2);;[204060]
380filter([1e12e13e14e1]# > 25);;[3040]
381# Scientific notation - edge cases
3821e+3;;1000
3831e-0;;1
3840e5;;0
3851.0e2;;100
38610e1;;100
3870.1e3;;100
3881.5e+2;;150
3892e-1;;0.2
390# Scientific notation - mixed with regular numbers
3911e2 + 50.5;;150.5
3921000 - 1e2;;900
39315 * 1e2;;1500
3941e3 / 2.5;;400
395# Scientific notation - complex expressions
396(1e2 + 2e2) * 1e1;;3000
3971e3 / (2e1 + 3e1);;20
398abs(-1e2);;100
399floor(1.23e2);;123
400ceil(1.23e2);;123
401round(1.234e2);;123
402# Scientific notation - in functions
4031e1 ^ 2;;100
404# Scientific notation - template strings
405`Value: ${1e3}`;; 'Value: 1000'
406`Scientific: ${2.5e2}`;; 'Scientific: 250'
407`Negative: ${-1e2}`;; 'Negative: -100'
408### Assignment
409# Basic assignment
410# Property assignment
411# Nested property assignment
412# Multiple assignments
413# Assignment with expressions
414# Assignment with function calls
415# Assignment with array operations
416# Assignment with conditional expressions
417# Assignment with object creation
418# Assignment with template strings
419# Assignment with return value
420# Closure 'as' alias syntax
421# Nested closures with 'as' aliases
422# Mixed # and 'as' alias
423# Backwards compatibility - # still works
424map([123]# * 2);;[246]
425filter([1234]# > 2);;[34]