Created
August 1, 2012 06:17
-
-
Save phiggins/3224215 to your computer and use it in GitHub Desktop.
broken_sexp_sort.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sexp_processor' | |
#def uses_if | |
# if some_func | |
# if some_other_func | |
# return | |
# end | |
# end | |
#end | |
sexps = [ | |
s(:defn, :uses_if, | |
s(:args), | |
s(:scope, | |
s(:block, | |
s(:if, | |
s(:call, nil, :some_func, s(:arglist)), | |
s(:if, s(:call, nil, :some_other_func, s(:arglist)), nil, s(:return)), | |
nil)))), | |
s(:defn, :uses_if, | |
s(:args), | |
s(:scope, | |
s(:block, | |
s(:if, | |
s(:call, nil, :some_func, s(:arglist)), | |
nil, | |
s(:if, s(:call, nil, :some_other_func, s(:arglist)), s(:return), nil))))) | |
] | |
p [:spaceship, (sexps[0] <=> sexps[1])] | |
p sexps.sort | |
__END__ | |
pete@balloon ~/projects/heckle $ ruby broken_sexp_sort.rb | |
[:spaceship, nil] | |
broken_sexp_sort.rb:32:in `sort': comparison of Sexp with Sexp failed (ArgumentError) | |
from broken_sexp_sort.rb:32:in `<main>' | |
pete@balloon ~/projects/heckle $ ruby -v | |
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
pete@balloon ~/projects/heckle $ gem list | |
*** LOCAL GEMS *** | |
bundler (1.1.3) | |
hoe (3.0.6, 3.0.4) | |
hoe-seattlerb (1.2.8) | |
json (1.7.3) | |
rake (0.9.2.2) | |
rdoc (3.12) | |
ruby2ruby (1.3.1) | |
ruby_parser (2.3.1) | |
rubygems-bundler (1.0.2) | |
rvm (1.11.3.3) | |
sexp_processor (3.2.0) | |
ZenTest (4.7.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment