@@ -346,6 +346,151 @@ func TestExamples(t *testing.T) {
346346 },
347347 want : arrayVal (intVal (1 ), intVal (3 )),
348348 },
349+ {
350+ name : "arrays/include_value_true" ,
351+ file : "arrays/extras.vibe" ,
352+ function : "include_value" ,
353+ args : []Value {
354+ arrayVal (intVal (1 ), intVal (2 ), intVal (3 )),
355+ intVal (2 ),
356+ },
357+ want : boolVal (true ),
358+ },
359+ {
360+ name : "arrays/include_value_false" ,
361+ file : "arrays/extras.vibe" ,
362+ function : "include_value" ,
363+ args : []Value {
364+ arrayVal (intVal (1 ), intVal (2 ), intVal (3 )),
365+ intVal (9 ),
366+ },
367+ want : boolVal (false ),
368+ },
369+ {
370+ name : "arrays/first_match" ,
371+ file : "arrays/extras.vibe" ,
372+ function : "first_match" ,
373+ args : []Value {
374+ arrayVal (intVal (2 ), intVal (5 ), intVal (7 )),
375+ intVal (4 ),
376+ },
377+ want : intVal (5 ),
378+ },
379+ {
380+ name : "arrays/first_match_index" ,
381+ file : "arrays/extras.vibe" ,
382+ function : "first_match_index" ,
383+ args : []Value {
384+ arrayVal (intVal (2 ), intVal (5 ), intVal (7 )),
385+ intVal (4 ),
386+ },
387+ want : intVal (1 ),
388+ },
389+ {
390+ name : "arrays/count_value" ,
391+ file : "arrays/extras.vibe" ,
392+ function : "count_value" ,
393+ args : []Value {
394+ arrayVal (intVal (1 ), intVal (2 ), intVal (1 ), intVal (3 )),
395+ intVal (1 ),
396+ },
397+ want : intVal (2 ),
398+ },
399+ {
400+ name : "arrays/count_large" ,
401+ file : "arrays/extras.vibe" ,
402+ function : "count_large" ,
403+ args : []Value {
404+ arrayVal (intVal (1 ), intVal (5 ), intVal (6 )),
405+ intVal (4 ),
406+ },
407+ want : intVal (2 ),
408+ },
409+ {
410+ name : "arrays/predicate_snapshot" ,
411+ file : "arrays/extras.vibe" ,
412+ function : "predicate_snapshot" ,
413+ args : []Value {
414+ arrayVal (intVal (2 ), intVal (11 ), intVal (4 )),
415+ },
416+ want : hashVal (map [string ]Value {
417+ "any_large" : boolVal (true ),
418+ "all_positive" : boolVal (true ),
419+ "none_negative" : boolVal (true ),
420+ }),
421+ },
422+ {
423+ name : "arrays/sort_values" ,
424+ file : "arrays/extras.vibe" ,
425+ function : "sort_values" ,
426+ args : []Value {
427+ arrayVal (intVal (3 ), intVal (1 ), intVal (2 )),
428+ },
429+ want : arrayVal (intVal (1 ), intVal (2 ), intVal (3 )),
430+ },
431+ {
432+ name : "arrays/sort_desc" ,
433+ file : "arrays/extras.vibe" ,
434+ function : "sort_desc" ,
435+ args : []Value {
436+ arrayVal (intVal (3 ), intVal (1 ), intVal (2 )),
437+ },
438+ want : arrayVal (intVal (3 ), intVal (2 ), intVal (1 )),
439+ },
440+ {
441+ name : "arrays/sort_words_by_length" ,
442+ file : "arrays/extras.vibe" ,
443+ function : "sort_words_by_length" ,
444+ args : []Value {
445+ arrayVal (strVal ("bbb" ), strVal ("a" ), strVal ("cc" )),
446+ },
447+ want : arrayVal (strVal ("a" ), strVal ("cc" ), strVal ("bbb" )),
448+ },
449+ {
450+ name : "arrays/partition_even" ,
451+ file : "arrays/extras.vibe" ,
452+ function : "partition_even" ,
453+ args : []Value {
454+ arrayVal (intVal (1 ), intVal (2 ), intVal (3 ), intVal (4 )),
455+ },
456+ want : arrayVal (
457+ arrayVal (intVal (2 ), intVal (4 )),
458+ arrayVal (intVal (1 ), intVal (3 )),
459+ ),
460+ },
461+ {
462+ name : "arrays/group_by_status" ,
463+ file : "arrays/extras.vibe" ,
464+ function : "group_by_status" ,
465+ args : []Value {
466+ arrayVal (
467+ hashVal (map [string ]Value {"id" : strVal ("p1" ), "status" : strVal ("active" )}),
468+ hashVal (map [string ]Value {"id" : strVal ("p2" ), "status" : strVal ("complete" )}),
469+ hashVal (map [string ]Value {"id" : strVal ("p3" ), "status" : strVal ("active" )}),
470+ ),
471+ },
472+ want : hashVal (map [string ]Value {
473+ "active" : arrayVal (
474+ hashVal (map [string ]Value {"id" : strVal ("p1" ), "status" : strVal ("active" )}),
475+ hashVal (map [string ]Value {"id" : strVal ("p3" ), "status" : strVal ("active" )}),
476+ ),
477+ "complete" : arrayVal (
478+ hashVal (map [string ]Value {"id" : strVal ("p2" ), "status" : strVal ("complete" )}),
479+ ),
480+ }),
481+ },
482+ {
483+ name : "arrays/tally_statuses" ,
484+ file : "arrays/extras.vibe" ,
485+ function : "tally_statuses" ,
486+ args : []Value {
487+ arrayVal (strVal ("active" ), strVal ("active" ), strVal ("complete" )),
488+ },
489+ want : hashVal (map [string ]Value {
490+ "active" : intVal (2 ),
491+ "complete" : intVal (1 ),
492+ }),
493+ },
349494 {
350495 name : "collections/make_player" ,
351496 file : "collections/hashes.vibe" ,
0 commit comments