[macruby-changes] [4601] DietRB/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 8 03:46:55 PDT 2010
Revision: 4601
http://trac.macosforge.org/projects/ruby/changeset/4601
Author: eloy.de.enige at gmail.com
Date: 2010-10-08 03:46:54 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Initialize Context with an empty state.
From: Eloy Duran <eloy.de.enige at gmail.com>
Modified Paths:
--------------
DietRB/trunk/lib/irb/context.rb
DietRB/trunk/spec/context_spec.rb
Modified: DietRB/trunk/lib/irb/context.rb
===================================================================
--- DietRB/trunk/lib/irb/context.rb 2010-10-08 10:46:45 UTC (rev 4600)
+++ DietRB/trunk/lib/irb/context.rb 2010-10-08 10:46:54 UTC (rev 4601)
@@ -1,14 +1,22 @@
module IRB
class Context
- attr_reader :object, :binding
+ attr_reader :object, :binding, :line, :source
def initialize(object)
- @object = object
+ @object = object
@binding = object.instance_eval { binding }
+ @line = 1
+ clear_buffer
end
def evaluate(source)
eval(source.to_s, @binding)
end
+
+ private
+
+ def clear_buffer
+ @source = Source.new
+ end
end
end
\ No newline at end of file
Modified: DietRB/trunk/spec/context_spec.rb
===================================================================
--- DietRB/trunk/spec/context_spec.rb 2010-10-08 10:46:45 UTC (rev 4600)
+++ DietRB/trunk/spec/context_spec.rb 2010-10-08 10:46:54 UTC (rev 4601)
@@ -15,6 +15,12 @@
eval("y", @context.binding).should == :ok
end
+ it "initializes with an 'empty' state" do
+ @context.line.should == 1
+ @context.source.should.be.instance_of IRB::Source
+ @context.source.to_s.should == ""
+ end
+
it "does not use the same binding copy of the top level object" do
lambda { eval("x", @context.binding) }.should.raise NameError
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/b2996f0e/attachment.html>
More information about the macruby-changes
mailing list