diff --git a/.gitignore b/.gitignore index f061b57..8c3d4af 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ FlexUnitCompilerApplication.mxml *.ipr *.iws .project +.idea \ No newline at end of file diff --git a/hamcrest-unit-test/src/org/hamcrest/collection/IsArrayContainingTest.as b/hamcrest-unit-test/src/org/hamcrest/collection/IsArrayContainingTest.as index eff7b02..f46ab1c 100755 --- a/hamcrest-unit-test/src/org/hamcrest/collection/IsArrayContainingTest.as +++ b/hamcrest-unit-test/src/org/hamcrest/collection/IsArrayContainingTest.as @@ -68,5 +68,13 @@ package org.hamcrest.collection matcher5, [ "e", "c", "b", "d" ]); // 'a' is missing } + + [Test] + public function matchesAllWithArray() : void{ + var matcherArray:Array = [equalTo("a"), equalTo("b"), equalTo("c")]; + var matcher:Matcher = hasItems(matcherArray); + + assertMatches("should match array containing matchers", matcher, ["a", "b", "c"]); + } } } diff --git a/hamcrest/src/org/hamcrest/collection/hasItems.as b/hamcrest/src/org/hamcrest/collection/hasItems.as index f0eda37..22f4da9 100644 --- a/hamcrest/src/org/hamcrest/collection/hasItems.as +++ b/hamcrest/src/org/hamcrest/collection/hasItems.as @@ -23,7 +23,14 @@ package org.hamcrest.collection */ public function hasItems(... rest):Matcher { - return allOf.apply(null, rest.map(hasItemsIterator)); + var matchers:Array = rest; + + if (rest.length == 1 && rest[0] is Array) + { + matchers = rest[0]; + } + + return allOf.apply(null, matchers.map(hasItemsIterator)); } }