Skip to content

Commit

Permalink
when read-eval is off, return the code string instead of nil
Browse files Browse the repository at this point in the history
  • Loading branch information
alandipert committed May 4, 2012
1 parent 78c62ec commit c482970
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
lector (0.0.1)
lector (0.0.2)
citrus

GEM
Expand Down
2 changes: 2 additions & 0 deletions lib/lector/types.rb
Expand Up @@ -15,6 +15,8 @@ module Code
def val
if $_LECTOR_READ_EVAL
eval(code.to_s.slice(3..-2))
else
code.to_s.slice(3..-2)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/lector/reader_spec.rb
Expand Up @@ -94,10 +94,10 @@
end

context 'read-evaling' do
it "shouldn't eval the code" do
Lector::read_s("#='1+2'").should == nil
it "returns the code when read-eval is off" do
Lector::read_s("#='1+2'").should == '1+2'
end
it "should eval the code" do
it "evals the code when read-eval is on" do
Lector::read_s("#='1+2'", :read_eval => true).should == 3
end

Expand Down

0 comments on commit c482970

Please sign in to comment.