40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
|
namespace nur;
|
|
|
|
use nur\t\TestCase;
|
|
|
|
class cTest extends TestCase {
|
|
function testFlatten() {
|
|
self::assertSame([], c::flatten(null));
|
|
self::assertSame([], c::flatten([]));
|
|
self::assertSame(["a", "b"], c::flatten(["a", "b"]));
|
|
self::assertSame(["a", "b"], c::flatten(["a", ["b"]]));
|
|
self::assertSame(["a", "b"], c::flatten([["a"], "b"]));
|
|
self::assertSame(["a", "b", "c"], c::flatten(["a", "b", "c"]));
|
|
self::assertSame(["a", "b", "c"], c::flatten(["a", ["b", "c"]]));
|
|
self::assertSame(["a", "b", "c"], c::flatten(["a", ["b", ["c"]]]));
|
|
|
|
self::assertSame(["a" => ["x", "y"]], c::flatten(["a" => "x", ["a" => "y"]]));
|
|
self::assertSame(["a" => ["x", "y"]], c::flatten([["a" => "x"], "a" => "y"]));
|
|
self::assertSame(["a" => ["x", "y"]], c::flatten([["a" => "x"], ["a" => "y"]]));
|
|
|
|
self::assertSame(["a" => ["x", "y"]], c::flatten(["a" => ["x", ["y"]]]));
|
|
}
|
|
|
|
function testFlattenQuote() {
|
|
# flatten ne quote AUCUNE valeur, c'est la responsabilité de \nur\v\v
|
|
self::assertSame(
|
|
["<a", "<b", "<c", "<d"],
|
|
c::flatten(["<a", "<b", ["<c", "<d"]]));
|
|
self::assertSame([
|
|
"<a" => "x>", "<b" => ["y>"],
|
|
"<c" => "z>", "<d" => ["t>"],
|
|
"<e" => ["w1>" ,"w2>"],
|
|
], c::flatten([
|
|
"<a" => "x>", "<b" => ["y>"],
|
|
["<c" => "z>", "<d" => ["t>"]],
|
|
"<e" => "w1>", ["<e" => "w2>"],
|
|
]));
|
|
}
|
|
}
|