diff options
author | murphy <murphy@rubychan.de> | 2006-10-18 10:28:21 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2006-10-18 10:28:21 +0000 |
commit | ec08216346b0d73b9118dbf498cff675924d40b0 (patch) | |
tree | 8976acc19c2784e525a214f889be8b0cf841a6c9 /test | |
parent | 4666c2ced49f4b45f6106f0a9cb728c3f2fb1814 (diff) | |
download | coderay-ec08216346b0d73b9118dbf498cff675924d40b0.tar.gz |
Fixed warning in bench.rb.
Ruby Scanner: improved handling of ambiguos values.
- operator methods are now :ident instead of :operator
- fancy_allowed and regexp_allowed are now value_expected
- value_expected works in operator method calls
- tests enhanced and adjusted
Scanner tests: new diffed option, diff doesn't imply noassert anymore
Diffstat (limited to 'test')
-rw-r--r-- | test/scanners/coderay_suite.rb | 6 | ||||
-rw-r--r-- | test/scanners/ruby/1.expected.raydebug | 2 | ||||
-rw-r--r-- | test/scanners/ruby/evil.expected.raydebug | 76 | ||||
-rw-r--r-- | test/scanners/ruby/example.expected.raydebug | 2 | ||||
-rw-r--r-- | test/scanners/ruby/strange.expected.raydebug | 7 | ||||
-rw-r--r-- | test/scanners/ruby/strange.in.rb | 7 |
6 files changed, 57 insertions, 43 deletions
diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb index 280e182..6a2725c 100644 --- a/test/scanners/coderay_suite.rb +++ b/test/scanners/coderay_suite.rb @@ -152,11 +152,11 @@ module CodeRay File.open(actual_filename, 'wb') { |f| f.write result } if ENV['diff'] diff = expected_filename.sub(/\.expected\..*/, '.debug.diff') - system "diff #{expected_filename} #{actual_filename} > #{diff}" - system "EDITOR #{diff}" + system "diff --text #{expected_filename} #{actual_filename} > #{diff}" + system "EDITOR #{diff}" if ENV['diffed'] end end - unless ENV['diff'] or ENV['noassert'] + unless ENV['noassert'] assert(ok, "Scan error: unexpected output") end else diff --git a/test/scanners/ruby/1.expected.raydebug b/test/scanners/ruby/1.expected.raydebug index 510e7c6..61e3dbb 100644 --- a/test/scanners/ruby/1.expected.raydebug +++ b/test/scanners/ruby/1.expected.raydebug @@ -17,7 +17,7 @@ reserved(module) class(Bytes) constant(FactorOfSuffix)operator([)ident(suff)operator(]) reserved(end) - reserved(def) constant(Bytes)operator(.)operator([]) ident(str) + reserved(def) constant(Bytes)operator(.)ident([]) ident(str) ident(n)operator(,) ident(fac) operator(=) ident(str) operator(/) regexp<delimiter(/)content((.+\)([A-Z]\))delimiter(/)> ident(n) operator(=) ident(n)operator(.)ident(to_i) ident(fac) operator(=) ident(factor_of_suffix) ident(fac) diff --git a/test/scanners/ruby/evil.expected.raydebug b/test/scanners/ruby/evil.expected.raydebug index b1e3231..5518de0 100644 --- a/test/scanners/ruby/evil.expected.raydebug +++ b/test/scanners/ruby/evil.expected.raydebug @@ -4,10 +4,10 @@ reserved(class) class(Class) reserved(end) reserved(end) comment(#def String(x\) x.to_s end #it's already built-in. duh!) -reserved(def) constant(String)operator(.)operator(*)operator(()ident(right)operator(\)) operator([)pre_constant(self)operator(,)ident(right)operator(]) reserved(end) -reserved(def) constant(String)operator(.)operator(<<)operator(()ident(right)operator(\)) operator([)pre_constant(self)operator(,)symbol(:<<)operator(,)ident(right)operator(]) reserved(end) -reserved(def) constant(String)operator(.)operator(/)operator(()ident(right)operator(\)) operator([)pre_constant(self)operator(,)symbol(:/)operator(,)ident(right)operator(]) reserved(end) -reserved(def) constant(String)operator(.)operator([])operator(()ident(right)operator(\)) operator([)pre_constant(self)operator(,)symbol(:[])operator(,)ident(right)operator(]) reserved(end) +reserved(def) constant(String)operator(.)ident(*)operator(()ident(right)operator(\)) operator([)pre_constant(self)operator(,)ident(right)operator(]) reserved(end) +reserved(def) constant(String)operator(.)ident(<<)operator(()ident(right)operator(\)) operator([)pre_constant(self)operator(,)symbol(:<<)operator(,)ident(right)operator(]) reserved(end) +reserved(def) constant(String)operator(.)ident(/)operator(()ident(right)operator(\)) operator([)pre_constant(self)operator(,)symbol(:/)operator(,)ident(right)operator(]) reserved(end) +reserved(def) constant(String)operator(.)ident([])operator(()ident(right)operator(\)) operator([)pre_constant(self)operator(,)symbol(:[])operator(,)ident(right)operator(]) reserved(end) ident(p)operator(()constant(String)operator(::)constant(Class)operator(\)) ident(p)operator(()constant(String)operator(::) constant(Class)operator(\)) ident(p)operator(()constant(String) operator(::)constant(Class)operator(\)) @@ -78,15 +78,15 @@ pre_constant(false) operator(?) ident(P?)operator(:) ident(p8) ident(P?) symbol(:p8) pre_constant(false) operator(?) ident(P?) operator(:) ident(p8) -pre_constant(self)operator(.)operator([])symbol(:p8) -pre_constant(false) operator(?) pre_constant(self)operator(.)operator([])operator(:) ident(p8) -pre_constant(self)operator(.)operator([]) symbol(:p8) -pre_constant(false) operator(?) pre_constant(self)operator(.)operator([]) operator(:) ident(p8) +pre_constant(self)operator(.)ident([])symbol(:p8) +pre_constant(false) operator(?) pre_constant(self)operator(.)ident([])operator(:) ident(p8) +pre_constant(self)operator(.)ident([]) symbol(:p8) +pre_constant(false) operator(?) pre_constant(self)operator(.)ident([]) operator(:) ident(p8) -pre_constant(self)operator(.)operator(<=>)symbol(:p8) -pre_constant(false) operator(?) pre_constant(self)operator(.)operator(<=>)operator(:) ident(p8) -pre_constant(self)operator(.)operator(<=>) symbol(:p8) -pre_constant(false) operator(?) pre_constant(self)operator(.)operator(<=>) operator(:) ident(p8) +pre_constant(self)operator(.)ident(<=>)symbol(:p8) +pre_constant(false) operator(?) pre_constant(self)operator(.)ident(<=>)operator(:) ident(p8) +pre_constant(self)operator(.)ident(<=>) symbol(:p8) +pre_constant(false) operator(?) pre_constant(self)operator(.)ident(<=>) operator(:) ident(p8) pre_constant(self) operator(<=>)symbol(:p8) comment(#false ? self <=>: p8 #gives ruby indigestion) @@ -390,9 +390,9 @@ reserved(def) method(`)operator(()ident(s)operator(\)) reserved(end) reserved(end) -integer(69)operator(.)operator(`)operator(()string<delimiter(')content(what a world)delimiter(')>operator(\)) +integer(69)operator(.)ident(`)operator(()string<delimiter(')content(what a world)delimiter(')>operator(\)) -integer(79)operator(::)operator(`)operator(()string<delimiter(')content(what a word)delimiter(')>operator(\)) +integer(79)operator(::)ident(`)operator(()string<delimiter(')content(what a word)delimiter(')>operator(\)) ident(p) symbol(:`) @@ -402,8 +402,8 @@ ident(a)operator(=)integer(5) ident(p) ident(p) integer(+5) ident(p) ident(a) integer(+5) -reserved(def) pre_constant(nil)operator(.)operator(+)operator(()ident(x)operator(\)) operator(~)ident(x) reserved(end) -reserved(def) pre_constant(nil)operator(.)operator([])operator(()operator(*)ident(x)operator(\)) operator([)ident(x)operator(]) reserved(end) +reserved(def) pre_constant(nil)operator(.)ident(+)operator(()ident(x)operator(\)) operator(~)ident(x) reserved(end) +reserved(def) pre_constant(nil)operator(.)ident([])operator(()operator(*)ident(x)operator(\)) operator([)ident(x)operator(]) reserved(end) ident(p)operator(() ident(p) operator(+) integer(5) operator(\)) ident(p)operator(() ident(p) integer(+5) operator(\)) ident(p)operator(() ident(p)integer(+5) operator(\)) @@ -417,28 +417,28 @@ reserved(class) class(Foou) reserved(def) method([]) ident(x)operator(=)integer(-100)operator(,)operator(&)ident(y)operator(;) ident(p) ident(x)operator(;) integer(100) reserved(end) reserved(end) ident(a0)operator(=)integer(8) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([])operator(!)pre_constant(false) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([]) operator(!)pre_constant(false) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([])operator(~)integer(9) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([]) operator(~)integer(9) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([])integer(-9) comment(#op) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([])integer(+9) comment(#op) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([]) integer(-9) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([]) integer(+9) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([])operator(<<)integer(9) comment(#op) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([]) string<delimiter(<<9)> comment(#value)string<content( +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([])operator(!)pre_constant(false) comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([]) operator(!)pre_constant(false) comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([])operator(~)integer(9) comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([]) operator(~)integer(9) comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([])integer(-9) comment(#op) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([])integer(+9) comment(#op) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([]) integer(-9) comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([]) integer(+9) comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([])operator(<<)integer(9) comment(#op) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([]) string<delimiter(<<9)> comment(#value)string<content( foobar)delimiter( 9)> -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([])operator(%)integer(9) comment(#op) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([])operator(/)integer(9) comment(#op) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([]) string<delimiter(%()content(9)delimiter(\))> comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([]) operator(/)integer(9)operator(/) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([])global_variable($9) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([])ident(a0) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([]) global_variable($9) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([]) ident(a0) comment(#value) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([])operator({)integer(9)operator(}) comment(#lambda (op\)) -ident(p) constant(Foou)operator(.)ident(new)operator(.)operator([]) operator({)integer(9)operator(}) comment(#lambda (op\)) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([])operator(%)integer(9) comment(#op) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([])operator(/)integer(9) comment(#op) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([]) string<delimiter(%()content(9)delimiter(\))> comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([]) regexp<delimiter(/)content(9)delimiter(/)> comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([])global_variable($9) comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([])ident(a0) comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([]) global_variable($9) comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([]) ident(a0) comment(#value) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([])operator({)integer(9)operator(}) comment(#lambda (op\)) +ident(p) constant(Foou)operator(.)ident(new)operator(.)ident([]) operator({)integer(9)operator(}) comment(#lambda (op\)) reserved(if) ident(p) reserved(then) ident(p) reserved(end) @@ -768,7 +768,7 @@ reserved(end) EOL)> reserved(def) method(add)operator(()operator(*)ident(args)operator(\)) - pre_constant(self)operator(.)operator(<<)operator(()operator(*)ident(args)operator(\)) + pre_constant(self)operator(.)ident(<<)operator(()operator(*)ident(args)operator(\)) reserved(end) @@ -841,7 +841,7 @@ reserved(def) method(yy)operator(;)reserved(yield) reserved(end) ident(block)operator(=)ident(proc)operator({)ident(p) string<delimiter(")content(blah blah)delimiter(")>operator(}) ident(yy) operator(&)ident(block) -ident(p)operator(()integer(1)operator(.)operator(+)integer(1)operator(\)) +ident(p)operator(()integer(1)operator(.)ident(+)integer(1)operator(\)) ident(p) ident(pppp) reserved(module) class(M66) diff --git a/test/scanners/ruby/example.expected.raydebug b/test/scanners/ruby/example.expected.raydebug index be68a13..e290d06 100644 --- a/test/scanners/ruby/example.expected.raydebug +++ b/test/scanners/ruby/example.expected.raydebug @@ -187,7 +187,7 @@ reserved(class) class(Set) ident(include) constant(Enumerable) comment(# Creates a new set containing the given objects.) - reserved(def) pre_constant(self)operator(.)operator([])operator(()operator(*)ident(ary)operator(\)) + reserved(def) pre_constant(self)operator(.)ident([])operator(()operator(*)ident(ary)operator(\)) ident(new)operator(()ident(ary)operator(\)) reserved(end) diff --git a/test/scanners/ruby/strange.expected.raydebug b/test/scanners/ruby/strange.expected.raydebug index b2f7d50..61a7cae 100644 --- a/test/scanners/ruby/strange.expected.raydebug +++ b/test/scanners/ruby/strange.expected.raydebug @@ -51,6 +51,13 @@ operator(%)constant(Quark) ident(dazu) operator(%) ident(abc) comment(# FIXME) +comment(# And here some special string cases) +ident(foo) operator(=) operator(%) ident(blah) comment(# comment here to ensure whitespace) +ident(foo)operator(()operator(%) ident(blah) operator(\)) +ident(foo) operator(<<) operator(%) ident(blah) comment(# stupid but has to work) +ident(foo) operator(=) operator(%) ident(blah) operator(+) operator(%) ident(blub) comment(# wicked) +ident(foo) operator(=) string<delimiter(%q )content(wicked)delimiter( )> comment(# works too) + symbol<delimiter(%s#)content(ruby allows strange)delimiter(#)>operator({)ident(constructs)operator(}) symbol<delimiter(%s#)content(ruby allows strange)delimiter(#)>global_variable($constructs) symbol<delimiter(%s#)content(ruby allows strange)delimiter(#)>class_variable(@@constructs) diff --git a/test/scanners/ruby/strange.in.rb b/test/scanners/ruby/strange.in.rb index 8369aaa..bf57322 100644 --- a/test/scanners/ruby/strange.in.rb +++ b/test/scanners/ruby/strange.in.rb @@ -51,6 +51,13 @@ puts 30.send(:/, 5) # prints 6 % abc # FIXME
+# And here some special string cases
+foo = % blah # comment here to ensure whitespace
+foo(% blah )
+foo << % blah # stupid but has to work
+foo = % blah + % blub # wicked
+foo = %q wicked # works too
+
%s#ruby allows strange#{constructs}
%s#ruby allows strange#$constructs
%s#ruby allows strange#@@constructs
|