From 2e91b27b92204c15724ca230369de4f4bd98718f Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Mon, 12 Sep 2016 00:02:50 -0400 Subject: [PATCH] Add test for array assignment code --- tests/ArrayAssignmentTest.php | 135 ++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 tests/ArrayAssignmentTest.php diff --git a/tests/ArrayAssignmentTest.php b/tests/ArrayAssignmentTest.php new file mode 100644 index 000000000..a3c347413 --- /dev/null +++ b/tests/ArrayAssignmentTest.php @@ -0,0 +1,135 @@ +create(ParserFactory::PREFER_PHP7); + + $config = \Psalm\Config::getInstance(); + $config->throw_exception = true; + $config->use_docblock_types = true; + } + + public function setUp() + { + \Psalm\Checker\FileChecker::clearCache(); + } + + public function testImplicitIntArrayCreation() + { + $stmts = self::$_parser->parse('check(true, true, $context); + $this->assertEquals('array', (string) $context->vars_in_scope['foo']); + + } + + public function testImplicit2DIntArrayCreation() + { + $stmts = self::$_parser->parse('check(true, true, $context); + $this->assertEquals('array>', (string) $context->vars_in_scope['foo']); + + } + + public function testImplicit3DIntArrayCreation() + { + $stmts = self::$_parser->parse('check(true, true, $context); + $this->assertEquals('array>>', (string) $context->vars_in_scope['foo']); + } + + public function testImplicit4DIntArrayCreation() + { + $stmts = self::$_parser->parse('check(true, true, $context); + $this->assertEquals('array>>>', (string) $context->vars_in_scope['foo']); + } + + public function testImplicitStringArrayCreation() + { + $stmts = self::$_parser->parse('check(true, true, $context); + $this->assertEquals('array', (string) $context->vars_in_scope['foo']); + + } + + public function testImplicit2DStringArrayCreation() + { + $stmts = self::$_parser->parse('check(true, true, $context); + $this->assertEquals('array>', (string) $context->vars_in_scope['foo']); + + } + + public function testImplicit3DStringArrayCreation() + { + $stmts = self::$_parser->parse('check(true, true, $context); + $this->assertEquals('array>>', (string) $context->vars_in_scope['foo']); + } + + public function testImplicit4DStringArrayCreation() + { + $stmts = self::$_parser->parse('check(true, true, $context); + $this->assertEquals('array>>>', (string) $context->vars_in_scope['foo']); + } +}