Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

Commit

Permalink
Capitalization.
Browse files Browse the repository at this point in the history
  • Loading branch information
wavexx committed Aug 4, 2014
1 parent 78fcbc5 commit bf54e89
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
7 changes: 3 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Remote output is also transparently redirected locally, and since the
evaluation is performed through a persistent co-process, you can actually spawn
interpreters on different hosts through "ssh" efficiently.

``bond`` currently supports PHP, Perl, Javascript (Node.js) and Python itself.
``bond`` currently supports PHP, Perl, JavaScript (Node.js) and Python itself.


A simple example
Expand Down Expand Up @@ -280,11 +280,10 @@ Gotchas:
perl.call('$object->method', ...)
Javascript
JavaScript
----------

Javascript is supported through `Node.js <http://nodejs.org/>`_, which uses the
V8 engine.
JavaScript is supported through `Node.js <http://nodejs.org/>`_.

Requirements:

Expand Down
8 changes: 4 additions & 4 deletions bond/Javascript/__init__.py → bond/JavaScript/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import json


# Javascript constants
# JavaScript constants
JS_PROMPT = r'> '
JS_PRELUDE = 'prelude.js'
JS_WRAP_PREFIX = '__PY_BOND'


class Javascript(Bond):
LANG = 'Javascript'
class JavaScript(Bond):
LANG = 'JavaScript'

def __init__(self, cmd="nodejs", args="-e \"require('repl').start({ignoreUndefined: true, terminal: false})\"",
xargs="", cwd=None, env=os.environ, trans_except=False, timeout=None, logfile=None):
Expand All @@ -34,4 +34,4 @@ def __init__(self, cmd="nodejs", args="-e \"require('repl').start({ignoreUndefin
# start the inner repl
proc.sendline(r'{JS_WRAP_PREFIX}_start({trans_except});'.format(
JS_WRAP_PREFIX=JS_WRAP_PREFIX, trans_except=int(trans_except)))
super(Javascript, self).__init__(proc, trans_except)
super(JavaScript, self).__init__(proc, trans_except)
File renamed without changes.
42 changes: 21 additions & 21 deletions test/test_Javascript.py → test/test_JavaScript.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import print_function
import bond
from bond.Javascript import Javascript
from bond.JavaScript import JavaScript

def test_basic():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)
js.close()


def test_call_marshalling():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

js.eval_block(r'function test_str() { return "Hello world!"; }')
assert(str(js.call('test_str')) == "Hello world!")
Expand Down Expand Up @@ -51,7 +51,7 @@ def test_call_marshalling():


def test_call_simple():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

# define a function and call it
js.eval_block('function test_simple() { return "Hello world!"; }')
Expand All @@ -68,7 +68,7 @@ def test_call_simple():


def test_call_stm():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

# test the call interface with a normal function
js.eval_block('function copy(arg) { return arg; }')
Expand All @@ -85,7 +85,7 @@ def test_call_stm():


def test_call_error():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)
js.eval_block('function test_simple(arg) { return eval(arg); }')
ret = js.call('test_simple', 1)
assert(ret == 1)
Expand All @@ -104,7 +104,7 @@ def test_call_error():


def test_eval():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

# literal values
assert(js.eval('1') == 1)
Expand All @@ -124,7 +124,7 @@ def test_eval():


def test_eval_error():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

# try a correct statement before
assert(js.eval('1') == 1)
Expand All @@ -143,7 +143,7 @@ def test_eval_error():


def test_ser_err():
js = Javascript(timeout=1, trans_except=True)
js = JavaScript(timeout=1, trans_except=True)

# construct an unserializable type
js.eval_block(r'''
Expand Down Expand Up @@ -204,7 +204,7 @@ def test_ser_err():


def test_exception():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

# remote exception
js.eval_block('function exceptional() { throw new Error("an error") }')
Expand Down Expand Up @@ -241,13 +241,13 @@ def test_export():
def call_me():
return 42

js = Javascript(timeout=1)
js = JavaScript(timeout=1)
js.export(call_me, 'call_me')
assert(js.call('call_me') == 42)


def test_export_redef():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

def call_me():
return 42
Expand All @@ -262,7 +262,7 @@ def call_me():


def test_export_invalid():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

def call_me():
return 42
Expand All @@ -278,7 +278,7 @@ def call_me():


def test_export_recursive():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

# define a remote function
js.eval_block(r'function func_js(arg) { return arg + 1; }')
Expand Down Expand Up @@ -315,7 +315,7 @@ def test_export_ser_err():
def call_me(arg):
pass

js = Javascript(timeout=1)
js = JavaScript(timeout=1)
js.export(call_me, 'call_me')
js.eval_block('var fd = function(){};')

Expand All @@ -332,7 +332,7 @@ def call_me(arg):


def test_export_except():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

def gen_exception():
raise Exception("test")
Expand All @@ -351,7 +351,7 @@ def gen_exception():


def test_output_redirect():
js = Javascript(timeout=1)
js = JavaScript(timeout=1)

# stdout
js.eval_block(r'console.log("console.log: Hello world!");')
Expand All @@ -365,8 +365,8 @@ def test_output_redirect():


def test_trans_except():
js_trans = Javascript(timeout=1, trans_except=True)
js_not_trans = Javascript(timeout=1, trans_except=False)
js_trans = JavaScript(timeout=1, trans_except=True)
js_not_trans = JavaScript(timeout=1, trans_except=False)

code = r'''function func() { throw func; }'''

Expand Down Expand Up @@ -398,8 +398,8 @@ def test_trans_except():


def test_export_trans_except():
js_trans = Javascript(timeout=1, trans_except=True)
js_not_trans = Javascript(timeout=1, trans_except=False)
js_trans = JavaScript(timeout=1, trans_except=True)
js_not_trans = JavaScript(timeout=1, trans_except=False)

def call_me():
raise RuntimeError("a runtime error")
Expand Down

0 comments on commit bf54e89

Please sign in to comment.