diff --git a/.travis.yml b/.travis.yml
old mode 100644
new mode 100755
index 792002cb..7b111cbd
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,11 @@
+dist: xenial
language: python
python:
- - "2.6"
- "2.7"
- - "3.3"
- - "3.4"
- "3.5"
- "3.6"
+ - "3.7"
+ - "3.8-dev"
# command to install dependencies!
install: "pip install -r requirements.txt && pip install numpy"
# command to run tests!
diff --git a/README.md b/README.md
index cd7a9997..dc72d685 100644
--- a/README.md
+++ b/README.md
@@ -64,15 +64,10 @@ Every feature of ECMA 5.1 is implemented (except of 'with' statement):
```
Unfortunately even though Js2Py can be generally used to translate huge Js files (over 50k lines long), in rare cases you may encounter some unexpected problems (like javascript calling a function with 300 arguments - python allows only 255). These problems are very hard to fix with current translation approach. I will try to implement an interpreter in near future which will hopefully fix all the edge cases.
-### JavaScript 'VirtualMachine' in Python
-
-If the translator for some reason does not work for you, you can try the new JS VM:
-
-```python
-from js2py.internals import seval
-seval.eval_js_vm(code)
-```
+#### Installation
+ pip install js2py
+
#### More advanced usage example
@@ -110,26 +105,95 @@ function bind(thisArg) { [python code] }
6
```
+You can also enable require support in JavaScript like this:
+
+```python
+>>> context = js2py.EvalJs(enable_require=True)
+>>> context.eval("require('esprima').parse('var a = 1')")
+```
+
+
+### JavaScript 'VirtualMachine' in Python
+
+As a fun experimental project I have also implemented a VM-based JavaScript
+(yes - there are 2 separate JS implementations in this repo). It is feature complete and faster than the translation based version.
+Below you can see a demo with a nice debug view (bytecode + execution sequence):
+
+```python
+>>> from js2py.internals import seval
+>>> seval.eval_js_vm("try {throw 3+3} catch (e) {console.log(e)}", debug=True)
+[LOAD_UNDEFINED(),
+ JUMP(4,),
+ LABEL(1,),
+ LOAD_UNDEFINED(),
+ POP(),
+ LOAD_NUMBER(3.0,),
+ LOAD_NUMBER(3.0,),
+ BINARY_OP('+',),
+ THROW(),
+ NOP(),
+ LABEL(2,),
+ LOAD_UNDEFINED(),
+ POP(),
+ LOAD('console',),
+ LOAD('e',),
+ LOAD_N_TUPLE(1,),
+ CALL_METHOD_DOT('log',),
+ NOP(),
+ LABEL(3,),
+ LOAD_UNDEFINED(),
+ NOP(),
+ LABEL(4,),
+ TRY_CATCH_FINALLY(1, 2, 'e', 3, False, 4)]
+
+0 LOAD_UNDEFINED()
+1 JUMP(4,)
+18 TRY_CATCH_FINALLY(1, 2, 'e', 3, False, 4)
+ ctx entry (from:2, to:9)
+ 2 LOAD_UNDEFINED()
+ 3 POP()
+ 4 LOAD_NUMBER(3.0,)
+ 5 LOAD_NUMBER(3.0,)
+ 6 BINARY_OP('+',)
+ 7 THROW()
+ ctx exit (js errors)
+ ctx entry (from:9, to:16)
+ 9 LOAD_UNDEFINED()
+ 10 POP()
+ 11 LOAD('console',)
+ 12 LOAD('e',)
+ 13 LOAD_N_TUPLE(1,)
+ 14 CALL_METHOD_DOT('log',)
+6
+ 15 NOP()
+ ctx exit (normal)
+
+```
+
+This is just a curiosity and I do not recommend using VM in practice (requires more polishing).
+
#### Limitations
-It has only 3 known limitations:
+There are 3 main limitations:
- "strict mode" is ignored
- with statement is not supported
- Indirect call to eval is treated as direct call to eval (hence always evals in local scope)
-Please let me know if you find any bugs - they will be fixed within 48 hours.
+They are generally not a big issue in practice.
+In practice more problematic are minor edge cases that unfortunately
+sometimes do happen. Please report a bug if you find one.
+
+Js2Py was able to successfully
+translate and run huge JS libraries like Babel (100k+ loc), esprima, crypto-js and more.
+You can try it yourself by importing any supported npm package via `js2py.require('your_package')`.
-#### Installation
- pip install js2py
-
-
#### Other Examples
@@ -180,26 +244,42 @@ Also, of course you can use Js2Py to parse (tree is the same as in esprima.js) a
#### Parsing:
```python
>>> js2py.parse_js('var $ = 5')
-{'body': [{'kind': 'var', 'declarations': [{'init': {'raw': None, 'type': u'Literal', 'value': 5.0}, 'type': u'VariableDeclarator', 'id': {'type': u'Identifier', 'name': u'$'}}], 'type': u'VariableDeclaration'}], 'type': u'Program'}
+{
+ "body": [
+ {
+ "declarations": [
+ {
+ "id": {
+ "name": "$",
+ "type": "Identifier"
+ },
+ "init": {
+ "raw": "5",
+ "type": "Literal",
+ "value": 5
+ },
+ "type": "VariableDeclarator"
+ }
+ ],
+ "kind": "var",
+ "type": "VariableDeclaration"
+ }
+ ],
+ "type": "Program"
+}
```
#### Translating:
```python
->>> print js2py.translate_js('var $ = 5')
-import js2py.pyjs, sys
-# Redefine builtin objects... Do you have a better idea?
-for m in sys.modules.keys():
- if m.startswith('js2py'):
- del sys.modules[m]
-del js2py.pyjs
-del js2py
+>>> print(js2py.translate_js('var $ = 5'))
from js2py.pyjs import *
# setting scope
var = Scope( JS_BUILTINS )
set_global_object(var)
+
# Code follows:
-var.registers([u'$'])
-var.put(u'$', Js(5.0))
+var.registers(['$'])
+var.put('$', Js(5.0))
```
diff --git a/js2py/base.py b/js2py/base.py
index 6043ed0e..52ab9ba6 100644
--- a/js2py/base.py
+++ b/js2py/base.py
@@ -5,6 +5,7 @@
from .translators.friendly_nodes import REGEXP_CONVERTER
from .utils.injector import fix_js_args
from types import FunctionType, ModuleType, GeneratorType, BuiltinFunctionType, MethodType, BuiltinMethodType
+from math import floor, log10
import traceback
try:
import numpy
@@ -50,7 +51,12 @@ def to_python(val):
return val.value
elif isinstance(val, PyObjectWrapper):
return val.__dict__['obj']
- return JsObjectWrapper(val)
+ elif isinstance(val, PyJsArray) and val.CONVERT_TO_PY_PRIMITIVES:
+ return to_list(val)
+ elif isinstance(val, PyJsObject) and val.CONVERT_TO_PY_PRIMITIVES:
+ return to_dict(val)
+ else:
+ return JsObjectWrapper(val)
def to_dict(js_obj,
@@ -255,6 +261,7 @@ class PyJs(object):
own = {}
GlobalObject = None
IS_CHILD_SCOPE = False
+ CONVERT_TO_PY_PRIMITIVES = False
value = None
buff = None
@@ -597,15 +604,7 @@ def to_string(self):
elif typ == 'Boolean':
return Js('true') if self.value else Js('false')
elif typ == 'Number': #or self.Class=='Number':
- if self.is_nan():
- return Js('NaN')
- elif self.is_infinity():
- sign = '-' if self.value < 0 else ''
- return Js(sign + 'Infinity')
- elif isinstance(self.value,
- long) or self.value.is_integer(): # dont print .0
- return Js(unicode(int(self.value)))
- return Js(unicode(self.value)) # accurate enough
+ return Js(unicode(js_dtoa(self.value)))
elif typ == 'String':
return self
else: #object
@@ -1040,7 +1039,7 @@ def PyJsComma(a, b):
return b
-from .internals.simplex import JsException as PyJsException
+from .internals.simplex import JsException as PyJsException, js_dtoa
import pyjsparser
pyjsparser.parser.ENABLE_JS2PY_ERRORS = lambda msg: MakeError('SyntaxError', msg)
@@ -1250,7 +1249,7 @@ def __repr__(self):
'Uint16Array', 'Int32Array', 'Uint32Array',
'Float32Array', 'Float64Array', 'Arguments'):
return repr(self.to_list())
- return repr(self.to_dict())
+ return str([(i[0], type(i[1]).__name__) for i in self.to_dict().items()])
def __len__(self):
return len(self._obj)
diff --git a/js2py/evaljs.py b/js2py/evaljs.py
index 3f5eeee5..ef4d7d95 100644
--- a/js2py/evaljs.py
+++ b/js2py/evaljs.py
@@ -116,36 +116,52 @@ def eval_js(js):
def eval_js6(js):
+ """Just like eval_js but with experimental support for js6 via babel."""
return eval_js(js6_to_js5(js))
def translate_js6(js):
+ """Just like translate_js but with experimental support for js6 via babel."""
return translate_js(js6_to_js5(js))
class EvalJs(object):
"""This class supports continuous execution of javascript under same context.
- >>> js = EvalJs()
- >>> js.execute('var a = 10;function f(x) {return x*x};')
- >>> js.f(9)
+ >>> ctx = EvalJs()
+ >>> ctx.execute('var a = 10;function f(x) {return x*x};')
+ >>> ctx.f(9)
81
- >>> js.a
+ >>> ctx.a
10
context is a python dict or object that contains python variables that should be available to JavaScript
For example:
- >>> js = EvalJs({'a': 30})
- >>> js.execute('var x = a')
- >>> js.x
+ >>> ctx = EvalJs({'a': 30})
+ >>> ctx.execute('var x = a')
+ >>> ctx.x
30
+ You can enable JS require function via enable_require. With this feature enabled you can use js modules
+ from npm, for example:
+ >>> ctx = EvalJs(enable_require=True)
+ >>> ctx.execute("var esprima = require('esprima');")
+ >>> ctx.execute("esprima.parse('var a = 1')")
+
You can run interactive javascript console with console method!"""
- def __init__(self, context={}):
+ def __init__(self, context={}, enable_require=False):
self.__dict__['_context'] = {}
exec (DEFAULT_HEADER, self._context)
self.__dict__['_var'] = self._context['var'].to_python()
+
+ if enable_require:
+ def _js_require_impl(npm_module_name):
+ from .node_import import require
+ from .base import to_python
+ return require(to_python(npm_module_name), context=self._context)
+ setattr(self._var, 'require', _js_require_impl)
+
if not isinstance(context, dict):
try:
context = context.__dict__
diff --git a/js2py/host/console.py b/js2py/host/console.py
index 3b44a479..50a08632 100644
--- a/js2py/host/console.py
+++ b/js2py/host/console.py
@@ -1,14 +1,15 @@
from ..base import *
-
@Js
def console():
pass
-
@Js
def log():
print(arguments[0])
-
console.put('log', log)
+console.put('debug', log)
+console.put('info', log)
+console.put('warn', log)
+console.put('error', log)
diff --git a/js2py/internals/base.py b/js2py/internals/base.py
index ec277c64..a02a2122 100644
--- a/js2py/internals/base.py
+++ b/js2py/internals/base.py
@@ -3,15 +3,19 @@
import datetime
-from desc import *
-from simplex import *
-from conversions import *
-import six
+from .desc import *
+from .simplex import *
+from .conversions import *
+
from pyjsparser import PyJsParser
-from itertools import izip
-from conversions import *
-from simplex import *
+import six
+if six.PY2:
+ from itertools import izip
+else:
+ izip = zip
+
+
def Type(obj):
diff --git a/js2py/internals/byte_trans.py b/js2py/internals/byte_trans.py
index 87fab4b4..e32bcb1e 100644
--- a/js2py/internals/byte_trans.py
+++ b/js2py/internals/byte_trans.py
@@ -1,8 +1,8 @@
-from code import Code
-from simplex import MakeError
-from opcodes import *
-from operations import *
-from trans_utils import *
+from .code import Code
+from .simplex import MakeError
+from .opcodes import *
+from .operations import *
+from .trans_utils import *
SPECIAL_IDENTIFIERS = {'true', 'false', 'this'}
@@ -465,10 +465,11 @@ def ObjectExpression(self, properties, **kwargs):
self.emit('LOAD_OBJECT', tuple(data))
def Program(self, body, **kwargs):
+ old_tape_len = len(self.exe.tape)
self.emit('LOAD_UNDEFINED')
self.emit(body)
# add function tape !
- self.exe.tape = self.function_declaration_tape + self.exe.tape
+ self.exe.tape = self.exe.tape[:old_tape_len] + self.function_declaration_tape + self.exe.tape[old_tape_len:]
def Pyimport(self, imp, **kwargs):
raise NotImplementedError(
@@ -735,17 +736,17 @@ def main():
#
# }
a.emit(d)
- print a.declared_vars
- print a.exe.tape
- print len(a.exe.tape)
+ print(a.declared_vars)
+ print(a.exe.tape)
+ print(len(a.exe.tape))
a.exe.compile()
def log(this, args):
- print args[0]
+ print(args[0])
return 999
- print a.exe.run(a.exe.space.GlobalObj)
+ print(a.exe.run(a.exe.space.GlobalObj))
if __name__ == '__main__':
diff --git a/js2py/internals/code.py b/js2py/internals/code.py
index 6bd6739f..9af0e602 100644
--- a/js2py/internals/code.py
+++ b/js2py/internals/code.py
@@ -1,16 +1,17 @@
-from opcodes import *
-from space import *
-from base import *
+from .opcodes import *
+from .space import *
+from .base import *
class Code:
'''Can generate, store and run sequence of ops representing js code'''
- def __init__(self, is_strict=False):
+ def __init__(self, is_strict=False, debug_mode=False):
self.tape = []
self.compiled = False
self.label_locs = None
self.is_strict = is_strict
+ self.debug_mode = debug_mode
self.contexts = []
self.current_ctx = None
@@ -22,6 +23,10 @@ def __init__(self, is_strict=False):
self.GLOBAL_THIS = None
self.space = None
+ # dbg
+ self.ctx_depth = 0
+
+
def get_new_label(self):
self._label_count += 1
return self._label_count
@@ -74,21 +79,35 @@ def execute_fragment_under_context(self, ctx, start_label, end_label):
# 0=normal, 1=return, 2=jump_outside, 3=errors
# execute_fragment_under_context returns:
# (return_value, typ, return_value/jump_loc/py_error)
- # ctx.stack must be len 1 and its always empty after the call.
+ # IMPARTANT: It is guaranteed that the length of the ctx.stack is unchanged.
'''
old_curr_ctx = self.current_ctx
+ self.ctx_depth += 1
+ old_stack_len = len(ctx.stack)
+ old_ret_len = len(self.return_locs)
+ old_ctx_len = len(self.contexts)
try:
self.current_ctx = ctx
return self._execute_fragment_under_context(
ctx, start_label, end_label)
except JsException as err:
- # undo the things that were put on the stack (if any)
- # don't worry, I know the recovery is possible through try statement and for this reason try statement
- # has its own context and stack so it will not delete the contents of the outer stack
- del ctx.stack[:]
+ if self.debug_mode:
+ self._on_fragment_exit("js errors")
+ # undo the things that were put on the stack (if any) to ensure a proper error recovery
+ del ctx.stack[old_stack_len:]
+ del self.return_locs[old_ret_len:]
+ del self.contexts[old_ctx_len :]
return undefined, 3, err
finally:
+ self.ctx_depth -= 1
self.current_ctx = old_curr_ctx
+ assert old_stack_len == len(ctx.stack)
+
+ def _get_dbg_indent(self):
+ return self.ctx_depth * ' '
+
+ def _on_fragment_exit(self, mode):
+ print(self._get_dbg_indent() + 'ctx exit (%s)' % mode)
def _execute_fragment_under_context(self, ctx, start_label, end_label):
start, end = self.label_locs[start_label], self.label_locs[end_label]
@@ -97,16 +116,20 @@ def _execute_fragment_under_context(self, ctx, start_label, end_label):
entry_level = len(self.contexts)
# for e in self.tape[start:end]:
# print e
-
+ if self.debug_mode:
+ print(self._get_dbg_indent() + 'ctx entry (from:%d, to:%d)' % (start, end))
while loc < len(self.tape):
- #print loc, self.tape[loc]
if len(self.contexts) == entry_level and loc >= end:
+ if self.debug_mode:
+ self._on_fragment_exit('normal')
assert loc == end
- assert len(ctx.stack) == (
- 1 + initial_len), 'Stack change must be equal to +1!'
+ delta_stack = len(ctx.stack) - initial_len
+ assert delta_stack == +1, 'Stack change must be equal to +1! got %d' % delta_stack
return ctx.stack.pop(), 0, None # means normal return
# execute instruction
+ if self.debug_mode:
+ print(self._get_dbg_indent() + str(loc), self.tape[loc])
status = self.tape[loc].eval(ctx)
# check status for special actions
@@ -116,9 +139,10 @@ def _execute_fragment_under_context(self, ctx, start_label, end_label):
if len(self.contexts) == entry_level:
# check if jumped outside of the fragment and break if so
if not start <= loc < end:
- assert len(ctx.stack) == (
- 1 + initial_len
- ), 'Stack change must be equal to +1!'
+ if self.debug_mode:
+ self._on_fragment_exit('jump outside loc:%d label:%d' % (loc, status))
+ delta_stack = len(ctx.stack) - initial_len
+ assert delta_stack == +1, 'Stack change must be equal to +1! got %d' % delta_stack
return ctx.stack.pop(), 2, status # jump outside
continue
@@ -137,7 +161,10 @@ def _execute_fragment_under_context(self, ctx, start_label, end_label):
# return: (None, None)
else:
if len(self.contexts) == entry_level:
- assert len(ctx.stack) == 1 + initial_len
+ if self.debug_mode:
+ self._on_fragment_exit('return')
+ delta_stack = len(ctx.stack) - initial_len
+ assert delta_stack == +1, 'Stack change must be equal to +1! got %d' % delta_stack
return undefined, 1, ctx.stack.pop(
) # return signal
return_value = ctx.stack.pop()
@@ -149,6 +176,8 @@ def _execute_fragment_under_context(self, ctx, start_label, end_label):
continue
# next instruction
loc += 1
+ if self.debug_mode:
+ self._on_fragment_exit('internal error - unexpected end of tape, will crash')
assert False, 'Remember to add NOP at the end!'
def run(self, ctx, starting_loc=0):
@@ -156,7 +185,8 @@ def run(self, ctx, starting_loc=0):
self.current_ctx = ctx
while loc < len(self.tape):
# execute instruction
- #print loc, self.tape[loc]
+ if self.debug_mode:
+ print(loc, self.tape[loc])
status = self.tape[loc].eval(ctx)
# check status for special actions
diff --git a/js2py/internals/constructors/jsfunction.py b/js2py/internals/constructors/jsfunction.py
index 9728fb38..d62731ac 100644
--- a/js2py/internals/constructors/jsfunction.py
+++ b/js2py/internals/constructors/jsfunction.py
@@ -42,6 +42,7 @@ def executable_code(code_str, space, global_context=True):
space.byte_generator.emit('LABEL', skip)
space.byte_generator.emit('NOP')
space.byte_generator.restore_state()
+
space.byte_generator.exe.compile(
start_loc=old_tape_len
) # dont read the code from the beginning, dont be stupid!
@@ -71,5 +72,5 @@ def _eval(this, args):
def log(this, args):
- print ' '.join(map(to_string, args))
+ print(' '.join(map(to_string, args)))
return undefined
diff --git a/js2py/internals/conversions.py b/js2py/internals/conversions.py
index b90a427d..8b2c7c30 100644
--- a/js2py/internals/conversions.py
+++ b/js2py/internals/conversions.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
# Type Conversions. to_type. All must return PyJs subclass instance
-from simplex import *
+from .simplex import *
def to_primitive(self, hint=None):
@@ -73,14 +73,7 @@ def to_string(self):
elif typ == 'Boolean':
return 'true' if self else 'false'
elif typ == 'Number': # or self.Class=='Number':
- if is_nan(self):
- return 'NaN'
- elif is_infinity(self):
- sign = '-' if self < 0 else ''
- return sign + 'Infinity'
- elif int(self) == self: # integer value!
- return unicode(int(self))
- return unicode(self) # todo make it print exactly like node.js
+ return js_dtoa(self)
else: # object
return to_string(to_primitive(self, 'String'))
diff --git a/js2py/internals/fill_space.py b/js2py/internals/fill_space.py
index 9aa9c4d2..329c8b28 100644
--- a/js2py/internals/fill_space.py
+++ b/js2py/internals/fill_space.py
@@ -1,29 +1,22 @@
from __future__ import unicode_literals
-from base import Scope
-from func_utils import *
-from conversions import *
+from .base import Scope
+from .func_utils import *
+from .conversions import *
import six
-from prototypes.jsboolean import BooleanPrototype
-from prototypes.jserror import ErrorPrototype
-from prototypes.jsfunction import FunctionPrototype
-from prototypes.jsnumber import NumberPrototype
-from prototypes.jsobject import ObjectPrototype
-from prototypes.jsregexp import RegExpPrototype
-from prototypes.jsstring import StringPrototype
-from prototypes.jsarray import ArrayPrototype
-import prototypes.jsjson as jsjson
-import prototypes.jsutils as jsutils
-
-from constructors import jsnumber
-from constructors import jsstring
-from constructors import jsarray
-from constructors import jsboolean
-from constructors import jsregexp
-from constructors import jsmath
-from constructors import jsobject
-from constructors import jsfunction
-from constructors import jsconsole
+from .prototypes.jsboolean import BooleanPrototype
+from .prototypes.jserror import ErrorPrototype
+from .prototypes.jsfunction import FunctionPrototype
+from .prototypes.jsnumber import NumberPrototype
+from .prototypes.jsobject import ObjectPrototype
+from .prototypes.jsregexp import RegExpPrototype
+from .prototypes.jsstring import StringPrototype
+from .prototypes.jsarray import ArrayPrototype
+from .prototypes import jsjson
+from .prototypes import jsutils
+
+from .constructors import jsnumber, jsstring, jsarray, jsboolean, jsregexp, jsmath, jsobject, jsfunction, jsconsole
+
def fill_proto(proto, proto_class, space):
@@ -155,7 +148,10 @@ def creator(this, args):
j = easy_func(creator, space)
j.name = unicode(typ)
- j.prototype = space.ERROR_TYPES[typ]
+
+ set_protected(j, 'prototype', space.ERROR_TYPES[typ])
+
+ set_non_enumerable(space.ERROR_TYPES[typ], 'constructor', j)
def new_create(args, space):
message = get_arg(args, 0)
@@ -178,6 +174,7 @@ def new_create(args, space):
setattr(space, err_type_name + u'Prototype', extra_err)
error_constructors[err_type_name] = construct_constructor(
err_type_name)
+
assert space.TypeErrorPrototype is not None
# RegExp
diff --git a/js2py/internals/func_utils.py b/js2py/internals/func_utils.py
index 3c0b8d57..58dfef9e 100644
--- a/js2py/internals/func_utils.py
+++ b/js2py/internals/func_utils.py
@@ -1,5 +1,5 @@
-from simplex import *
-from conversions import *
+from .simplex import *
+from .conversions import *
import six
if six.PY3:
diff --git a/js2py/internals/opcodes.py b/js2py/internals/opcodes.py
index 0f3127db..15c57ccd 100644
--- a/js2py/internals/opcodes.py
+++ b/js2py/internals/opcodes.py
@@ -1,5 +1,5 @@
-from operations import *
-from base import get_member, get_member_dot, PyJsFunction, Scope
+from .operations import *
+from .base import get_member, get_member_dot, PyJsFunction, Scope
class OP_CODE(object):
diff --git a/js2py/internals/operations.py b/js2py/internals/operations.py
index d9875088..35b90179 100644
--- a/js2py/internals/operations.py
+++ b/js2py/internals/operations.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
-from simplex import *
-from conversions import *
+from .simplex import *
+from .conversions import *
# ------------------------------------------------------------------------------
# Unary operations
diff --git a/js2py/internals/prototypes/jsstring.py b/js2py/internals/prototypes/jsstring.py
index b56246e2..be38802e 100644
--- a/js2py/internals/prototypes/jsstring.py
+++ b/js2py/internals/prototypes/jsstring.py
@@ -4,7 +4,7 @@
import re
from ..conversions import *
from ..func_utils import *
-from jsregexp import RegExpExec
+from .jsregexp import RegExpExec
DIGS = set(u'0123456789')
WHITE = u"\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF"
diff --git a/js2py/internals/seval.py b/js2py/internals/seval.py
index a3ed39c0..cd8ea50f 100644
--- a/js2py/internals/seval.py
+++ b/js2py/internals/seval.py
@@ -1,18 +1,21 @@
import pyjsparser
-from space import Space
-import fill_space
-from byte_trans import ByteCodeGenerator
-from code import Code
-from simplex import MakeError
-import sys
-sys.setrecursionlimit(100000)
+from .space import Space
+from . import fill_space
+from .byte_trans import ByteCodeGenerator
+from .code import Code
+from .simplex import *
pyjsparser.parser.ENABLE_JS2PY_ERRORS = lambda msg: MakeError(u'SyntaxError', unicode(msg))
-
-def eval_js_vm(js):
+def get_js_bytecode(js):
a = ByteCodeGenerator(Code())
+ d = pyjsparser.parse(js)
+ a.emit(d)
+ return a.exe.tape
+
+def eval_js_vm(js, debug=False):
+ a = ByteCodeGenerator(Code(debug_mode=debug))
s = Space()
a.exe.space = s
s.exe = a.exe
@@ -21,7 +24,10 @@ def eval_js_vm(js):
a.emit(d)
fill_space.fill_space(s, a)
- # print a.exe.tape
+ if debug:
+ from pprint import pprint
+ pprint(a.exe.tape)
+ print()
a.exe.compile()
return a.exe.run(a.exe.space.GlobalObj)
diff --git a/js2py/internals/simplex.py b/js2py/internals/simplex.py
index b05f6174..4cd247eb 100644
--- a/js2py/internals/simplex.py
+++ b/js2py/internals/simplex.py
@@ -1,6 +1,10 @@
from __future__ import unicode_literals
import six
-
+if six.PY3:
+ basestring = str
+ long = int
+ xrange = range
+ unicode = str
#Undefined
class PyJsUndefined(object):
@@ -75,7 +79,7 @@ def is_callable(self):
def is_infinity(self):
- return self == float('inf') or self == -float('inf')
+ return self == Infinity or self == -Infinity
def is_nan(self):
@@ -114,7 +118,7 @@ def __str__(self):
return self.mes.to_string().value
else:
if self.throw is not None:
- from conversions import to_string
+ from .conversions import to_string
return to_string(self.throw)
else:
return self.typ + ': ' + self.message
@@ -131,3 +135,26 @@ def value_from_js_exception(js_exception, space):
return js_exception.throw
else:
return space.NewError(js_exception.typ, js_exception.message)
+
+
+def js_dtoa(number):
+ if is_nan(number):
+ return u'NaN'
+ elif is_infinity(number):
+ if number > 0:
+ return u'Infinity'
+ return u'-Infinity'
+ elif number == 0.:
+ return u'0'
+ elif abs(number) < 1e-6 or abs(number) >= 1e21:
+ frac, exponent = unicode(repr(float(number))).split('e')
+ # Remove leading zeros from the exponent.
+ exponent = int(exponent)
+ return frac + ('e' if exponent < 0 else 'e+') + unicode(exponent)
+ elif abs(number) < 1e-4: # python starts to return exp notation while we still want the prec
+ frac, exponent = unicode(repr(float(number))).split('e-')
+ base = u'0.' + u'0' * (int(exponent) - 1) + frac.lstrip('-').replace('.', '')
+ return base if number > 0. else u'-' + base
+ elif isinstance(number, long) or number.is_integer(): # dont print .0
+ return unicode(int(number))
+ return unicode(repr(number)) # python representation should be equivalent.
diff --git a/js2py/internals/space.py b/js2py/internals/space.py
index 7283070c..cb2e77ae 100644
--- a/js2py/internals/space.py
+++ b/js2py/internals/space.py
@@ -1,5 +1,5 @@
-from base import *
-from simplex import *
+from .base import *
+from .simplex import *
class Space(object):
diff --git a/js2py/internals/trans_utils.py b/js2py/internals/trans_utils.py
index 235b46a8..f99c0994 100644
--- a/js2py/internals/trans_utils.py
+++ b/js2py/internals/trans_utils.py
@@ -1,3 +1,10 @@
+import six
+if six.PY3:
+ basestring = str
+ long = int
+ xrange = range
+ unicode = str
+
def to_key(literal_or_identifier):
''' returns string representation of this object'''
if literal_or_identifier['type'] == 'Identifier':
diff --git a/js2py/node_import.py b/js2py/node_import.py
index a49a1f51..605c4b3a 100644
--- a/js2py/node_import.py
+++ b/js2py/node_import.py
@@ -1,6 +1,6 @@
__all__ = ['require']
import subprocess, os, codecs, glob
-from .evaljs import translate_js
+from .evaljs import translate_js, DEFAULT_HEADER
import six
DID_INIT = False
DIRNAME = os.path.dirname(os.path.abspath(__file__))
@@ -15,7 +15,7 @@ def _init():
'node -v', shell=True, cwd=DIRNAME
) == 0, 'You must have node installed! run: brew install node'
assert subprocess.call(
- 'cd %s;npm install babel-core babel-cli babel-preset-es2015 babel-polyfill babelify browserify'
+ 'cd %s;npm install babel-core babel-cli babel-preset-es2015 babel-polyfill babelify browserify browserify-shim'
% repr(DIRNAME),
shell=True,
cwd=DIRNAME) == 0, 'Could not link required node_modules'
@@ -46,12 +46,18 @@ def _init():
'''
+def _get_module_py_name(module_name):
+ return module_name.replace('-', '_')
-def require(module_name, include_polyfill=False, update=False):
+def _get_module_var_name(module_name):
+ return _get_module_py_name(module_name).rpartition('/')[-1]
+
+
+def _get_and_translate_npm_module(module_name, include_polyfill=False, update=False):
assert isinstance(module_name, str), 'module_name must be a string!'
- py_name = module_name.replace('-', '_')
+ py_name = _get_module_py_name(module_name)
module_filename = '%s.py' % py_name
- var_name = py_name.rpartition('/')[-1]
+ var_name = _get_module_var_name(module_name)
if not os.path.exists(os.path.join(PY_NODE_MODULES_PATH,
module_filename)) or update:
_init()
@@ -77,7 +83,7 @@ def require(module_name, include_polyfill=False, update=False):
# convert the module
assert subprocess.call(
- '''node -e "(require('browserify')('./%s').bundle(function (err,data) {fs.writeFile('%s', require('babel-core').transform(data, {'presets': require('babel-preset-es2015')}).code, ()=>{});}))"'''
+ '''node -e "(require('browserify')('./%s').bundle(function (err,data) {if (err) {console.log(err);throw new Error(err);};fs.writeFile('%s', require('babel-core').transform(data, {'presets': require('babel-preset-es2015')}).code, ()=>{});}))"'''
% (in_file_name, out_file_name),
shell=True,
cwd=DIRNAME,
@@ -88,7 +94,8 @@ def require(module_name, include_polyfill=False, update=False):
"utf-8") as f:
js_code = f.read()
os.remove(os.path.join(DIRNAME, out_file_name))
-
+ if len(js_code) < 50:
+ raise RuntimeError("Candidate JS bundle too short - likely browserify issue.")
js_code += GET_FROM_GLOBALS_FUNC
js_code += ';var %s = getFromGlobals(%s);%s' % (
var_name, repr(module_name), var_name)
@@ -107,7 +114,32 @@ def require(module_name, include_polyfill=False, update=False):
os.path.join(PY_NODE_MODULES_PATH, module_filename), "r",
"utf-8") as f:
py_code = f.read()
+ return py_code
+
+
+def require(module_name, include_polyfill=False, update=False, context=None):
+ """
+ Installs the provided npm module, exports a js bundle via browserify, converts to ECMA 5.1 via babel and
+ finally translates the generated JS bundle to Python via Js2Py.
+ Returns a pure python object that behaves like the installed module. Nice!
- context = {}
+ :param module_name: Name of the npm module to require. For example 'esprima'.
+ :param include_polyfill: Whether the babel-polyfill should be included as part of the translation. May be needed
+ for some modules that use unsupported features.
+ :param update: Whether to force update the translation. Otherwise uses a cached version if exists.
+ :param context: Optional context in which the translated module should be executed in. If provided, the
+ header (js2py imports) will be skipped as it is assumed that the context already has all the necessary imports.
+ :return: The JsObjectWrapper containing the translated module object. Can be used like a standard python object.
+ """
+ py_code = _get_and_translate_npm_module(module_name, include_polyfill=include_polyfill, update=update)
+ # this is a bit hacky but we need to strip the default header from the generated code...
+ if context is not None:
+ if not py_code.startswith(DEFAULT_HEADER):
+ # new header version? retranslate...
+ assert not update, "Unexpected header."
+ py_code = _get_and_translate_npm_module(module_name, include_polyfill=include_polyfill, update=True)
+ assert py_code.startswith(DEFAULT_HEADER), "Unexpected header."
+ py_code = py_code[len(DEFAULT_HEADER):]
+ context = {} if context is None else context
exec (py_code, context)
- return context['var'][var_name].to_py()
+ return context['var'][_get_module_var_name(module_name)].to_py()
diff --git a/js2py/prototypes/jsfunction.py b/js2py/prototypes/jsfunction.py
index f9598a31..2ed417e0 100644
--- a/js2py/prototypes/jsfunction.py
+++ b/js2py/prototypes/jsfunction.py
@@ -6,8 +6,6 @@
xrange = range
unicode = str
-# todo fix apply and bind
-
class FunctionPrototype:
def toString():
@@ -41,6 +39,7 @@ def apply():
return this.call(obj, args)
def bind(thisArg):
+ arguments_ = arguments
target = this
if not target.is_callable():
raise this.MakeError(
@@ -48,5 +47,5 @@ def bind(thisArg):
if len(arguments) <= 1:
args = ()
else:
- args = tuple([arguments[e] for e in xrange(1, len(arguments))])
+ args = tuple([arguments_[e] for e in xrange(1, len(arguments_))])
return this.PyJsBoundFunction(target, thisArg, args)
diff --git a/js2py/translators/translating_nodes.py b/js2py/translators/translating_nodes.py
index 0ae93dd9..371c8ede 100644
--- a/js2py/translators/translating_nodes.py
+++ b/js2py/translators/translating_nodes.py
@@ -218,27 +218,36 @@ def ArrayExpression(type, elements): # todo fix null inside problem
def ObjectExpression(type, properties):
- name = inline_stack.require('Object')
+ name = None
elems = []
after = ''
for p in properties:
if p['kind'] == 'init':
elems.append('%s:%s' % Property(**p))
- elif p['kind'] == 'set':
- k, setter = Property(
- **p
- ) # setter is just a lval referring to that function, it will be defined in InlineStack automatically
- after += '%s.define_own_property(%s, {"set":%s, "configurable":True, "enumerable":True})\n' % (
- name, k, setter)
- elif p['kind'] == 'get':
- k, getter = Property(**p)
- after += '%s.define_own_property(%s, {"get":%s, "configurable":True, "enumerable":True})\n' % (
- name, k, getter)
else:
- raise RuntimeError('Unexpected object propery kind')
- obj = '%s = Js({%s})\n' % (name, ','.join(elems))
- inline_stack.define(name, obj + after)
- return name
+ if name is None:
+ name = inline_stack.require('Object')
+ if p['kind'] == 'set':
+ k, setter = Property(
+ **p
+ ) # setter is just a lval referring to that function, it will be defined in InlineStack automatically
+ after += '%s.define_own_property(%s, {"set":%s, "configurable":True, "enumerable":True})\n' % (
+ name, k, setter)
+ elif p['kind'] == 'get':
+ k, getter = Property(**p)
+ after += '%s.define_own_property(%s, {"get":%s, "configurable":True, "enumerable":True})\n' % (
+ name, k, getter)
+ else:
+ raise RuntimeError('Unexpected object propery kind')
+ definition = 'Js({%s})' % ','.join(elems)
+ if name is None:
+ return definition
+ body = '%s = %s\n' % (name, definition)
+ body += after
+ body += 'return %s\n' % name
+ code = 'def %s():\n%s' % (name, indent(body))
+ inline_stack.define(name, code)
+ return name + '()'
def Property(type, kind, key, computed, value, method, shorthand):
diff --git a/js2py/translators/translator.py b/js2py/translators/translator.py
index 66bf9abe..16ed5bdb 100644
--- a/js2py/translators/translator.py
+++ b/js2py/translators/translator.py
@@ -15,7 +15,7 @@
CP_NUMERIC_RE = re.compile(r'(?
- Strict Mode - Adding property to the arguments object successful
- under strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- "use strict";
-
- function _10_5_7_b_3_fun() {
- arguments[1] = 12;
- return arguments[0] === 30 && arguments[1] === 12;
- };
-
- return _10_5_7_b_3_fun(30);
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.5-7-b-4-s.js b/tests/test_cases/language/arguments-object/10.5-7-b-4-s.js
deleted file mode 100755
index 3f9f1ec6..00000000
--- a/tests/test_cases/language/arguments-object/10.5-7-b-4-s.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.5-7-b-4-s
-description: >
- Strict Mode - Deleting property of the arguments object successful
- under strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- "use strict";
-
- function _10_5_7_b_4_fun() {
- var _10_5_7_b_4_1 = arguments[0] === 30 && arguments[1] === 12;
- delete arguments[1];
- var _10_5_7_b_4_2 = arguments[0] === 30 && typeof arguments[1] === "undefined";
- return _10_5_7_b_4_1 && _10_5_7_b_4_2;
- };
- return _10_5_7_b_4_fun(30, 12);
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-10-c-ii-1-s.js b/tests/test_cases/language/arguments-object/10.6-10-c-ii-1-s.js
deleted file mode 100755
index 771355e5..00000000
--- a/tests/test_cases/language/arguments-object/10.6-10-c-ii-1-s.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-10-c-ii-1-s
-description: >
- arguments[i] remains same after changing actual parameters in
- strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- function foo(a,b,c)
- {
- 'use strict';
- a = 1; b = 'str'; c = 2.1;
- return (arguments[0] === 10 && arguments[1] === 'sss' && arguments[2] === 1);
- }
- return foo(10, 'sss', 1);
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-10-c-ii-1.js b/tests/test_cases/language/arguments-object/10.6-10-c-ii-1.js
deleted file mode 100755
index c9ad44df..00000000
--- a/tests/test_cases/language/arguments-object/10.6-10-c-ii-1.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-10-c-ii-1
-description: arguments[i] change with actual parameters
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- function foo(a,b,c)
- {
- a = 1; b = 'str'; c = 2.1;
- if(arguments[0] === 1 && arguments[1] === 'str' && arguments[2] === 2.1)
- return true;
- }
- return foo(10,'sss',1);
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-10-c-ii-2-s.js b/tests/test_cases/language/arguments-object/10.6-10-c-ii-2-s.js
deleted file mode 100755
index b39ec15b..00000000
--- a/tests/test_cases/language/arguments-object/10.6-10-c-ii-2-s.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-10-c-ii-2-s
-description: arguments[i] doesn't map to actual parameters in strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
-
- function foo(a,b,c)
- {
- 'use strict';
- arguments[0] = 1; arguments[1] = 'str'; arguments[2] = 2.1;
- return 10 === a && 'sss' === b && 1 === c;
- }
- return foo(10,'sss',1);
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-10-c-ii-2.js b/tests/test_cases/language/arguments-object/10.6-10-c-ii-2.js
deleted file mode 100755
index c1eee201..00000000
--- a/tests/test_cases/language/arguments-object/10.6-10-c-ii-2.js
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-10-c-ii-2
-description: arguments[i] map to actual parameter
-includes: [runTestCase.js]
----*/
-
-function testcase() {
-
- function foo(a,b,c)
- {
- arguments[0] = 1; arguments[1] = 'str'; arguments[2] = 2.1;
- if(1 === a && 'str' === b && 2.1 === c)
- return true;
- }
- return foo(10,'sss',1);
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-11-b-1.js b/tests/test_cases/language/arguments-object/10.6-11-b-1.js
deleted file mode 100755
index cd6949ce..00000000
--- a/tests/test_cases/language/arguments-object/10.6-11-b-1.js
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-11-b-1
-description: >
- Arguments Object has index property '0' as its own property, it
- shoulde be writable, enumerable, configurable and does not invoke
- the setter defined on Object.prototype[0] (Step 11.b)
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- try {
- var data = "data";
- var getFunc = function () {
- return data;
- };
-
- var setFunc = function (value) {
- data = value;
- };
-
- Object.defineProperty(Object.prototype, "0", {
- get: getFunc,
- set: setFunc,
- configurable: true
- });
-
- var argObj = (function () { return arguments })(1);
-
- var verifyValue = false;
- verifyValue = (argObj[0] === 1);
-
- var verifyEnumerable = false;
- for (var p in argObj) {
- if (p === "0" && argObj.hasOwnProperty("0")) {
- verifyEnumerable = true;
- }
- }
-
- var verifyWritable = false;
- argObj[0] = 1001;
- verifyWritable = (argObj[0] === 1001);
-
- var verifyConfigurable = false;
- delete argObj[0];
- verifyConfigurable = argObj.hasOwnProperty("0");
-
- return verifyValue && verifyWritable && verifyEnumerable && !verifyConfigurable && data === "data";
- } finally {
- delete Object.prototype[0];
- }
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-12-1.js b/tests/test_cases/language/arguments-object/10.6-12-1.js
deleted file mode 100755
index 539b49c6..00000000
--- a/tests/test_cases/language/arguments-object/10.6-12-1.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-12-1
-description: Accessing callee property of Arguments object is allowed
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- try
- {
- arguments.callee;
- return true;
- }
- catch (e) {
- }
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-12-2.js b/tests/test_cases/language/arguments-object/10.6-12-2.js
deleted file mode 100755
index 2376d2c4..00000000
--- a/tests/test_cases/language/arguments-object/10.6-12-2.js
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-12-2
-description: arguments.callee has correct attributes
-includes: [runTestCase.js]
----*/
-
-function testcase() {
-
- var desc = Object.getOwnPropertyDescriptor(arguments,"callee");
- if(desc.configurable === true &&
- desc.enumerable === false &&
- desc.writable === true &&
- desc.hasOwnProperty('get') == false &&
- desc.hasOwnProperty('put') == false)
- return true;
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-13-1.js b/tests/test_cases/language/arguments-object/10.6-13-1.js
deleted file mode 100755
index 3def632f..00000000
--- a/tests/test_cases/language/arguments-object/10.6-13-1.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-13-1
-description: Accessing caller property of Arguments object is allowed
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- try
- {
- arguments.caller;
- return true;
- }
- catch (e) {
- }
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-13-a-1.js b/tests/test_cases/language/arguments-object/10.6-13-a-1.js
deleted file mode 100755
index 9bedd01e..00000000
--- a/tests/test_cases/language/arguments-object/10.6-13-a-1.js
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-13-a-1
-description: >
- In non-strict mode, arguments object should have its own 'callee'
- property defined (Step 13.a)
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- try {
- Object.defineProperty(Object.prototype, "callee", {
- value: 1,
- writable: false,
- configurable: true
- });
-
- var argObj = (function () { return arguments })();
-
- var verifyValue = false;
- verifyValue = typeof argObj.callee === "function";
-
- var verifyWritable = false;
- argObj.callee = 1001;
- verifyWritable = (argObj.callee === 1001);
-
- var verifyEnumerable = false;
- for (var p in argObj) {
- if (p === "callee" && argObj.hasOwnProperty("callee")) {
- verifyEnumerable = true;
- }
- }
-
- var verifyConfigurable = false;
- delete argObj.callee;
- verifyConfigurable = argObj.hasOwnProperty("callee");
-
- return verifyValue && verifyWritable && !verifyEnumerable && !verifyConfigurable;
- } finally {
- delete Object.prototype.callee;
- }
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-13-a-2.js b/tests/test_cases/language/arguments-object/10.6-13-a-2.js
deleted file mode 100755
index 3cdce0d6..00000000
--- a/tests/test_cases/language/arguments-object/10.6-13-a-2.js
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-13-a-2
-description: A direct call to arguments.callee.caller should work
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- var called = false;
-
- function test1(flag) {
- if (flag!==true) {
- test2();
- } else {
- called = true;
- }
- }
-
- function test2() {
- if(arguments.callee.caller===undefined) {
- called=true; // Extension not supported - fake it
- } else {
- arguments.callee.caller(true);
- }
- }
-
- test1();
- return called;
-}
-
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-13-a-3.js b/tests/test_cases/language/arguments-object/10.6-13-a-3.js
deleted file mode 100755
index 86454f9c..00000000
--- a/tests/test_cases/language/arguments-object/10.6-13-a-3.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-13-a-3
-description: An indirect call to arguments.callee.caller should work
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- var called = false;
-
- function test1(flag) {
- if (flag!==true) {
- test2();
- } else {
- called = true;
- }
- }
-
- function test2() {
- if (arguments.callee.caller===undefined) {
- called = true; //Extension not supported - fake it
- } else {
- var explicit = arguments.callee.caller;
- explicit(true);
- }
- }
-
- test1();
- return called;
-}
-
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-13-b-1-s.js b/tests/test_cases/language/arguments-object/10.6-13-b-1-s.js
deleted file mode 100755
index c2666194..00000000
--- a/tests/test_cases/language/arguments-object/10.6-13-b-1-s.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-13-b-1-s
-description: >
- Accessing caller property of Arguments object throws TypeError in
- strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- 'use strict';
- try
- {
- arguments.caller;
- }
- catch (e) {
- if(e instanceof TypeError)
- return true;
- }
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-13-b-2-s.js b/tests/test_cases/language/arguments-object/10.6-13-b-2-s.js
deleted file mode 100755
index 8db28513..00000000
--- a/tests/test_cases/language/arguments-object/10.6-13-b-2-s.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-13-b-2-s
-description: arguments.caller exists in strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
-
- 'use strict';
- var desc = Object.getOwnPropertyDescriptor(arguments,"caller");
- return desc!== undefined;
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-13-b-3-s.js b/tests/test_cases/language/arguments-object/10.6-13-b-3-s.js
deleted file mode 100755
index c7b56413..00000000
--- a/tests/test_cases/language/arguments-object/10.6-13-b-3-s.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-13-b-3-s
-description: arguments.caller is non-configurable in strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
-
- 'use strict';
- var desc = Object.getOwnPropertyDescriptor(arguments,"caller");
-
- return (desc.configurable === false &&
- desc.enumerable === false &&
- desc.hasOwnProperty('value') == false &&
- desc.hasOwnProperty('writable') == false &&
- desc.hasOwnProperty('get') == true &&
- desc.hasOwnProperty('set') == true);
-
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-13-c-1-s.js b/tests/test_cases/language/arguments-object/10.6-13-c-1-s.js
deleted file mode 100755
index 4f25f14a..00000000
--- a/tests/test_cases/language/arguments-object/10.6-13-c-1-s.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-13-c-1-s
-description: >
- Accessing callee property of Arguments object throws TypeError in
- strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- 'use strict';
- try
- {
- arguments.callee;
- return false;
- }
- catch (e) {
- return (e instanceof TypeError);
- }
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-13-c-2-s.js b/tests/test_cases/language/arguments-object/10.6-13-c-2-s.js
deleted file mode 100755
index 125852d3..00000000
--- a/tests/test_cases/language/arguments-object/10.6-13-c-2-s.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-13-c-2-s
-description: arguments.callee is exists in strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
-
- 'use strict';
- var desc = Object.getOwnPropertyDescriptor(arguments,"callee");
- return desc !== undefined;
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-13-c-3-s.js b/tests/test_cases/language/arguments-object/10.6-13-c-3-s.js
deleted file mode 100755
index 6182ad0f..00000000
--- a/tests/test_cases/language/arguments-object/10.6-13-c-3-s.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-13-c-3-s
-description: arguments.callee is non-configurable in strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
-
- 'use strict';
- var desc = Object.getOwnPropertyDescriptor(arguments,"callee");
- return (desc.configurable === false &&
- desc.enumerable === false &&
- desc.hasOwnProperty('value') == false &&
- desc.hasOwnProperty('writable') == false &&
- desc.hasOwnProperty('get') == true &&
- desc.hasOwnProperty('set') == true);
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-14-1-s.js b/tests/test_cases/language/arguments-object/10.6-14-1-s.js
deleted file mode 100755
index f7f76465..00000000
--- a/tests/test_cases/language/arguments-object/10.6-14-1-s.js
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-14-1-s
-description: Strict Mode - 'callee' exists and 'caller' exists under strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- "use strict";
- var argObj = function () {
- return arguments;
- } ();
- return argObj.hasOwnProperty("callee") && argObj.hasOwnProperty("caller");
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-14-b-1-s.js b/tests/test_cases/language/arguments-object/10.6-14-b-1-s.js
deleted file mode 100755
index 488b443d..00000000
--- a/tests/test_cases/language/arguments-object/10.6-14-b-1-s.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-14-b-1-s
-description: >
- Strict Mode - [[Enumerable]] attribute value in 'caller' is false
- under strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- "use strict";
-
- var argObj = function () {
- return arguments;
- } ();
-
- var verifyEnumerable = false;
- for (var _10_6_14_b_1 in argObj) {
- if (argObj.hasOwnProperty(_10_6_14_b_1) && _10_6_14_b_1 === "caller") {
- verifyEnumerable = true;
- }
- }
- return !verifyEnumerable && argObj.hasOwnProperty("caller");
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-14-b-4-s.js b/tests/test_cases/language/arguments-object/10.6-14-b-4-s.js
deleted file mode 100755
index 8a8b54a7..00000000
--- a/tests/test_cases/language/arguments-object/10.6-14-b-4-s.js
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-14-b-4-s
-description: >
- Strict Mode - TypeError is thrown when accessing the [[Set]]
- attribute in 'caller' under strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- "use strict";
-
- var argObj = function () {
- return arguments;
- } ();
-
- try {
- argObj.caller = {};
- return false;
- } catch (e) {
- return e instanceof TypeError;
- }
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-14-c-1-s.js b/tests/test_cases/language/arguments-object/10.6-14-c-1-s.js
deleted file mode 100755
index 215e95db..00000000
--- a/tests/test_cases/language/arguments-object/10.6-14-c-1-s.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-14-c-1-s
-description: >
- Strict Mode - [[Enumerable]] attribute value in 'callee' is false
- under strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- "use strict";
-
- var argObj = function () {
- return arguments;
- } ();
-
- var verifyEnumerable = false;
- for (var _10_6_14_c_1 in argObj) {
- if (argObj.hasOwnProperty(_10_6_14_c_1) && _10_6_14_c_1 === "callee") {
- verifyEnumerable = true;
- }
- }
- return !verifyEnumerable && argObj.hasOwnProperty("callee");
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-14-c-4-s.js b/tests/test_cases/language/arguments-object/10.6-14-c-4-s.js
deleted file mode 100755
index 9f2baa39..00000000
--- a/tests/test_cases/language/arguments-object/10.6-14-c-4-s.js
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-14-c-4-s
-description: >
- Strict Mode - TypeError is thrown when accessing the [[Set]]
- attribute in 'callee' under strict mode
-flags: [onlyStrict]
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- "use strict";
-
- var argObj = function () {
- return arguments;
- } ();
-
- try {
- argObj.callee = {};
- return false;
- } catch (e) {
- return e instanceof TypeError;
- }
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-1gs.js b/tests/test_cases/language/arguments-object/10.6-1gs.js
deleted file mode 100755
index b4bf6b28..00000000
--- a/tests/test_cases/language/arguments-object/10.6-1gs.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-1gs
-description: >
- Strict Mode - arguments.callee cannot be accessed in a strict
- function, but does not throw an early error
-flags: [onlyStrict]
----*/
-
-"use strict";
-function f_10_6_1_gs(){
- return arguments.callee;
-}
diff --git a/tests/test_cases/language/arguments-object/10.6-2gs.js b/tests/test_cases/language/arguments-object/10.6-2gs.js
deleted file mode 100755
index d5782511..00000000
--- a/tests/test_cases/language/arguments-object/10.6-2gs.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-2gs
-description: >
- Strict Mode - arguments.callee cannot be accessed in a strict
- function
-negative: .
-flags: [onlyStrict]
----*/
-
-"use strict";
-function f_10_6_1_gs(){
- return arguments.callee;
-}
-f_10_6_1_gs();
diff --git a/tests/test_cases/language/arguments-object/10.6-5-1.js b/tests/test_cases/language/arguments-object/10.6-5-1.js
deleted file mode 100755
index 058a96c7..00000000
--- a/tests/test_cases/language/arguments-object/10.6-5-1.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-5-1
-description: >
- [[Prototype]] property of Arguments is set to Object prototype
- object
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- if(Object.getPrototypeOf(arguments) === Object.getPrototypeOf({}))
- return true;
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-6-1.js b/tests/test_cases/language/arguments-object/10.6-6-1.js
deleted file mode 100755
index 3ac99bd3..00000000
--- a/tests/test_cases/language/arguments-object/10.6-6-1.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-6-1
-description: "'length property of arguments object exists"
-includes: [runTestCase.js]
----*/
-
-function testcase() {
-
- var desc = Object.getOwnPropertyDescriptor(arguments,"length");
- return desc !== undefined
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-6-2.js b/tests/test_cases/language/arguments-object/10.6-6-2.js
deleted file mode 100755
index 6a1f56e4..00000000
--- a/tests/test_cases/language/arguments-object/10.6-6-2.js
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-6-2
-description: "'length' property of arguments object has correct attributes"
-includes: [runTestCase.js]
----*/
-
-function testcase() {
-
- var desc = Object.getOwnPropertyDescriptor(arguments,"length");
- if(desc.configurable === true &&
- desc.enumerable === false &&
- desc.writable === true )
- return true;
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-6-3.js b/tests/test_cases/language/arguments-object/10.6-6-3.js
deleted file mode 100755
index bd461a05..00000000
--- a/tests/test_cases/language/arguments-object/10.6-6-3.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-6-3
-description: >
- 'length' property of arguments object for 0 argument function
- exists
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- var arguments= undefined;
- return (function () {return arguments.length !== undefined})();
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-6-4.js b/tests/test_cases/language/arguments-object/10.6-6-4.js
deleted file mode 100755
index 1ece6916..00000000
--- a/tests/test_cases/language/arguments-object/10.6-6-4.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-6-4
-description: >
- 'length' property of arguments object for 0 argument function call
- is 0 even with formal parameters
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- var arguments= undefined;
- return (function (a,b,c) {return arguments.length === 0})();
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/10.6-7-1.js b/tests/test_cases/language/arguments-object/10.6-7-1.js
deleted file mode 100755
index ca2238d4..00000000
--- a/tests/test_cases/language/arguments-object/10.6-7-1.js
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2012 Ecma International. All rights reserved.
-// Ecma International makes this code available under the terms and conditions set
-// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
-// "Use Terms"). Any redistribution of this code must retain the above
-// copyright and this notice and otherwise comply with the Use Terms.
-
-/*---
-es5id: 10.6-7-1
-description: >
- Arguments Object has length as its own property and does not
- invoke the setter defined on Object.prototype.length (Step 7)
-includes: [runTestCase.js]
----*/
-
-function testcase() {
- try {
- var data = "data";
- var getFunc = function () {
- return 12;
- };
-
- var setFunc = function (value) {
- data = value;
- };
-
- Object.defineProperty(Object.prototype, "length", {
- get: getFunc,
- set: setFunc,
- configurable: true
- });
-
- var verifyValue = false;
- var argObj = (function () { return arguments })();
- verifyValue = (argObj.length === 0);
-
- var verifyWritable = false;
- argObj.length = 1001;
- verifyWritable = (argObj.length === 1001);
-
- var verifyEnumerable = false;
- for (var p in argObj) {
- if (p === "length") {
- verifyEnumerable = true;
- }
- }
-
- var verifyConfigurable = false;
- delete argObj.length;
- verifyConfigurable = argObj.hasOwnProperty("length");
-
- return verifyValue && verifyWritable && !verifyEnumerable && !verifyConfigurable && data === "data";
- } finally {
- delete Object.prototype.length;
- }
- }
-runTestCase(testcase);
diff --git a/tests/test_cases/language/arguments-object/S10.1.6_A1_T2.js b/tests/test_cases/language/arguments-object/S10.1.6_A1_T2.js
deleted file mode 100755
index 89e5ec69..00000000
--- a/tests/test_cases/language/arguments-object/S10.1.6_A1_T2.js
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- The activation object is initialised with a property with name arguments
- and attributes {DontDelete}
-es5id: 10.1.6_A1_T2
-description: Checking funtion which returns property "arguments"
----*/
-
-var ARG_STRING = "value of the argument property";
-
-function f1() {
- this.constructor.prototype.arguments = ARG_STRING;
- return arguments;
-}
-
-//CHECK#1
-if ((new f1(1,2,3,4,5)).length !== 5)
- $ERROR('#1: (new f1(1,2,3,4,5)).length===5, where f1 returns "arguments" that is set to "'+ ARG_STRING + '"');
-
-//CHECK#2
-if ((new f1(1,2,3,4,5))[3] !== 4)
- $ERROR('#2: (new f1(1,2,3,4,5))[3]===4, where f1 returns "arguments" that is set to "'+ ARG_STRING + '"');
-
-//CHECK#3
-var x = new f1(1,2,3,4,5);
-if (delete x[3] !== true)
- $ERROR('#3.1: Function parameters have attribute {DontDelete}');
-
-if (x[3] === 4)
- $ERROR('#3.2: Function parameters have attribute {DontDelete}');
diff --git a/tests/test_cases/language/arguments-object/S10.1.6_A1_T3.js b/tests/test_cases/language/arguments-object/S10.1.6_A1_T3.js
deleted file mode 100755
index 4349aa4a..00000000
--- a/tests/test_cases/language/arguments-object/S10.1.6_A1_T3.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- The activation object is initialised with a property with name arguments
- and attributes {DontDelete}
-es5id: 10.1.6_A1_T3
-description: Checking function which returns "this"
-flags: [noStrict]
----*/
-
-function f1() {
- if (delete arguments) {
- $ERROR("#1: Function parameters have attribute {DontDelete}" + arguments);
- }
- return arguments;
-}
-
-f1();
diff --git a/tests/test_cases/language/arguments-object/S10.6_A1.js b/tests/test_cases/language/arguments-object/S10.6_A1.js
deleted file mode 100755
index e1ff7841..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A1.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- When control enters an execution context for function code,
- an arguments object is created and initialised
-es5id: 10.6_A1
-description: Executing function which uses arguments object
----*/
-
-//CHECK#1
-function f1(){
- return arguments;
-}
-
-try{
- var x = f1();
-}
-catch(e){
- $ERROR("#1: arguments doesn't exists");
-}
-
-//CHECK#2
-var f2 = function(){
- return arguments;
-}
-
-try{
- var x = f2();
-}
-catch(e){
- $ERROR("#2: arguments doesn't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A2.js b/tests/test_cases/language/arguments-object/S10.6_A2.js
deleted file mode 100755
index f5b4d777..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A2.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- The value of the internal [[Prototype]] property of the
- created arguments object is the original Object prototype object, the one
- that is the initial value of Object.prototype
-es5id: 10.6_A2
-description: Checking arguments.constructor.prototype===Object.prototype
----*/
-
-//CHECK#1
-function f1(){
- return arguments.constructor.prototype;
-}
-try{
- if(f1() !== Object.prototype){
- $ERROR('#1: arguments.constructor.prototype === Object.prototype');
- }
-}
-catch(e){
- $ERROR("#1: arguments doesn't exists");
-}
-
-//CHECK#2
-var f2 = function(){return arguments.constructor.prototype;};
-try{
- if(f2() !== Object.prototype){
- $ERROR('#2: arguments.constructor.prototype === Object.prototype');
- }
-}
-catch(e){
- $ERROR("#2: arguments doesn't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A3_T1.js b/tests/test_cases/language/arguments-object/S10.6_A3_T1.js
deleted file mode 100755
index 8e4ad5c7..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A3_T1.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- A property is created with name callee with property
- attributes { DontEnum } and no others
-es5id: 10.6_A3_T1
-description: Checking existence of arguments.callee property
----*/
-
-//CHECK#1
-function f1(){
- return arguments.hasOwnProperty("callee");
-}
-try{
- if(f1() !== true){
- $ERROR("#1: arguments object doesn't contains property 'callee'");
- }
-}
-catch(e){
- $ERROR("#1: arguments object doesn't exists");
-}
-
-//CHECK#2
-var f2 = function(){return arguments.hasOwnProperty("callee");};
-try{
- if(f2() !== true){
- $ERROR("#2: arguments object doesn't contains property 'callee'");
- }
-}
-catch(e){
- $ERROR("#2: arguments object doesn't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A3_T2.js b/tests/test_cases/language/arguments-object/S10.6_A3_T2.js
deleted file mode 100755
index d06369d6..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A3_T2.js
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- A property is created with name callee with property
- attributes { DontEnum } and no others
-es5id: 10.6_A3_T2
-description: Checking if enumerating the arguments.callee property fails
----*/
-
-//CHECK#1
-function f1(){
- for(var x in arguments){
- if (x === "callee"){
- return false;
- }
- }
- return true;
-}
-
-try{
- if(!f1()){
- $ERROR("#1: A property callee don't have attribute { DontEnum }");
- }
-}
-catch(e){
- $ERROR("#1: arguments object don't exists");
-}
-
-//CHECK#2
-var f2 = function(){
- for(var x in arguments){
- if (x === "callee"){
- return false;
- }
- }
- return true;
-}
-
-try{
- if(!f2()){
- $ERROR("#2: A property callee don't have attribute { DontEnum }");
- }
-}
-catch(e){
- $ERROR("#2: arguments object don't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A3_T3.js b/tests/test_cases/language/arguments-object/S10.6_A3_T3.js
deleted file mode 100755
index 3d735cd3..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A3_T3.js
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- A property is created with name callee with property
- attributes { DontEnum } and no others
-es5id: 10.6_A3_T3
-description: Checking if deleting arguments.callee property fails
-flags: [noStrict]
----*/
-
-//CHECK#1
-function f1(){
- return (delete arguments.callee);
-}
-
-try{
- if(!f1()){
- $ERROR("#1: A property callee have attribute { DontDelete }");
- }
-}
-catch(e){
- $ERROR("#1: arguments object don't exists");
-}
-
-//CHECK#2
-var f2 = function(){
- return (delete arguments.callee);
-}
-
-try{
- if(!f2()){
- $ERROR("#2: A property callee have attribute { DontDelete }");
- }
-}
-catch(e){
- $ERROR("#2: arguments object don't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A3_T4.js b/tests/test_cases/language/arguments-object/S10.6_A3_T4.js
deleted file mode 100755
index 6be7774f..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A3_T4.js
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- A property is created with name callee with property
- attributes { DontEnum } and no others
-es5id: 10.6_A3_T4
-description: Overriding arguments.callee property
-flags: [noStrict]
----*/
-
-var str = "something different";
-//CHECK#1
-function f1(){
- arguments.callee = str;
- return arguments;
-}
-
-try{
- if(f1().callee !== str){
- $ERROR("#1: A property callee have attribute { ReadOnly }");
- }
-}
-catch(e){
- $ERROR("#1: arguments object don't exists");
-}
-
-//CHECK#2
-var f2 = function(){
- arguments.callee = str;
- return arguments;
- }
-try{
- if(f2().callee !== str){
- $ERROR("#2: A property callee have attribute { ReadOnly }");
- }
-}
-catch(e){
- $ERROR("#2: arguments object don't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A4.js b/tests/test_cases/language/arguments-object/S10.6_A4.js
deleted file mode 100755
index 0ed7598b..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A4.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- The initial value of the created property callee is the
- Function object being executed
-es5id: 10.6_A4
-description: Checking that arguments.callee === function object
-flags: [noStrict]
----*/
-
-//CHECK#1
-function f1(){
- return arguments.callee;
-}
-
-try{
- if(f1 !== f1()){
- $ERROR('#1: arguments.callee === f1');
- }
-}
-catch(e){
- $ERROR("#1: arguments object doesn't exists");
-}
-
-//CHECK#2
-var f2 = function(){return arguments.callee;};
-
-try{
- if(f2 !== f2()){
- $ERROR('#2: arguments.callee === f2');
- }
-}
-catch(e){
- $ERROR("#1: arguments object doesn't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A5_T1.js b/tests/test_cases/language/arguments-object/S10.6_A5_T1.js
deleted file mode 100755
index df172978..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A5_T1.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- A property is created with name length with property
- attributes { DontEnum } and no others
-es5id: 10.6_A5_T1
-description: Checking existence of arguments.length property
----*/
-
-//CHECK#1
-function f1(){
- return arguments.hasOwnProperty("length");
-}
-try{
- if(f1() !== true){
- $ERROR("#1: arguments object doesn't contains property 'length'");
- }
-}
-catch(e){
- $ERROR("#1: arguments object doesn't exists");
-}
-
-//CHECK#2
-var f2 = function(){return arguments.hasOwnProperty("length");};
-try{
- if(f2() !== true){
- $ERROR("#2: arguments object doesn't contains property 'length'");
- }
-}
-catch(e){
- $ERROR("#2: arguments object doesn't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A5_T2.js b/tests/test_cases/language/arguments-object/S10.6_A5_T2.js
deleted file mode 100755
index 47027610..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A5_T2.js
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- A property is created with name length with property
- attributes { DontEnum } and no others
-es5id: 10.6_A5_T2
-description: Checking if enumerating the arguments.length property fails
----*/
-
-//CHECK#1
-function f1(){
- for(var x in arguments){
- if (x === "length"){
- return false;
- }
- }
- return true;
-}
-
-try{
- if(!f1()){
- $ERROR("#1: A property length don't have attribute { DontEnum }");
- }
-}
-catch(e){
- $ERROR("#1: arguments object don't exists");
-}
-
-//CHECK#2
-var f2 = function(){
- for(var x in arguments){
- if (x === "length"){
- return false;
- }
- }
- return true;
-}
-
-try{
- if(!f2()){
- $ERROR("#2: A property length don't have attribute { DontEnum }");
- }
-}
-catch(e){
- $ERROR("#2: arguments object don't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A5_T3.js b/tests/test_cases/language/arguments-object/S10.6_A5_T3.js
deleted file mode 100755
index b2859558..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A5_T3.js
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- A property is created with name length with property
- attributes { DontEnum } and no others
-es5id: 10.6_A5_T3
-description: Checking if deleting arguments.length property fails
----*/
-
-//CHECK#1
-function f1(){
- return (delete arguments.length);
-}
-
-try{
- if(!f1()){
- $ERROR("#1: A property length have attribute { DontDelete }");
- }
-}
-catch(e){
- $ERROR("#1: arguments object don't exists");
-}
-
-//CHECK#2
-var f2 = function(){
- return (delete arguments.length);
-}
-
-try{
- if(!f2()){
- $ERROR("#2: A property length have attribute { DontDelete }");
- }
-}
-catch(e){
- $ERROR("#2: arguments object don't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A5_T4.js b/tests/test_cases/language/arguments-object/S10.6_A5_T4.js
deleted file mode 100755
index 4336f11c..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A5_T4.js
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- A property is created with name length with property
- attributes { DontEnum } and no others
-es5id: 10.6_A5_T4
-description: Overriding arguments.length property
----*/
-
-var str = "something different";
-//CHECK#1
-function f1(){
- arguments.length = str;
- return arguments;
-}
-
-try{
- if(f1().length !== str){
- $ERROR("#1: A property length have attribute { ReadOnly }");
- }
-}
-catch(e){
- $ERROR("#1: arguments object don't exists");
-}
-
-//CHECK#2
-var f2 = function(){
- arguments.length = str;
- return arguments;
- };
-try{
- if(f2().length !== str){
- $ERROR("#2: A property length have attribute { ReadOnly }");
- }
-}
-catch(e){
- $ERROR("#2: arguments object don't exists");
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A6.js b/tests/test_cases/language/arguments-object/S10.6_A6.js
deleted file mode 100755
index e0eaf30a..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A6.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: >
- The initial value of the created property length is the number
- of actual parameter values supplied by the caller
-es5id: 10.6_A6
-description: Create function, that returned arguments.length
----*/
-
-function f1(){
- return arguments.length;
-}
-
-//CHECK#1
-if(!(f1() === 0)){
- $ERROR('#1: argument.length === 0');
-}
-
-//CHECK#2
-if(!(f1(0) === 1)){
- $ERROR('#2: argument.length === 1');
-}
-
-//CHECK#3
-if(!(f1(0, 1) === 2)){
- $ERROR('#3: argument.length === 2');
-}
-
-//CHECK#4
-if(!(f1(0, 1, 2) === 3)){
- $ERROR('#4: argument.length === 3');
-}
-
-//CHECK#5
-if(!(f1(0, 1, 2, 3) === 4)){
- $ERROR('#5: argument.length === 4');
-}
-
-var f2 = function(){return arguments.length;};
-
-//CHECK#6
-if(!(f2() === 0)){
- $ERROR('#6: argument.length === 0');
-}
-
-//CHECK#7
-if(!(f2(0) === 1)){
- $ERROR('#7: argument.length === 1');
-}
-
-//CHECK#8
-if(!(f2(0, 1) === 2)){
- $ERROR('#8: argument.length === 2');
-}
-
-//CHECK#9
-if(!(f2(0, 1, 2) === 3)){
- $ERROR('#9: argument.length === 3');
-}
-
-//CHECK#10
-if(!(f2(0, 1, 2, 3) === 4)){
- $ERROR('#10: argument.length === 4');
-}
diff --git a/tests/test_cases/language/arguments-object/S10.6_A7.js b/tests/test_cases/language/arguments-object/S10.6_A7.js
deleted file mode 100755
index 7012e9f9..00000000
--- a/tests/test_cases/language/arguments-object/S10.6_A7.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2009 the Sputnik authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-
-/*---
-info: Get arguments of function
-es5id: 10.6_A7
-description: Use property arguments
----*/
-
-function f1() {
- return arguments;
-}
-
-//CHECK#1-5
-for(var i = 1; i < 5; i++){
-if (f1(1,2,3,4,5)[i] !== (i+1))
- $ERROR("#"+i+": Returning function's arguments work wrong, f1(1,2,3,4,5)["+i+"] !== "+(i+1));
-}
diff --git a/tests/test_cases/language/statements/function/S13.2.1_A1_T1.js b/tests/test_cases/language/statements/function/S13.2.1_A1_T1.js
index 5fb7a9a5..7ed84848 100755
--- a/tests/test_cases/language/statements/function/S13.2.1_A1_T1.js
+++ b/tests/test_cases/language/statements/function/S13.2.1_A1_T1.js
@@ -7,66 +7,3 @@ es5id: 13.2.1_A1_T1
description: Creating function calls 32 elements depth
---*/
-(function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){
- (function(){})()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
- })()
-})()