diff options
Diffstat (limited to 'vendor/kzykhys/pygments/test/KzykHys/Pygments')
6 files changed, 325 insertions, 0 deletions
diff --git a/vendor/kzykhys/pygments/test/KzykHys/Pygments/PygmentsTest.php b/vendor/kzykhys/pygments/test/KzykHys/Pygments/PygmentsTest.php new file mode 100644 index 00000000..2110e0d8 --- /dev/null +++ b/vendor/kzykhys/pygments/test/KzykHys/Pygments/PygmentsTest.php @@ -0,0 +1,116 @@ +<?php + +use KzykHys\Pygments\Pygments; +use Symfony\Component\Finder\Finder; + +/** + * @author Kazuyuki Hayashi <hayashi@valnur.net> + */ +class PygmentsTest extends PHPUnit_Framework_TestCase +{ + + /** + * @dataProvider provideSamples + */ + public function testHighlight($input, $expected, $expectedL, $lexer) + { + $pygments = new Pygments(); + + $this->assertEquals($expected, $pygments->highlight($input, null, 'html')); + $this->assertEquals($expected, $pygments->highlight($input, $lexer, 'html')); + $this->assertEquals($expectedL, $pygments->highlight($input, null, 'html', array('linenos' => 1))); + } + + /** + * @dataProvider provideCss + */ + public function testGetCss($expected, $expectedA, $style) + { + $pygments = new Pygments(); + + $this->assertEquals($expected, $pygments->getCss($style)); + $this->assertEquals($expectedA, $pygments->getCss($style, '.syntax')); + } + + public function testGetLexers() + { + $pygments = new Pygments(); + $lexers = $pygments->getLexers(); + + $this->assertArrayHasKey('python', $lexers); + } + + public function testGetFormatters() + { + $pygments = new Pygments(); + $formatters = $pygments->getFormatters(); + + $this->assertArrayHasKey('html', $formatters); + } + + public function testGetStyles() + { + $pygments = new Pygments(); + $styles = $pygments->getStyles(); + + $this->assertArrayHasKey('monokai', $styles); + } + + public function testGuessLexer() + { + $pygments = new Pygments(); + + $this->assertEquals('php', $pygments->guessLexer('index.php')); + $this->assertEquals('go', $pygments->guessLexer('main.go')); + } + + public function provideSamples() + { + $finder = new Finder(); + $finder + ->in(__DIR__ . '/Resources/example') + ->name("*.in") + ->notName('*.linenos.out') + ->files() + ->ignoreVCS(true); + + $samples = array(); + + /* @var \Symfony\Component\Finder\SplFileInfo $file */ + foreach ($finder as $file) { + $samples[] = array( + $file->getContents(), + file_get_contents(str_replace('.in', '.out', $file->getPathname())), + file_get_contents(str_replace('.in', '.linenos.out', $file->getPathname())), + preg_replace('/\..*/', '', $file->getFilename()) + ); + } + + return $samples; + } + + public function provideCss() + { + $finder = new Finder(); + $finder + ->in(__DIR__ . '/Resources/css') + ->files() + ->ignoreVCS(true) + ->name('*.css') + ->notName('*.prefix.css'); + + $css = array(); + + /* @var \Symfony\Component\Finder\SplFileInfo $file */ + foreach ($finder as $file) { + $css[] = array( + $file->getContents(), + file_get_contents(str_replace('.css', '.prefix.css', $file->getPathname())), + str_replace('.css', '', $file->getFilename()) + ); + } + + return $css; + } + +}
\ No newline at end of file diff --git a/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/css/default.css b/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/css/default.css new file mode 100644 index 00000000..67e6ea39 --- /dev/null +++ b/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/css/default.css @@ -0,0 +1,61 @@ +.hll { background-color: #ffffcc } +.c { color: #408080; font-style: italic } /* Comment */ +.err { border: 1px solid #FF0000 } /* Error */ +.k { color: #008000; font-weight: bold } /* Keyword */ +.o { color: #666666 } /* Operator */ +.cm { color: #408080; font-style: italic } /* Comment.Multiline */ +.cp { color: #BC7A00 } /* Comment.Preproc */ +.c1 { color: #408080; font-style: italic } /* Comment.Single */ +.cs { color: #408080; font-style: italic } /* Comment.Special */ +.gd { color: #A00000 } /* Generic.Deleted */ +.ge { font-style: italic } /* Generic.Emph */ +.gr { color: #FF0000 } /* Generic.Error */ +.gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.gi { color: #00A000 } /* Generic.Inserted */ +.go { color: #888888 } /* Generic.Output */ +.gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +.gs { font-weight: bold } /* Generic.Strong */ +.gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.gt { color: #0044DD } /* Generic.Traceback */ +.kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +.kp { color: #008000 } /* Keyword.Pseudo */ +.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +.kt { color: #B00040 } /* Keyword.Type */ +.m { color: #666666 } /* Literal.Number */ +.s { color: #BA2121 } /* Literal.String */ +.na { color: #7D9029 } /* Name.Attribute */ +.nb { color: #008000 } /* Name.Builtin */ +.nc { color: #0000FF; font-weight: bold } /* Name.Class */ +.no { color: #880000 } /* Name.Constant */ +.nd { color: #AA22FF } /* Name.Decorator */ +.ni { color: #999999; font-weight: bold } /* Name.Entity */ +.ne { color: #D2413A; font-weight: bold } /* Name.Exception */ +.nf { color: #0000FF } /* Name.Function */ +.nl { color: #A0A000 } /* Name.Label */ +.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ +.nt { color: #008000; font-weight: bold } /* Name.Tag */ +.nv { color: #19177C } /* Name.Variable */ +.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ +.w { color: #bbbbbb } /* Text.Whitespace */ +.mf { color: #666666 } /* Literal.Number.Float */ +.mh { color: #666666 } /* Literal.Number.Hex */ +.mi { color: #666666 } /* Literal.Number.Integer */ +.mo { color: #666666 } /* Literal.Number.Oct */ +.sb { color: #BA2121 } /* Literal.String.Backtick */ +.sc { color: #BA2121 } /* Literal.String.Char */ +.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ +.s2 { color: #BA2121 } /* Literal.String.Double */ +.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ +.sh { color: #BA2121 } /* Literal.String.Heredoc */ +.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ +.sx { color: #008000 } /* Literal.String.Other */ +.sr { color: #BB6688 } /* Literal.String.Regex */ +.s1 { color: #BA2121 } /* Literal.String.Single */ +.ss { color: #19177C } /* Literal.String.Symbol */ +.bp { color: #008000 } /* Name.Builtin.Pseudo */ +.vc { color: #19177C } /* Name.Variable.Class */ +.vg { color: #19177C } /* Name.Variable.Global */ +.vi { color: #19177C } /* Name.Variable.Instance */ +.il { color: #666666 } /* Literal.Number.Integer.Long */ diff --git a/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/css/default.prefix.css b/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/css/default.prefix.css new file mode 100644 index 00000000..eb17bc3e --- /dev/null +++ b/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/css/default.prefix.css @@ -0,0 +1,62 @@ +.syntax .hll { background-color: #ffffcc } +.syntax { background: #f8f8f8; } +.syntax .c { color: #408080; font-style: italic } /* Comment */ +.syntax .err { border: 1px solid #FF0000 } /* Error */ +.syntax .k { color: #008000; font-weight: bold } /* Keyword */ +.syntax .o { color: #666666 } /* Operator */ +.syntax .cm { color: #408080; font-style: italic } /* Comment.Multiline */ +.syntax .cp { color: #BC7A00 } /* Comment.Preproc */ +.syntax .c1 { color: #408080; font-style: italic } /* Comment.Single */ +.syntax .cs { color: #408080; font-style: italic } /* Comment.Special */ +.syntax .gd { color: #A00000 } /* Generic.Deleted */ +.syntax .ge { font-style: italic } /* Generic.Emph */ +.syntax .gr { color: #FF0000 } /* Generic.Error */ +.syntax .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.syntax .gi { color: #00A000 } /* Generic.Inserted */ +.syntax .go { color: #888888 } /* Generic.Output */ +.syntax .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +.syntax .gs { font-weight: bold } /* Generic.Strong */ +.syntax .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.syntax .gt { color: #0044DD } /* Generic.Traceback */ +.syntax .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +.syntax .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +.syntax .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +.syntax .kp { color: #008000 } /* Keyword.Pseudo */ +.syntax .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +.syntax .kt { color: #B00040 } /* Keyword.Type */ +.syntax .m { color: #666666 } /* Literal.Number */ +.syntax .s { color: #BA2121 } /* Literal.String */ +.syntax .na { color: #7D9029 } /* Name.Attribute */ +.syntax .nb { color: #008000 } /* Name.Builtin */ +.syntax .nc { color: #0000FF; font-weight: bold } /* Name.Class */ +.syntax .no { color: #880000 } /* Name.Constant */ +.syntax .nd { color: #AA22FF } /* Name.Decorator */ +.syntax .ni { color: #999999; font-weight: bold } /* Name.Entity */ +.syntax .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ +.syntax .nf { color: #0000FF } /* Name.Function */ +.syntax .nl { color: #A0A000 } /* Name.Label */ +.syntax .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ +.syntax .nt { color: #008000; font-weight: bold } /* Name.Tag */ +.syntax .nv { color: #19177C } /* Name.Variable */ +.syntax .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ +.syntax .w { color: #bbbbbb } /* Text.Whitespace */ +.syntax .mf { color: #666666 } /* Literal.Number.Float */ +.syntax .mh { color: #666666 } /* Literal.Number.Hex */ +.syntax .mi { color: #666666 } /* Literal.Number.Integer */ +.syntax .mo { color: #666666 } /* Literal.Number.Oct */ +.syntax .sb { color: #BA2121 } /* Literal.String.Backtick */ +.syntax .sc { color: #BA2121 } /* Literal.String.Char */ +.syntax .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ +.syntax .s2 { color: #BA2121 } /* Literal.String.Double */ +.syntax .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ +.syntax .sh { color: #BA2121 } /* Literal.String.Heredoc */ +.syntax .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ +.syntax .sx { color: #008000 } /* Literal.String.Other */ +.syntax .sr { color: #BB6688 } /* Literal.String.Regex */ +.syntax .s1 { color: #BA2121 } /* Literal.String.Single */ +.syntax .ss { color: #19177C } /* Literal.String.Symbol */ +.syntax .bp { color: #008000 } /* Name.Builtin.Pseudo */ +.syntax .vc { color: #19177C } /* Name.Variable.Class */ +.syntax .vg { color: #19177C } /* Name.Variable.Global */ +.syntax .vi { color: #19177C } /* Name.Variable.Instance */ +.syntax .il { color: #666666 } /* Literal.Number.Integer.Long */ diff --git a/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/example/php.php.in b/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/example/php.php.in new file mode 100644 index 00000000..b5d94041 --- /dev/null +++ b/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/example/php.php.in @@ -0,0 +1,21 @@ +<?php + +class Foo +{ + const TEST_CONST = 1; + + public static $staticProperty = null; + + public $property = null; + + public static function staticMethod() + { + return new static(); + } + + public function method() + { + return $this; + } + +}
\ No newline at end of file diff --git a/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/example/php.php.linenos.out b/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/example/php.php.linenos.out new file mode 100644 index 00000000..c646cc9d --- /dev/null +++ b/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/example/php.php.linenos.out @@ -0,0 +1,43 @@ +<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21</pre></div></td><td class="code"><div class="highlight"><pre><span class="cp"><?php</span> + +<span class="k">class</span> <span class="nc">Foo</span> +<span class="p">{</span> + <span class="k">const</span> <span class="no">TEST_CONST</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> + + <span class="k">public</span> <span class="k">static</span> <span class="nv">$staticProperty</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span> + + <span class="k">public</span> <span class="nv">$property</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span> + + <span class="k">public</span> <span class="k">static</span> <span class="k">function</span> <span class="nf">staticMethod</span><span class="p">()</span> + <span class="p">{</span> + <span class="k">return</span> <span class="k">new</span> <span class="k">static</span><span class="p">();</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">method</span><span class="p">()</span> + <span class="p">{</span> + <span class="k">return</span> <span class="nv">$this</span><span class="p">;</span> + <span class="p">}</span> + +<span class="p">}</span> +</pre></div> +</td></tr></table>
\ No newline at end of file diff --git a/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/example/php.php.out b/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/example/php.php.out new file mode 100644 index 00000000..c5e907f1 --- /dev/null +++ b/vendor/kzykhys/pygments/test/KzykHys/Pygments/Resources/example/php.php.out @@ -0,0 +1,22 @@ +<div class="highlight"><pre><span class="cp"><?php</span> + +<span class="k">class</span> <span class="nc">Foo</span> +<span class="p">{</span> + <span class="k">const</span> <span class="no">TEST_CONST</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> + + <span class="k">public</span> <span class="k">static</span> <span class="nv">$staticProperty</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span> + + <span class="k">public</span> <span class="nv">$property</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span> + + <span class="k">public</span> <span class="k">static</span> <span class="k">function</span> <span class="nf">staticMethod</span><span class="p">()</span> + <span class="p">{</span> + <span class="k">return</span> <span class="k">new</span> <span class="k">static</span><span class="p">();</span> + <span class="p">}</span> + + <span class="k">public</span> <span class="k">function</span> <span class="nf">method</span><span class="p">()</span> + <span class="p">{</span> + <span class="k">return</span> <span class="nv">$this</span><span class="p">;</span> + <span class="p">}</span> + +<span class="p">}</span> +</pre></div> |