Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added doctests for with and parseInt #6

Merged
merged 1 commit into from
Jul 27, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions testsrc/doctests/parseint.doctest
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
js> parseInt
function parseInt() { [native code for parseInt, arity=2] }
js> parseInt("0");
0
js> parseInt("1")
1
js> parseInt("-1")
-1
js> parseInt(" 2")
2
js> parseInt("3then some other chars")
3
js> parseInt('0xF')
15
js> parseInt('0xf')
15
js> parseInt('010')
8
22 changes: 22 additions & 0 deletions testsrc/doctests/with.doctest
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
js> load('testsrc/doctests/util.js');

js> // when the variable is not in the with-object, it'll be set on the outer scope
js> (function() { with ({}) { var foo = 1; }; return foo; })()
1

js> // when the function is not in the with-object, it'll be set on the outer scope
js> (function() { with ({}) { function foo() { return 2; } }; return foo(); })()
2

js> // when the variable is in the with-object, it will be updated on the with-object
js> (function() { var obj = {foo:0}; with (obj) { var foo = 3; }; return obj.foo; })()
3

js> // functions declared inside with blocks are always bound to the closest enclosing function
js> (function() { function foo(){ return 0; }; with ({}) { function foo() { return 4; } }; return foo(); })()
4

js> // functions declared inside with blocks do not affect the properties of the with-obj
js> (function() { var obj = {foo:5}; with (obj) { function foo() { return 0; } }; return obj.foo; })()
5