|
|
|
@ -425,6 +425,34 @@ class TestJSInterpreter(unittest.TestCase):
|
|
|
|
|
self._test(jsi, [''], args=['', '-'])
|
|
|
|
|
self._test(jsi, [], args=['', ''])
|
|
|
|
|
|
|
|
|
|
def test_slice(self):
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice()}', [0, 1, 2, 3, 4, 5, 6, 7, 8])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(0)}', [0, 1, 2, 3, 4, 5, 6, 7, 8])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(5)}', [5, 6, 7, 8])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(99)}', [])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(-2)}', [7, 8])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(-99)}', [0, 1, 2, 3, 4, 5, 6, 7, 8])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(0, 0)}', [])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(1, 0)}', [])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(0, 1)}', [0])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(3, 6)}', [3, 4, 5])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(1, -1)}', [1, 2, 3, 4, 5, 6, 7])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(-1, 1)}', [])
|
|
|
|
|
self._test('function f(){return [0, 1, 2, 3, 4, 5, 6, 7, 8].slice(-3, -1)}', [6, 7])
|
|
|
|
|
self._test('function f(){return "012345678".slice()}', '012345678')
|
|
|
|
|
self._test('function f(){return "012345678".slice(0)}', '012345678')
|
|
|
|
|
self._test('function f(){return "012345678".slice(5)}', '5678')
|
|
|
|
|
self._test('function f(){return "012345678".slice(99)}', '')
|
|
|
|
|
self._test('function f(){return "012345678".slice(-2)}', '78')
|
|
|
|
|
self._test('function f(){return "012345678".slice(-99)}', '012345678')
|
|
|
|
|
self._test('function f(){return "012345678".slice(0, 0)}', '')
|
|
|
|
|
self._test('function f(){return "012345678".slice(1, 0)}', '')
|
|
|
|
|
self._test('function f(){return "012345678".slice(0, 1)}', '0')
|
|
|
|
|
self._test('function f(){return "012345678".slice(3, 6)}', '345')
|
|
|
|
|
self._test('function f(){return "012345678".slice(1, -1)}', '1234567')
|
|
|
|
|
self._test('function f(){return "012345678".slice(-1, 1)}', '')
|
|
|
|
|
self._test('function f(){return "012345678".slice(-3, -1)}', '67')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|
|
|
|
|