diff options
author | murphy <murphy@rubychan.de> | 2006-10-15 15:10:04 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2006-10-15 15:10:04 +0000 |
commit | f5768c09019b303e82b7b7905b137b0e1df3823c (patch) | |
tree | a0bca63a318f848c6932070b4779226520fa040c /test/scanners/ruby/test-fitter.in.rb | |
parent | dd1f6c2ed2fa76d8862233494519d797e9ffb488 (diff) | |
download | coderay-f5768c09019b303e82b7b7905b137b0e1df3823c.tar.gz |
Moved scanner tests into test/scanners.
Diffstat (limited to 'test/scanners/ruby/test-fitter.in.rb')
-rw-r--r-- | test/scanners/ruby/test-fitter.in.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/scanners/ruby/test-fitter.in.rb b/test/scanners/ruby/test-fitter.in.rb new file mode 100644 index 0000000..7d00da6 --- /dev/null +++ b/test/scanners/ruby/test-fitter.in.rb @@ -0,0 +1,45 @@ +require 'benchmark'
+require 'fits'
+
+N = 100_000
+
+def test s
+ puts s
+ Benchmark.bm 10 do |bm|
+ bm.report 'default' do
+ N.times { s =~ /\A\w+\z/ }
+ end
+
+ bm.report 'fits?' do
+ N.times { s.fits? /\w+/ }
+ end
+
+ bm.report 'f' do
+ N.times { s =~ /\w+/.f }
+ end
+
+ re = /\w+/.f
+
+ bm.report 'preparsed' do
+ N.times { s =~ re }
+ end
+ end
+ puts
+end
+
+a.fits? / bla /x
+
+test 'harmlessline'
+
+test <<EOL
+<div style=\"font-size:2px\">Destroy my HTML!
+harmlessline
+EOL
+
+test <<EOL
+harmlessline
+harmlesslineharmlessline
+<div style=\"font-size:2px\">Destroy my HTML!
+harmlessline
+EOL
+
|