function testCountGroups() { $lexer = new Lexer(); $count = $lexer->countGroups('('); $this->assertEquals(1, $count); $count = $lexer->countGroups('(aa)((bb)gg)'); $this->assertEquals(3, $count); $count = $lexer->countGroups('\\('); $this->assertEquals(0, $count); $count = $lexer->countGroups('\\\\('); $this->assertEquals(1, $count); $count = $lexer->countGroups('(\\\\()'); $this->assertEquals(2, $count); $count = $lexer->countGroups('\\(()'); $this->assertEquals(1, $count); $count = $lexer->countGroups('(?:aaa)'); $this->assertEquals(0, $count); $count = $lexer->countGroups('aaa(?!bbb)(ccc)+'); $this->assertEquals(1, $count); $count = $lexer->countGroups('1(2(3(4)*)*)*'); $this->assertEquals(3, $count); $count = $lexer->countGroups('[-]?(0|[1-9][0-9]*)(\\.[0-9]+)?([eE][+-]?[0-9]+)?'); $this->assertEquals(3, $count); $count = $lexer->countGroups('"([^"\\\\]|[\\\\](["\\\\/bfnrt]|u[0-9a-z]{4}))*"'); $this->assertEquals(2, $count); }