Skip to content

Commit e085591

Browse files
author
Paul Davis
committed
zomg Test before code. Its TDD!
Looking to add iteration of wrapped objects. Tests here. Code tomorrow.
1 parent cc21276 commit e085591

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

tests/test-iterate.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2009 Paul J. Davis <paul.joseph.davis@gmail.com>
2+
#
3+
# This file is part of the python-spidermonkey package released
4+
# under the MIT license.
5+
import t
6+
7+
class Foo(object):
8+
def __init__(self):
9+
self.blam = 8
10+
self.zing = "yessiree"
11+
12+
@t.glbl("zip", Foo())
13+
def test_iter_py(cx, glbl):
14+
js = """
15+
var ret = [];
16+
for(var v in zip) {
17+
ret.push(v)
18+
}
19+
ret;
20+
"""
21+
t.eq(cx.execute(js), ["blam", "zing"])
22+
23+
@t.cx()
24+
def test_iter_js(cx):
25+
ret = cx.execute('var f = {"foo": 1, "domino": "daily"}; f;')
26+
keys = [k for k in ret]
27+
keys.sort()
28+
t.eq(keys, ["domino", "foo"])
29+

0 commit comments

Comments
 (0)