82 lines
2.0 KiB
Plaintext
82 lines
2.0 KiB
Plaintext
import.version:3.0.0 {unitt}!
|
|
import {src/flatten-array}!
|
|
|
|
describe "Flatten Array" [
|
|
it "empty" [
|
|
expects.be:'equal? @[
|
|
[]
|
|
flattenCollection []
|
|
]
|
|
]
|
|
|
|
it.skip "no nesting" [
|
|
expects.be:'equal? @[
|
|
[0 1 2]
|
|
flattenCollection [0 1 2]
|
|
]
|
|
]
|
|
|
|
it.skip "flattens a nested array" [
|
|
expects.be:'equal? @[
|
|
[]
|
|
flattenCollection [[[]]]
|
|
]
|
|
]
|
|
|
|
it.skip "flattens array with just integers present" [
|
|
expects.be:'equal? @[
|
|
[1 2 3 4 5 6 7 8]
|
|
flattenCollection [1 [2 3 4 5 6 7] 8]
|
|
]
|
|
]
|
|
|
|
it.skip "5 level nesting" [
|
|
expects.be:'equal? @[
|
|
[0 2 2 3 8 100 4 50 neg 2]
|
|
flattenCollection [0 2 [[2 3] 8 100 4 [[[50]]]] neg 2]
|
|
]
|
|
]
|
|
|
|
it.skip "6 level nesting" [
|
|
expects.be:'equal? @[
|
|
[1 2 3 4 5 6 7 8]
|
|
flattenCollection [1 [2 [[3]] [4 [[5]]] 6 7] 8]
|
|
]
|
|
]
|
|
|
|
it.skip "null values are omitted from the final result" [
|
|
expects.be:'equal? @[
|
|
[1 2]
|
|
flattenCollection @[1 2 null]
|
|
]
|
|
]
|
|
|
|
it.skip "consecutive null values at the front of the array are omitted from the final result" [
|
|
expects.be:'equal? @[
|
|
[3]
|
|
flattenCollection @[null null 3]
|
|
]
|
|
]
|
|
|
|
it.skip "consecutive null values in the middle of the array are omitted from the final result" [
|
|
expects.be:'equal? @[
|
|
[1 4]
|
|
flattenCollection @[1 null null 4]
|
|
]
|
|
]
|
|
|
|
it.skip "6 level nested array with null values" [
|
|
expects.be:'equal? @[
|
|
[0 2 2 3 8 100 2]
|
|
flattenCollection @[0 2 @[[2 3] 8 @[@[100]] null @[@[null]]] 2]
|
|
]
|
|
]
|
|
|
|
it.skip "all values in nested array are null" [
|
|
expects.be:'equal? @[
|
|
[]
|
|
flattenCollection @[null @[@[@[null]]] null null @[@[null null] null] null]
|
|
]
|
|
]
|
|
]
|