Skip to content

Commit

Permalink
Renamed test file for (string-to-num). Added (gets) to standard library.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongough committed Mar 13, 2011
1 parent bea1f9f commit 5fcd1d3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
7 changes: 0 additions & 7 deletions examples/guess-the-number.scm
Expand Up @@ -5,13 +5,6 @@
end
"))

(define gets
(native_function "
Proc.new() do |arguments, interpreter|
$stdin.gets
end
"))

(define number (+ (rand 9) 1))

(display "\n\nI'm thinking of a number between 1 and 10,\n")
Expand Down
6 changes: 6 additions & 0 deletions lib/flea/standard_library/gets.scm
@@ -0,0 +1,6 @@
(define gets
(native_function "
Proc.new() do |arguments, interpreter|
$stdin.gets
end
"))
23 changes: 23 additions & 0 deletions spec/flea/standard_library/gets_spec.rb
@@ -0,0 +1,23 @@
require File.dirname(__FILE__) + '/../../spec_helper'

describe "Standard Library" do
describe "gets" do
before :each do
@interpreter = Flea::Interpreter.new
@old_stdin = $stdin
@buffer = StringIO.new
$stdin = @buffer
end

it "should get input from STDIN" do
@buffer.string = "test\n"
result = @interpreter.run('(gets)')
result.should == "test\n"
end

after :each do
$stdin = @old_stdin
end

end
end

0 comments on commit 5fcd1d3

Please sign in to comment.