@@ -350,35 +350,193 @@ describe.each(runtimes.runtimeList)(
350
350
`run: ${ nums } ->{select t is array_min(nums)}`
351
351
) . malloyResultMatches ( runtime , { t : 1 } ) ;
352
352
} ) ;
353
- /*
354
- define('array_cum_sum', arrayOfT, 'number');
355
- define('array_duplicates', arrayOfT, arrayOfT);
356
- define('array_except', arrayOfT, arrayOfT, arrayOfT);
357
- define('array_normalize', arrayOfT, 'number', arrayOfT);
358
- define('array_position', arrayOfT, {generic: 'T'}, 'number');
359
- define('array_remove', arrayOfT, {generic: 'T'}, arrayOfT);
360
- // mtoy todo document missing lambda sort
361
- define('array_sort', arrayOfT, arrayOfT);
362
- define('array_sort_desc', arrayOfT, arrayOfT);
363
- define('array_split_into_chunks', arrayOfT, 'number', arrayOfArrayOfT);
364
- define('array_sum', arrayOfT, arrayOfT);
365
- define('arrays_overlap', arrayOfT, arrayOfT, 'boolean');
366
- define('array_union', arrayOfT, arrayOfT, arrayOfT);
367
- define('cardinality', arrayOfT, 'number');
368
- define('remove_nulls', arrayOfT, arrayOfT);
369
- define('reverse', arrayOfT, arrayOfT);
370
- define('shuffle', arrayOfT, arrayOfT);
371
- define('array_top_n', arrayOfT, 'number', arrayOfT);
372
- define('combinations', arrayOfT, 'number', arrayOfArrayOfT);
373
- define('contains', arrayOfT, {generic: 'T'}, 'boolean');
374
- define('element_at', arrayOfT, 'number', {generic: 'T'});
375
- // hard to believe, but this is what flatten does
376
- define('flatten', arrayOfArrayOfT, arrayOfT);
377
- define('ngrams', arrayOfT, 'number', arrayOfArrayOfT);
378
- define('repeat', {generic: 'T'}, 'number', arrayOfT);
379
- define('slice', arrayOfT, 'number', 'number', arrayOfT);
380
- define('trim_array', arrayOfT, 'number', arrayOfT);
381
- */
353
+ it ( 'runs array_cum_sum' , async ( ) => {
354
+ await expect (
355
+ `run: ${ nums } ->{select t is array_cum_sum(nums)}`
356
+ ) . malloyResultMatches ( runtime , { t : [ 4 , 5 , 6 ] } ) ;
357
+ } ) ;
358
+ it ( 'runs array_duplicates' , async ( ) => {
359
+ await expect (
360
+ `run: ${ nums } ->{select t is array_cum_sum(nums)}`
361
+ ) . malloyResultMatches ( runtime , { t : [ 1 ] } ) ;
362
+ } ) ;
363
+ it ( 'runs array_sort' , async ( ) => {
364
+ await expect (
365
+ `run: ${ nums } ->{select t is array_sort(nums)}`
366
+ ) . malloyResultMatches ( runtime , { t : [ 1 , 1 , 4 ] } ) ;
367
+ } ) ;
368
+ it ( 'runs repeat' , async ( ) => {
369
+ await expect (
370
+ `run: ${ nums } ->{select t is repeat('x', 2)}`
371
+ ) . malloyResultMatches ( runtime , { t : [ 'x' , 'x' ] } ) ;
372
+ } ) ;
373
+ it ( 'runs slice' , async ( ) => {
374
+ await expect (
375
+ `run: ${ nums } ->{select t is slice(nums, 2, 2)}`
376
+ ) . malloyResultMatches ( runtime , { t : [ '1' , '1' ] } ) ;
377
+ } ) ;
378
+ it ( 'runs cardinality' , async ( ) => {
379
+ await expect (
380
+ `run: ${ nums } ->{select t is cardinality(nums)}`
381
+ ) . malloyResultMatches ( runtime , { t : 3 } ) ;
382
+ } ) ;
383
+ it ( 'runs array_sum' , async ( ) => {
384
+ await expect (
385
+ `run: ${ nums } ->{select t is array_sum(nums)}`
386
+ ) . malloyResultMatches ( runtime , { t : 6 } ) ;
387
+ } ) ;
388
+ it ( 'runs contains' , async ( ) => {
389
+ await expect (
390
+ `run: ${ nums } ->{select t is contains(nums, 42)}`
391
+ ) . malloyResultMatches ( runtime , { t : false } ) ;
392
+ } ) ;
393
+ it ( 'runs array_except' , async ( ) => {
394
+ await expect (
395
+ `run: ${ nums } ->{select t is array_except(nums, [4])}`
396
+ ) . malloyResultMatches ( runtime , { t : [ 1 ] } ) ;
397
+ } ) ;
398
+ it ( 'runs array_normalize' , async ( ) => {
399
+ await expect (
400
+ `run: ${ nums } ->{select t is array_normalize(nums, 40)}`
401
+ ) . malloyResultMatches ( runtime , { t : [ 1 , 0.25 , 0.25 ] } ) ;
402
+ } ) ;
403
+ it ( 'runs array_position' , async ( ) => {
404
+ await expect (
405
+ `run: ${ nums } ->{select t is array_position(nums, 1, 2)}`
406
+ ) . malloyResultMatches ( runtime , { t : 3 } ) ;
407
+ } ) ;
408
+ it ( 'runs array_remove' , async ( ) => {
409
+ await expect (
410
+ `run: ${ nums } ->{select t is array_remove(nums, 1)}`
411
+ ) . malloyResultMatches ( runtime , { t : [ 4 ] } ) ;
412
+ } ) ;
413
+ it ( 'runs array_sort_desc' , async ( ) => {
414
+ await expect (
415
+ `run: ${ nums } ->{select t is array_sort_desc([1,2,3], 1)}`
416
+ ) . malloyResultMatches ( runtime , { t : [ 3 , 2 , 1 ] } ) ;
417
+ } ) ;
418
+ it ( 'runs array_split_into_chunks' , async ( ) => {
419
+ await expect (
420
+ `run: ${ nums } ->{select t is array_split_into_chunks(num, 1)}`
421
+ ) . malloyResultMatches ( runtime , { t : [ [ 4 ] , [ 1 ] , [ 1 ] ] } ) ;
422
+ } ) ;
423
+ it ( 'runs arrays_overlap' , async ( ) => {
424
+ await expect (
425
+ `run: ${ nums } ->{select t is array_overlap(num, [2,3,4])}`
426
+ ) . malloyResultMatches ( runtime , { t : true } ) ;
427
+ } ) ;
428
+ it ( 'runs arrays_union' , async ( ) => {
429
+ await expect (
430
+ `run: ${ nums } ->{select t is array_union(num, [2])}`
431
+ ) . malloyResultMatches ( runtime , { t : [ 4 , 1 , 2 ] } ) ;
432
+ } ) ;
433
+ it ( 'runs remove_nulls' , async ( ) => {
434
+ await expect (
435
+ `run: ${ nums } ->{select t is remove_nulls([null, 2])}`
436
+ ) . malloyResultMatches ( runtime , { t : [ 2 ] } ) ;
437
+ } ) ;
438
+ it ( 'runs reverse' , async ( ) => {
439
+ await expect (
440
+ `run: ${ nums } ->{select t is reverse(nums)}`
441
+ ) . malloyResultMatches ( runtime , { t : [ 1 , 1 , 4 ] } ) ;
442
+ } ) ;
443
+ it ( 'runs shuffle' , async ( ) => {
444
+ await expect (
445
+ `run: ${ nums } ->{select t is shuffle([1])}`
446
+ ) . malloyResultMatches ( runtime , { t : [ 1 ] } ) ;
447
+ } ) ;
448
+ it ( 'runs array_top_n' , async ( ) => {
449
+ await expect (
450
+ `run: ${ nums } ->{select t is array_top_n(nums, 2)}`
451
+ ) . malloyResultMatches ( runtime , { t : [ 4 , 1 ] } ) ;
452
+ } ) ;
453
+ it ( 'runs combinations' , async ( ) => {
454
+ await expect (
455
+ `run: ${ nums } ->{select t is combinations([1,2,3], 2)}`
456
+ ) . malloyResultMatches ( runtime , {
457
+ t : [
458
+ [ 1 , 2 ] ,
459
+ [ 1 , 3 ] ,
460
+ [ 2 , 3 ] ,
461
+ ] ,
462
+ } ) ;
463
+ } ) ;
464
+ it ( 'runs element_at' , async ( ) => {
465
+ await expect (
466
+ `run: ${ nums } ->{select t is element_at(nums, 1)}`
467
+ ) . malloyResultMatches ( runtime , { t : 4 } ) ;
468
+ } ) ;
469
+ it ( 'runs flatten' , async ( ) => {
470
+ await expect (
471
+ `run: ${ nums } ->{select t is flatten([1], [2])}`
472
+ ) . malloyResultMatches ( runtime , { t : [ 1 , 2 ] } ) ;
473
+ } ) ;
474
+ it ( 'runs ngrams' , async ( ) => {
475
+ await expect (
476
+ `run: ${ nums } ->{select t is ngrams([1,2,3], 2)}`
477
+ ) . malloyResultMatches ( runtime , {
478
+ t : [
479
+ [ 1 , 2 ] ,
480
+ [ 2 , 3 ] ,
481
+ ] ,
482
+ } ) ;
483
+ } ) ;
484
+ it ( 'runs trim_array' , async ( ) => {
485
+ await expect (
486
+ `run: ${ nums } ->{select t is trim_array(nums, 2)}`
487
+ ) . malloyResultMatches ( runtime , { t : [ 4 ] } ) ;
488
+ } ) ;
489
+ it ( 'runs sequence(n1,n2)' , async ( ) => {
490
+ await expect (
491
+ `run: ${ nums } ->{select t is sequence(1,2)}`
492
+ ) . malloyResultMatches ( runtime , { t : [ 1 , 2 ] } ) ;
493
+ } ) ;
494
+ it ( 'runs sequence(n1,n2,n3)' , async ( ) => {
495
+ await expect (
496
+ `run: ${ nums } ->{select t is sequence(10, 20, 10)}`
497
+ ) . malloyResultMatches ( runtime , { t : [ 10 , 20 ] } ) ;
498
+ } ) ;
499
+ it ( 'runs sequence(d1,d2)' , async ( ) => {
500
+ await expect (
501
+ `run: ${ nums } ->{select t is sequence(@2001-01-01, @2001-01-02)}`
502
+ ) . malloyResultMatches ( runtime , { t : [ 1 , 2 ] } ) ;
503
+ } ) ;
504
+ it ( 'runs sequence(ts1,ts2)' , async ( ) => {
505
+ await expect (
506
+ `run: ${ nums } ->{select t is sequence(@2001-01-01 00:00:00, @2001-01-02 00:00:00)}`
507
+ ) . malloyResultMatches ( runtime , { t : [ 1 , 2 ] } ) ;
508
+ } ) ;
509
+ it ( 'runs array_intersect(a1,a2)' , async ( ) => {
510
+ await expect (
511
+ `run: ${ nums } ->{select t is array_intersect(nums, [4])}`
512
+ ) . malloyResultMatches ( runtime , { t : [ 4 ] } ) ;
513
+ } ) ;
514
+ it ( 'runs array_intersect(a)' , async ( ) => {
515
+ await expect (
516
+ `run: ${ nums } ->{select t is array_intersect([[1,2], [2,3]])}`
517
+ ) . malloyResultMatches ( runtime , { t : [ 2 ] } ) ;
518
+ } ) ;
519
+ it ( 'runs array_join(a,s)' , async ( ) => {
520
+ await expect (
521
+ `run: ${ nums } ->{select t is array_join(nums, ',')}`
522
+ ) . malloyResultMatches ( runtime , { t : '4,1,1' } ) ;
523
+ } ) ;
524
+ it ( 'runs array_join(a,s, n)' , async ( ) => {
525
+ await expect (
526
+ `run: ${ nums } ->{select t is array_join([1, null], ',', 42)}`
527
+ ) . malloyResultMatches ( runtime , { t : [ 1 , 42 ] } ) ;
528
+ } ) ;
529
+ it ( 'runs array_least_frequent(a)' , async ( ) => {
530
+ await expect (
531
+ `run: ${ nums } ->{select t is array_least_frequent(nums)}`
532
+ ) . malloyResultMatches ( runtime , { t : [ 4 ] } ) ;
533
+ } ) ;
534
+ it ( 'runs array_least_frequent(a, n)' , async ( ) => {
535
+ await expect (
536
+ `run: ${ nums } ->{select t is array_least_frequent(nums)}`
537
+ ) . malloyResultMatches ( runtime , { t : [ 4 , 1 ] } ) ;
538
+ } ) ;
539
+ // mtoy todo document missing lambda sort
382
540
} ) ;
383
541
}
384
542
) ;
0 commit comments