diff options
Diffstat (limited to 'plugins/wp-syntax/test')
-rw-r--r-- | plugins/wp-syntax/test/code.php | 101 | ||||
-rw-r--r-- | plugins/wp-syntax/test/index.php | 206 |
2 files changed, 0 insertions, 307 deletions
diff --git a/plugins/wp-syntax/test/code.php b/plugins/wp-syntax/test/code.php deleted file mode 100644 index ed314446..00000000 --- a/plugins/wp-syntax/test/code.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php - -$code = array(); -$code['php'] = <<<EOF -<div id="foo"> -<?php - function foo() { - echo "Hello World!\\n"; - } - for (\$i = 0; \$i < 10 $i++) { - foo(); - } -?> -</div> -EOF; - -$code['lisp'] = <<<EOF -(defun foo - "bleh *bleh* bleh" - (interactive)) -EOF; - -$code['java'] = <<<EOF -public class Hello { - public static void main(String[] args) { - System.out.println("Hello World!"); - } -} -EOF; - -$code['xml'] = <<<EOF -<xml> - <foo> - <bar id="howdy">"Hello World!"</bar> - </foo> -</xml> -EOF; - -$code['html'] = <<<EOF -<html><head><title>Hello World</title></head> - <body> - <h1>Hello World!</h1> - <p><strong>howdy</strong></p> - </body> -</html> -EOF; - -$code['ruby'] = <<<EOF -class Example - def example(arg1) - return "Hello: " + arg1.to_s - end -end -EOF; - -$code['rails'] = <<<EOF -ActionController::Routing::Routes.draw do |map| - map.connect ':controller/:action', :action => 'index', :requirements => { :action => /(?:[a-z](?:[-_]?[a-z]+)*)/ } - map.connect ':controller/:id', :action => 'show', :requirements => { :id => /\d+/ } - map.connect ':controller/:id/:action', -end -EOF; - -$code['ocaml'] = <<<EOF -let square x = x * x;; -val square : int -> int = -let rec fact x = - if x < = 1 then 1 else x * fact (x - 1);; -val fact : int -> int = -fact 5;; - : int = 120 -square 120;; - : int = 14400 -EOF; - -$code['python'] = <<<EOF -from itertools import islice - -def fib(): - x, y = 1, 1 - while True: - yield x - x, y = y, x + y - -for num in islice(fib(), 20): - print num -EOF; - -$code['c'] = <<<EOF -_tcsncat_s(CurrentFileName, MAX_PATH, TEXT("\\\\"), MAX_PATH); -_tcsncat_s(CurrentFileName, MAX_PATH, FileInformation.cFileName, MAX_PATH); - -if(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) -{ - RecurseFileSystem(CurrentFileName); -} -else -{ - /* Do action on file here! */ -} -EOF; - -?> diff --git a/plugins/wp-syntax/test/index.php b/plugins/wp-syntax/test/index.php deleted file mode 100644 index 437c96dc..00000000 --- a/plugins/wp-syntax/test/index.php +++ /dev/null @@ -1,206 +0,0 @@ -<?php - -$code = array(); -$test_filter = array(); - -include("code.php"); - -function test_lang($lang, $language = null, $line = null, $escaped = null) -{ - global $code; - if (!isset($language)) $language = $lang; - else $as = "as $language"; - - if (isset($escaped)) $c = htmlspecialchars($code[$lang]); - else { $c = $code[$lang]; $escaped = "false"; } - - $snippet = <<<EOF -<h2>$lang $as</h2> -<p>This *is* what some <code>$lang</code> code looks like (escaped:$escaped):</p> -<pre lang='$language' line="$line" escaped="$escaped"> \t \r -$c -</pre> -EOF; - - return $snippet; -} - -function gather_content() -{ - $content = ''; - $content .= test_lang('php'); - $content .= test_lang('lisp', null, 1); - $content .= test_lang('java', null, 1); - $content .= test_lang('xml'); - $content .= test_lang('xml', null, null, "true"); - $content .= test_lang('html', 'html4strict'); - $content .= test_lang('html', 'xml', 18); - $content .= test_lang('html', 'xml', 18, "true"); - $content .= test_lang('ocaml'); - $content .= test_lang('python'); - $content .= test_lang('ruby', null, 18); - $content .= test_lang('ruby'); - $content .= test_lang('rails'); - $content .= test_lang('c'); - return $content; -} - -function test_head() -{ - echo apply_filters("wp_head", ""); -} - -function test_all() -{ - echo apply_filters("the_content", gather_content()); -} - -function test_all_with_other_filters() -{ - add_filter('the_content', 'pre_killer'); // bad if run before GeSHi - add_filter('the_content', 'amp_exposer'); // bad if run after GeSHi - - if (file_exists("filters/filters.php")) - { - include("filters/filters.php"); - } - - echo apply_filters("the_content", gather_content()); -} - -include("../wp-syntax.php"); -?> - -<html> -<head> -<title>WP-Syntax Test Page</title> -<link rel="stylesheet" href="../wp-syntax.css" type="text/css" media="screen" /> -<?php -test_head(); -define("TEMPLATEPATH", "../"); -test_head(); -?> -<style type="text/css" media="screen"> -.wp_syntax td div, .wp_syntax div div { - padding: 0; -} -</style> -</head> - -<body> -<div style="width:50%;"> - <h1>Vanilla, without other filters</h1> -<?php -test_all(); -?> - - <h1>Modified, with other filters</h1> -<?php -test_all_with_other_filters(); -?> -</div> -</body> -</html> - - -<?php - -function amp_exposer($content) -{ - return str_replace("&", "&", $content); -} - -function pre_killer($content) -{ - return preg_replace("/<(\/)?pre([^>]*)>/", "[$1pre$2]", $content); -} - -/* - * === WORDPRESS STUBS === - */ -function get_bloginfo($arg) { - return "http://yourblog.com/blog"; -} - -function get_option($arg) { - return "http://yourblog.com/blog"; -} - -function remove_filter($tag, $function_to_remove, $priority = 10) -{ - return true; -} - -function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) -{ - global $test_filter; - - $test_filter[$tag][$priority][] = $function_to_add; - $test_filter[$tag][$priority] = array_unique($test_filter[$tag][$priority]); - - return true; -} - -function apply_filters($tag, $string) -{ - global $test_filter; - - if (!isset($test_filter[$tag])) return $string; - - uksort($test_filter[$tag], "strnatcasecmp"); - - foreach ($test_filter[$tag] as $priority => $functions) - { - if (is_null($functions)) continue; - - foreach($functions as $function) - { - $string = call_user_func_array($function, array($string)); - } - } - return $string; -} - -function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) -{ - add_filter($tag, $function_to_add, $priority, $accepted_args); -} - -function do_action($tag, $arg = '') { - global $test_filter; - - if (!isset($test_filter[$tag])) return; - - uksort($test_filter[$tag], "strnatcasecmp"); - - foreach ($test_filter[$tag] as $priority => $functions) - { - if (is_null($functions)) continue; - - foreach($functions as $function) - { - call_user_func_array($function, array($arg)); - } - } -} - -function do_action_ref_array($tag, $args) { - global $test_filter; - - if (!isset($test_filter[$tag])) return; - - uksort($test_filter[$tag], "strnatcasecmp"); - - foreach ($test_filter[$tag] as $priority => $functions) - { - if (is_null($functions)) continue; - - foreach($functions as $function) - { - call_user_func_array($function, $args); - } - } -} - -?> - |