Skip to content

Commit

Permalink
Make raw_input work - Issue skulpt#37
Browse files Browse the repository at this point in the history
This is Issue: 74 in Google Code

I added a completely new raw_input function even though it does
exactly the same as input() - but since input() is not a good
implementation, someone someday might come by and fix input()
and I don't want them breaking raw_input()

There is no unit test because prompt is not mocked.
  • Loading branch information
csev committed Jan 23, 2013
1 parent 7b5246f commit 4d6bce8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/builtin.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ Sk.builtin.getattr = function(obj, name, default_)
return ret;
};

Sk.builtin.raw_input = function(obj, name, default_)
{
var x = prompt(obj.v);
return new Sk.builtin.str(x);
};

Sk.builtin.input = function(obj, name, default_)
{
var x = prompt(obj.v);
Expand Down
1 change: 1 addition & 0 deletions src/builtindict.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Sk.builtins = {
'tuple': Sk.builtin.tuple,
'type': Sk.builtin.type,
'input': Sk.builtin.input,
'raw_input': Sk.builtin.raw_input,
/*'read': Sk.builtin.read,*/
'jseval': Sk.builtin.jseval,
'jsmillis': Sk.builtin.jsmillis,
Expand Down

0 comments on commit 4d6bce8

Please sign in to comment.