Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 9b3dd2a

Browse files
azjezzfredemmott
authored andcommitted
Add support for type checking Container and KeyedContainer. (#8)
* Update IsType.php * tests `KeyedContainer` and `Container` types
1 parent 300f3b3 commit 9b3dd2a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Constraint/IsType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public static function getTypes(): ImmMap<string, self::TPredicate> {
4141
'vec' => ($x ==> ($x is vec<_>)),
4242
'dict' => ($x ==> ($x is dict<_, _>)),
4343
'keyset' => ($x ==> ($x is keyset<_>)),
44+
'Container' => ($x ==> ($x is Container<_>)),
45+
'KeyedContainer' => ($x ==> ($x is KeyedContainer<_, _>)),
4446
};
4547
}
4648

tests/ExpectObjTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public function testBasicSuccesses(): void {
5252
expect(vec[])->toNotBeType('array');
5353
expect(dict[])->toBeType('dict');
5454
expect(keyset[])->toBeType('keyset');
55+
expect(Set {})->toBeType('Container');
56+
// vec[] is keyed by int type.
57+
expect(vec[])->toBeType('KeyedContainer');
58+
expect(dict[])->toBeType('KeyedContainer');
5559
expect(array(1, 2, 3))->toContain(2);
5660
expect(array(1, 2, 3))->toNotContain(7);
5761

0 commit comments

Comments
 (0)