Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed test file for (string-to-num). Added (gets) to standard library.
- Loading branch information
1 parent
bea1f9f
commit 5fcd1d3
Showing
4 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(define gets | ||
(native_function " | ||
Proc.new() do |arguments, interpreter| | ||
$stdin.gets | ||
end | ||
")) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
File renamed without changes.