Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: None  |  size: 2.28 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/kernel/bootstrap/block_environment.rb b/kernel/bootstrap/block_environment.rb
  2. index ccc91b4..80cb6df 100644
  3. --- a/kernel/bootstrap/block_environment.rb
  4. +++ b/kernel/bootstrap/block_environment.rb
  5. @@ -23,6 +23,8 @@ module Rubinius
  6.      end
  7.  
  8.      class AsMethod < Executable
  9. +      attr_reader :block_env
  10. +
  11.        def self.new(block_env)
  12.          Rubinius.primitive :block_as_method_create
  13.          raise PrimitiveFailure, "BlockEnvironment::AsMethod.new failed"
  14. @@ -59,6 +61,31 @@ module Rubinius
  15.        def defined_line
  16.          @block_env.line
  17.        end
  18. +
  19. +      def ==(other)
  20. +        cm = @block_env.instance_variable_get("@code")
  21. +        other_cm = other.block_env.instance_variable_get("@code")
  22. +        scope = @block_env.instance_variable_get("@scope")
  23. +        other_scope = other.block_env.instance_variable_get("@scope")
  24. +        top_scope = @block_env.instance_variable_get("@top_scope")
  25. +        other_top_scope = other.block_env.instance_variable_get("@top_scope")
  26. +        this_module = @block_env.instance_variable_get("@module")
  27. +        other_module = other.block_env.instance_variable_get("@module")
  28. +
  29. +        scope            == other_scope            &&
  30. +        top_scope        == other_top_scope        &&
  31. +        this_module      == other_module           &&
  32. +        cm.iseq          == other_cm.iseq          &&
  33. +        cm.stack_size    == other_cm.stack_size    &&
  34. +        cm.local_count   == other_cm.local_count   &&
  35. +        cm.required_args == other_cm.required_args &&
  36. +        cm.total_args    == other_cm.total_args    &&
  37. +        cm.splat         == other_cm.splat         &&
  38. +        cm.literals      == other_cm.literals      &&
  39. +        cm.lines         == other_cm.lines         &&
  40. +        cm.file          == other_cm.file          &&
  41. +        cm.local_names   == other_cm.local_names
  42. +      end
  43.      end
  44.    end
  45.  end
  46. diff --git a/spec/tags/19/ruby/core/method/eql_tags.txt b/spec/tags/19/ruby/core/method/eql_tags.txt
  47. index 37953dc..8f28f6b 100644
  48. --- a/spec/tags/19/ruby/core/method/eql_tags.txt
  49. +++ b/spec/tags/19/ruby/core/method/eql_tags.txt
  50. @@ -1,3 +1,2 @@
  51.  fails:Method#eql? returns true if a method was defined using the other one
  52. -fails:Method#eql? returns true for methods defined using the same block/proc
  53.  fails:Method#eql? returns true for the same method missing