Permalink
Browse files

Merge branch 'feature/function-composition' into develop

  • Loading branch information...
ralphbean committed Mar 21, 2012
2 parents b387fa4 + ff432f2 commit 5f46d506935c1ca9f97923d25b22ae89a9098fcb
Showing with 16 additions and 1 deletion.
  1. +11 −0 tests/test_js.py
  2. +5 −1 tw2/core/js.py
@@ -15,6 +15,17 @@ def test_js_function(self):
json = self.encode({"onLoad": js_function("do_something")("param")})
eq_(json, '{"onLoad": do_something(\\"param\\")}')
def test_js_function_composition(self):
f = js_function("f")
g = js_function("g")
h = js_function("h")
y = js_symbol("y")
obj = f(g(h("x", y)))
eq_(str(obj), """f(g(h("x", y)))""")
def test_js_symbol(self):
obj = self.encode({"onLoad": js_symbol("param")})
eq_(obj, '{"onLoad": param}')
@@ -223,10 +223,14 @@ def __call__(self, *args):
def __get_js_repr(self):
if self.__called:
args = self.__args
return '%s(%s)' % (
rep = '%s(%s)' % (
self.__name,
', '.join(imap(encoder.encode, args))
)
return rep\
.replace('\\"', '"')\
.replace("\\'", "'")\
.replace('\\n', '\n')
else:
return self.__name

0 comments on commit 5f46d50

Please sign in to comment.