From 02d31af47c1cff892b519f7bab702490d697ee60 Mon Sep 17 00:00:00 2001
From: Eugine Blikh <bigbes@gmail.com>
Date: Tue, 16 Jul 2013 21:22:23 +0400
Subject: [PATCH] Rewrite big tests to lua (as much as possible)

---
 test/big/bitset.result                   |  84 +-
 test/big/bitset.test                     | 173 ++--
 test/big/hash.result                     | 638 ++++++++-------
 test/big/hash.test                       | 663 +++++++---------
 test/big/hash_multipart.result           | 144 +++-
 test/big/hash_multipart.test             |  97 ++-
 test/big/iterator.result                 |  94 +--
 test/big/iterator.test                   | 331 ++++----
 test/big/lua.result                      | 972 +++++------------------
 test/big/lua.test                        | 532 ++++++-------
 test/big/{ => lua}/bitset.lua            |   0
 test/big/{ => lua}/index_random_test.lua |   0
 test/big/{ => lua}/push.lua              |   0
 test/big/{ => lua}/utils.lua             |  42 +
 test/big/suite.ini                       |  10 +-
 test/big/tree_pk.result                  | 734 +++++++++++------
 test/big/tree_pk.test                    | 360 ++++-----
 test/big/tree_pk_multipart.result        | 260 ++++--
 test/big/tree_pk_multipart.test          | 291 +++----
 test/big/tree_variants.result            | 192 +++--
 test/big/tree_variants.test              |  81 +-
 21 files changed, 2793 insertions(+), 2905 deletions(-)
 rename test/big/{ => lua}/bitset.lua (100%)
 rename test/big/{ => lua}/index_random_test.lua (100%)
 rename test/big/{ => lua}/push.lua (100%)
 rename test/big/{ => lua}/utils.lua (62%)

diff --git a/test/big/bitset.result b/test/big/bitset.result
index 999adfbf34..84cb0b8ba5 100644
--- a/test/big/bitset.result
+++ b/test/big/bitset.result
@@ -4,21 +4,21 @@ dofile('utils.lua')
 dofile('bitset.lua')
 ---
 ...
-
-#-----------------------------------------------------------------------------#
-# BitsetIndex: insert/delete
-#-----------------------------------------------------------------------------#
-
+------------------------------------------------------------------------------
+-- BitsetIndex: insert/delete
+------------------------------------------------------------------------------
+---
+...
 test_insert_delete(128)
 ---
 sorted output
 $       1$
 ...
-
-#-----------------------------------------------------------------------------#
-# BitsetIndex: ALL
-#-----------------------------------------------------------------------------#
-
+------------------------------------------------------------------------------
+-- BitsetIndex: ALL
+------------------------------------------------------------------------------
+---
+...
 clear()
 ---
 ...
@@ -157,11 +157,11 @@ $     126$
 $     127$
 $     128$
 ...
-
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ALL_SET (single bit)
-#-----------------------------------------------------------------------------#
-
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ALL_SET (single bit)
+------------------------------------------------------------------------------
+---
+...
 dump(box.index.BITS_ALL_SET, 0)
 ---
 sorted output
@@ -382,11 +382,11 @@ dump(box.index.BITS_ALL_SET, 4294967296)
 ---
 error: 'Supplied key field type does not match index type: expected u32'
 ...
-
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ALL_SET (multiple bit)
-#-----------------------------------------------------------------------------#
-
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ALL_SET (multiple bit)
+------------------------------------------------------------------------------
+---
+...
 dump(box.index.BITS_ALL_SET, 3)
 ---
 sorted output
@@ -547,11 +547,11 @@ dump(box.index.BITS_ALL_SET, 4294967295)
 ---
 sorted output
 ...
-
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ALL_NOT_SET (single bit)
-#-----------------------------------------------------------------------------#
-
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ALL_NOT_SET (single bit)
+------------------------------------------------------------------------------
+---
+...
 dump(box.index.BITS_ALL_NOT_SET, 0)
 ---
 sorted output
@@ -824,11 +824,11 @@ dump(box.index.BITS_ALL_NOT_SET, 4294967296)
 ---
 error: 'Supplied key field type does not match index type: expected u32'
 ...
-
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ALL_NOT_SET (multiple bit)
-#-----------------------------------------------------------------------------#
-
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ALL_NOT_SET (multiple bit)
+------------------------------------------------------------------------------
+---
+...
 dump(box.index.BITS_ALL_NOT_SET, 3)
 ---
 sorted output
@@ -949,11 +949,11 @@ dump(box.index.BITS_ALL_NOT_SET, 4294967295)
 ---
 sorted output
 ...
-
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ANY_SET (single bit)
-#-----------------------------------------------------------------------------#
-
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ANY_SET (single bit)
+------------------------------------------------------------------------------
+---
+...
 dump(box.index.BITS_ANY_SET, 0)
 ---
 sorted output
@@ -1035,11 +1035,11 @@ dump(box.index.BITS_ANY_SET, 4294967296)
 ---
 error: 'Supplied key field type does not match index type: expected u32'
 ...
-
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ANY_SET (multiple bit)
-#-----------------------------------------------------------------------------#
-
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ANY_SET (multiple bit)
+------------------------------------------------------------------------------
+---
+...
 dump(box.index.BITS_ANY_SET, 7)
 ---
 sorted output
@@ -1396,3 +1396,7 @@ $     125$
 $     126$
 $     127$
 ...
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua 
+
+---
+...
diff --git a/test/big/bitset.test b/test/big/bitset.test
index 985301f056..dfcc2d90c5 100644
--- a/test/big/bitset.test
+++ b/test/big/bitset.test
@@ -1,108 +1,65 @@
-# encoding: utf-8
-#
-
-import os
-import shutil
-
-for file in ("utils.lua", "bitset.lua"):
-    src_path = os.path.join("big/", file)
-    dst_path = os.path.join(vardir, file)
-    shutil.copy(src_path, dst_path)
-    admin("dofile('%s')" % (file)) 
-    os.unlink(dst_path);
-
-print """
-#-----------------------------------------------------------------------------#
-# BitsetIndex: insert/delete
-#-----------------------------------------------------------------------------#
-""";
-
-admin("test_insert_delete(128)")
-
-print """
-#-----------------------------------------------------------------------------#
-# BitsetIndex: ALL
-#-----------------------------------------------------------------------------#
-""";
-
-admin("clear()")
-admin("fill(1, 128)")
-admin("dump(box.index.BITS_ALL)")
-
-print """
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ALL_SET (single bit)
-#-----------------------------------------------------------------------------#
-""";
-
-admin("dump(box.index.BITS_ALL_SET, 0)")
-
-admin("dump(box.index.BITS_ALL_SET, 1)")
-admin("dump(box.index.BITS_ALL_SET, 2)")
-admin("dump(box.index.BITS_ALL_SET, 8)")
-admin("dump(box.index.BITS_ALL_SET, 1073741824)")
-admin("dump(box.index.BITS_ALL_SET, 2147483648)")
-admin("dump(box.index.BITS_ALL_SET, 4294967296)")
-
-print """
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ALL_SET (multiple bit)
-#-----------------------------------------------------------------------------#
-""";
-
-admin("dump(box.index.BITS_ALL_SET, 3)")
-admin("dump(box.index.BITS_ALL_SET, 7)")
-admin("dump(box.index.BITS_ALL_SET, 31)")
-admin("dump(box.index.BITS_ALL_SET, 5)")
-admin("dump(box.index.BITS_ALL_SET, 10)")
-admin("dump(box.index.BITS_ALL_SET, 27)")
-admin("dump(box.index.BITS_ALL_SET, 341)")
-admin("dump(box.index.BITS_ALL_SET, 2147483649)")
-admin("dump(box.index.BITS_ALL_SET, 4294967295)")
-
-print """
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ALL_NOT_SET (single bit)
-#-----------------------------------------------------------------------------#
-""";
-
-admin("dump(box.index.BITS_ALL_NOT_SET, 0)")
-
-admin("dump(box.index.BITS_ALL_NOT_SET, 2)")
-admin("dump(box.index.BITS_ALL_NOT_SET, 8)")
-admin("dump(box.index.BITS_ALL_NOT_SET, 4294967296)")
-
-print """
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ALL_NOT_SET (multiple bit)
-#-----------------------------------------------------------------------------#
-""";
-
-admin("dump(box.index.BITS_ALL_NOT_SET, 3)")
-admin("dump(box.index.BITS_ALL_NOT_SET, 7)")
-admin("dump(box.index.BITS_ALL_NOT_SET, 10)")
-admin("dump(box.index.BITS_ALL_NOT_SET, 27)")
-admin("dump(box.index.BITS_ALL_NOT_SET, 85)")
-admin("dump(box.index.BITS_ALL_NOT_SET, 4294967295)")
-
-print """
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ANY_SET (single bit)
-#-----------------------------------------------------------------------------#
-""";
-
-admin("dump(box.index.BITS_ANY_SET, 0)")
-
-admin("dump(box.index.BITS_ANY_SET, 16)")
-admin("dump(box.index.BITS_ANY_SET, 128)")
-admin("dump(box.index.BITS_ANY_SET, 4294967296)")
-
-print """
-#-----------------------------------------------------------------------------#
-# BitsetIndex: BITS_ANY_SET (multiple bit)
-#-----------------------------------------------------------------------------#
-""";
-
-admin("dump(box.index.BITS_ANY_SET, 7)")
-admin("dump(box.index.BITS_ANY_SET, 84)")
-admin("dump(box.index.BITS_ANY_SET, 113)")
+dofile('utils.lua');
+dofile('bitset.lua');
+------------------------------------------------------------------------------
+-- BitsetIndex: insert/delete
+------------------------------------------------------------------------------;
+test_insert_delete(128);
+------------------------------------------------------------------------------
+-- BitsetIndex: ALL
+------------------------------------------------------------------------------;
+clear();
+fill(1, 128);
+dump(box.index.BITS_ALL);
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ALL_SET (single bit)
+------------------------------------------------------------------------------;
+dump(box.index.BITS_ALL_SET, 0);
+dump(box.index.BITS_ALL_SET, 1);
+dump(box.index.BITS_ALL_SET, 2);
+dump(box.index.BITS_ALL_SET, 8);
+dump(box.index.BITS_ALL_SET, 1073741824);
+dump(box.index.BITS_ALL_SET, 2147483648);
+dump(box.index.BITS_ALL_SET, 4294967296);
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ALL_SET (multiple bit)
+------------------------------------------------------------------------------;
+dump(box.index.BITS_ALL_SET, 3);
+dump(box.index.BITS_ALL_SET, 7);
+dump(box.index.BITS_ALL_SET, 31);
+dump(box.index.BITS_ALL_SET, 5);
+dump(box.index.BITS_ALL_SET, 10);
+dump(box.index.BITS_ALL_SET, 27);
+dump(box.index.BITS_ALL_SET, 341);
+dump(box.index.BITS_ALL_SET, 2147483649);
+dump(box.index.BITS_ALL_SET, 4294967295);
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ALL_NOT_SET (single bit)
+------------------------------------------------------------------------------;
+dump(box.index.BITS_ALL_NOT_SET, 0);
+dump(box.index.BITS_ALL_NOT_SET, 2);
+dump(box.index.BITS_ALL_NOT_SET, 8);
+dump(box.index.BITS_ALL_NOT_SET, 4294967296);
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ALL_NOT_SET (multiple bit)
+------------------------------------------------------------------------------;
+dump(box.index.BITS_ALL_NOT_SET, 3);
+dump(box.index.BITS_ALL_NOT_SET, 7);
+dump(box.index.BITS_ALL_NOT_SET, 10);
+dump(box.index.BITS_ALL_NOT_SET, 27);
+dump(box.index.BITS_ALL_NOT_SET, 85);
+dump(box.index.BITS_ALL_NOT_SET, 4294967295);
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ANY_SET (single bit)
+------------------------------------------------------------------------------;
+dump(box.index.BITS_ANY_SET, 0);
+dump(box.index.BITS_ANY_SET, 16);
+dump(box.index.BITS_ANY_SET, 128);
+dump(box.index.BITS_ANY_SET, 4294967296);
+------------------------------------------------------------------------------
+-- BitsetIndex: BITS_ANY_SET (multiple bit)
+------------------------------------------------------------------------------;
+dump(box.index.BITS_ANY_SET, 7);
+dump(box.index.BITS_ANY_SET, 84);
+dump(box.index.BITS_ANY_SET, 113);
+
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua 
diff --git a/test/big/hash.result b/test/big/hash.result
index 758b09e6e9..43ef6ff307 100644
--- a/test/big/hash.result
+++ b/test/big/hash.result
@@ -1,16 +1,17 @@
-
-#=============================================================================#
-# 32-bit hash tests
-#=============================================================================#
-
-
-#-----------------------------------------------------------------------------#
-# 32-bit hash insert fields tests
-#-----------------------------------------------------------------------------#
-
-
-# Insert valid fieds
-
+dofile('utils.lua')
+--=============================================================================
+== 32-bit hash tests
+--=============================================================================
+---
+...
+-------------------------------------------------------------------------------
+-- 32-bit hash insert fields tests
+-------------------------------------------------------------------------------
+---
+...
+-- Insert valid fieds
+---
+...
 box.space[10]:insert(0, 'value1 v1.0', 'value2 v1.0')
 ---
  - 0: {'value1 v1.0', 'value2 v1.0'}
@@ -27,21 +28,21 @@ box.space[10]:insert(3, 'value1 v1.0', 'value2 v1.0')
 ---
  - 3: {'value1 v1.0', 'value2 v1.0'}
 ...
-
-# Insert invalid fields
-
+-- Insert invalid fields
+---
+...
 box.space[10]:insert('invalid key', 'value1 v1.0', 'value2 v1.0')
 ---
 error: 'Supplied key field type does not match index type: expected NUM'
 ...
-
-#-----------------------------------------------------------------------------#
-# 32-bit hash replace fields tests
-#-----------------------------------------------------------------------------#
-
-
-# Replace valid fieds
-
+-------------------------------------------------------------------------------
+-- 32-bit hash replace fields tests
+-------------------------------------------------------------------------------
+---
+...
+-- Replace valid fieds
+---
+...
 box.space[10]:replace(3, 'value1 v1.31', 'value2 1.12')
 ---
  - 3: {'value1 v1.31', 'value2 1.12'}
@@ -54,21 +55,21 @@ box.space[10]:replace(2, 'value1 v1.43', 'value2 1.92')
 ---
  - 2: {'value1 v1.43', 'value2 1.92'}
 ...
-
-# Replace invalid fields
-
+-- Replace invalid fields
+---
+...
 box.space[10]:replace('invalid key', 'value1 v1.0', 'value2 v1.0')
 ---
 error: 'Supplied key field type does not match index type: expected NUM'
 ...
-
-#-----------------------------------------------------------------------------#
-# 32-bit hash select fields test
-#-----------------------------------------------------------------------------#
-
-
-# select by valid keys
-
+-------------------------------------------------------------------------------
+-- 32-bit hash select fields test
+-------------------------------------------------------------------------------
+---
+...
+-- select by valid keys
+---
+...
 box.space[10]:select(0, 0)
 ---
  - 0: {'value1 v1.0', 'value2 v1.0'}
@@ -91,9 +92,9 @@ box.space[10]:select(0, 4)
 box.space[10]:select(0, 5)
 ---
 ...
-
-# select by invalid keys
-
+-- select by invalid keys
+---
+...
 box.space[10]:select(0, 'invalid key')
 ---
 error: 'Supplied key field type does not match index type: expected u32'
@@ -102,14 +103,14 @@ box.space[10]:select(0, 1, 2)
 ---
 error: 'Invalid key part count (expected [0..1], got 2)'
 ...
-
-#-----------------------------------------------------------------------------#
-# 32-bit hash delete fields test
-#-----------------------------------------------------------------------------#
-
-
-# delete by valid keys
-
+-------------------------------------------------------------------------------
+-- 32-bit hash delete fields test
+-------------------------------------------------------------------------------
+---
+...
+-- delete by valid keys
+---
+...
 box.space[10]:delete(0)
 ---
  - 0: {'value1 v1.0', 'value2 v1.0'}
@@ -132,9 +133,9 @@ box.space[10]:delete(4)
 box.space[10]:delete(5)
 ---
 ...
-
-# delete by invalid keys
-
+-- delete by invalid keys
+---
+...
 box.space[10]:delete('invalid key')
 ---
 error: 'Supplied key field type does not match index type: expected u32'
@@ -143,19 +144,19 @@ box.space[10]:delete(1, 2)
 ---
 error: 'Invalid key part count in an exact match (expected 1, got 2)'
 ...
-
-#=============================================================================#
-# 64-bit hash tests
-#=============================================================================#
-
-
-#-----------------------------------------------------------------------------#
-# 64-bit hash inset fields tests
-#-----------------------------------------------------------------------------#
-
-
-# Insert valid fieds
-
+--=============================================================================
+-- 64-bit hash tests
+--=============================================================================
+---
+...
+-------------------------------------------------------------------------------
+-- 64-bit hash inset fields tests
+-------------------------------------------------------------------------------
+---
+...
+-- Insert valid fieds
+---
+...
 box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0')
 ---
  - 0: {'value1 v1.0', 'value2 v1.0'}
@@ -172,9 +173,9 @@ box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0')
 ---
  - 3: {'value1 v1.0', 'value2 v1.0'}
 ...
-
-# Insert invalid fields
-
+-- Insert invalid fields
+---
+...
 box.space[11]:insert(100, 'value1 v1.0', 'value2 v1.0')
 ---
 error: 'Supplied key field type does not match index type: expected NUM64'
@@ -195,14 +196,14 @@ box.space[11]:insert('invalid key', 'value1 v1.0', 'value2 v1.0')
 ---
 error: 'Supplied key field type does not match index type: expected NUM64'
 ...
-
-#-----------------------------------------------------------------------------#
-# 64-bit hash replace fields tests
-#-----------------------------------------------------------------------------#
-
-
-# Replace valid fieds
-
+-------------------------------------------------------------------------------
+-- 64-bit hash replace fields tests
+-------------------------------------------------------------------------------
+---
+...
+-- Replace valid fieds
+---
+...
 box.space[11]:replace(3ULL, 'value1 v1.31', 'value2 1.12')
 ---
  - 3: {'value1 v1.31', 'value2 1.12'}
@@ -215,9 +216,9 @@ box.space[11]:replace(2ULL, 'value1 v1.43', 'value2 1.92')
 ---
  - 2: {'value1 v1.43', 'value2 1.92'}
 ...
-
-# Replace invalid fields
-
+-- Replace invalid fields
+---
+...
 box.space[11]:replace(3, 'value1 v1.31', 'value2 1.12')
 ---
 error: 'Supplied key field type does not match index type: expected NUM64'
@@ -234,14 +235,14 @@ box.space[11]:replace('invalid key', 'value1 v1.0', 'value2 v1.0')
 ---
 error: 'Supplied key field type does not match index type: expected NUM64'
 ...
-
-#-----------------------------------------------------------------------------#
-# 64-bit hash select fields test
-#-----------------------------------------------------------------------------#
-
-
-# select by valid keys
-
+-------------------------------------------------------------------------------
+-- 64-bit hash select fields test
+-------------------------------------------------------------------------------
+---
+...
+-- select by valid keys
+---
+...
 box.space[11]:select(0, 0ULL)
 ---
  - 0: {'value1 v1.0', 'value2 v1.0'}
@@ -264,9 +265,9 @@ box.space[11]:select(0, 4ULL)
 box.space[11]:select(0, 5ULL)
 ---
 ...
-
-# select by valid NUM keys
-
+-- select by valid NUM keys
+---
+...
 box.space[11]:select(0, 0)
 ---
  - 0: {'value1 v1.0', 'value2 v1.0'}
@@ -289,9 +290,9 @@ box.space[11]:select(0, 4)
 box.space[11]:select(0, 5)
 ---
 ...
-
-# select by invalid keys
-
+-- select by invalid keys
+---
+...
 box.space[11]:select(0, 'invalid key')
 ---
 error: 'Supplied key field type does not match index type: expected u64'
@@ -300,14 +301,14 @@ box.space[11]:select(0, '00000001', '00000002')
 ---
 error: 'Invalid key part count (expected [0..1], got 2)'
 ...
-
-#-----------------------------------------------------------------------------#
-# 64-bit hash delete fields test
-#-----------------------------------------------------------------------------#
-
-
-# delete by valid keys
-
+-------------------------------------------------------------------------------
+-- 64-bit hash delete fields test
+-------------------------------------------------------------------------------
+---
+...
+-- delete by valid keys
+---
+...
 box.space[11]:delete(0ULL)
 ---
  - 0: {'value1 v1.0', 'value2 v1.0'}
@@ -346,9 +347,9 @@ box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0')
 ---
  - 3: {'value1 v1.0', 'value2 v1.0'}
 ...
-
-# delete by valid NUM keys
-
+-- delete by valid NUM keys
+---
+...
 box.space[11]:delete(0)
 ---
  - 0: {'value1 v1.0', 'value2 v1.0'}
@@ -371,9 +372,9 @@ box.space[11]:delete(4)
 box.space[11]:delete(5)
 ---
 ...
-
-# delete by invalid keys
-
+-- delete by invalid keys
+---
+...
 box.space[11]:delete('invalid key')
 ---
 error: 'Supplied key field type does not match index type: expected u64'
@@ -382,19 +383,19 @@ box.space[11]:delete('00000001', '00000002')
 ---
 error: 'Invalid key part count in an exact match (expected 1, got 2)'
 ...
-
-#=============================================================================#
-# String hash tests
-#=============================================================================#
-
-
-#-----------------------------------------------------------------------------#
-# String hash inset fields tests
-#-----------------------------------------------------------------------------#
-
-
-# Insert valid fieds
-
+--=============================================================================
+-- String hash tests
+--=============================================================================
+---
+...
+-------------------------------------------------------------------------------
+-- String hash inset fields tests
+-------------------------------------------------------------------------------
+---
+...
+-- Insert valid fieds
+---
+...
 box.space[12]:insert('key 0', 'value1 v1.0', 'value2 v1.0')
 ---
  - 'key 0': {'value1 v1.0', 'value2 v1.0'}
@@ -411,14 +412,14 @@ box.space[12]:insert('key 3', 'value1 v1.0', 'value2 v1.0')
 ---
  - 'key 3': {'value1 v1.0', 'value2 v1.0'}
 ...
-
-#-----------------------------------------------------------------------------#
-# String hash replace fields tests
-#-----------------------------------------------------------------------------#
-
-
-# Replace valid fieds
-
+-------------------------------------------------------------------------------
+-- String hash replace fields tests
+-------------------------------------------------------------------------------
+---
+...
+-- Replace valid fieds
+---
+...
 box.space[12]:replace('key 3', 'value1 v1.31', 'value2 1.12')
 ---
  - 'key 3': {'value1 v1.31', 'value2 1.12'}
@@ -431,14 +432,14 @@ box.space[12]:replace('key 2', 'value1 v1.43', 'value2 1.92')
 ---
  - 'key 2': {'value1 v1.43', 'value2 1.92'}
 ...
-
-#-----------------------------------------------------------------------------#
-# String hash select fields test
-#-----------------------------------------------------------------------------#
-
-
-# select by valid keys
-
+-------------------------------------------------------------------------------
+-- String hash select fields test
+-------------------------------------------------------------------------------
+---
+...
+-- select by valid keys
+---
+...
 box.space[12]:select(0, 'key 0')
 ---
  - 'key 0': {'value1 v1.0', 'value2 v1.0'}
@@ -461,21 +462,21 @@ box.space[12]:select(0, 'key 4')
 box.space[12]:select(0, 'key 5')
 ---
 ...
-
-# select by invalid keys
-
+-- select by invalid keys
+---
+...
 box.space[12]:select(0, 'key 1', 'key 2')
 ---
 error: 'Invalid key part count (expected [0..1], got 2)'
 ...
-
-#-----------------------------------------------------------------------------#
-# String hash delete fields test
-#-----------------------------------------------------------------------------#
-
-
-# delete by valid keys
-
+-------------------------------------------------------------------------------
+-- String hash delete fields test
+-------------------------------------------------------------------------------
+---
+...
+-- delete by valid keys
+---
+...
 box.space[12]:delete('key 0')
 ---
  - 'key 0': {'value1 v1.0', 'value2 v1.0'}
@@ -498,13 +499,16 @@ box.space[12]:delete('key 4')
 box.space[12]:delete('key 5')
 ---
 ...
-
-# delete by invalid keys
-
+-- delete by invalid keys
+---
+...
 box.space[12]:delete('key 1', 'key 2')
 ---
 error: 'Invalid key part count in an exact match (expected 1, got 2)'
 ...
+-- clean-up
+---
+...
 box.space[10]:truncate()
 ---
 ...
@@ -514,128 +518,230 @@ box.space[11]:truncate()
 box.space[12]:truncate()
 ---
 ...
+------------------------
+-- hash::replace tests
+------------------------
+---
+...
 box.space[21]:truncate()
 ---
 ...
-insert into t21 values (0, 0, 0, 0)
-Insert OK, 1 row affected
-insert into t21 values (1, 1, 1, 1)
-Insert OK, 1 row affected
-insert into t21 values (2, 2, 2, 2)
-Insert OK, 1 row affected
-replace into t21 values (1, 1, 1, 1)
-Replace OK, 1 row affected
-replace into t21 values (1, 10, 10, 10)
-Replace OK, 1 row affected
-replace into t21 values (1, 1, 1, 1)
-Replace OK, 1 row affected
-select * from t21 WHERE k0 = 10
-No match
-select * from t21 WHERE k1 = 10
-No match
-select * from t21 WHERE k2 = 10
-No match
-select * from t21 WHERE k3 = 10
-No match
-select * from t21 WHERE k0 = 1
-Found 1 tuple:
-[1, 1, 1, 1]
-select * from t21 WHERE k1 = 1
-Found 1 tuple:
-[1, 1, 1, 1]
-select * from t21 WHERE k2 = 1
-Found 1 tuple:
-[1, 1, 1, 1]
-select * from t21 WHERE k3 = 1
-Found 1 tuple:
-[1, 1, 1, 1]
-insert into t21 values (10, 10, 10, 10)
-Insert OK, 1 row affected
-delete from t21 WHERE k0 = 10
-Delete OK, 1 row affected
-select * from t21 WHERE k0 = 10
-No match
-select * from t21 WHERE k1 = 10
-No match
-select * from t21 WHERE k2 = 10
-No match
-select * from t21 WHERE k3 = 10
-No match
-insert into t21 values (1, 10, 10, 10)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 0'
-select * from t21 WHERE k0 = 10
-No match
-select * from t21 WHERE k1 = 10
-No match
-select * from t21 WHERE k2 = 10
-No match
-select * from t21 WHERE k3 = 10
-No match
-select * from t21 WHERE k0 = 1
-Found 1 tuple:
-[1, 1, 1, 1]
-replace into t21 values (10, 10, 10, 10)
-An error occurred: ER_TUPLE_NOT_FOUND, 'Tuple doesn't exist in index 0'
-select * from t21 WHERE k0 = 10
-No match
-select * from t21 WHERE k1 = 10
-No match
-select * from t21 WHERE k2 = 10
-No match
-select * from t21 WHERE k3 = 10
-No match
-insert into t21 values (10, 0, 10, 10)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 1'
-select * from t21 WHERE k0 = 10
-No match
-select * from t21 WHERE k1 = 10
-No match
-select * from t21 WHERE k2 = 10
-No match
-select * from t21 WHERE k3 = 10
-No match
-select * from t21 WHERE k1 = 0
-Found 1 tuple:
-[0, 0, 0, 0]
-replace into t21 values (2, 0, 10, 10)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 1'
-select * from t21 WHERE k0 = 10
-No match
-select * from t21 WHERE k1 = 10
-No match
-select * from t21 WHERE k2 = 10
-No match
-select * from t21 WHERE k3 = 10
-No match
-select * from t21 WHERE k1 = 0
-Found 1 tuple:
-[0, 0, 0, 0]
-insert into t21 values (10, 10, 10, 0)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 3'
-select * from t21 WHERE k0 = 10
-No match
-select * from t21 WHERE k1 = 10
-No match
-select * from t21 WHERE k2 = 10
-No match
-select * from t21 WHERE k3 = 10
-No match
-select * from t21 WHERE k3 = 0
-Found 1 tuple:
-[0, 0, 0, 0]
-replace into t21 values (2, 10, 10, 0)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 3'
-select * from t21 WHERE k0 = 10
-No match
-select * from t21 WHERE k1 = 10
-No match
-select * from t21 WHERE k2 = 10
-No match
-select * from t21 WHERE k3 = 10
-No match
-select * from t21 WHERE k3 = 0
-Found 1 tuple:
-[0, 0, 0, 0]
+box.space[21]:insert(0, 0, 0, 0)
+---
+ - 0: {0, 0, 0}
+...
+box.space[21]:insert(1, 1, 1, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.space[21]:insert(2, 2, 2, 2)
+---
+ - 2: {2, 2, 2}
+...
+-- OK
+---
+...
+box.replace_if_exists(21, 1, 1, 1, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.replace_if_exists(21, 1, 10, 10, 10)
+---
+ - 1: {10, 10, 10}
+...
+box.replace_if_exists(21, 1, 1, 1, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.space[21]:select(0, 10)
+---
+...
+box.space[21]:select(1, 10)
+---
+...
+box.space[21]:select(2, 10)
+---
+...
+box.space[21]:select(3, 10)
+---
+...
+box.space[21]:select(0, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.space[21]:select(1, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.space[21]:select(2, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.space[21]:select(3, 1)
+---
+ - 1: {1, 1, 1}
+...
+-- OK
+---
+...
+box.space[21]:insert(10, 10, 10, 10)
+---
+ - 10: {10, 10, 10}
+...
+box.space[21]:delete(10)
+---
+ - 10: {10, 10, 10}
+...
+box.space[21]:select(0, 10)
+---
+...
+box.space[21]:select(1, 10)
+---
+...
+box.space[21]:select(2, 10)
+---
+...
+box.space[21]:select(3, 10)
+---
+...
+-- TupleFound (primary key)
+---
+...
+box.space[21]:insert(1, 10, 10, 10)
+---
+error: 'Duplicate key exists in unique index 0'
+...
+box.space[21]:select(0, 10)
+---
+...
+box.space[21]:select(1, 10)
+---
+...
+box.space[21]:select(2, 10)
+---
+...
+box.space[21]:select(3, 10)
+---
+...
+box.space[21]:select(0, 1)
+---
+ - 1: {1, 1, 1}
+...
+-- TupleNotFound (primary key)
+---
+...
+box.replace_if_exists(21, 10, 10, 10, 10)
+---
+error: 'Tuple doesn''t exist in index 0'
+...
+box.space[21]:select(0, 10)
+---
+...
+box.space[21]:select(1, 10)
+---
+...
+box.space[21]:select(2, 10)
+---
+...
+box.space[21]:select(3, 10)
+---
+...
+-- TupleFound (key --1)
+---
+...
+box.space[21]:insert(10, 0, 10, 10)
+---
+error: 'Duplicate key exists in unique index 1'
+...
+box.space[21]:select(0, 10)
+---
+...
+box.space[21]:select(1, 10)
+---
+...
+box.space[21]:select(2, 10)
+---
+...
+box.space[21]:select(3, 10)
+---
+...
+box.space[21]:select(1, 0)
+---
+ - 0: {0, 0, 0}
+...
+-- TupleFound (key --1)
+---
+...
+box.replace_if_exists(21, 2, 0, 10, 10)
+---
+error: 'Duplicate key exists in unique index 1'
+...
+box.space[21]:select(0, 10)
+---
+...
+box.space[21]:select(1, 10)
+---
+...
+box.space[21]:select(2, 10)
+---
+...
+box.space[21]:select(3, 10)
+---
+...
+box.space[21]:select(1, 0)
+---
+ - 0: {0, 0, 0}
+...
+-- TupleFound (key --3)
+---
+...
+box.space[21]:insert(10, 10, 10, 0)
+---
+error: 'Duplicate key exists in unique index 3'
+...
+box.space[21]:select(0, 10)
+---
+...
+box.space[21]:select(1, 10)
+---
+...
+box.space[21]:select(2, 10)
+---
+...
+box.space[21]:select(3, 10)
+---
+...
+box.space[21]:select(3, 0)
+---
+ - 0: {0, 0, 0}
+...
+-- TupleFound (key --3)
+---
+...
+box.replace_if_exists(21, 2, 10, 10, 0)
+---
+error: 'Duplicate key exists in unique index 3'
+...
+box.space[21]:select(0, 10)
+---
+...
+box.space[21]:select(1, 10)
+---
+...
+box.space[21]:select(2, 10)
+---
+...
+box.space[21]:select(3, 10)
+---
+...
+box.space[21]:select(3, 0)
+---
+ - 0: {0, 0, 0}
+...
 box.space[21]:truncate()
 ---
 ...
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
+
+---
+...
diff --git a/test/big/hash.test b/test/big/hash.test
index 76b5b153e6..52d6fc24c7 100644
--- a/test/big/hash.test
+++ b/test/big/hash.test
@@ -1,377 +1,286 @@
-# encoding: utf-8
-#
-
-print """
-#=============================================================================#
-# 32-bit hash tests
-#=============================================================================#
-"""
-
-print """
-#-----------------------------------------------------------------------------#
-# 32-bit hash insert fields tests
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# Insert valid fieds
-"""
-admin("box.space[10]:insert(0, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[10]:insert(1, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[10]:insert(2, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[10]:insert(3, 'value1 v1.0', 'value2 v1.0')")
-
-print """
-# Insert invalid fields
-"""
-admin("box.space[10]:insert('invalid key', 'value1 v1.0', 'value2 v1.0')")
-
-
-print """
-#-----------------------------------------------------------------------------#
-# 32-bit hash replace fields tests
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# Replace valid fieds
-"""
-admin("box.space[10]:replace(3, 'value1 v1.31', 'value2 1.12')")
-admin("box.space[10]:replace(1, 'value1 v1.32', 'value2 1.72')")
-admin("box.space[10]:replace(2, 'value1 v1.43', 'value2 1.92')")
-
-print """
-# Replace invalid fields
-"""
-admin("box.space[10]:replace('invalid key', 'value1 v1.0', 'value2 v1.0')")
-
-
-print """
-#-----------------------------------------------------------------------------#
-# 32-bit hash select fields test
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# select by valid keys
-"""
-admin("box.space[10]:select(0, 0)")
-admin("box.space[10]:select(0, 1)")
-admin("box.space[10]:select(0, 2)")
-admin("box.space[10]:select(0, 3)")
-admin("box.space[10]:select(0, 4)")
-admin("box.space[10]:select(0, 5)")
-
-print """
-# select by invalid keys
-"""
-admin("box.space[10]:select(0, 'invalid key')")
-admin("box.space[10]:select(0, 1, 2)")
-
-
-print """
-#-----------------------------------------------------------------------------#
-# 32-bit hash delete fields test
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# delete by valid keys
-"""
-admin("box.space[10]:delete(0)")
-admin("box.space[10]:delete(1)")
-admin("box.space[10]:delete(2)")
-admin("box.space[10]:delete(3)")
-admin("box.space[10]:delete(4)")
-admin("box.space[10]:delete(5)")
-
-print """
-# delete by invalid keys
-"""
-admin("box.space[10]:delete('invalid key')")
-admin("box.space[10]:delete(1, 2)")
-
-
-print """
-#=============================================================================#
-# 64-bit hash tests
-#=============================================================================#
-"""
-
-print """
-#-----------------------------------------------------------------------------#
-# 64-bit hash inset fields tests
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# Insert valid fieds
-"""
-admin("box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0')")
-
-print """
-# Insert invalid fields
-"""
-admin("box.space[11]:insert(100, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[11]:insert(101, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[11]:insert(102, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[11]:insert(103, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[11]:insert('invalid key', 'value1 v1.0', 'value2 v1.0')")
-
-print """
-#-----------------------------------------------------------------------------#
-# 64-bit hash replace fields tests
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# Replace valid fieds
-"""
-admin("box.space[11]:replace(3ULL, 'value1 v1.31', 'value2 1.12')")
-admin("box.space[11]:replace(1ULL, 'value1 v1.32', 'value2 1.72')")
-admin("box.space[11]:replace(2ULL, 'value1 v1.43', 'value2 1.92')")
-
-print """
-# Replace invalid fields
-"""
-admin("box.space[11]:replace(3, 'value1 v1.31', 'value2 1.12')")
-admin("box.space[11]:replace(1, 'value1 v1.32', 'value2 1.72')")
-admin("box.space[11]:replace(2, 'value1 v1.43', 'value2 1.92')")
-admin("box.space[11]:replace('invalid key', 'value1 v1.0', 'value2 v1.0')")
-
-print """
-#-----------------------------------------------------------------------------#
-# 64-bit hash select fields test
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# select by valid keys
-"""
-admin("box.space[11]:select(0, 0ULL)")
-admin("box.space[11]:select(0, 1ULL)")
-admin("box.space[11]:select(0, 2ULL)")
-admin("box.space[11]:select(0, 3ULL)")
-admin("box.space[11]:select(0, 4ULL)")
-admin("box.space[11]:select(0, 5ULL)")
-
-print """
-# select by valid NUM keys
-"""
-admin("box.space[11]:select(0, 0)")
-admin("box.space[11]:select(0, 1)")
-admin("box.space[11]:select(0, 2)")
-admin("box.space[11]:select(0, 3)")
-admin("box.space[11]:select(0, 4)")
-admin("box.space[11]:select(0, 5)")
-
-print """
-# select by invalid keys
-"""
-admin("box.space[11]:select(0, 'invalid key')")
-admin("box.space[11]:select(0, '00000001', '00000002')")
-
-print """
-#-----------------------------------------------------------------------------#
-# 64-bit hash delete fields test
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# delete by valid keys
-"""
-admin("box.space[11]:delete(0ULL)")
-admin("box.space[11]:delete(1ULL)")
-admin("box.space[11]:delete(2ULL)")
-admin("box.space[11]:delete(3ULL)")
-admin("box.space[11]:delete(4ULL)")
-admin("box.space[11]:delete(5ULL)")
-
-admin("box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0')")
-
-print """
-# delete by valid NUM keys
-"""
-admin("box.space[11]:delete(0)")
-admin("box.space[11]:delete(1)")
-admin("box.space[11]:delete(2)")
-admin("box.space[11]:delete(3)")
-admin("box.space[11]:delete(4)")
-admin("box.space[11]:delete(5)")
-
-print """
-# delete by invalid keys
-"""
-admin("box.space[11]:delete('invalid key')")
-admin("box.space[11]:delete('00000001', '00000002')")
-
-
-print """
-#=============================================================================#
-# String hash tests
-#=============================================================================#
-"""
-
-print """
-#-----------------------------------------------------------------------------#
-# String hash inset fields tests
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# Insert valid fieds
-"""
-admin("box.space[12]:insert('key 0', 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[12]:insert('key 1', 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[12]:insert('key 2', 'value1 v1.0', 'value2 v1.0')")
-admin("box.space[12]:insert('key 3', 'value1 v1.0', 'value2 v1.0')")
-
-
-print """
-#-----------------------------------------------------------------------------#
-# String hash replace fields tests
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# Replace valid fieds
-"""
-admin("box.space[12]:replace('key 3', 'value1 v1.31', 'value2 1.12')")
-admin("box.space[12]:replace('key 1', 'value1 v1.32', 'value2 1.72')")
-admin("box.space[12]:replace('key 2', 'value1 v1.43', 'value2 1.92')")
-
-
-print """
-#-----------------------------------------------------------------------------#
-# String hash select fields test
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# select by valid keys
-"""
-admin("box.space[12]:select(0, 'key 0')")
-admin("box.space[12]:select(0, 'key 1')")
-admin("box.space[12]:select(0, 'key 2')")
-admin("box.space[12]:select(0, 'key 3')")
-admin("box.space[12]:select(0, 'key 4')")
-admin("box.space[12]:select(0, 'key 5')")
-
-print """
-# select by invalid keys
-"""
-admin("box.space[12]:select(0, 'key 1', 'key 2')")
-
-
-print """
-#-----------------------------------------------------------------------------#
-# String hash delete fields test
-#-----------------------------------------------------------------------------#
-"""
-
-print """
-# delete by valid keys
-"""
-admin("box.space[12]:delete('key 0')")
-admin("box.space[12]:delete('key 1')")
-admin("box.space[12]:delete('key 2')")
-admin("box.space[12]:delete('key 3')")
-admin("box.space[12]:delete('key 4')")
-admin("box.space[12]:delete('key 5')")
-print """
-# delete by invalid keys
-"""
-admin("box.space[12]:delete('key 1', 'key 2')")
-
-
-# clean-up
-admin("box.space[10]:truncate()")
-admin("box.space[11]:truncate()")
-admin("box.space[12]:truncate()")
-
-#
-# hash::replace tests
-#
-
-admin("box.space[21]:truncate()")
-
-sql("insert into t21 values (0, 0, 0, 0)")
-sql("insert into t21 values (1, 1, 1, 1)")
-sql("insert into t21 values (2, 2, 2, 2)")
-
-# OK
-sql("replace into t21 values (1, 1, 1, 1)")
-sql("replace into t21 values (1, 10, 10, 10)")
-sql("replace into t21 values (1, 1, 1, 1)")
-sql("select * from t21 WHERE k0 = 10")
-sql("select * from t21 WHERE k1 = 10")
-sql("select * from t21 WHERE k2 = 10")
-sql("select * from t21 WHERE k3 = 10")
-sql("select * from t21 WHERE k0 = 1")
-sql("select * from t21 WHERE k1 = 1")
-sql("select * from t21 WHERE k2 = 1")
-sql("select * from t21 WHERE k3 = 1")
-
-# OK
-sql("insert into t21 values (10, 10, 10, 10)")
-sql("delete from t21 WHERE k0 = 10")
-sql("select * from t21 WHERE k0 = 10")
-sql("select * from t21 WHERE k1 = 10")
-sql("select * from t21 WHERE k2 = 10")
-sql("select * from t21 WHERE k3 = 10")
-
-
-# TupleFound (primary key)
-sql("insert into t21 values (1, 10, 10, 10)")
-sql("select * from t21 WHERE k0 = 10")
-sql("select * from t21 WHERE k1 = 10")
-sql("select * from t21 WHERE k2 = 10")
-sql("select * from t21 WHERE k3 = 10")
-sql("select * from t21 WHERE k0 = 1")
-
-# TupleNotFound (primary key)
-sql("replace into t21 values (10, 10, 10, 10)")
-sql("select * from t21 WHERE k0 = 10")
-sql("select * from t21 WHERE k1 = 10")
-sql("select * from t21 WHERE k2 = 10")
-sql("select * from t21 WHERE k3 = 10")
-
-# TupleFound (key #1)
-sql("insert into t21 values (10, 0, 10, 10)")
-sql("select * from t21 WHERE k0 = 10")
-sql("select * from t21 WHERE k1 = 10")
-sql("select * from t21 WHERE k2 = 10")
-sql("select * from t21 WHERE k3 = 10")
-sql("select * from t21 WHERE k1 = 0")
-
-# TupleFound (key #1)
-sql("replace into t21 values (2, 0, 10, 10)")
-sql("select * from t21 WHERE k0 = 10")
-sql("select * from t21 WHERE k1 = 10")
-sql("select * from t21 WHERE k2 = 10")
-sql("select * from t21 WHERE k3 = 10")
-sql("select * from t21 WHERE k1 = 0")
-
-# TupleFound (key #3)
-sql("insert into t21 values (10, 10, 10, 0)")
-sql("select * from t21 WHERE k0 = 10")
-sql("select * from t21 WHERE k1 = 10")
-sql("select * from t21 WHERE k2 = 10")
-sql("select * from t21 WHERE k3 = 10")
-sql("select * from t21 WHERE k3 = 0")
-
-# TupleFound (key #3)
-sql("replace into t21 values (2, 10, 10, 0)")
-sql("select * from t21 WHERE k0 = 10")
-sql("select * from t21 WHERE k1 = 10")
-sql("select * from t21 WHERE k2 = 10")
-sql("select * from t21 WHERE k3 = 10")
-sql("select * from t21 WHERE k3 = 0")
-
-admin("box.space[21]:truncate()")
+dofile('utils.lua')
+
+--=============================================================================
+== 32-bit hash tests
+--=============================================================================;
+-------------------------------------------------------------------------------
+-- 32-bit hash insert fields tests
+-------------------------------------------------------------------------------;
+
+-- Insert valid fieds;
+box.space[10]:insert(0, 'value1 v1.0', 'value2 v1.0');
+box.space[10]:insert(1, 'value1 v1.0', 'value2 v1.0');
+box.space[10]:insert(2, 'value1 v1.0', 'value2 v1.0');
+box.space[10]:insert(3, 'value1 v1.0', 'value2 v1.0');
+
+-- Insert invalid fields;
+box.space[10]:insert('invalid key', 'value1 v1.0', 'value2 v1.0');
+
+-------------------------------------------------------------------------------
+-- 32-bit hash replace fields tests
+-------------------------------------------------------------------------------;
+
+-- Replace valid fieds;
+box.space[10]:replace(3, 'value1 v1.31', 'value2 1.12');
+box.space[10]:replace(1, 'value1 v1.32', 'value2 1.72');
+box.space[10]:replace(2, 'value1 v1.43', 'value2 1.92');
+
+-- Replace invalid fields;
+box.space[10]:replace('invalid key', 'value1 v1.0', 'value2 v1.0');
+
+-------------------------------------------------------------------------------
+-- 32-bit hash select fields test
+-------------------------------------------------------------------------------;
+
+-- select by valid keys;
+box.space[10]:select(0, 0);
+box.space[10]:select(0, 1);
+box.space[10]:select(0, 2);
+box.space[10]:select(0, 3);
+box.space[10]:select(0, 4);
+box.space[10]:select(0, 5);
+
+-- select by invalid keys;
+box.space[10]:select(0, 'invalid key');
+box.space[10]:select(0, 1, 2);
+
+-------------------------------------------------------------------------------
+-- 32-bit hash delete fields test
+-------------------------------------------------------------------------------;
+
+-- delete by valid keys;
+box.space[10]:delete(0);
+box.space[10]:delete(1);
+box.space[10]:delete(2);
+box.space[10]:delete(3);
+box.space[10]:delete(4);
+box.space[10]:delete(5);
+
+-- delete by invalid keys;
+box.space[10]:delete('invalid key');
+box.space[10]:delete(1, 2);
+
+--=============================================================================
+-- 64-bit hash tests
+--=============================================================================;
+-------------------------------------------------------------------------------
+-- 64-bit hash inset fields tests
+-------------------------------------------------------------------------------;
+
+-- Insert valid fieds;
+box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0');
+box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0');
+box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0');
+box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0');
+
+-- Insert invalid fields;
+box.space[11]:insert(100, 'value1 v1.0', 'value2 v1.0');
+box.space[11]:insert(101, 'value1 v1.0', 'value2 v1.0');
+box.space[11]:insert(102, 'value1 v1.0', 'value2 v1.0');
+box.space[11]:insert(103, 'value1 v1.0', 'value2 v1.0');
+box.space[11]:insert('invalid key', 'value1 v1.0', 'value2 v1.0');
+
+-------------------------------------------------------------------------------
+-- 64-bit hash replace fields tests
+-------------------------------------------------------------------------------;
+
+-- Replace valid fieds;
+box.space[11]:replace(3ULL, 'value1 v1.31', 'value2 1.12');
+box.space[11]:replace(1ULL, 'value1 v1.32', 'value2 1.72');
+box.space[11]:replace(2ULL, 'value1 v1.43', 'value2 1.92');
+
+-- Replace invalid fields;
+box.space[11]:replace(3, 'value1 v1.31', 'value2 1.12');
+box.space[11]:replace(1, 'value1 v1.32', 'value2 1.72');
+box.space[11]:replace(2, 'value1 v1.43', 'value2 1.92');
+box.space[11]:replace('invalid key', 'value1 v1.0', 'value2 v1.0');
+
+-------------------------------------------------------------------------------
+-- 64-bit hash select fields test
+-------------------------------------------------------------------------------;
+
+-- select by valid keys;
+box.space[11]:select(0, 0ULL);
+box.space[11]:select(0, 1ULL);
+box.space[11]:select(0, 2ULL);
+box.space[11]:select(0, 3ULL);
+box.space[11]:select(0, 4ULL);
+box.space[11]:select(0, 5ULL);
+
+-- select by valid NUM keys;
+box.space[11]:select(0, 0);
+box.space[11]:select(0, 1);
+box.space[11]:select(0, 2);
+box.space[11]:select(0, 3);
+box.space[11]:select(0, 4);
+box.space[11]:select(0, 5);
+
+-- select by invalid keys;
+box.space[11]:select(0, 'invalid key');
+box.space[11]:select(0, '00000001', '00000002');
+
+-------------------------------------------------------------------------------
+-- 64-bit hash delete fields test
+-------------------------------------------------------------------------------;
+
+-- delete by valid keys;
+box.space[11]:delete(0ULL);
+box.space[11]:delete(1ULL);
+box.space[11]:delete(2ULL);
+box.space[11]:delete(3ULL);
+box.space[11]:delete(4ULL);
+box.space[11]:delete(5ULL);
+
+box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0');
+box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0');
+box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0');
+box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0');
+
+-- delete by valid NUM keys;
+box.space[11]:delete(0);
+box.space[11]:delete(1);
+box.space[11]:delete(2);
+box.space[11]:delete(3);
+box.space[11]:delete(4);
+box.space[11]:delete(5);
+
+-- delete by invalid keys;
+box.space[11]:delete('invalid key');
+box.space[11]:delete('00000001', '00000002');
+
+--=============================================================================
+-- String hash tests
+--=============================================================================;
+-------------------------------------------------------------------------------
+-- String hash inset fields tests
+-------------------------------------------------------------------------------;
+
+-- Insert valid fieds;
+box.space[12]:insert('key 0', 'value1 v1.0', 'value2 v1.0');
+box.space[12]:insert('key 1', 'value1 v1.0', 'value2 v1.0');
+box.space[12]:insert('key 2', 'value1 v1.0', 'value2 v1.0');
+box.space[12]:insert('key 3', 'value1 v1.0', 'value2 v1.0');
+
+-------------------------------------------------------------------------------
+-- String hash replace fields tests
+-------------------------------------------------------------------------------;
+
+-- Replace valid fieds;
+box.space[12]:replace('key 3', 'value1 v1.31', 'value2 1.12');
+box.space[12]:replace('key 1', 'value1 v1.32', 'value2 1.72');
+box.space[12]:replace('key 2', 'value1 v1.43', 'value2 1.92');
+
+-------------------------------------------------------------------------------
+-- String hash select fields test
+-------------------------------------------------------------------------------;
+
+-- select by valid keys;
+box.space[12]:select(0, 'key 0');
+box.space[12]:select(0, 'key 1');
+box.space[12]:select(0, 'key 2');
+box.space[12]:select(0, 'key 3');
+box.space[12]:select(0, 'key 4');
+box.space[12]:select(0, 'key 5');
+
+-- select by invalid keys;
+box.space[12]:select(0, 'key 1', 'key 2');
+
+-------------------------------------------------------------------------------
+-- String hash delete fields test
+-------------------------------------------------------------------------------;
+
+-- delete by valid keys;
+box.space[12]:delete('key 0');
+box.space[12]:delete('key 1');
+box.space[12]:delete('key 2');
+box.space[12]:delete('key 3');
+box.space[12]:delete('key 4');
+box.space[12]:delete('key 5');
+
+-- delete by invalid keys;
+box.space[12]:delete('key 1', 'key 2');
+
+-- clean-up;
+box.space[10]:truncate();
+box.space[11]:truncate();
+box.space[12]:truncate();
+
+------------------------
+-- hash::replace tests
+------------------------;
+
+box.space[21]:truncate();
+box.space[21]:insert(0, 0, 0, 0);
+box.space[21]:insert(1, 1, 1, 1);
+box.space[21]:insert(2, 2, 2, 2);
+
+-- OK;
+box.replace_if_exists(21, 1, 1, 1, 1);
+box.replace_if_exists(21, 1, 10, 10, 10);
+box.replace_if_exists(21, 1, 1, 1, 1);
+box.space[21]:select(0, 10);
+box.space[21]:select(1, 10);
+box.space[21]:select(2, 10);
+box.space[21]:select(3, 10);
+box.space[21]:select(0, 1);
+box.space[21]:select(1, 1);
+box.space[21]:select(2, 1);
+box.space[21]:select(3, 1);
+
+-- OK;
+box.space[21]:insert(10, 10, 10, 10);
+box.space[21]:delete(10);
+box.space[21]:select(0, 10);
+box.space[21]:select(1, 10);
+box.space[21]:select(2, 10);
+box.space[21]:select(3, 10);
+
+-- TupleFound (primary key);
+box.space[21]:insert(1, 10, 10, 10);
+box.space[21]:select(0, 10);
+box.space[21]:select(1, 10);
+box.space[21]:select(2, 10);
+box.space[21]:select(3, 10);
+box.space[21]:select(0, 1);
+
+-- TupleNotFound (primary key);
+box.replace_if_exists(21, 10, 10, 10, 10);
+box.space[21]:select(0, 10);
+box.space[21]:select(1, 10);
+box.space[21]:select(2, 10);
+box.space[21]:select(3, 10);
+
+-- TupleFound (key --1);
+box.space[21]:insert(10, 0, 10, 10);
+box.space[21]:select(0, 10);
+box.space[21]:select(1, 10);
+box.space[21]:select(2, 10);
+box.space[21]:select(3, 10);
+box.space[21]:select(1, 0);
+
+-- TupleFound (key --1);
+box.replace_if_exists(21, 2, 0, 10, 10);
+box.space[21]:select(0, 10);
+box.space[21]:select(1, 10);
+box.space[21]:select(2, 10);
+box.space[21]:select(3, 10);
+box.space[21]:select(1, 0);
+
+-- TupleFound (key --3);
+box.space[21]:insert(10, 10, 10, 0);
+box.space[21]:select(0, 10);
+box.space[21]:select(1, 10);
+box.space[21]:select(2, 10);
+box.space[21]:select(3, 10);
+box.space[21]:select(3, 0);
+
+-- TupleFound (key --3);
+box.replace_if_exists(21, 2, 10, 10, 0);
+box.space[21]:select(0, 10);
+box.space[21]:select(1, 10);
+box.space[21]:select(2, 10);
+box.space[21]:select(3, 10);
+box.space[21]:select(3, 0);
+box.space[21]:truncate();
+
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
diff --git a/test/big/hash_multipart.result b/test/big/hash_multipart.result
index f0b858fc8d..dab656a52b 100644
--- a/test/big/hash_multipart.result
+++ b/test/big/hash_multipart.result
@@ -1,69 +1,129 @@
-insert into t27 values (0, 'foo', 0, '', 1)
-Insert OK, 1 row affected
-insert into t27 values (0, 'foo', 1, '', 1)
-Insert OK, 1 row affected
-insert into t27 values (1, 'foo', 0, '', 2)
-Insert OK, 1 row affected
-insert into t27 values (1, 'foo', 1, '', 2)
-Insert OK, 1 row affected
-insert into t27 values (0, 'bar', 0, '', 3)
-Insert OK, 1 row affected
-insert into t27 values (0, 'bar', 1, '', 3)
-Insert OK, 1 row affected
-insert into t27 values (1, 'bar', 0, '', 4)
-Insert OK, 1 row affected
-insert into t27 values (1, 'bar', 1, '', 4)
-Insert OK, 1 row affected
-insert into t27 values (1, 'bar', 1, '', 5)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 0'
- function box.select_all(space)     space = tonumber(space)     local result = {}         for k, v in box.space[space]:pairs() do             table.insert(result, v)     end     return unpack(result) end 
----
-...
-call box.select_all('27')
-Found 8 tuples:
-[0, 'bar', 0, '', 3]
-[0, 'bar', 1, '', 3]
-[0, 'foo', 0, '', 1]
-[0, 'foo', 1, '', 1]
-[1, 'bar', 0, '', 4]
-[1, 'bar', 1, '', 4]
-[1, 'foo', 0, '', 2]
-[1, 'foo', 1, '', 2]
-box.select(27, 0, 1, 'foo', 0)
+dofile('utils.lua')
+-- insert rows
 ---
+...
+box.space[27]:insert(0, 'foo', 0, '', 1)
+---
+ - 0: {'foo', 0, '', 1}
+...
+box.space[27]:insert(0, 'foo', 1, '', 1)
+---
+ - 0: {'foo', 1, '', 1}
+...
+box.space[27]:insert(1, 'foo', 0, '', 2)
+---
+ - 1: {'foo', 0, '', 2}
+...
+box.space[27]:insert(1, 'foo', 1, '', 2)
+---
+ - 1: {'foo', 1, '', 2}
+...
+box.space[27]:insert(0, 'bar', 0, '', 3)
+---
+ - 0: {'bar', 0, '', 3}
+...
+box.space[27]:insert(0, 'bar', 1, '', 3)
+---
+ - 0: {'bar', 1, '', 3}
+...
+box.space[27]:insert(1, 'bar', 0, '', 4)
+---
+ - 1: {'bar', 0, '', 4}
+...
+box.space[27]:insert(1, 'bar', 1, '', 4)
+---
+ - 1: {'bar', 1, '', 4}
+...
+-- try to insert a row with a duplicate key
+---
+...
+box.space[27]:insert(1, 'bar', 1, '', 5)
+---
+error: 'Duplicate key exists in unique index 0'
+...
+-- output all rows
+---
+...
+function box.select_all(space)
+    local result = {}
+    for k, v in box.space[space]:pairs() do
+        table.insert(result, v)
+    end
+    return result
+end
+---
+...
+unpack(box.sort(box.select_all(27)))
+-- primary index select
+---
+ - 0: {'bar', 0, '', 3}
+ - 0: {'bar', 1, '', 3}
+ - 0: {'foo', 0, '', 1}
+ - 0: {'foo', 1, '', 1}
+ - 1: {'bar', 0, '', 4}
+ - 1: {'bar', 1, '', 4}
  - 1: {'foo', 0, '', 2}
+ - 1: {'foo', 1, '', 2}
 ...
-box.select(27, 0, 1, 'bar', 0)
+box.space[27]:select(0, 1, 'foo', 0)
+---
+ - 1: {'foo', 0, '', 2}
+...
+box.space[27]:select(0, 1, 'bar', 0)
 ---
  - 1: {'bar', 0, '', 4}
 ...
-box.select(27, 0, 1, 'foo')
+-- primary index select with missing part
+---
+...
+box.space[27]:select(0, 1, 'foo')
 ---
 error: 'Invalid key part count in an exact match (expected 3, got 2)'
 ...
-box.select(27, 0, 1, 'foo', 0, 0)
+-- primary index select with extra part
+---
+...
+box.space[27]:select(0, 1, 'foo', 0, 0)
 ---
 error: 'Invalid key part count (expected [0..3], got 4)'
 ...
-box.select(27, 0, 1, 'foo', 'baz')
+-- primary index select with wrong type
+---
+...
+box.space[27]:select(0, 1, 'foo', 'baz')
 ---
 error: 'Supplied key field type does not match index type: expected u32'
 ...
-box.select(27, 1, 1, 4)
+-- secondary index select
+---
+...
+box.space[27]:select(1, 1, 4)
 ---
  - 1: {'bar', 1, '', 4}
 ...
-box.select(27, 1, 1, 5)
+-- secondary index select with no such key
+---
+...
+box.space[27]:select(1, 1, 5)
+---
+...
+-- secondary index select with missing part
 ---
 ...
-box.select(27, 1, 1)
+box.space[27]:select(1, 1)
 ---
 error: 'Invalid key part count in an exact match (expected 2, got 1)'
 ...
-box.select(27, 1, 1, 'baz')
+-- secondary index select with wrong type
+---
+...
+box.space[27]:select(1, 1, 'baz')
 ---
 error: 'Supplied key field type does not match index type: expected u32'
 ...
+-- cleanup
+---
+...
 box.space[27]:truncate()
 ---
 ...
@@ -71,3 +131,7 @@ box.space[27]:len()
 ---
  - 0
 ...
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
+
+---
+...
diff --git a/test/big/hash_multipart.test b/test/big/hash_multipart.test
index 178dd696d0..b6c2a91c4a 100644
--- a/test/big/hash_multipart.test
+++ b/test/big/hash_multipart.test
@@ -1,53 +1,50 @@
-# encoding: utf-8
-#
-
-# insert rows
-sql("insert into t27 values (0, 'foo', 0, '', 1)")
-sql("insert into t27 values (0, 'foo', 1, '', 1)")
-sql("insert into t27 values (1, 'foo', 0, '', 2)")
-sql("insert into t27 values (1, 'foo', 1, '', 2)")
-sql("insert into t27 values (0, 'bar', 0, '', 3)")
-sql("insert into t27 values (0, 'bar', 1, '', 3)")
-sql("insert into t27 values (1, 'bar', 0, '', 4)")
-sql("insert into t27 values (1, 'bar', 1, '', 4)")
-# try to insert a row with a duplicate key
-sql("insert into t27 values (1, 'bar', 1, '', 5)")
-
-# output all rows
-lua_code = """
+dofile('utils.lua')
+
+-- insert rows;
+box.space[27]:insert(0, 'foo', 0, '', 1);
+box.space[27]:insert(0, 'foo', 1, '', 1);
+box.space[27]:insert(1, 'foo', 0, '', 2);
+box.space[27]:insert(1, 'foo', 1, '', 2);
+box.space[27]:insert(0, 'bar', 0, '', 3);
+box.space[27]:insert(0, 'bar', 1, '', 3);
+box.space[27]:insert(1, 'bar', 0, '', 4);
+box.space[27]:insert(1, 'bar', 1, '', 4);
+
+-- try to insert a row with a duplicate key;
+box.space[27]:insert(1, 'bar', 1, '', 5);
+
+-- output all rows;
 function box.select_all(space)
-    space = tonumber(space)
     local result = {}
-        for k, v in box.space[space]:pairs() do
-            table.insert(result, v)
+    for k, v in box.space[space]:pairs() do
+        table.insert(result, v)
     end
-    return unpack(result)
-end
-"""
-admin(lua_code.replace('\n', ' '))
-sql.sort = True
-sql("call box.select_all('27')")
-sql.sort = False
-
-# primary index select
-admin("box.select(27, 0, 1, 'foo', 0)")
-admin("box.select(27, 0, 1, 'bar', 0)")
-# primary index slect with missing part
-admin("box.select(27, 0, 1, 'foo')")
-# primary index slect with extra part
-admin("box.select(27, 0, 1, 'foo', 0, 0)")
-# primary index select with wrong type
-admin("box.select(27, 0, 1, 'foo', 'baz')")
-
-# secondary index select
-admin("box.select(27, 1, 1, 4)")
-# secondary index select with no such key
-admin("box.select(27, 1, 1, 5)")
-# secondary index select with missing part
-admin("box.select(27, 1, 1)")
-# secondary index select with wrong type
-admin("box.select(27, 1, 1, 'baz')")
-
-# cleanup
-admin("box.space[27]:truncate()")
-admin("box.space[27]:len()")
+    return result
+end;
+
+unpack(box.sort(box.select_all(27)))
+
+-- primary index select;
+box.space[27]:select(0, 1, 'foo', 0);
+box.space[27]:select(0, 1, 'bar', 0);
+-- primary index select with missing part;
+box.space[27]:select(0, 1, 'foo');
+-- primary index select with extra part;
+box.space[27]:select(0, 1, 'foo', 0, 0);
+-- primary index select with wrong type;
+box.space[27]:select(0, 1, 'foo', 'baz');
+
+-- secondary index select;
+box.space[27]:select(1, 1, 4);
+-- secondary index select with no such key;
+box.space[27]:select(1, 1, 5);
+-- secondary index select with missing part;
+box.space[27]:select(1, 1);
+-- secondary index select with wrong type;
+box.space[27]:select(1, 1, 'baz');
+
+-- cleanup;
+box.space[27]:truncate();
+box.space[27]:len();
+
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
diff --git a/test/big/iterator.result b/test/big/iterator.result
index 65baf70a82..833f5e8bbb 100644
--- a/test/big/iterator.result
+++ b/test/big/iterator.result
@@ -1,51 +1,51 @@
 dofile('utils.lua')
 ---
 ...
-box.insert(20, 'pid_001', 'sid_001', 'tid_998', 'a')
+box.space[20]:insert('pid_001', 'sid_001', 'tid_998', 'a')
 ---
  - 'pid_001': {'sid_001', 'tid_998', 'a'}
 ...
-box.insert(20, 'pid_002', 'sid_001', 'tid_997', 'a')
+box.space[20]:insert('pid_002', 'sid_001', 'tid_997', 'a')
 ---
  - 'pid_002': {'sid_001', 'tid_997', 'a'}
 ...
-box.insert(20, 'pid_003', 'sid_002', 'tid_997', 'b')
+box.space[20]:insert('pid_003', 'sid_002', 'tid_997', 'b')
 ---
  - 'pid_003': {'sid_002', 'tid_997', 'b'}
 ...
-box.insert(20, 'pid_005', 'sid_002', 'tid_996', 'b')
+box.space[20]:insert('pid_005', 'sid_002', 'tid_996', 'b')
 ---
  - 'pid_005': {'sid_002', 'tid_996', 'b'}
 ...
-box.insert(20, 'pid_007', 'sid_003', 'tid_996', 'a')
+box.space[20]:insert('pid_007', 'sid_003', 'tid_996', 'a')
 ---
  - 'pid_007': {'sid_003', 'tid_996', 'a'}
 ...
-box.insert(20, 'pid_011', 'sid_004', 'tid_996', 'c')
+box.space[20]:insert('pid_011', 'sid_004', 'tid_996', 'c')
 ---
  - 'pid_011': {'sid_004', 'tid_996', 'c'}
 ...
-box.insert(20, 'pid_013', 'sid_005', 'tid_996', 'b')
+box.space[20]:insert('pid_013', 'sid_005', 'tid_996', 'b')
 ---
  - 'pid_013': {'sid_005', 'tid_996', 'b'}
 ...
-box.insert(20, 'pid_017', 'sid_006', 'tid_996', 'a')
+box.space[20]:insert('pid_017', 'sid_006', 'tid_996', 'a')
 ---
  - 'pid_017': {'sid_006', 'tid_996', 'a'}
 ...
-box.insert(20, 'pid_019', 'sid_005', 'tid_995', 'a')
+box.space[20]:insert('pid_019', 'sid_005', 'tid_995', 'a')
 ---
  - 'pid_019': {'sid_005', 'tid_995', 'a'}
 ...
-box.insert(20, 'pid_023', 'sid_005', 'tid_994', 'a')
+box.space[20]:insert('pid_023', 'sid_005', 'tid_994', 'a')
 ---
  - 'pid_023': {'sid_005', 'tid_994', 'a'}
 ...
-
-#-----------------------------------------------------------------------------#
-# Iterator: tree single-part unique
-#-----------------------------------------------------------------------------#
-
+-------------------------------------------------------------------------------
+-- Iterator: tree single-part unique
+-------------------------------------------------------------------------------
+---
+...
 iterate(20, 0, 0, 1)
 ---
 $pid_001$
@@ -210,11 +210,11 @@ iterate(20, 0, 0, 1, box.index.LE, 'pid_000')
 iterate(20, 0, 0, 1, box.index.LT, 'pid_000')
 ---
 ...
-
-#-----------------------------------------------------------------------------#
-# Iterator: tree single-part non-unique
-#-----------------------------------------------------------------------------#
-
+-------------------------------------------------------------------------------
+-- Iterator: tree single-part non-unique
+-------------------------------------------------------------------------------
+---
+...
 iterate(20, 1, 1, 2, box.index.ALL)
 ---
 $sid_001$
@@ -362,11 +362,11 @@ iterate(20, 1, 1, 2, box.index.LE, 'sid_000')
 iterate(20, 1, 1, 2, box.index.LT, 'sid_000')
 ---
 ...
-
-#-----------------------------------------------------------------------------#
-# Iterator: tree multi-part unique
-#-----------------------------------------------------------------------------#
-
+-------------------------------------------------------------------------------
+-- Iterator: tree multi-part unique
+-------------------------------------------------------------------------------
+---
+...
 iterate(20, 2, 1, 3, box.index.ALL)
 ---
 $sid_001$tid_997$
@@ -589,11 +589,11 @@ iterate(20, 2, 1, 3, box.index.LE, 'sid_000')
 iterate(20, 2, 1, 3, box.index.LT, 'sid_000')
 ---
 ...
-
-#-----------------------------------------------------------------------------#
-# Iterator: tree multi-part non-unique
-#-----------------------------------------------------------------------------#
-
+-------------------------------------------------------------------------------
+-- Iterator: tree multi-part non-unique
+-------------------------------------------------------------------------------
+---
+...
 iterate(20, 3, 2, 4, box.index.ALL)
 ---
 $tid_994$a$
@@ -766,11 +766,11 @@ iterate(20, 3, 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys')
 ---
 error: 'utils.lua:27: Key part count 4 is greater than index part count 2'
 ...
-
-#-----------------------------------------------------------------------------#
-# Iterator: hash single-part unique
-#-----------------------------------------------------------------------------#
-
+-------------------------------------------------------------------------------
+-- Iterator: hash single-part unique
+-------------------------------------------------------------------------------
+---
+...
 iterate(20, 4, 0, 1)
 ---
 sorted output
@@ -839,11 +839,11 @@ iterate(20, 4, 0, 1, box.index.GE, 'pid_999')
 ---
 sorted output
 ...
-
-#-----------------------------------------------------------------------------#
-# Iterator: hash multi-part unique
-#-----------------------------------------------------------------------------#
-
+-------------------------------------------------------------------------------
+-- Iterator: hash multi-part unique
+-------------------------------------------------------------------------------
+---
+...
 iterate(20, 5, 1, 3, box.index.ALL)
 ---
 sorted output
@@ -901,11 +901,11 @@ iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999')
 ---
 $sid_006$tid_996$
 ...
-
-#-----------------------------------------------------------------------------#
-# Iterator: various
-#-----------------------------------------------------------------------------#
-
+-------------------------------------------------------------------------------
+-- Iterator: various
+-------------------------------------------------------------------------------
+---
+...
 box.space[20].index[0]:iterator(-666)
 ---
 error: 'unknown iterator type: -666'
@@ -913,3 +913,7 @@ error: 'unknown iterator type: -666'
 box.space[20]:truncate()
 ---
 ...
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
+
+---
+...
diff --git a/test/big/iterator.test b/test/big/iterator.test
index 2fab2f5e7d..47134149e9 100644
--- a/test/big/iterator.test
+++ b/test/big/iterator.test
@@ -1,174 +1,157 @@
-# encoding: utf-8
-#
-import os
-import shutil
-
-iterator_lua_path = os.path.join(vardir, "utils.lua")
-shutil.copy("big/utils.lua", iterator_lua_path)
-
-admin("dofile('utils.lua')")
-shutil.rmtree(iterator_lua_path, True)
-
-admin("box.insert(20, 'pid_001', 'sid_001', 'tid_998', 'a')")
-admin("box.insert(20, 'pid_002', 'sid_001', 'tid_997', 'a')")
-admin("box.insert(20, 'pid_003', 'sid_002', 'tid_997', 'b')")
-admin("box.insert(20, 'pid_005', 'sid_002', 'tid_996', 'b')")
-admin("box.insert(20, 'pid_007', 'sid_003', 'tid_996', 'a')")
-admin("box.insert(20, 'pid_011', 'sid_004', 'tid_996', 'c')")
-admin("box.insert(20, 'pid_013', 'sid_005', 'tid_996', 'b')")
-admin("box.insert(20, 'pid_017', 'sid_006', 'tid_996', 'a')")
-admin("box.insert(20, 'pid_019', 'sid_005', 'tid_995', 'a')")
-admin("box.insert(20, 'pid_023', 'sid_005', 'tid_994', 'a')")
-
-print """
-#-----------------------------------------------------------------------------#
-# Iterator: tree single-part unique
-#-----------------------------------------------------------------------------#
-"""
-admin("iterate(20, 0, 0, 1)")
-admin("iterate(20, 0, 0, 1, box.index.ALL)")
-admin("iterate(20, 0, 0, 1, box.index.EQ)")
-admin("iterate(20, 0, 0, 1, box.index.REQ)")
-admin("iterate(20, 0, 0, 1, box.index.GE)")
-admin("iterate(20, 0, 0, 1, box.index.GT)")
-admin("iterate(20, 0, 0, 1, box.index.LE)")
-admin("iterate(20, 0, 0, 1, box.index.LT)")
-admin("iterate(20, 0, 0, 1, box.index.EQ, 'pid_003')")
-admin("iterate(20, 0, 0, 1, box.index.REQ, 'pid_003')")
-admin("iterate(20, 0, 0, 1, box.index.EQ, 'pid_666')")
-admin("iterate(20, 0, 0, 1, box.index.REQ, 'pid_666')")
-admin("iterate(20, 0, 0, 1, box.index.GE, 'pid_001')")
-admin("iterate(20, 0, 0, 1, box.index.GT, 'pid_001')")
-admin("iterate(20, 0, 0, 1, box.index.GE, 'pid_999')")
-admin("iterate(20, 0, 0, 1, box.index.GT, 'pid_999')")
-admin("iterate(20, 0, 0, 1, box.index.LE, 'pid_002')")
-admin("iterate(20, 0, 0, 1, box.index.LT, 'pid_002')")
-admin("iterate(20, 0, 0, 1, box.index.LE, 'pid_000')")
-admin("iterate(20, 0, 0, 1, box.index.LT, 'pid_000')")
-
-print """
-#-----------------------------------------------------------------------------#
-# Iterator: tree single-part non-unique
-#-----------------------------------------------------------------------------#
-"""
-admin("iterate(20, 1, 1, 2, box.index.ALL)")
-admin("iterate(20, 1, 1, 2, box.index.EQ)")
-admin("iterate(20, 1, 1, 2, box.index.REQ)")
-admin("iterate(20, 1, 1, 2, box.index.GE)")
-admin("iterate(20, 1, 1, 2, box.index.GT)")
-admin("iterate(20, 1, 1, 2, box.index.LE)")
-admin("iterate(20, 1, 1, 2, box.index.LT)")
-admin("iterate(20, 1, 1, 2, box.index.EQ, 'sid_005')")
-admin("iterate(20, 1, 1, 2, box.index.REQ, 'sid_005')")
-admin("iterate(20, 1, 1, 2, box.index.GE, 'sid_005')")
-admin("iterate(20, 1, 1, 2, box.index.GT, 'sid_005')")
-admin("iterate(20, 1, 1, 2, box.index.GE, 'sid_999')")
-admin("iterate(20, 1, 1, 2, box.index.GT, 'sid_999')")
-admin("iterate(20, 1, 1, 2, box.index.LE, 'sid_005')")
-admin("iterate(20, 1, 1, 2, box.index.LT, 'sid_005')")
-admin("iterate(20, 1, 1, 2, box.index.LE, 'sid_000')")
-admin("iterate(20, 1, 1, 2, box.index.LT, 'sid_000')")
-
-print """
-#-----------------------------------------------------------------------------#
-# Iterator: tree multi-part unique
-#-----------------------------------------------------------------------------#
-"""
-admin("iterate(20, 2, 1, 3, box.index.ALL)")
-admin("iterate(20, 2, 1, 3, box.index.EQ)")
-admin("iterate(20, 2, 1, 3, box.index.REQ)")
-admin("iterate(20, 2, 1, 3, box.index.GE)")
-admin("iterate(20, 2, 1, 3, box.index.GT)")
-admin("iterate(20, 2, 1, 3, box.index.LE)")
-admin("iterate(20, 2, 1, 3, box.index.LT)")
-admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005')")
-admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995')")
-admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999')")
-admin("iterate(20, 2, 1, 3, box.index.REQ, 'sid_005')")
-admin("iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_995')")
-admin("iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_999')")
-admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_005')")
-admin("iterate(20, 2, 1, 3, box.index.GT, 'sid_005')")
-admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995')")
-admin("iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_995')")
-admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999')")
-admin("iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_999')")
-admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_999')")
-admin("iterate(20, 2, 1, 3, box.index.GT, 'sid_999')")
-admin("iterate(20, 2, 1, 3, box.index.LE, 'sid_005')")
-admin("iterate(20, 2, 1, 3, box.index.LT, 'sid_005')")
-admin("iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_997')")
-admin("iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_997')")
-admin("iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_000')")
-admin("iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_000')")
-admin("iterate(20, 2, 1, 3, box.index.LE, 'sid_000')")
-admin("iterate(20, 2, 1, 3, box.index.LT, 'sid_000')")
-
-print """
-#-----------------------------------------------------------------------------#
-# Iterator: tree multi-part non-unique
-#-----------------------------------------------------------------------------#
-"""
-
-admin("iterate(20, 3, 2, 4, box.index.ALL)")
-admin("iterate(20, 3, 2, 4, box.index.EQ)")
-admin("iterate(20, 3, 2, 4, box.index.REQ)")
-admin("iterate(20, 3, 2, 4, box.index.GE)")
-admin("iterate(20, 3, 2, 4, box.index.GT)")
-admin("iterate(20, 3, 2, 4, box.index.LE)")
-admin("iterate(20, 3, 2, 4, box.index.LT)")
-admin("iterate(20, 3, 2, 4, box.index.EQ, 'tid_996')")
-admin("iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'a')")
-admin("iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'z')")
-admin("iterate(20, 3, 2, 4, box.index.REQ, 'tid_996')")
-admin("iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', 'a')")
-admin("iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', '0')")
-admin("iterate(20, 3, 2, 4, box.index.GE, 'tid_997')")
-admin("iterate(20, 3, 2, 4, box.index.GT, 'tid_997')")
-admin("iterate(20, 3, 2, 4, box.index.GE, 'tid_998')")
-admin("iterate(20, 3, 2, 4, box.index.GT, 'tid_998')")
-admin("iterate(20, 3, 2, 4, box.index.LE, 'tid_997')")
-admin("iterate(20, 3, 2, 4, box.index.LT, 'tid_997')")
-admin("iterate(20, 3, 2, 4, box.index.LE, 'tid_000')")
-admin("iterate(20, 3, 2, 4, box.index.LT, 'tid_000')")
-admin("iterate(20, 3, 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys')")
-
-print """
-#-----------------------------------------------------------------------------#
-# Iterator: hash single-part unique
-#-----------------------------------------------------------------------------#
-"""
-
-admin("iterate(20, 4, 0, 1)")
-admin("iterate(20, 4, 0, 1, box.index.ALL)")
-admin("iterate(20, 4, 0, 1, box.index.EQ)")
-admin("iterate(20, 4, 0, 1, box.index.GE)")
-admin("iterate(20, 4, 0, 1, box.index.EQ, 'pid_003')")
-admin("iterate(20, 4, 0, 1, box.index.EQ, 'pid_666')")
-admin("iterate(20, 4, 0, 1, box.index.GE, 'pid_001')")
-admin("iterate(20, 4, 0, 1, box.index.GE, 'pid_999')")
-
-print """
-#-----------------------------------------------------------------------------#
-# Iterator: hash multi-part unique
-#-----------------------------------------------------------------------------#
-"""
-admin("iterate(20, 5, 1, 3, box.index.ALL)")
-admin("iterate(20, 5, 1, 3, box.index.EQ)")
-admin("iterate(20, 5, 1, 3, box.index.EQ, 'sid_005')")
-admin("iterate(20, 5, 1, 3, box.index.GE)")
-admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995')")
-admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999')")
-admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995', 'a')")
-admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995')")
-admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999')")
-
-print """
-#-----------------------------------------------------------------------------#
-# Iterator: various
-#-----------------------------------------------------------------------------#
-"""
-
-admin("box.space[20].index[0]:iterator(-666)")
-
-admin("box.space[20]:truncate()")
+dofile('utils.lua');
+
+box.space[20]:insert('pid_001', 'sid_001', 'tid_998', 'a');
+box.space[20]:insert('pid_002', 'sid_001', 'tid_997', 'a');
+box.space[20]:insert('pid_003', 'sid_002', 'tid_997', 'b');
+box.space[20]:insert('pid_005', 'sid_002', 'tid_996', 'b');
+box.space[20]:insert('pid_007', 'sid_003', 'tid_996', 'a');
+box.space[20]:insert('pid_011', 'sid_004', 'tid_996', 'c');
+box.space[20]:insert('pid_013', 'sid_005', 'tid_996', 'b');
+box.space[20]:insert('pid_017', 'sid_006', 'tid_996', 'a');
+box.space[20]:insert('pid_019', 'sid_005', 'tid_995', 'a');
+box.space[20]:insert('pid_023', 'sid_005', 'tid_994', 'a');
+
+-------------------------------------------------------------------------------
+-- Iterator: tree single-part unique
+-------------------------------------------------------------------------------;
+
+iterate(20, 0, 0, 1);
+iterate(20, 0, 0, 1, box.index.ALL);
+iterate(20, 0, 0, 1, box.index.EQ);
+iterate(20, 0, 0, 1, box.index.REQ);
+iterate(20, 0, 0, 1, box.index.GE);
+iterate(20, 0, 0, 1, box.index.GT);
+iterate(20, 0, 0, 1, box.index.LE);
+iterate(20, 0, 0, 1, box.index.LT);
+iterate(20, 0, 0, 1, box.index.EQ, 'pid_003');
+iterate(20, 0, 0, 1, box.index.REQ, 'pid_003');
+iterate(20, 0, 0, 1, box.index.EQ, 'pid_666');
+iterate(20, 0, 0, 1, box.index.REQ, 'pid_666');
+iterate(20, 0, 0, 1, box.index.GE, 'pid_001');
+iterate(20, 0, 0, 1, box.index.GT, 'pid_001');
+iterate(20, 0, 0, 1, box.index.GE, 'pid_999');
+iterate(20, 0, 0, 1, box.index.GT, 'pid_999');
+iterate(20, 0, 0, 1, box.index.LE, 'pid_002');
+iterate(20, 0, 0, 1, box.index.LT, 'pid_002');
+iterate(20, 0, 0, 1, box.index.LE, 'pid_000');
+iterate(20, 0, 0, 1, box.index.LT, 'pid_000');
+
+-------------------------------------------------------------------------------
+-- Iterator: tree single-part non-unique
+-------------------------------------------------------------------------------;
+
+iterate(20, 1, 1, 2, box.index.ALL);
+iterate(20, 1, 1, 2, box.index.EQ);
+iterate(20, 1, 1, 2, box.index.REQ);
+iterate(20, 1, 1, 2, box.index.GE);
+iterate(20, 1, 1, 2, box.index.GT);
+iterate(20, 1, 1, 2, box.index.LE);
+iterate(20, 1, 1, 2, box.index.LT);
+iterate(20, 1, 1, 2, box.index.EQ, 'sid_005');
+iterate(20, 1, 1, 2, box.index.REQ, 'sid_005');
+iterate(20, 1, 1, 2, box.index.GE, 'sid_005');
+iterate(20, 1, 1, 2, box.index.GT, 'sid_005');
+iterate(20, 1, 1, 2, box.index.GE, 'sid_999');
+iterate(20, 1, 1, 2, box.index.GT, 'sid_999');
+iterate(20, 1, 1, 2, box.index.LE, 'sid_005');
+iterate(20, 1, 1, 2, box.index.LT, 'sid_005');
+iterate(20, 1, 1, 2, box.index.LE, 'sid_000');
+iterate(20, 1, 1, 2, box.index.LT, 'sid_000');
+
+-------------------------------------------------------------------------------
+-- Iterator: tree multi-part unique
+-------------------------------------------------------------------------------;
+
+iterate(20, 2, 1, 3, box.index.ALL);
+iterate(20, 2, 1, 3, box.index.EQ);
+iterate(20, 2, 1, 3, box.index.REQ);
+iterate(20, 2, 1, 3, box.index.GE);
+iterate(20, 2, 1, 3, box.index.GT);
+iterate(20, 2, 1, 3, box.index.LE);
+iterate(20, 2, 1, 3, box.index.LT);
+iterate(20, 2, 1, 3, box.index.EQ, 'sid_005');
+iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995');
+iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999');
+iterate(20, 2, 1, 3, box.index.REQ, 'sid_005');
+iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_995');
+iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_999');
+iterate(20, 2, 1, 3, box.index.GE, 'sid_005');
+iterate(20, 2, 1, 3, box.index.GT, 'sid_005');
+iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995');
+iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_995');
+iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999');
+iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_999');
+iterate(20, 2, 1, 3, box.index.GE, 'sid_999');
+iterate(20, 2, 1, 3, box.index.GT, 'sid_999');
+iterate(20, 2, 1, 3, box.index.LE, 'sid_005');
+iterate(20, 2, 1, 3, box.index.LT, 'sid_005');
+iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_997');
+iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_997');
+iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_000');
+iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_000');
+iterate(20, 2, 1, 3, box.index.LE, 'sid_000');
+iterate(20, 2, 1, 3, box.index.LT, 'sid_000');
+
+-------------------------------------------------------------------------------
+-- Iterator: tree multi-part non-unique
+-------------------------------------------------------------------------------;
+
+iterate(20, 3, 2, 4, box.index.ALL);
+iterate(20, 3, 2, 4, box.index.EQ);
+iterate(20, 3, 2, 4, box.index.REQ);
+iterate(20, 3, 2, 4, box.index.GE);
+iterate(20, 3, 2, 4, box.index.GT);
+iterate(20, 3, 2, 4, box.index.LE);
+iterate(20, 3, 2, 4, box.index.LT);
+iterate(20, 3, 2, 4, box.index.EQ, 'tid_996');
+iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'a');
+iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'z');
+iterate(20, 3, 2, 4, box.index.REQ, 'tid_996');
+iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', 'a');
+iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', '0');
+iterate(20, 3, 2, 4, box.index.GE, 'tid_997');
+iterate(20, 3, 2, 4, box.index.GT, 'tid_997');
+iterate(20, 3, 2, 4, box.index.GE, 'tid_998');
+iterate(20, 3, 2, 4, box.index.GT, 'tid_998');
+iterate(20, 3, 2, 4, box.index.LE, 'tid_997');
+iterate(20, 3, 2, 4, box.index.LT, 'tid_997');
+iterate(20, 3, 2, 4, box.index.LE, 'tid_000');
+iterate(20, 3, 2, 4, box.index.LT, 'tid_000');
+iterate(20, 3, 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys');
+
+-------------------------------------------------------------------------------
+-- Iterator: hash single-part unique
+-------------------------------------------------------------------------------;
+
+iterate(20, 4, 0, 1);
+iterate(20, 4, 0, 1, box.index.ALL);
+iterate(20, 4, 0, 1, box.index.EQ);
+iterate(20, 4, 0, 1, box.index.GE);
+iterate(20, 4, 0, 1, box.index.EQ, 'pid_003');
+iterate(20, 4, 0, 1, box.index.EQ, 'pid_666');
+iterate(20, 4, 0, 1, box.index.GE, 'pid_001');
+iterate(20, 4, 0, 1, box.index.GE, 'pid_999');
+
+-------------------------------------------------------------------------------
+-- Iterator: hash multi-part unique
+-------------------------------------------------------------------------------;
+
+iterate(20, 5, 1, 3, box.index.ALL);
+iterate(20, 5, 1, 3, box.index.EQ);
+iterate(20, 5, 1, 3, box.index.EQ, 'sid_005');
+iterate(20, 5, 1, 3, box.index.GE);
+iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995');
+iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999');
+iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995', 'a');
+iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995');
+iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999');
+
+-------------------------------------------------------------------------------
+-- Iterator: various
+-------------------------------------------------------------------------------;
+
+box.space[20].index[0]:iterator(-666);
+
+box.space[20]:truncate();
+
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
diff --git a/test/big/lua.result b/test/big/lua.result
index 0c8cebeb9b..61a4c93a66 100644
--- a/test/big/lua.result
+++ b/test/big/lua.result
@@ -1,8 +1,10 @@
 dofile('index_random_test.lua')
 ---
 ...
-insert into t1 values ('brave', 'new', 'world')
-Insert OK, 1 row affected
+box.space[1]:insert('brave', 'new', 'world')
+---
+ - 'brave': {'new', 'world'}
+...
 box.space[1].index[1]:min()
 ---
  - 'brave': {'new', 'world'}
@@ -11,36 +13,48 @@ box.space[1].index[1]:max()
 ---
  - 'brave': {'new', 'world'}
 ...
-call box.select('1', '1', 'new', 'world')
-Found 1 tuple:
-['brave', 'new', 'world']
-#
-# A test case for Bug #904208
-# "assert failed, when key cardinality is greater than index cardinality"
-# https://bugs.launchpad.net/tarantool/+bug/904208
-#
-call box.select('1', '1', 'new', 'world', 'order')
-An error occurred: ER_KEY_PART_COUNT, 'Invalid key part count (expected [0..2], got 3)'
-call box.delete('1', 'brave')
-Found 1 tuple:
-['brave', 'new', 'world']
-#
-# A test case for Bug #902091
-# "Positioned iteration over a multipart index doesn't work"
-# https://bugs.launchpad.net/tarantool/+bug/902091
-#
-insert into t1 values ('item 1', 'alabama', 'song')
-Insert OK, 1 row affected
+box.select('1', '1', 'new', 'world')
+---
+ - 'brave': {'new', 'world'}
+...
+-- A test case for Bug #904208
+-- "assert failed, when key cardinality is greater than index cardinality"
+--  https://bugs.launchpad.net/tarantool/+bug/904208 
+---
+...
+box.select('1', '1', 'new', 'world', 'order')
+---
+error: 'Invalid key part count (expected [0..2], got 3)'
+...
+box.delete('1', 'brave')
+---
+ - 'brave': {'new', 'world'}
+...
+-- A test case for Bug #902091
+-- "Positioned iteration over a multipart index doesn't work"
+-- https://bugs.launchpad.net/tarantool/+bug/902091
+---
+...
+box.space[1]:insert('item 1', 'alabama', 'song')
+---
+ - 'item 1': {'alabama', 1735290739}
+...
 box.select(1, 1, 'alabama')
 ---
  - 'item 1': {'alabama', 1735290739}
 ...
-insert into t1 values ('item 2', 'california', 'dreaming ')
-Insert OK, 1 row affected
-insert into t1 values ('item 3', 'california', 'uber alles')
-Insert OK, 1 row affected
-insert into t1 values ('item 4', 'georgia', 'on my mind')
-Insert OK, 1 row affected
+box.space[1]:insert('item 2', 'california', 'dreaming ')
+---
+ - 'item 2': {'california', 'dreaming '}
+...
+box.space[1]:insert('item 3', 'california', 'uber alles')
+---
+ - 'item 3': {'california', 'uber alles'}
+...
+box.space[1]:insert('item 4', 'georgia', 'on my mind')
+---
+ - 'item 4': {'georgia', 'on my mind'}
+...
 iter, tuple = box.space[1].index[1]:next('california')
 ---
 ...
@@ -48,42 +62,64 @@ tuple
 ---
  - 'item 2': {'california', 'dreaming '}
 ...
-iter, tuple = box.space[1].index[1]:next(iter)
+_, tuple = box.space[1].index[1]:next(iter)
 ---
 ...
 tuple
 ---
  - 'item 3': {'california', 'uber alles'}
 ...
-call box.delete('1', 'item 1')
-Found 1 tuple:
-['item 1', 'alabama', 1735290739]
-call box.delete('1', 'item 2')
-Found 1 tuple:
-['item 2', 'california', 'dreaming ']
-call box.delete('1', 'item 3')
-Found 1 tuple:
-['item 3', 'california', 'uber alles']
-call box.delete('1', 'item 4')
-Found 1 tuple:
-['item 4', 'georgia', 'on my mind']
-insert into t5 values ('01234567', 'new', 'world')
-Insert OK, 1 row affected
-insert into t5 values ('00000000', 'of', 'puppets')
-Insert OK, 1 row affected
-insert into t5 values ('00000001', 'of', 'might', 'and', 'magic')
-Insert OK, 1 row affected
-call box.select_range(5, 1, 2, 'of')
-Found 2 tuples:
-['00000001', 'of', 'might', 'and', 'magic']
-['00000000', 'of', 'puppets']
-call box.select_reverse_range(5, 1, 2, 'of')
-Found 2 tuples:
-['00000000', 'of', 'puppets']
-['00000001', 'of', 'might', 'and', 'magic']
+box.delete('1', 'item 1')
+---
+ - 'item 1': {'alabama', 1735290739}
+...
+box.delete('1', 'item 2')
+---
+ - 'item 2': {'california', 'dreaming '}
+...
+box.delete('1', 'item 3')
+---
+ - 'item 3': {'california', 'uber alles'}
+...
+box.delete('1', 'item 4')
+---
+ - 'item 4': {'georgia', 'on my mind'}
+...
+--
+-- Check range scan over multipart keys
+--
+---
+...
+box.space[5]:insert('01234567', 'new', 'world')
+---
+ - 3978425819141910832: {'new', 'world'}
+...
+box.space[5]:insert('00000000', 'of', 'puppets')
+---
+ - 3472328296227680304: {26223, 'puppets'}
+...
+box.space[5]:insert('00000001', 'of', 'might', 'and', 'magic')
+---
+ - 3544385890265608240: {26223, 'might', 'and', 'magic'}
+...
+box.select_range(5, 1, 2, 'of')
+---
+ - 3544385890265608240: {26223, 'might', 'and', 'magic'}
+ - 3472328296227680304: {26223, 'puppets'}
+...
+box.select_reverse_range(5, 1, 2, 'of')
+---
+ - 3472328296227680304: {26223, 'puppets'}
+ - 3544385890265608240: {26223, 'might', 'and', 'magic'}
+...
 box.space[5]:truncate()
 ---
 ...
+--
+-- Lua 64bit numbers support
+--
+---
+...
 box.insert('8', tonumber64('18446744073709551615'), 'magic')
 ---
  - 18446744073709551615: {'magic'}
@@ -94,9 +130,9 @@ tu = box.select('8', '0', tonumber64('18446744073709551615'))
 num = box.unpack('l', tu[0])
 ---
 ...
-print(num)
+num
 ---
-18446744073709551615
+ - 18446744073709551615
 ...
 type(num) == 'cdata'
 ---
@@ -133,13 +169,10 @@ num = box.unpack('l', tu[0])
 num2 = box.unpack('l', tu2[0])
 ---
 ...
-print(num)
----
-125
-...
-print(num2)
+num, num2
 ---
-125
+ - 125
+ - 125
 ...
 type(num) == 'cdata'
 ---
@@ -160,6 +193,11 @@ num2 == tonumber64('125')
 box.space[8]:truncate()
 ---
 ...
+--
+-- Lua select_reverse_range
+--
+---
+...
 box.insert(14, 0, 0)
 ---
  - 0: {0}
@@ -236,78 +274,74 @@ box.select_reverse_range(14, 1, 4)
 box.space[14]:truncate()
 ---
 ...
-
-#
-# Tests for box.index iterators
-#
-
-box.insert(16, 'pid_1', 'sid_1', 'tid_999')
+--
+-- Tests for box.index iterators
+--
 ---
- - 'pid_1': {'sid_1', 'tid_999'}
 ...
-box.insert(16, 'pid_2', 'sid_1', 'tid_998')
+pid = 1
 ---
- - 'pid_2': {'sid_1', 'tid_998'}
 ...
-box.insert(16, 'pid_3', 'sid_1', 'tid_997')
+tid = 999
 ---
- - 'pid_3': {'sid_1', 'tid_997'}
 ...
-box.insert(16, 'pid_4', 'sid_2', 'tid_996')
+for sid = 1, 2 do
+    for i = 1, 3 do
+        box.space[16]:insert('pid_'..pid, 'sid_'..sid, 'tid_'..tid)
+        pid = pid + 1
+        tid = tid - 1
+    end
+end
 ---
- - 'pid_4': {'sid_2', 'tid_996'}
 ...
-box.insert(16, 'pid_5', 'sid_2', 'tid_995')
+for k, v in box.space[16].index[1].next,       box.space[16].index[1], 'sid_1' do print(' - ', v) end
 ---
+ - 'pid_3': {'sid_1', 'tid_997'}
+ - 'pid_2': {'sid_1', 'tid_998'}
+ - 'pid_1': {'sid_1', 'tid_999'}
+ - 'pid_6': {'sid_2', 'tid_994'}
  - 'pid_5': {'sid_2', 'tid_995'}
+ - 'pid_4': {'sid_2', 'tid_996'}
 ...
-box.insert(16, 'pid_6', 'sid_2', 'tid_994')
+for k, v in box.space[16].index[1].prev,       box.space[16].index[1], 'sid_2' do print(' - ', v) end
 ---
+ - 'pid_4': {'sid_2', 'tid_996'}
+ - 'pid_5': {'sid_2', 'tid_995'}
  - 'pid_6': {'sid_2', 'tid_994'}
+ - 'pid_1': {'sid_1', 'tid_999'}
+ - 'pid_2': {'sid_1', 'tid_998'}
+ - 'pid_3': {'sid_1', 'tid_997'}
 ...
-for k, v in box.space[16].index[1].next, box.space[16].index[1], 'sid_1' do print(v) end
----
-'pid_3': {'sid_1', 'tid_997'}
-'pid_2': {'sid_1', 'tid_998'}
-'pid_1': {'sid_1', 'tid_999'}
-'pid_6': {'sid_2', 'tid_994'}
-'pid_5': {'sid_2', 'tid_995'}
-'pid_4': {'sid_2', 'tid_996'}
-...
-for k, v in box.space[16].index[1].prev, box.space[16].index[1], 'sid_2' do print(v) end
+for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_1' do print(' - ', v) end
 ---
-'pid_4': {'sid_2', 'tid_996'}
-'pid_5': {'sid_2', 'tid_995'}
-'pid_6': {'sid_2', 'tid_994'}
-'pid_1': {'sid_1', 'tid_999'}
-'pid_2': {'sid_1', 'tid_998'}
-'pid_3': {'sid_1', 'tid_997'}
+ - 'pid_3': {'sid_1', 'tid_997'}
+ - 'pid_2': {'sid_1', 'tid_998'}
+ - 'pid_1': {'sid_1', 'tid_999'}
 ...
-for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_1' do print(v) end
+for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_1' do print(' - ', v) end
 ---
-'pid_3': {'sid_1', 'tid_997'}
-'pid_2': {'sid_1', 'tid_998'}
-'pid_1': {'sid_1', 'tid_999'}
+ - 'pid_1': {'sid_1', 'tid_999'}
+ - 'pid_2': {'sid_1', 'tid_998'}
+ - 'pid_3': {'sid_1', 'tid_997'}
 ...
-for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_1' do print(v) end
+for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_2' do print(' - ', v) end
 ---
-'pid_1': {'sid_1', 'tid_999'}
-'pid_2': {'sid_1', 'tid_998'}
-'pid_3': {'sid_1', 'tid_997'}
+ - 'pid_6': {'sid_2', 'tid_994'}
+ - 'pid_5': {'sid_2', 'tid_995'}
+ - 'pid_4': {'sid_2', 'tid_996'}
 ...
-for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_2' do print(v) end
+for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_2' do print(' - ', v) end
 ---
-'pid_6': {'sid_2', 'tid_994'}
-'pid_5': {'sid_2', 'tid_995'}
-'pid_4': {'sid_2', 'tid_996'}
+ - 'pid_4': {'sid_2', 'tid_996'}
+ - 'pid_5': {'sid_2', 'tid_995'}
+ - 'pid_6': {'sid_2', 'tid_994'}
 ...
-for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_2' do print(v) end
+box.space[16]:truncate()
 ---
-'pid_4': {'sid_2', 'tid_996'}
-'pid_5': {'sid_2', 'tid_995'}
-'pid_6': {'sid_2', 'tid_994'}
 ...
-box.space[16]:truncate()
+--
+-- Tests for lua idx:count()
+--
 ---
 ...
 box.insert(17, 1, 1, 1)
@@ -365,6 +399,11 @@ error: 'index.count(): one or more arguments expected'
 box.space[17]:truncate()
 ---
 ...
+--
+-- Tests for lua box.auto_increment
+--
+---
+...
 box.space[18]:truncate()
 ---
 ...
@@ -387,6 +426,11 @@ box.auto_increment(18, 'c')
 box.space[18]:truncate()
 ---
 ...
+--
+-- Tests for lua box.auto_increment with NUM64 keys
+--
+---
+...
 box.space[25]:truncate()
 ---
 ...
@@ -409,7 +453,12 @@ box.auto_increment(25, 'c')
 box.space[25]:truncate()
 ---
 ...
-t=box.insert(12, '1', '2', '3', '4', '5', '6', '7')
+--
+-- Tests for lua tuple:transform()
+--
+---
+...
+t = box.insert(12, '1', '2', '3', '4', '5', '6', '7')
 ---
 ...
 t:transform(7, 0, '8', '9', '100')
@@ -480,7 +529,12 @@ t:transform(0, 1, {})
 ---
 error: 'tuple.transform(): unsupported field type ''table'''
 ...
-t=box.insert(12, 'A', '2', '3', '4', '3', '2', '5', '6', '3', '7')
+--
+-- Tests for lua tuple:find() and tuple:findall()
+--
+---
+...
+t = box.insert(12, 'A', '2', '3', '4', '3', '2', '5', '6', '3', '7')
 ---
 ...
 t:find('2')
@@ -532,7 +586,7 @@ t:findall(4, '3')
  - 4
  - 8
 ...
-t=box.insert(12, 'Z', '2', 2, 3, tonumber64(2))
+t = box.insert(12, 'Z', '2', 2, 3, tonumber64(2))
 ---
 ...
 t:find(2)
@@ -550,11 +604,11 @@ t:find('2')
 box.space[12]:truncate()
 ---
 ...
-#
-# A test case for Bug #1038784
-# transform returns wrong tuple and put broken reply into socket
-# https://bugs.launchpad.net/tarantool/+bug/1038784
-#
+-- A test case for Bug #1038784
+-- transform returns wrong tuple and put broken reply into socket
+-- https://bugs.launchpad.net/tarantool/+bug/1038784
+---
+...
 dofile('push.lua')
 ---
 ...
@@ -598,7 +652,11 @@ push_collection(5, 1038784, 'hey')
 ---
  - 1038784: {26984, 'hey', 'hey', 'hey', 'hey'}
 ...
-# A test case for Bug#1060967: truncation of 64-bit numbers
+--
+-- A test case for Bug#1060967: truncation of 64-bit numbers
+--
+---
+...
 box.space[5]:insert(2^51, 'hello', 'world')
 ---
  - 2251799813685248: {'hello', 'world'}
@@ -610,7 +668,13 @@ box.space[5]:select(0, 2^51)
 box.space[5]:truncate()
 ---
 ...
-# Test that we print index number in error ER_INDEX_VIOLATION
+--
+-- Test that we print index number in error ER_INDEX_VIOLATION
+---
+...
+--
+---
+...
 box.space[1]:insert(1, 'hello', 'world')
 ---
  - 1: {'hello', 'world'}
@@ -622,12 +686,15 @@ error: 'Duplicate key exists in unique index 1'
 box.space[1]:truncate()
 ---
 ...
-#
-# A test case for Bug #1042798
-# Truncate hangs when primary key is not in linear or starts at the first field
-# https://bugs.launchpad.net/tarantool/+bug/1042798
-#
-for k, f in pairs(box.space[23].index[0].key_field) do print(k, ' => ', f.fieldno) end
+-- A test case for Bug #1042798
+-- Truncate hangs when primary key is not in linear or starts at the first field
+-- https://bugs.launchpad.net/tarantool/+bug/1042798
+---
+...
+-- Print key fields in pk
+---
+...
+for k, f in pairs(box.space[23].index[0].key_field) do print(k,  ' => ', f.fieldno) end
 ---
 0 => 2
 1 => 1
@@ -644,652 +711,45 @@ box.insert(23, 20, 30, 40, 50)
 ---
  - 20: {30, 40, 50}
 ...
-for _k, v in box.space[23]:pairs() do print(v) end
+for _, v in box.space[23]:pairs() do print(' - ', v) end
+---
+ - 1: {2, 3, 4}
+ - 10: {20, 30, 40}
+ - 20: {30, 40, 50}
+...
+-- Truncate must not hang
 ---
-1: {2, 3, 4}
-10: {20, 30, 40}
-20: {30, 40, 50}
 ...
 box.space[23]:truncate()
 ---
 ...
-for _k, v in box.space[23]:pairs() do print(v) end
+-- Empty result
+---
+...
+for _, v in box.space[23]:pairs() do print(' - ', v) end
+---
+...
+-------------------------------------------------------------------------------
+-- TreeIndex::random()
+-------------------------------------------------------------------------------
 ---
 ...
-
-#-----------------------------------------------------------------------------#
-# TreeIndex::random()
-#-----------------------------------------------------------------------------#
-
 index_random_test(26, 0)
 ---
 all values have been found
  - true
 ...
-
-#-----------------------------------------------------------------------------#
-# HashIndex::random()
-#-----------------------------------------------------------------------------#
-
+-------------------------------------------------------------------------------
+-- HashIndex::random()
+-------------------------------------------------------------------------------
+---
+...
 index_random_test(26, 1)
 ---
 all values have been found
  - true
 ...
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
 
-#
-# A test case for Bug#1200228
-# https://bugs.launchpad.net/tarantool/+bug/1200228
-# box.auto_increment counter resets
-# Test for correct little-endian comparison of integer fields.
-# (unsigned)
-#
-for i = 1, 300 do box.insert(2, i, i) print(box.space[2].index[0]:max()) end
----
-1: {1}
-2: {2}
-3: {3}
-4: {4}
-5: {5}
-6: {6}
-7: {7}
-8: {8}
-9: {9}
-10: {10}
-11: {11}
-12: {12}
-13: {13}
-14: {14}
-15: {15}
-16: {16}
-17: {17}
-18: {18}
-19: {19}
-20: {20}
-21: {21}
-22: {22}
-23: {23}
-24: {24}
-25: {25}
-26: {26}
-27: {27}
-28: {28}
-29: {29}
-30: {30}
-31: {31}
-32: {32}
-33: {33}
-34: {34}
-35: {35}
-36: {36}
-37: {37}
-38: {38}
-39: {39}
-40: {40}
-41: {41}
-42: {42}
-43: {43}
-44: {44}
-45: {45}
-46: {46}
-47: {47}
-48: {48}
-49: {49}
-50: {50}
-51: {51}
-52: {52}
-53: {53}
-54: {54}
-55: {55}
-56: {56}
-57: {57}
-58: {58}
-59: {59}
-60: {60}
-61: {61}
-62: {62}
-63: {63}
-64: {64}
-65: {65}
-66: {66}
-67: {67}
-68: {68}
-69: {69}
-70: {70}
-71: {71}
-72: {72}
-73: {73}
-74: {74}
-75: {75}
-76: {76}
-77: {77}
-78: {78}
-79: {79}
-80: {80}
-81: {81}
-82: {82}
-83: {83}
-84: {84}
-85: {85}
-86: {86}
-87: {87}
-88: {88}
-89: {89}
-90: {90}
-91: {91}
-92: {92}
-93: {93}
-94: {94}
-95: {95}
-96: {96}
-97: {97}
-98: {98}
-99: {99}
-100: {100}
-101: {101}
-102: {102}
-103: {103}
-104: {104}
-105: {105}
-106: {106}
-107: {107}
-108: {108}
-109: {109}
-110: {110}
-111: {111}
-112: {112}
-113: {113}
-114: {114}
-115: {115}
-116: {116}
-117: {117}
-118: {118}
-119: {119}
-120: {120}
-121: {121}
-122: {122}
-123: {123}
-124: {124}
-125: {125}
-126: {126}
-127: {127}
-128: {128}
-129: {129}
-130: {130}
-131: {131}
-132: {132}
-133: {133}
-134: {134}
-135: {135}
-136: {136}
-137: {137}
-138: {138}
-139: {139}
-140: {140}
-141: {141}
-142: {142}
-143: {143}
-144: {144}
-145: {145}
-146: {146}
-147: {147}
-148: {148}
-149: {149}
-150: {150}
-151: {151}
-152: {152}
-153: {153}
-154: {154}
-155: {155}
-156: {156}
-157: {157}
-158: {158}
-159: {159}
-160: {160}
-161: {161}
-162: {162}
-163: {163}
-164: {164}
-165: {165}
-166: {166}
-167: {167}
-168: {168}
-169: {169}
-170: {170}
-171: {171}
-172: {172}
-173: {173}
-174: {174}
-175: {175}
-176: {176}
-177: {177}
-178: {178}
-179: {179}
-180: {180}
-181: {181}
-182: {182}
-183: {183}
-184: {184}
-185: {185}
-186: {186}
-187: {187}
-188: {188}
-189: {189}
-190: {190}
-191: {191}
-192: {192}
-193: {193}
-194: {194}
-195: {195}
-196: {196}
-197: {197}
-198: {198}
-199: {199}
-200: {200}
-201: {201}
-202: {202}
-203: {203}
-204: {204}
-205: {205}
-206: {206}
-207: {207}
-208: {208}
-209: {209}
-210: {210}
-211: {211}
-212: {212}
-213: {213}
-214: {214}
-215: {215}
-216: {216}
-217: {217}
-218: {218}
-219: {219}
-220: {220}
-221: {221}
-222: {222}
-223: {223}
-224: {224}
-225: {225}
-226: {226}
-227: {227}
-228: {228}
-229: {229}
-230: {230}
-231: {231}
-232: {232}
-233: {233}
-234: {234}
-235: {235}
-236: {236}
-237: {237}
-238: {238}
-239: {239}
-240: {240}
-241: {241}
-242: {242}
-243: {243}
-244: {244}
-245: {245}
-246: {246}
-247: {247}
-248: {248}
-249: {249}
-250: {250}
-251: {251}
-252: {252}
-253: {253}
-254: {254}
-255: {255}
-256: {256}
-257: {257}
-258: {258}
-259: {259}
-260: {260}
-261: {261}
-262: {262}
-263: {263}
-264: {264}
-265: {265}
-266: {266}
-267: {267}
-268: {268}
-269: {269}
-270: {270}
-271: {271}
-272: {272}
-273: {273}
-274: {274}
-275: {275}
-276: {276}
-277: {277}
-278: {278}
-279: {279}
-280: {280}
-281: {281}
-282: {282}
-283: {283}
-284: {284}
-285: {285}
-286: {286}
-287: {287}
-288: {288}
-289: {289}
-290: {290}
-291: {291}
-292: {292}
-293: {293}
-294: {294}
-295: {295}
-296: {296}
-297: {297}
-298: {298}
-299: {299}
-300: {300}
-...
-box.space[2]:select_range(0, 300)
----
- - 1: {1}
- - 2: {2}
- - 3: {3}
- - 4: {4}
- - 5: {5}
- - 6: {6}
- - 7: {7}
- - 8: {8}
- - 9: {9}
- - 10: {10}
- - 11: {11}
- - 12: {12}
- - 13: {13}
- - 14: {14}
- - 15: {15}
- - 16: {16}
- - 17: {17}
- - 18: {18}
- - 19: {19}
- - 20: {20}
- - 21: {21}
- - 22: {22}
- - 23: {23}
- - 24: {24}
- - 25: {25}
- - 26: {26}
- - 27: {27}
- - 28: {28}
- - 29: {29}
- - 30: {30}
- - 31: {31}
- - 32: {32}
- - 33: {33}
- - 34: {34}
- - 35: {35}
- - 36: {36}
- - 37: {37}
- - 38: {38}
- - 39: {39}
- - 40: {40}
- - 41: {41}
- - 42: {42}
- - 43: {43}
- - 44: {44}
- - 45: {45}
- - 46: {46}
- - 47: {47}
- - 48: {48}
- - 49: {49}
- - 50: {50}
- - 51: {51}
- - 52: {52}
- - 53: {53}
- - 54: {54}
- - 55: {55}
- - 56: {56}
- - 57: {57}
- - 58: {58}
- - 59: {59}
- - 60: {60}
- - 61: {61}
- - 62: {62}
- - 63: {63}
- - 64: {64}
- - 65: {65}
- - 66: {66}
- - 67: {67}
- - 68: {68}
- - 69: {69}
- - 70: {70}
- - 71: {71}
- - 72: {72}
- - 73: {73}
- - 74: {74}
- - 75: {75}
- - 76: {76}
- - 77: {77}
- - 78: {78}
- - 79: {79}
- - 80: {80}
- - 81: {81}
- - 82: {82}
- - 83: {83}
- - 84: {84}
- - 85: {85}
- - 86: {86}
- - 87: {87}
- - 88: {88}
- - 89: {89}
- - 90: {90}
- - 91: {91}
- - 92: {92}
- - 93: {93}
- - 94: {94}
- - 95: {95}
- - 96: {96}
- - 97: {97}
- - 98: {98}
- - 99: {99}
- - 100: {100}
- - 101: {101}
- - 102: {102}
- - 103: {103}
- - 104: {104}
- - 105: {105}
- - 106: {106}
- - 107: {107}
- - 108: {108}
- - 109: {109}
- - 110: {110}
- - 111: {111}
- - 112: {112}
- - 113: {113}
- - 114: {114}
- - 115: {115}
- - 116: {116}
- - 117: {117}
- - 118: {118}
- - 119: {119}
- - 120: {120}
- - 121: {121}
- - 122: {122}
- - 123: {123}
- - 124: {124}
- - 125: {125}
- - 126: {126}
- - 127: {127}
- - 128: {128}
- - 129: {129}
- - 130: {130}
- - 131: {131}
- - 132: {132}
- - 133: {133}
- - 134: {134}
- - 135: {135}
- - 136: {136}
- - 137: {137}
- - 138: {138}
- - 139: {139}
- - 140: {140}
- - 141: {141}
- - 142: {142}
- - 143: {143}
- - 144: {144}
- - 145: {145}
- - 146: {146}
- - 147: {147}
- - 148: {148}
- - 149: {149}
- - 150: {150}
- - 151: {151}
- - 152: {152}
- - 153: {153}
- - 154: {154}
- - 155: {155}
- - 156: {156}
- - 157: {157}
- - 158: {158}
- - 159: {159}
- - 160: {160}
- - 161: {161}
- - 162: {162}
- - 163: {163}
- - 164: {164}
- - 165: {165}
- - 166: {166}
- - 167: {167}
- - 168: {168}
- - 169: {169}
- - 170: {170}
- - 171: {171}
- - 172: {172}
- - 173: {173}
- - 174: {174}
- - 175: {175}
- - 176: {176}
- - 177: {177}
- - 178: {178}
- - 179: {179}
- - 180: {180}
- - 181: {181}
- - 182: {182}
- - 183: {183}
- - 184: {184}
- - 185: {185}
- - 186: {186}
- - 187: {187}
- - 188: {188}
- - 189: {189}
- - 190: {190}
- - 191: {191}
- - 192: {192}
- - 193: {193}
- - 194: {194}
- - 195: {195}
- - 196: {196}
- - 197: {197}
- - 198: {198}
- - 199: {199}
- - 200: {200}
- - 201: {201}
- - 202: {202}
- - 203: {203}
- - 204: {204}
- - 205: {205}
- - 206: {206}
- - 207: {207}
- - 208: {208}
- - 209: {209}
- - 210: {210}
- - 211: {211}
- - 212: {212}
- - 213: {213}
- - 214: {214}
- - 215: {215}
- - 216: {216}
- - 217: {217}
- - 218: {218}
- - 219: {219}
- - 220: {220}
- - 221: {221}
- - 222: {222}
- - 223: {223}
- - 224: {224}
- - 225: {225}
- - 226: {226}
- - 227: {227}
- - 228: {228}
- - 229: {229}
- - 230: {230}
- - 231: {231}
- - 232: {232}
- - 233: {233}
- - 234: {234}
- - 235: {235}
- - 236: {236}
- - 237: {237}
- - 238: {238}
- - 239: {239}
- - 240: {240}
- - 241: {241}
- - 242: {242}
- - 243: {243}
- - 244: {244}
- - 245: {245}
- - 246: {246}
- - 247: {247}
- - 248: {248}
- - 249: {249}
- - 250: {250}
- - 251: {251}
- - 252: {252}
- - 253: {253}
- - 254: {254}
- - 255: {255}
- - 256: {256}
- - 257: {257}
- - 258: {258}
- - 259: {259}
- - 260: {260}
- - 261: {261}
- - 262: {262}
- - 263: {263}
- - 264: {264}
- - 265: {265}
- - 266: {266}
- - 267: {267}
- - 268: {268}
- - 269: {269}
- - 270: {270}
- - 271: {271}
- - 272: {272}
- - 273: {273}
- - 274: {274}
- - 275: {275}
- - 276: {276}
- - 277: {277}
- - 278: {278}
- - 279: {279}
- - 280: {280}
- - 281: {281}
- - 282: {282}
- - 283: {283}
- - 284: {284}
- - 285: {285}
- - 286: {286}
- - 287: {287}
- - 288: {288}
- - 289: {289}
- - 290: {290}
- - 291: {291}
- - 292: {292}
- - 293: {293}
- - 294: {294}
- - 295: {295}
- - 296: {296}
- - 297: {297}
- - 298: {298}
- - 299: {299}
- - 300: {300}
-...
-box.space[2]:truncate()
 ---
 ...
diff --git a/test/big/lua.test b/test/big/lua.test
index a73a740307..c4d6510689 100644
--- a/test/big/lua.test
+++ b/test/big/lua.test
@@ -1,280 +1,252 @@
-# encoding: utf-8
-#
-import os
-import shutil
-
-for file in ("index_random_test.lua",):
-    src_path = os.path.join("big/", file)
-    dst_path = os.path.join(vardir, file)
-    shutil.copy(src_path, dst_path)
-    admin("dofile('%s')" % (file))
-    os.unlink(dst_path);
-
-sql("insert into t1 values ('brave', 'new', 'world')")
-admin("box.space[1].index[1]:min()")
-admin("box.space[1].index[1]:max()")
-sql("call box.select('1', '1', 'new', 'world')")
-print """#
-# A test case for Bug #904208
-# "assert failed, when key cardinality is greater than index cardinality"
-# https://bugs.launchpad.net/tarantool/+bug/904208
-#"""
-sql("call box.select('1', '1', 'new', 'world', 'order')")
-sql("call box.delete('1', 'brave')")
-
-print """#
-# A test case for Bug #902091
-# "Positioned iteration over a multipart index doesn't work"
-# https://bugs.launchpad.net/tarantool/+bug/902091
-#"""
-sql("insert into t1 values ('item 1', 'alabama', 'song')")
-admin("box.select(1, 1, 'alabama')")
-sql("insert into t1 values ('item 2', 'california', 'dreaming ')")
-sql("insert into t1 values ('item 3', 'california', 'uber alles')")
-sql("insert into t1 values ('item 4', 'georgia', 'on my mind')")
-admin("iter, tuple = box.space[1].index[1]:next('california')")
-admin("tuple")
-admin("iter, tuple = box.space[1].index[1]:next(iter)")
-admin("tuple")
-sql("call box.delete('1', 'item 1')")
-sql("call box.delete('1', 'item 2')")
-sql("call box.delete('1', 'item 3')")
-sql("call box.delete('1', 'item 4')")
-
-#
-# Check range scan over multipart keys
-#
-sql("insert into t5 values ('01234567', 'new', 'world')")
-sql("insert into t5 values ('00000000', 'of', 'puppets')")
-sql("insert into t5 values ('00000001', 'of', 'might', 'and', 'magic')")
-sql("call box.select_range(5, 1, 2, 'of')")
-sql("call box.select_reverse_range(5, 1, 2, 'of')")
-admin("box.space[5]:truncate()")
-
-#
-# Lua 64bit numbers support
-#
-admin("box.insert('8', tonumber64('18446744073709551615'), 'magic')")
-admin("tu = box.select('8', '0', tonumber64('18446744073709551615'))")
-admin("num = box.unpack('l', tu[0])")
-admin("print(num)")
-admin("type(num) == 'cdata'")
-admin("num == tonumber64('18446744073709551615')")
-admin("num = box.unpack('l', tu[0])")
-admin("num == tonumber64('18446744073709551615')")
-admin("box.delete(8, 18446744073709551615ULL)")
-admin("box.insert('8', 125ULL, 'magic')")
-admin("tu = box.select('8', '0', 125)")
-admin("tu2 = box.select('8', '0', 125LL)")
-admin("num = box.unpack('l', tu[0])")
-admin("num2 = box.unpack('l', tu2[0])")
-admin("print(num)")
-admin("print(num2)")
-admin("type(num) == 'cdata'")
-admin("type(num2) == 'cdata'")
-admin("num == tonumber64('125')")
-admin("num2 == tonumber64('125')")
-admin("box.space[8]:truncate()")
-
-#
-# Lua select_reverse_range
-#
-admin("box.insert(14, 0, 0)")
-admin("box.insert(14, 1, 0)")
-admin("box.insert(14, 2, 0)")
-admin("box.insert(14, 3, 0)")
-admin("box.insert(14, 4, 0)")
-admin("box.insert(14, 5, 0)")
-admin("box.insert(14, 6, 0)")
-admin("box.insert(14, 7, 0)")
-admin("box.insert(14, 8, 0)")
-admin("box.insert(14, 9, 0)")
-admin("box.select_range(14, 1, 10)")
-admin("box.select_reverse_range(14, 1, 10)")
-admin("box.select_reverse_range(14, 1, 4)")
-admin("box.space[14]:truncate()")
-
-print """
-#
-# Tests for box.index iterators
-#
-"""
-pid = 1
-tid = 999
-for sid in [1, 2]:
-    for i in range(1, 4):
-        admin("box.insert(16, 'pid_%d', 'sid_%d', 'tid_%d')" % (pid, sid, tid))
-        pid += 1
-        tid -= 1
-
-admin("for k, v in box.space[16].index[1].next, box.space[16].index[1], 'sid_1' do print(v) end")
-admin("for k, v in box.space[16].index[1].prev, box.space[16].index[1], 'sid_2' do print(v) end")
-admin("for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_1' do print(v) end")
-admin("for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_1' do print(v) end")
-admin("for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_2' do print(v) end")
-admin("for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_2' do print(v) end")
-admin("box.space[16]:truncate()")
-
-#
-# Tests for lua idx:count()
-#
-admin("box.insert(17, 1, 1, 1)")
-admin("box.insert(17, 2, 2, 0)")
-admin("box.insert(17, 3, 2, 1)")
-admin("box.insert(17, 4, 3, 0)")
-admin("box.insert(17, 5, 3, 1)")
-admin("box.insert(17, 6, 3, 2)")
-admin("box.space[17].index[1]:count(1)")
-admin("box.space[17].index[1]:count(2)")
-admin("box.space[17].index[1]:count(2, 1)")
-admin("box.space[17].index[1]:count(2, 2)")
-admin("box.space[17].index[1]:count(3)")
-admin("box.space[17].index[1]:count(3, 3)")
-admin("box.space[17].index[1]:count()")
-admin("box.space[17]:truncate()")
-
-#
-# Tests for lua box.auto_increment
-#
-admin("box.space[18]:truncate()")
-admin("box.auto_increment(18, 'a')")
-admin("box.insert(18, 5)")
-admin("box.auto_increment(18, 'b')")
-admin("box.auto_increment(18, 'c')")
-admin("box.space[18]:truncate()")
-
-#
-# Tests for lua box.auto_increment with NUM64 keys
-#
-admin("box.space[25]:truncate()")
-admin("box.auto_increment(25, 'a')")
-admin("box.insert(25, tonumber64(5))")
-admin("box.auto_increment(25, 'b')")
-admin("box.auto_increment(25, 'c')")
-admin("box.space[25]:truncate()")
-
-#
-# Tests for lua tuple:transform()
-#
-admin("t=box.insert(12, '1', '2', '3', '4', '5', '6', '7')")
-admin("t:transform(7, 0, '8', '9', '100')")
-admin("t:transform(0, 1)")
-admin("t:transform(1, 4)")
-admin("t:transform(-1, 1)")
-admin("t:transform(-3, 2)")
-admin("t:transform(0, 0, 'A')")
-admin("t:transform(-1, 0, 'A')")
-admin("t:transform(0, 1, 'A')")
-admin("t:transform(-1, 1, 'B')")
-admin("t:transform(0, 2, 'C')")
-admin("t:transform(2, 0, 'hello')")
-admin("t:transform(0, -1, 'C')")
-admin("t:transform(0, 100)")
-admin("t:transform(-100, 1)")
-admin("t:transform(0, 3, 1, 2, 3)")
-admin("t:transform(3, 1, tonumber64(4))")
-admin("t:transform(0, 1, {})")
-
-#
-# Tests for lua tuple:find() and tuple:findall()
-#
-admin("t=box.insert(12, 'A', '2', '3', '4', '3', '2', '5', '6', '3', '7')")
-admin("t:find('2')")
-admin("t:find('4')")
-admin("t:find('5')")
-admin("t:find('A')")
-admin("t:find('0')")
-
-admin("t:findall('A')")
-admin("t:findall('2')")
-admin("t:findall('3')")
-admin("t:findall('0')")
-
-admin("t:find(2, '2')")
-admin("t:find(89, '2')")
-admin("t:findall(4, '3')")
-
-admin("t=box.insert(12, 'Z', '2', 2, 3, tonumber64(2))")
-admin("t:find(2)")
-admin("t:find(tonumber64(2))")
-admin("t:find('2')")
-admin("box.space[12]:truncate()")
-
-print """#
-# A test case for Bug #1038784
-# transform returns wrong tuple and put broken reply into socket
-# https://bugs.launchpad.net/tarantool/+bug/1038784
-#"""
-
-push_lua_path = os.path.join(vardir, "push.lua")
-shutil.copy("big/push.lua", push_lua_path)
-
-admin("dofile('push.lua')")
-shutil.rmtree(push_lua_path, True)
-
-admin("push_collection(0, 1038784, 'hello')")
-admin("push_collection(0, 1038784, 'hello')")
-admin("push_collection(0, 1038784, 'hello')")
-
-admin("push_collection(1, 1038784, 'hi')")
-admin("push_collection(2, 1038784, 'hi')")
-admin("push_collection(2, 1038784, 'hi')")
-
-admin("push_collection(5, 1038784, 'hey')")
-admin("push_collection(5, 1038784, 'hey')")
-admin("push_collection(5, 1038784, 'hey')")
-admin("push_collection(5, 1038784, 'hey')")
-
-print """# A test case for Bug#1060967: truncation of 64-bit numbers"""
-admin("box.space[5]:insert(2^51, 'hello', 'world')")
-admin("box.space[5]:select(0, 2^51)")
-admin("box.space[5]:truncate()")
-print """# Test that we print index number in error ER_INDEX_VIOLATION"""
-admin("box.space[1]:insert(1, 'hello', 'world')")
-admin("box.space[1]:insert(2, 'hello', 'world')")
-admin("box.space[1]:truncate()")
-
-print """#
-# A test case for Bug #1042798
-# Truncate hangs when primary key is not in linear or starts at the first field
-# https://bugs.launchpad.net/tarantool/+bug/1042798
-#"""
-
-# Print key fields in pk
-admin("for k, f in pairs(box.space[23].index[0].key_field) do print(k, ' => ', f.fieldno) end")
-admin("box.insert(23, 1, 2, 3, 4)")
-admin("box.insert(23, 10, 20, 30, 40)")
-admin("box.insert(23, 20, 30, 40, 50)")
-admin("for _k, v in box.space[23]:pairs() do print(v) end")
-# Truncate must not hang
-admin("box.space[23]:truncate()")
-# Empty result
-admin("for _k, v in box.space[23]:pairs() do print(v) end")
-
-print """
-#-----------------------------------------------------------------------------#
-# TreeIndex::random()
-#-----------------------------------------------------------------------------#
-""";
-
-admin("index_random_test(26, 0)")
-
-print """
-#-----------------------------------------------------------------------------#
-# HashIndex::random()
-#-----------------------------------------------------------------------------#
-""";
-
-admin("index_random_test(26, 1)")
-
-print """
-#
-# A test case for Bug#1200228
-# https://bugs.launchpad.net/tarantool/+bug/1200228
-# box.auto_increment counter resets
-# Test for correct little-endian comparison of integer fields.
-# (unsigned)
-#"""
-admin("for i = 1, 300 do box.insert(2, i, i) print(box.space[2].index[0]:max()) end")
-admin("box.space[2]:select_range(0, 300)")
-admin("box.space[2]:truncate()")
+dofile('index_random_test.lua');
+
+box.space[1]:insert('brave', 'new', 'world');
+box.space[1].index[1]:min();
+box.space[1].index[1]:max();
+box.select('1', '1', 'new', 'world');
+
+-- A test case for Bug #904208
+-- "assert failed, when key cardinality is greater than index cardinality"
+--  https://bugs.launchpad.net/tarantool/+bug/904208 ;
+
+box.select('1', '1', 'new', 'world', 'order');
+box.delete('1', 'brave');
+
+-- A test case for Bug #902091
+-- "Positioned iteration over a multipart index doesn't work"
+-- https://bugs.launchpad.net/tarantool/+bug/902091;
+
+box.space[1]:insert('item 1', 'alabama', 'song');
+box.select(1, 1, 'alabama');
+box.space[1]:insert('item 2', 'california', 'dreaming ');
+box.space[1]:insert('item 3', 'california', 'uber alles');
+box.space[1]:insert('item 4', 'georgia', 'on my mind');
+iter, tuple = box.space[1].index[1]:next('california');
+tuple;
+_, tuple = box.space[1].index[1]:next(iter);
+tuple;
+box.delete('1', 'item 1');
+box.delete('1', 'item 2');
+box.delete('1', 'item 3');
+box.delete('1', 'item 4');
+
+--
+-- Check range scan over multipart keys
+--;
+box.space[5]:insert('01234567', 'new', 'world');
+box.space[5]:insert('00000000', 'of', 'puppets');
+box.space[5]:insert('00000001', 'of', 'might', 'and', 'magic');
+box.select_range(5, 1, 2, 'of');
+box.select_reverse_range(5, 1, 2, 'of');
+box.space[5]:truncate();
+
+--
+-- Lua 64bit numbers support
+--;
+box.insert('8', tonumber64('18446744073709551615'), 'magic');
+tu = box.select('8', '0', tonumber64('18446744073709551615'));
+num = box.unpack('l', tu[0]);
+num;
+type(num) == 'cdata';
+num == tonumber64('18446744073709551615');
+num = box.unpack('l', tu[0]);
+num == tonumber64('18446744073709551615');
+box.delete(8, 18446744073709551615ULL);
+box.insert('8', 125ULL, 'magic');
+tu = box.select('8', '0', 125);
+tu2 = box.select('8', '0', 125LL);
+num = box.unpack('l', tu[0]);
+num2 = box.unpack('l', tu2[0]);
+num, num2;
+type(num) == 'cdata';
+type(num2) == 'cdata';
+num == tonumber64('125');
+num2 == tonumber64('125');
+box.space[8]:truncate();
+
+--
+-- Lua select_reverse_range
+--;
+box.insert(14, 0, 0);
+box.insert(14, 1, 0);
+box.insert(14, 2, 0);
+box.insert(14, 3, 0);
+box.insert(14, 4, 0);
+box.insert(14, 5, 0);
+box.insert(14, 6, 0);
+box.insert(14, 7, 0);
+box.insert(14, 8, 0);
+box.insert(14, 9, 0);
+box.select_range(14, 1, 10);
+box.select_reverse_range(14, 1, 10);
+box.select_reverse_range(14, 1, 4);
+box.space[14]:truncate();
+
+--
+-- Tests for box.index iterators
+--;
+pid = 1;
+tid = 999;
+for sid = 1, 2 do
+    for i = 1, 3 do
+        box.space[16]:insert('pid_'..pid, 'sid_'..sid, 'tid_'..tid)
+        pid = pid + 1
+        tid = tid - 1
+    end
+end;
+
+for k, v in box.space[16].index[1].next,       box.space[16].index[1], 'sid_1' do print(' - ', v) end;
+for k, v in box.space[16].index[1].prev,       box.space[16].index[1], 'sid_2' do print(' - ', v) end;
+for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_1' do print(' - ', v) end;
+for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_1' do print(' - ', v) end;
+for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_2' do print(' - ', v) end;
+for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_2' do print(' - ', v) end;
+box.space[16]:truncate();
+
+--
+-- Tests for lua idx:count()
+--;
+box.insert(17, 1, 1, 1);
+box.insert(17, 2, 2, 0);
+box.insert(17, 3, 2, 1);
+box.insert(17, 4, 3, 0);
+box.insert(17, 5, 3, 1);
+box.insert(17, 6, 3, 2);
+box.space[17].index[1]:count(1);
+box.space[17].index[1]:count(2);
+box.space[17].index[1]:count(2, 1);
+box.space[17].index[1]:count(2, 2);
+box.space[17].index[1]:count(3);
+box.space[17].index[1]:count(3, 3);
+box.space[17].index[1]:count();
+box.space[17]:truncate();
+
+--
+-- Tests for lua box.auto_increment
+--;
+box.space[18]:truncate();
+box.auto_increment(18, 'a');
+box.insert(18, 5);
+box.auto_increment(18, 'b');
+box.auto_increment(18, 'c');
+box.space[18]:truncate();
+
+--
+-- Tests for lua box.auto_increment with NUM64 keys
+--;
+box.space[25]:truncate();
+box.auto_increment(25, 'a');
+box.insert(25, tonumber64(5));
+box.auto_increment(25, 'b');
+box.auto_increment(25, 'c');
+box.space[25]:truncate();
+
+--
+-- Tests for lua tuple:transform()
+--;
+t = box.insert(12, '1', '2', '3', '4', '5', '6', '7');
+t:transform(7, 0, '8', '9', '100');
+t:transform(0, 1);
+t:transform(1, 4);
+t:transform(-1, 1);
+t:transform(-3, 2);
+t:transform(0, 0, 'A');
+t:transform(-1, 0, 'A');
+t:transform(0, 1, 'A');
+t:transform(-1, 1, 'B');
+t:transform(0, 2, 'C');
+t:transform(2, 0, 'hello');
+t:transform(0, -1, 'C');
+t:transform(0, 100);
+t:transform(-100, 1);
+t:transform(0, 3, 1, 2, 3);
+t:transform(3, 1, tonumber64(4));
+t:transform(0, 1, {});
+
+--
+-- Tests for lua tuple:find() and tuple:findall()
+--;
+t = box.insert(12, 'A', '2', '3', '4', '3', '2', '5', '6', '3', '7');
+t:find('2');
+t:find('4');
+t:find('5');
+t:find('A');
+t:find('0');
+
+t:findall('A');
+t:findall('2');
+t:findall('3');
+t:findall('0');
+
+t:find(2, '2');
+t:find(89, '2');
+t:findall(4, '3');
+
+t = box.insert(12, 'Z', '2', 2, 3, tonumber64(2));
+t:find(2);
+t:find(tonumber64(2));
+t:find('2');
+box.space[12]:truncate();
+
+-- A test case for Bug #1038784
+-- transform returns wrong tuple and put broken reply into socket
+-- https://bugs.launchpad.net/tarantool/+bug/1038784;
+dofile('push.lua');
+
+push_collection(0, 1038784, 'hello');
+push_collection(0, 1038784, 'hello');
+push_collection(0, 1038784, 'hello');
+
+push_collection(1, 1038784, 'hi');
+push_collection(2, 1038784, 'hi');
+push_collection(2, 1038784, 'hi');
+
+push_collection(5, 1038784, 'hey');
+push_collection(5, 1038784, 'hey');
+push_collection(5, 1038784, 'hey');
+push_collection(5, 1038784, 'hey');
+
+--
+-- A test case for Bug#1060967: truncation of 64-bit numbers
+--;
+box.space[5]:insert(2^51, 'hello', 'world');
+box.space[5]:select(0, 2^51);
+box.space[5]:truncate();
+
+--
+-- Test that we print index number in error ER_INDEX_VIOLATION;
+--;
+box.space[1]:insert(1, 'hello', 'world');
+box.space[1]:insert(2, 'hello', 'world');
+box.space[1]:truncate();
+
+-- A test case for Bug #1042798
+-- Truncate hangs when primary key is not in linear or starts at the first field
+-- https://bugs.launchpad.net/tarantool/+bug/1042798;
+
+-- Print key fields in pk;
+for k, f in pairs(box.space[23].index[0].key_field) do print(k,  ' => ', f.fieldno) end;
+box.insert(23, 1, 2, 3, 4);
+box.insert(23, 10, 20, 30, 40);
+box.insert(23, 20, 30, 40, 50);
+for _, v in box.space[23]:pairs() do print(' - ', v) end;
+
+-- Truncate must not hang;
+box.space[23]:truncate();
+
+-- Empty result;
+for _, v in box.space[23]:pairs() do print(' - ', v) end;
+
+-------------------------------------------------------------------------------
+-- TreeIndex::random()
+-------------------------------------------------------------------------------;
+
+index_random_test(26, 0);
+
+-------------------------------------------------------------------------------
+-- HashIndex::random()
+-------------------------------------------------------------------------------;
+
+index_random_test(26, 1);
+
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
diff --git a/test/big/bitset.lua b/test/big/lua/bitset.lua
similarity index 100%
rename from test/big/bitset.lua
rename to test/big/lua/bitset.lua
diff --git a/test/big/index_random_test.lua b/test/big/lua/index_random_test.lua
similarity index 100%
rename from test/big/index_random_test.lua
rename to test/big/lua/index_random_test.lua
diff --git a/test/big/push.lua b/test/big/lua/push.lua
similarity index 100%
rename from test/big/push.lua
rename to test/big/lua/push.lua
diff --git a/test/big/utils.lua b/test/big/lua/utils.lua
similarity index 62%
rename from test/big/utils.lua
rename to test/big/lua/utils.lua
index 2e32faa1dc..6365935e05 100644
--- a/test/big/utils.lua
+++ b/test/big/lua/utils.lua
@@ -80,3 +80,45 @@ function table.generate(iter)
 
 	return t;
 end
+
+-- sort all rows as strings(not for tables);
+function box.sort(tuples)
+    function compare_tables(t1, t2) 
+        return (tostring(t1) < tostring(t2))
+    end 
+    table.sort(tuples, compare_tables) 
+    return tuples
+end;
+
+-- return string tuple
+function box.tuple.to_string(tuple, yaml)
+    ans = '['
+    for i = 0, #tuple - 1 do
+        if #i == 4 then
+            ans = ans..box.unpack('i', i)
+        elseif #i == 8 then
+            ans = ans..box.unpack('l', i)
+        else
+            ans = ans..'\''..tostring(i)..'\''
+        end
+        if not #i == #tuple -1 then
+            ans = ans..', '
+        end
+    end
+    ans = ans..']'
+    if yaml then
+        ans = ' - '..ans
+    end
+    return ans
+end;
+
+--replace if tuple already presented func
+function box.replace_if_exists(space, ...)
+    local field_count = select('#', ...)
+        return box.process(13,
+            box.pack('iiV',
+                tonumber(space),
+                bit.bor(box.flags.BOX_RETURN_TUPLE,
+                    box.flags.BOX_REPLACE),
+                field_count, ...))
+end;
diff --git a/test/big/suite.ini b/test/big/suite.ini
index 84f40d225a..b1f42ac6f5 100644
--- a/test/big/suite.ini
+++ b/test/big/suite.ini
@@ -1,9 +1,5 @@
 [default]
-core = python tarantool
-description = tarantool/box, various namespace configurations and properties
+core = lua tarantool
 config = tarantool.cfg
-# put disabled tests here
-# disabled = lua.test
-# put disabled in valgrind test here
-#valgrind_disabled = ...
-release_disabled = hash_errinj.test
+description = lua analogue of big tests
+lua_libs = lua/utils.lua lua/bitset.lua lua/index_random_test.lua lua/push.lua
diff --git a/test/big/tree_pk.result b/test/big/tree_pk.result
index 5c1b32e911..61f14a1b99 100644
--- a/test/big/tree_pk.result
+++ b/test/big/tree_pk.result
@@ -1,132 +1,248 @@
-insert into t2 values (1, 'tuple')
-Insert OK, 1 row affected
+dofile('utils.lua')
+---
+...
+-- integer keys
+---
+...
+box.space[2]:insert(1, 'tuple')
+---
+ - 1: {'tuple'}
+...
 save snapshot
 ---
 ok
 ...
-insert into t2 values (2, 'tuple 2')
-Insert OK, 1 row affected
+box.space[2]:insert(2, 'tuple 2')
+---
+ - 2: {'tuple 2'}
+...
 save snapshot
 ---
 ok
 ...
-insert into t2 values (3, 'tuple 3')
-Insert OK, 1 row affected
-select * from t2 where k0 = 1
-Found 1 tuple:
-[1, 'tuple']
-select * from t2 where k0 = 2
-Found 1 tuple:
-[2, 'tuple 2']
-select * from t2 where k0 = 3
-Found 1 tuple:
-[3, 'tuple 3']
-delete from t2 where k0 = 1
-Delete OK, 1 row affected
-delete from t2 where k0 = 2
-Delete OK, 1 row affected
-delete from t2 where k0 = 3
-Delete OK, 1 row affected
-insert into t2 VALUES('xxxxxxx')
-An error occurred: ER_KEY_FIELD_TYPE, 'Supplied key field type does not match index type: expected NUM'
-insert into t2 VALUES('')
-An error occurred: ER_KEY_FIELD_TYPE, 'Supplied key field type does not match index type: expected NUM'
-insert into t2 VALUES('12')
-An error occurred: ER_KEY_FIELD_TYPE, 'Supplied key field type does not match index type: expected NUM'
-insert into t3 values ('identifier', 'tuple')
-Insert OK, 1 row affected
+box.space[2]:insert(3, 'tuple 3')
+---
+ - 3: {'tuple 3'}
+...
+box.space[2]:select(0, 1)
+---
+ - 1: {'tuple'}
+...
+box.space[2]:select(0, 2)
+---
+ - 2: {'tuple 2'}
+...
+box.space[2]:select(0, 3)
+---
+ - 3: {'tuple 3'}
+...
+-- Cleanup
+---
+...
+box.space[2]:delete(1)
+---
+ - 1: {'tuple'}
+...
+box.space[2]:delete(2)
+---
+ - 2: {'tuple 2'}
+...
+box.space[2]:delete(3)
+---
+ - 3: {'tuple 3'}
+...
+-- Test incorrect keys - supplied key field type does not match index type
+-- https://bugs.launchpad.net/tarantool/+bug/1072624
+---
+...
+box.space[2]:insert('xxxxxxx')
+---
+error: 'Supplied key field type does not match index type: expected NUM'
+...
+box.space[2]:insert('')
+---
+error: 'Supplied key field type does not match index type: expected NUM'
+...
+box.space[2]:insert('12')
+---
+error: 'Supplied key field type does not match index type: expected NUM'
+...
+-- string keys
+---
+...
+box.space[3]:insert('identifier', 'tuple')
+---
+ - 'identifier': {'tuple'}
+...
 save snapshot
 ---
 ok
 ...
-insert into t3 values ('second', 'tuple 2')
-Insert OK, 1 row affected
+box.space[3]:insert('second', 'tuple 2')
+---
+ - 'second': {'tuple 2'}
+...
 save snapshot
 ---
 ok
 ...
-call box.select_range('3', '0', '100', 'second')
-Found 1 tuple:
-['second', 'tuple 2']
-call box.select_range('3', '0', '100', 'identifier')
-Found 2 tuples:
-['identifier', 'tuple']
-['second', 'tuple 2']
-insert into t3 values ('third', 'tuple 3')
-Insert OK, 1 row affected
-select * from t3 where k0 = 'identifier'
-Found 1 tuple:
-['identifier', 'tuple']
-select * from t3 where k0 = 'second'
-Found 1 tuple:
-['second', 'tuple 2']
-select * from t3 where k0 = 'third'
-Found 1 tuple:
-['third', 'tuple 3']
-delete from t3 where k0 = 'identifier'
-Delete OK, 1 row affected
-delete from t3 where k0 = 'second'
-Delete OK, 1 row affected
-delete from t3 where k0 = 'third'
-Delete OK, 1 row affected
-insert into t2 values (1, 'tuple')
-Insert OK, 1 row affected
-insert into t3 values (1, 'tuple')
-Insert OK, 1 row affected
-insert into t3 values (2, 'tuple')
-Insert OK, 1 row affected
- function box.crossjoin(space0, space1, limit)   space0 = tonumber(space0)   space1 = tonumber(space1)   limit = tonumber(limit)   local result = {}   for k0, v0 in box.space[space0]:pairs() do     for k1, v1 in box.space[space1]:pairs() do       if limit <= 0 then         return unpack(result)       end       newtuple = {v0:unpack()}       for _, v in v1:pairs() do table.insert(newtuple, v) end       table.insert(result, newtuple)       limit = limit - 1     end   end   return unpack(result) end
----
-...
-call box.crossjoin('3', '3', '0')
-No match
-call box.crossjoin('3', '3', '5')
-Found 4 tuples:
-[1, 'tuple', 1, 'tuple']
-[1, 'tuple', 2, 'tuple']
-[2, 'tuple', 1, 'tuple']
-[2, 'tuple', 2, 'tuple']
-call box.crossjoin('3', '3', '10000')
-Found 4 tuples:
-[1, 'tuple', 1, 'tuple']
-[1, 'tuple', 2, 'tuple']
-[2, 'tuple', 1, 'tuple']
-[2, 'tuple', 2, 'tuple']
-call box.crossjoin('3', '2', '10000')
-Found 2 tuples:
-[1, 'tuple', 1, 'tuple']
-[2, 'tuple', 1, 'tuple']
+box.select_range('3', '0', '100', 'second')
+---
+ - 'second': {'tuple 2'}
+...
+box.select_range('3', '0', '100', 'identifier')
+---
+ - 'identifier': {'tuple'}
+ - 'second': {'tuple 2'}
+...
+box.space[3]:insert('third', 'tuple 3')
+---
+ - 'third': {'tuple 3'}
+...
+box.space[3]:select(0, 'identifier')
+---
+ - 'identifier': {'tuple'}
+...
+box.space[3]:select(0, 'second')
+---
+ - 'second': {'tuple 2'}
+...
+box.space[3]:select(0, 'third')
+---
+ - 'third': {'tuple 3'}
+...
+-- Cleanup
+---
+...
+box.space[3]:delete('identifier')
+---
+ - 'identifier': {'tuple'}
+...
+box.space[3]:delete('second')
+---
+ - 'second': {'tuple 2'}
+...
+box.space[3]:delete('third')
+---
+ - 'third': {'tuple 3'}
+...
+function box.crossjoin(space0, space1, limit)
+    space0 = tonumber(space0)
+    space1 = tonumber(space1)
+    limit = tonumber(limit)
+    local result = {}
+    for k0, v0 in box.space[space0]:pairs() do
+        for k1, v1 in box.space[space1]:pairs() do
+            if limit <= 0 then
+                return unpack(result)
+            end
+            newtuple = {v0:unpack()}
+            for _, v in v1:pairs() do 
+                table.insert(newtuple, v) 
+            end
+            table.insert(result, box.tuple.new(newtuple))
+            limit = limit - 1
+        end
+    end
+    return unpack(result)
+end
+---
+...
+box.space[2]:insert(1, 'tuple')
+---
+ - 1: {'tuple'}
+...
+box.space[3]:insert(1, 'tuple')
+---
+ - 1: {'tuple'}
+...
+box.space[3]:insert(2, 'tuple')
+---
+ - 2: {'tuple'}
+...
+ 
+box.crossjoin('3', '3', '0')
+---
+...
+box.crossjoin('3', '3', '5')
+---
+ - 1: {'tuple', 1, 'tuple'}
+ - 1: {'tuple', 2, 'tuple'}
+ - 2: {'tuple', 1, 'tuple'}
+ - 2: {'tuple', 2, 'tuple'}
+...
+box.crossjoin('3', '3', '10000')
+---
+ - 1: {'tuple', 1, 'tuple'}
+ - 1: {'tuple', 2, 'tuple'}
+ - 2: {'tuple', 1, 'tuple'}
+ - 2: {'tuple', 2, 'tuple'}
+...
+box.crossjoin('3', '2', '10000')
+---
+ - 1: {'tuple', 1, 'tuple'}
+ - 2: {'tuple', 1, 'tuple'}
+...
 box.space[3]:truncate()
 ---
 ...
-insert into t2 values (200, 'select me!')
-Insert OK, 1 row affected
-select * from t2 where k0 = 200
-Found 1 tuple:
-[200, 'select me!']
-select * from t2 where k0 = 199
-No match
-select * from t2 where k0 = 201
-No match
-insert into t15 values ('abcd')
-Insert OK, 1 row affected
-insert into t15 values ('abcda')
-Insert OK, 1 row affected
-insert into t15 values ('abcda_')
-Insert OK, 1 row affected
-insert into t15 values ('abcdb')
-Insert OK, 1 row affected
-insert into t15 values ('abcdb_')
-Insert OK, 1 row affected
-insert into t15 values ('abcdb__')
-Insert OK, 1 row affected
-insert into t15 values ('abcdb___')
-Insert OK, 1 row affected
-insert into t15 values ('abcdc')
-Insert OK, 1 row affected
-insert into t15 values ('abcdc_')
-Insert OK, 1 row affected
-box.space[15].index[0]:select_range(3, 'abcdb')
+-- Bug #922520 - select missing keys
+---
+...
+box.space[2]:insert(200, 'select me!')
+---
+ - 200: {'select me!'}
+...
+box.space[2]:select(0, 200)
+---
+ - 200: {'select me!'}
+...
+box.space[2]:select(0, 199)
+---
+...
+box.space[2]:select(0, 201)
+---
+...
+-- Test partially specified keys in TREE indexes
+---
+...
+box.space[15]:insert('abcd')
+---
+ - 1684234849: {}
+...
+box.space[15]:insert('abcda')
+---
+ - 'abcda': {}
+...
+box.space[15]:insert('abcda_')
+---
+ - 'abcda_': {}
+...
+box.space[15]:insert('abcdb')
+---
+ - 'abcdb': {}
+...
+box.space[15]:insert('abcdb_')
+---
+ - 'abcdb_': {}
+...
+box.space[15]:insert('abcdb__')
+---
+ - 'abcdb__': {}
+...
+box.space[15]:insert('abcdb___')
+---
+ - 6872316432586334817: {}
+...
+box.space[15]:insert('abcdc')
+---
+ - 'abcdc': {}
+...
+box.space[15]:insert('abcdc_')
+---
+ - 'abcdc_': {}
+...
+unpack(box.sort({box.space[15].index[0]:select_range(3, 'abcdb')}))
 ---
  - 'abcdb': {}
  - 'abcdb_': {}
@@ -135,149 +251,267 @@ box.space[15].index[0]:select_range(3, 'abcdb')
 box.space[15]:truncate()
 ---
 ...
+--
+-- tree::replace tests
+--
+---
+...
 box.space[22]:truncate()
 ---
 ...
-insert into t22 values (0, 0, 0, 0)
-Insert OK, 1 row affected
-insert into t22 values (1, 1, 1, 1)
-Insert OK, 1 row affected
-insert into t22 values (2, 2, 2, 2)
-Insert OK, 1 row affected
-replace into t22 values (1, 1, 1, 1)
-Replace OK, 1 row affected
-replace into t22 values (1, 10, 10, 10)
-Replace OK, 1 row affected
-replace into t22 values (1, 1, 1, 1)
-Replace OK, 1 row affected
-select * from t22 WHERE k0 = 10
-No match
-select * from t22 WHERE k1 = 10
-No match
-select * from t22 WHERE k2 = 10
-No match
-select * from t22 WHERE k3 = 10
-No match
-select * from t22 WHERE k0 = 1
-Found 1 tuple:
-[1, 1, 1, 1]
-select * from t22 WHERE k1 = 1
-Found 1 tuple:
-[1, 1, 1, 1]
-select * from t22 WHERE k2 = 1
-Found 1 tuple:
-[1, 1, 1, 1]
-select * from t22 WHERE k3 = 1
-Found 1 tuple:
-[1, 1, 1, 1]
-insert into t22 values (10, 10, 10, 10)
-Insert OK, 1 row affected
-delete from t22 WHERE k0 = 10
-Delete OK, 1 row affected
-select * from t22 WHERE k0 = 10
-No match
-select * from t22 WHERE k1 = 10
-No match
-select * from t22 WHERE k2 = 10
-No match
-select * from t22 WHERE k3 = 10
-No match
-insert into t22 values (1, 10, 10, 10)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 0'
-select * from t22 WHERE k0 = 10
-No match
-select * from t22 WHERE k1 = 10
-No match
-select * from t22 WHERE k2 = 10
-No match
-select * from t22 WHERE k3 = 10
-No match
-select * from t22 WHERE k0 = 1
-Found 1 tuple:
-[1, 1, 1, 1]
-replace into t22 values (10, 10, 10, 10)
-An error occurred: ER_TUPLE_NOT_FOUND, 'Tuple doesn't exist in index 0'
-select * from t22 WHERE k0 = 10
-No match
-select * from t22 WHERE k1 = 10
-No match
-select * from t22 WHERE k2 = 10
-No match
-select * from t22 WHERE k3 = 10
-No match
-insert into t22 values (10, 0, 10, 10)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 1'
-select * from t22 WHERE k0 = 10
-No match
-select * from t22 WHERE k1 = 10
-No match
-select * from t22 WHERE k2 = 10
-No match
-select * from t22 WHERE k3 = 10
-No match
-select * from t22 WHERE k1 = 0
-Found 1 tuple:
-[0, 0, 0, 0]
-replace into t22 values (2, 0, 10, 10)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 1'
-select * from t22 WHERE k0 = 10
-No match
-select * from t22 WHERE k1 = 10
-No match
-select * from t22 WHERE k2 = 10
-No match
-select * from t22 WHERE k3 = 10
-No match
-select * from t22 WHERE k1 = 0
-Found 1 tuple:
-[0, 0, 0, 0]
-insert into t22 values (10, 10, 10, 0)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 3'
-select * from t22 WHERE k0 = 10
-No match
-select * from t22 WHERE k1 = 10
-No match
-select * from t22 WHERE k2 = 10
-No match
-select * from t22 WHERE k3 = 10
-No match
-select * from t22 WHERE k3 = 0
-Found 1 tuple:
-[0, 0, 0, 0]
-replace into t22 values (2, 10, 10, 0)
-An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 3'
-select * from t22 WHERE k0 = 10
-No match
-select * from t22 WHERE k1 = 10
-No match
-select * from t22 WHERE k2 = 10
-No match
-select * from t22 WHERE k3 = 10
-No match
-select * from t22 WHERE k3 = 0
-Found 1 tuple:
-[0, 0, 0, 0]
-insert into t22 values (4, 4, 0, 4)
-Insert OK, 1 row affected
-insert into t22 values (5, 5, 0, 5)
-Insert OK, 1 row affected
-insert into t22 values (6, 6, 0, 6)
-Insert OK, 1 row affected
-replace into t22 values (5, 5, 0, 5)
-Replace OK, 1 row affected
-select * from t22 WHERE k2 = 0
-Found 4 tuples:
-[0, 0, 0, 0]
-[4, 4, 0, 4]
-[5, 5, 0, 5]
-[6, 6, 0, 6]
-delete from t22 WHERE k0 = 5
-Delete OK, 1 row affected
-select * from t22 WHERE k2 = 0
-Found 3 tuples:
-[0, 0, 0, 0]
-[4, 4, 0, 4]
-[6, 6, 0, 6]
+box.space[22]:insert(0, 0, 0, 0)
+---
+ - 0: {0, 0, 0}
+...
+box.space[22]:insert(1, 1, 1, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.space[22]:insert(2, 2, 2, 2)
+---
+ - 2: {2, 2, 2}
+...
+-- OK
+---
+...
+box.replace_if_exists(22, 1, 1, 1, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.replace_if_exists(22, 1, 10, 10, 10)
+---
+ - 1: {10, 10, 10}
+...
+box.replace_if_exists(22, 1, 1, 1, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.space[22]:select(0, 10)
+---
+...
+box.space[22]:select(1, 10)
+---
+...
+box.space[22]:select(2, 10)
+---
+...
+box.space[22]:select(3, 10)
+---
+...
+box.space[22]:select(0, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.space[22]:select(1, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.space[22]:select(2, 1)
+---
+ - 1: {1, 1, 1}
+...
+box.space[22]:select(3, 1)
+---
+ - 1: {1, 1, 1}
+...
+-- OK
+---
+...
+box.space[22]:insert(10, 10, 10, 10)
+---
+ - 10: {10, 10, 10}
+...
+box.space[22]:delete(10)
+---
+ - 10: {10, 10, 10}
+...
+box.space[22]:select(0, 10)
+---
+...
+box.space[22]:select(1, 10)
+---
+...
+box.space[22]:select(2, 10)
+---
+...
+box.space[22]:select(3, 10)
+---
+...
+
+-- TupleFound (primary key)
+---
+...
+box.space[22]:insert(1, 10, 10, 10)
+---
+error: 'Duplicate key exists in unique index 0'
+...
+box.space[22]:select(0, 10)
+---
+...
+box.space[22]:select(1, 10)
+---
+...
+box.space[22]:select(2, 10)
+---
+...
+box.space[22]:select(3, 10)
+---
+...
+box.space[22]:select(0, 1)
+---
+ - 1: {1, 1, 1}
+...
+-- TupleNotFound (primary key)
+---
+...
+box.replace_if_exists(22, 10, 10, 10, 10)
+---
+error: 'Tuple doesn''t exist in index 0'
+...
+box.space[22]:select(0, 10)
+---
+...
+box.space[22]:select(1, 10)
+---
+...
+box.space[22]:select(2, 10)
+---
+...
+box.space[22]:select(3, 10)
+---
+...
+-- TupleFound (key #1)
+---
+...
+box.space[22]:insert(10, 0, 10, 10)
+---
+error: 'Duplicate key exists in unique index 1'
+...
+box.space[22]:select(0, 10)
+---
+...
+box.space[22]:select(1, 10)
+---
+...
+box.space[22]:select(2, 10)
+---
+...
+box.space[22]:select(3, 10)
+---
+...
+box.space[22]:select(1, 0)
+---
+ - 0: {0, 0, 0}
+...
+-- TupleFound (key #1)
+---
+...
+box.replace_if_exists(22, 2, 0, 10, 10)
+---
+error: 'Duplicate key exists in unique index 1'
+...
+box.space[22]:select(0, 10)
+---
+...
+box.space[22]:select(1, 10)
+---
+...
+box.space[22]:select(2, 10)
+---
+...
+box.space[22]:select(3, 10)
+---
+...
+box.space[22]:select(1, 0)
+---
+ - 0: {0, 0, 0}
+...
+-- TupleFound (key #3)
+---
+...
+box.space[22]:insert(10, 10, 10, 0)
+---
+error: 'Duplicate key exists in unique index 3'
+...
+box.space[22]:select(0, 10)
+---
+...
+box.space[22]:select(1, 10)
+---
+...
+box.space[22]:select(2, 10)
+---
+...
+box.space[22]:select(3, 10)
+---
+...
+box.space[22]:select(3, 0)
+---
+ - 0: {0, 0, 0}
+...
+-- TupleFound (key #3)
+---
+...
+box.replace_if_exists(22, 2, 10, 10, 0)
+---
+error: 'Duplicate key exists in unique index 3'
+...
+box.space[22]:select(0, 10)
+---
+...
+box.space[22]:select(1, 10)
+---
+...
+box.space[22]:select(2, 10)
+---
+...
+box.space[22]:select(3, 10)
+---
+...
+box.space[22]:select(3, 0)
+---
+ - 0: {0, 0, 0}
+...
+-- Non-Uniq test (key #2)
+---
+...
+box.space[22]:insert(4, 4, 0, 4)
+---
+ - 4: {4, 0, 4}
+...
+box.space[22]:insert(5, 5, 0, 5)
+---
+ - 5: {5, 0, 5}
+...
+box.space[22]:insert(6, 6, 0, 6)
+---
+ - 6: {6, 0, 6}
+...
+box.replace_if_exists(22, 5, 5, 0, 5)
+---
+ - 5: {5, 0, 5}
+...
+unpack(box.sort({box.space[22]:select(2, 0)}))
+---
+ - 0: {0, 0, 0}
+ - 4: {4, 0, 4}
+ - 5: {5, 0, 5}
+ - 6: {6, 0, 6}
+...
+box.space[22]:delete(5)
+---
+ - 5: {5, 0, 5}
+...
+unpack(box.sort({box.space[22]:select(2, 0)}))
+---
+ - 0: {0, 0, 0}
+ - 4: {4, 0, 4}
+ - 6: {6, 0, 6}
+...
 box.space[22]:truncate()
 ---
 ...
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
+
+---
+...
diff --git a/test/big/tree_pk.test b/test/big/tree_pk.test
index 8484a4064a..62d09d0392 100644
--- a/test/big/tree_pk.test
+++ b/test/big/tree_pk.test
@@ -1,181 +1,183 @@
-# encoding: utf-8
-#
-# integer keys
-sql("insert into t2 values (1, 'tuple')")
-admin("save snapshot")
-sql("insert into t2 values (2, 'tuple 2')")
-admin("save snapshot")
-
-sql("insert into t2 values (3, 'tuple 3')")
-sql("select * from t2 where k0 = 1")
-sql("select * from t2 where k0 = 2")
-sql("select * from t2 where k0 = 3")
-
-# Cleanup
-sql("delete from t2 where k0 = 1")
-sql("delete from t2 where k0 = 2")
-sql("delete from t2 where k0 = 3")
-
-# Test incorrect keys - supplied key field type does not match index type
-# https://bugs.launchpad.net/tarantool/+bug/1072624
-sql("insert into t2 VALUES('xxxxxxx')")
-sql("insert into t2 VALUES('')")
-sql("insert into t2 VALUES('12')")
-
-# string keys
-sql("insert into t3 values ('identifier', 'tuple')")
-admin("save snapshot")
-sql("insert into t3 values ('second', 'tuple 2')")
-admin("save snapshot")
-sql("call box.select_range('3', '0', '100', 'second')")
-sql("call box.select_range('3', '0', '100', 'identifier')")
-
-sql("insert into t3 values ('third', 'tuple 3')")
-sql("select * from t3 where k0 = 'identifier'")
-sql("select * from t3 where k0 = 'second'")
-sql("select * from t3 where k0 = 'third'")
-
-# Cleanup
-sql("delete from t3 where k0 = 'identifier'")
-sql("delete from t3 where k0 = 'second'")
-sql("delete from t3 where k0 = 'third'")
-lua = """
+dofile('utils.lua');
+
+-- integer keys;
+box.space[2]:insert(1, 'tuple');
+save snapshot;
+box.space[2]:insert(2, 'tuple 2');
+save snapshot;
+
+box.space[2]:insert(3, 'tuple 3');
+box.space[2]:select(0, 1);
+box.space[2]:select(0, 2);
+box.space[2]:select(0, 3);
+
+-- Cleanup;
+box.space[2]:delete(1);
+box.space[2]:delete(2);
+box.space[2]:delete(3);
+
+-- Test incorrect keys - supplied key field type does not match index type
+-- https://bugs.launchpad.net/tarantool/+bug/1072624;
+box.space[2]:insert('xxxxxxx');
+box.space[2]:insert('');
+box.space[2]:insert('12');
+
+-- string keys;
+box.space[3]:insert('identifier', 'tuple');
+save snapshot;
+box.space[3]:insert('second', 'tuple 2');
+save snapshot;
+box.select_range('3', '0', '100', 'second');
+box.select_range('3', '0', '100', 'identifier');
+
+box.space[3]:insert('third', 'tuple 3');
+box.space[3]:select(0, 'identifier');
+box.space[3]:select(0, 'second');
+box.space[3]:select(0, 'third');
+
+-- Cleanup;
+box.space[3]:delete('identifier');
+box.space[3]:delete('second');
+box.space[3]:delete('third');
+
 function box.crossjoin(space0, space1, limit)
-  space0 = tonumber(space0)
-  space1 = tonumber(space1)
-  limit = tonumber(limit)
-  local result = {}
-  for k0, v0 in box.space[space0]:pairs() do
-    for k1, v1 in box.space[space1]:pairs() do
-      if limit <= 0 then
-        return unpack(result)
-      end
-      newtuple = {v0:unpack()}
-      for _, v in v1:pairs() do table.insert(newtuple, v) end
-      table.insert(result, newtuple)
-      limit = limit - 1
+    space0 = tonumber(space0)
+    space1 = tonumber(space1)
+    limit = tonumber(limit)
+    local result = {}
+    for k0, v0 in box.space[space0]:pairs() do
+        for k1, v1 in box.space[space1]:pairs() do
+            if limit <= 0 then
+                return unpack(result)
+            end
+            newtuple = {v0:unpack()}
+            for _, v in v1:pairs() do 
+                table.insert(newtuple, v) 
+            end
+            table.insert(result, box.tuple.new(newtuple))
+            limit = limit - 1
+        end
     end
-  end
-  return unpack(result)
-end"""
-sql("insert into t2 values (1, 'tuple')")
-sql("insert into t3 values (1, 'tuple')")
-sql("insert into t3 values (2, 'tuple')")
-admin(lua.replace('\n', ' ')) 
-sql("call box.crossjoin('3', '3', '0')")
-sql("call box.crossjoin('3', '3', '5')")
-sql("call box.crossjoin('3', '3', '10000')")
-sql("call box.crossjoin('3', '2', '10000')")
-admin("box.space[3]:truncate()")
-
-# Bug #922520 - select missing keys
-sql("insert into t2 values (200, 'select me!')")
-sql("select * from t2 where k0 = 200")
-sql("select * from t2 where k0 = 199")
-sql("select * from t2 where k0 = 201")
-
-# Test partially specified keys in TREE indexes
-sql("insert into t15 values ('abcd')")
-sql("insert into t15 values ('abcda')")
-sql("insert into t15 values ('abcda_')")
-sql("insert into t15 values ('abcdb')")
-sql("insert into t15 values ('abcdb_')")
-sql("insert into t15 values ('abcdb__')")
-sql("insert into t15 values ('abcdb___')")
-sql("insert into t15 values ('abcdc')")
-sql("insert into t15 values ('abcdc_')")
-admin("box.space[15].index[0]:select_range(3, 'abcdb')")
-admin("box.space[15]:truncate()")
-
-#
-# tree::replace tests
-#
-
-admin("box.space[22]:truncate()")
-
-sql("insert into t22 values (0, 0, 0, 0)")
-sql("insert into t22 values (1, 1, 1, 1)")
-sql("insert into t22 values (2, 2, 2, 2)")
-
-# OK
-sql("replace into t22 values (1, 1, 1, 1)")
-sql("replace into t22 values (1, 10, 10, 10)")
-sql("replace into t22 values (1, 1, 1, 1)")
-sql("select * from t22 WHERE k0 = 10")
-sql("select * from t22 WHERE k1 = 10")
-sql("select * from t22 WHERE k2 = 10")
-sql("select * from t22 WHERE k3 = 10")
-sql("select * from t22 WHERE k0 = 1")
-sql("select * from t22 WHERE k1 = 1")
-sql("select * from t22 WHERE k2 = 1")
-sql("select * from t22 WHERE k3 = 1")
-
-# OK
-sql("insert into t22 values (10, 10, 10, 10)")
-sql("delete from t22 WHERE k0 = 10")
-sql("select * from t22 WHERE k0 = 10")
-sql("select * from t22 WHERE k1 = 10")
-sql("select * from t22 WHERE k2 = 10")
-sql("select * from t22 WHERE k3 = 10")
-
-
-# TupleFound (primary key)
-sql("insert into t22 values (1, 10, 10, 10)")
-sql("select * from t22 WHERE k0 = 10")
-sql("select * from t22 WHERE k1 = 10")
-sql("select * from t22 WHERE k2 = 10")
-sql("select * from t22 WHERE k3 = 10")
-sql("select * from t22 WHERE k0 = 1")
-
-# TupleNotFound (primary key)
-sql("replace into t22 values (10, 10, 10, 10)")
-sql("select * from t22 WHERE k0 = 10")
-sql("select * from t22 WHERE k1 = 10")
-sql("select * from t22 WHERE k2 = 10")
-sql("select * from t22 WHERE k3 = 10")
-
-# TupleFound (key #1)
-sql("insert into t22 values (10, 0, 10, 10)")
-sql("select * from t22 WHERE k0 = 10")
-sql("select * from t22 WHERE k1 = 10")
-sql("select * from t22 WHERE k2 = 10")
-sql("select * from t22 WHERE k3 = 10")
-sql("select * from t22 WHERE k1 = 0")
-
-# TupleFound (key #1)
-sql("replace into t22 values (2, 0, 10, 10)")
-sql("select * from t22 WHERE k0 = 10")
-sql("select * from t22 WHERE k1 = 10")
-sql("select * from t22 WHERE k2 = 10")
-sql("select * from t22 WHERE k3 = 10")
-sql("select * from t22 WHERE k1 = 0")
-
-# TupleFound (key #3)
-sql("insert into t22 values (10, 10, 10, 0)")
-sql("select * from t22 WHERE k0 = 10")
-sql("select * from t22 WHERE k1 = 10")
-sql("select * from t22 WHERE k2 = 10")
-sql("select * from t22 WHERE k3 = 10")
-sql("select * from t22 WHERE k3 = 0")
-
-# TupleFound (key #3)
-sql("replace into t22 values (2, 10, 10, 0)")
-sql("select * from t22 WHERE k0 = 10")
-sql("select * from t22 WHERE k1 = 10")
-sql("select * from t22 WHERE k2 = 10")
-sql("select * from t22 WHERE k3 = 10")
-sql("select * from t22 WHERE k3 = 0")
-
-sql.sort = True
-# Non-Uniq test (key #2)
-sql("insert into t22 values (4, 4, 0, 4)")
-sql("insert into t22 values (5, 5, 0, 5)")
-sql("insert into t22 values (6, 6, 0, 6)")
-sql("replace into t22 values (5, 5, 0, 5)")
-sql("select * from t22 WHERE k2 = 0")
-sql("delete from t22 WHERE k0 = 5")
-sql("select * from t22 WHERE k2 = 0")
-sql.sort = False
-
-admin("box.space[22]:truncate()")
-
+    return unpack(result)
+end;
+
+box.space[2]:insert(1, 'tuple');
+box.space[3]:insert(1, 'tuple');
+box.space[3]:insert(2, 'tuple');
+ 
+box.crossjoin('3', '3', '0');
+box.crossjoin('3', '3', '5');
+box.crossjoin('3', '3', '10000');
+box.crossjoin('3', '2', '10000');
+box.space[3]:truncate();
+
+-- Bug #922520 - select missing keys;
+box.space[2]:insert(200, 'select me!');
+box.space[2]:select(0, 200);
+box.space[2]:select(0, 199);
+box.space[2]:select(0, 201);
+
+-- Test partially specified keys in TREE indexes;
+box.space[15]:insert('abcd');
+box.space[15]:insert('abcda');
+box.space[15]:insert('abcda_');
+box.space[15]:insert('abcdb');
+box.space[15]:insert('abcdb_');
+box.space[15]:insert('abcdb__');
+box.space[15]:insert('abcdb___');
+box.space[15]:insert('abcdc');
+box.space[15]:insert('abcdc_');
+unpack(box.sort({box.space[15].index[0]:select_range(3, 'abcdb')}));
+box.space[15]:truncate();
+
+--
+-- tree::replace tests
+--;
+
+box.space[22]:truncate();
+
+box.space[22]:insert(0, 0, 0, 0);
+box.space[22]:insert(1, 1, 1, 1);
+box.space[22]:insert(2, 2, 2, 2);
+
+-- OK;
+box.replace_if_exists(22, 1, 1, 1, 1);
+box.replace_if_exists(22, 1, 10, 10, 10);
+box.replace_if_exists(22, 1, 1, 1, 1);
+box.space[22]:select(0, 10);
+box.space[22]:select(1, 10);
+box.space[22]:select(2, 10);
+box.space[22]:select(3, 10);
+box.space[22]:select(0, 1);
+box.space[22]:select(1, 1);
+box.space[22]:select(2, 1);
+box.space[22]:select(3, 1);
+
+-- OK;
+box.space[22]:insert(10, 10, 10, 10);
+box.space[22]:delete(10);
+box.space[22]:select(0, 10);
+box.space[22]:select(1, 10);
+box.space[22]:select(2, 10);
+box.space[22]:select(3, 10);
+
+
+-- TupleFound (primary key);
+box.space[22]:insert(1, 10, 10, 10);
+box.space[22]:select(0, 10);
+box.space[22]:select(1, 10);
+box.space[22]:select(2, 10);
+box.space[22]:select(3, 10);
+box.space[22]:select(0, 1);
+
+-- TupleNotFound (primary key);
+box.replace_if_exists(22, 10, 10, 10, 10);
+box.space[22]:select(0, 10);
+box.space[22]:select(1, 10);
+box.space[22]:select(2, 10);
+box.space[22]:select(3, 10);
+
+-- TupleFound (key #1);
+box.space[22]:insert(10, 0, 10, 10);
+box.space[22]:select(0, 10);
+box.space[22]:select(1, 10);
+box.space[22]:select(2, 10);
+box.space[22]:select(3, 10);
+box.space[22]:select(1, 0);
+
+-- TupleFound (key #1);
+box.replace_if_exists(22, 2, 0, 10, 10);
+box.space[22]:select(0, 10);
+box.space[22]:select(1, 10);
+box.space[22]:select(2, 10);
+box.space[22]:select(3, 10);
+box.space[22]:select(1, 0);
+
+-- TupleFound (key #3);
+box.space[22]:insert(10, 10, 10, 0);
+box.space[22]:select(0, 10);
+box.space[22]:select(1, 10);
+box.space[22]:select(2, 10);
+box.space[22]:select(3, 10);
+box.space[22]:select(3, 0);
+
+-- TupleFound (key #3);
+box.replace_if_exists(22, 2, 10, 10, 0);
+box.space[22]:select(0, 10);
+box.space[22]:select(1, 10);
+box.space[22]:select(2, 10);
+box.space[22]:select(3, 10);
+box.space[22]:select(3, 0);
+
+-- Non-Uniq test (key #2);
+box.space[22]:insert(4, 4, 0, 4);
+box.space[22]:insert(5, 5, 0, 5);
+box.space[22]:insert(6, 6, 0, 6);
+box.replace_if_exists(22, 5, 5, 0, 5);
+unpack(box.sort({box.space[22]:select(2, 0)}));
+box.space[22]:delete(5);
+unpack(box.sort({box.space[22]:select(2, 0)}));
+
+box.space[22]:truncate();
+
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
diff --git a/test/big/tree_pk_multipart.result b/test/big/tree_pk_multipart.result
index 2f3294de95..2b3aaa0934 100644
--- a/test/big/tree_pk_multipart.result
+++ b/test/big/tree_pk_multipart.result
@@ -1,43 +1,96 @@
-insert into t9 values ('Vincent', 'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?')
-Insert OK, 1 row affected
-insert into t9 values ('Jules', 'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?')
-Insert OK, 1 row affected
-insert into t9 values ('Vincent', 'Jules', 1, 'No man, they got the metric system. They wouldn`t know what the f--k a Quarter Pounder is.')
-Insert OK, 1 row affected
-insert into t9 values ('Jules', 'Vincent', 1, 'Then what do they call it?')
-Insert OK, 1 row affected
-insert into t9 values ('Vincent', 'Jules', 2, 'They call it a `Royale` with cheese.')
-Insert OK, 1 row affected
-insert into t9 values ('Jules', 'Vincent', 2, 'A `Royale` with cheese!')
-Insert OK, 1 row affected
-insert into t9 values ('Vincent', 'Jules', 3, 'That`s right.')
-Insert OK, 1 row affected
-insert into t9 values ('Jules', 'Vincent', 3, 'What do they call a Big Mac?')
-Insert OK, 1 row affected
-insert into t9 values ('Vincent', 'Jules', 4, 'A Big Mac`s a Big Mac, but they call it `Le Big Mac.`')
-Insert OK, 1 row affected
-insert into t9 values ('Jules', 'Vincent', 4, '`Le Big Mac!`')
-Insert OK, 1 row affected
-insert into t9 values ('Vincent', 'Jules', 5, 'Ha, ha, ha.')
-Insert OK, 1 row affected
-insert into t9 values ('Jules', 'Vincent', 5, 'What do they call a `Whopper`?')
-Insert OK, 1 row affected
-insert into t9 values ('Vincent', 'Jules', 6, 'I dunno, I didn`t go into Burger King.')
-Insert OK, 1 row affected
-insert into t9 values ('The Wolf!', 'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.')
-Insert OK, 1 row affected
-insert into t9 values ('Vincent', 'The Wolf!', 0, 'A please would be nice.')
-Insert OK, 1 row affected
-insert into t9 values ('The Wolf!', 'Vincent', 1, 'Come again?')
-Insert OK, 1 row affected
-insert into t9 values ('Vincent', 'The Wolf!', 1, 'I said a please would be nice.')
-Insert OK, 1 row affected
-insert into t9 values ('The Wolf!', 'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.')
-Insert OK, 1 row affected
-insert into t9 values ('The Wolf!', 'Vincent', 3, 'I don`t mean any disrespect, I just don`t like people barking orders at me.')
-Insert OK, 1 row affected
-insert into t9 values ('Vincent', 'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.')
-Insert OK, 1 row affected
+--
+-- Insert test
+--
+---
+...
+box.space[9]:insert('Vincent', 'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?')
+---
+ - 'Vincent': {'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?'}
+...
+box.space[9]:insert('Jules', 'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?')
+---
+ - 'Jules': {'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?'}
+...
+box.space[9]:insert('Vincent', 'Jules', 1, 'No man, they got the metric system. They wouldn`t know what the f--k a Quarter Pounder is.')
+---
+ - 'Vincent': {'Jules', 1, 'No man, they got the metric system. They wouldn`t know what the f--k a Quarter Pounder is.'}
+...
+box.space[9]:insert('Jules', 'Vincent', 1, 'Then what do they call it?')
+---
+ - 'Jules': {'Vincent', 1, 'Then what do they call it?'}
+...
+box.space[9]:insert('Vincent', 'Jules', 2, 'They call it a `Royale` with cheese.')
+---
+ - 'Vincent': {'Jules', 2, 'They call it a `Royale` with cheese.'}
+...
+box.space[9]:insert('Jules', 'Vincent', 2, 'A `Royale` with cheese!')
+---
+ - 'Jules': {'Vincent', 2, 'A `Royale` with cheese!'}
+...
+box.space[9]:insert('Vincent', 'Jules', 3, 'That`s right.')
+---
+ - 'Vincent': {'Jules', 3, 'That`s right.'}
+...
+box.space[9]:insert('Jules', 'Vincent', 3, 'What do they call a Big Mac?')
+---
+ - 'Jules': {'Vincent', 3, 'What do they call a Big Mac?'}
+...
+box.space[9]:insert('Vincent', 'Jules', 4, 'A Big Mac`s a Big Mac, but they call it `Le Big Mac.`')
+---
+ - 'Vincent': {'Jules', 4, 'A Big Mac`s a Big Mac, but they call it `Le Big Mac.`'}
+...
+box.space[9]:insert('Jules', 'Vincent', 4, '`Le Big Mac!`')
+---
+ - 'Jules': {'Vincent', 4, '`Le Big Mac!`'}
+...
+box.space[9]:insert('Vincent', 'Jules', 5, 'Ha, ha, ha.')
+---
+ - 'Vincent': {'Jules', 5, 'Ha, ha, ha.'}
+...
+box.space[9]:insert('Jules', 'Vincent', 5, 'What do they call a `Whopper`?')
+---
+ - 'Jules': {'Vincent', 5, 'What do they call a `Whopper`?'}
+...
+box.space[9]:insert('Vincent', 'Jules', 6, 'I dunno, I didn`t go into Burger King.')
+---
+ - 'Vincent': {'Jules', 6, 'I dunno, I didn`t go into Burger King.'}
+...
+box.space[9]:insert('The Wolf!', 'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.')
+---
+ - 'The Wolf!': {'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.'}
+...
+box.space[9]:insert('Vincent', 'The Wolf!', 0, 'A please would be nice.')
+---
+ - 'Vincent': {'The Wolf!', 0, 'A please would be nice.'}
+...
+box.space[9]:insert('The Wolf!', 'Vincent', 1, 'Come again?')
+---
+ - 'The Wolf!': {'Vincent', 1, 'Come again?'}
+...
+box.space[9]:insert('Vincent', 'The Wolf!', 1, 'I said a please would be nice.')
+---
+ - 'Vincent': {'The Wolf!', 1, 'I said a please would be nice.'}
+...
+box.space[9]:insert('The Wolf!', 'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.')
+---
+ - 'The Wolf!': {'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.'}
+...
+box.space[9]:insert('The Wolf!', 'Vincent', 3, 'I don`t mean any disrespect, I just don`t like people barking orders at me.')
+---
+ - 'The Wolf!': {'Vincent', 3, 'I don`t mean any disrespect, I just don`t like people barking orders at me.'}
+...
+box.space[9]:insert('Vincent', 'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.')
+---
+ - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'}
+...
+--
+-- Select test
+--
+---
+...
+-- Select by one entry
+---
+...
 box.select(9, 0, 'Vincent', 'Jules', 0)
 ---
  - 'Vincent': {'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?'}
@@ -118,6 +171,9 @@ box.select(9, 0, 'Vincent', 'The Wolf!', 2)
 ---
  - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'}
 ...
+-- Select all messages from Vincent to Jules
+---
+...
 box.select(9, 0, 'Vincent', 'Jules')
 ---
  - 'Vincent': {'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?'}
@@ -128,6 +184,9 @@ box.select(9, 0, 'Vincent', 'Jules')
  - 'Vincent': {'Jules', 5, 'Ha, ha, ha.'}
  - 'Vincent': {'Jules', 6, 'I dunno, I didn`t go into Burger King.'}
 ...
+-- Select all messages from Jules to Vincent
+---
+...
 box.select(9, 0, 'Jules', 'Vincent')
 ---
  - 'Jules': {'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?'}
@@ -137,12 +196,18 @@ box.select(9, 0, 'Jules', 'Vincent')
  - 'Jules': {'Vincent', 4, '`Le Big Mac!`'}
  - 'Jules': {'Vincent', 5, 'What do they call a `Whopper`?'}
 ...
+-- Select all messages from Vincent to The Wolf
+---
+...
 box.select(9, 0, 'Vincent', 'The Wolf!')
 ---
  - 'Vincent': {'The Wolf!', 0, 'A please would be nice.'}
  - 'Vincent': {'The Wolf!', 1, 'I said a please would be nice.'}
  - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'}
 ...
+-- Select all messages from The Wolf to Vincent
+---
+...
 box.select(9, 0, 'The Wolf!', 'Vincent')
 ---
  - 'The Wolf!': {'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.'}
@@ -150,6 +215,9 @@ box.select(9, 0, 'The Wolf!', 'Vincent')
  - 'The Wolf!': {'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.'}
  - 'The Wolf!': {'Vincent', 3, 'I don`t mean any disrespect, I just don`t like people barking orders at me.'}
 ...
+-- Select all Vincent messages
+---
+...
 box.select(9, 0, 'Vincent')
 ---
  - 'Vincent': {'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?'}
@@ -163,6 +231,14 @@ box.select(9, 0, 'Vincent')
  - 'Vincent': {'The Wolf!', 1, 'I said a please would be nice.'}
  - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'}
 ...
+--
+-- Delete test
+--
+---
+...
+-- Delete some messages from the The Wolf and Vincent dialog
+---
+...
 box.delete(9, 'The Wolf!', 'Vincent', 0)
 ---
  - 'The Wolf!': {'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.'}
@@ -183,27 +259,47 @@ box.update(9, {'Updated', 'The Wolf!', 1}, '=p#p', 0, 'Vincent', 4, '')
 ---
  - 'Vincent': {'The Wolf!', 1, 'I said a please would be nice.'}
 ...
+-- Checking Vincent's last messages
+---
+...
 box.select(9, 0, 'Vincent', 'The Wolf!')
 ---
  - 'Vincent': {'The Wolf!', 1, 'I said a please would be nice.'}
  - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'}
 ...
+-- Checking The Wolf's last messages
+---
+...
 box.select(9, 0, 'The Wolf!', 'Vincent')
 ---
  - 'The Wolf!': {'Vincent', 1, 'Come again?'}
  - 'The Wolf!': {'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.'}
 ...
+-- try to delete nonexistent message
+---
+...
 box.delete(9, 'Vincent', 'The Wolf!', 3)
 ---
 ...
+-- try to delete patrial defined key
+---
+...
 box.delete(9, 'Vincent', 'The Wolf!')
 ---
 error: 'Invalid key part count in an exact match (expected 3, got 2)'
 ...
+-- try to delete by invalid key
+---
+...
 box.delete(9, 'The Wolf!', 'Vincent', 1, 'Come again?')
 ---
 error: 'Invalid key part count in an exact match (expected 3, got 4)'
 ...
+--
+-- Update test
+--
+---
+...
 box.update(9, {'The Wolf!', 'Vincent', 1}, '=p', 3, '<ooops>')
 ---
  - 'The Wolf!': {'Vincent', 1, '<ooops>'}
@@ -212,23 +308,38 @@ box.update(9, {'Vincent', 'The Wolf!', 1}, '=p', 3, '<ooops>')
 ---
  - 'Vincent': {'The Wolf!', 1, '<ooops>'}
 ...
+-- Checking Vincent's last messages
+---
+...
 box.select(9, 0, 'Vincent', 'The Wolf!')
 ---
  - 'Vincent': {'The Wolf!', 1, '<ooops>'}
  - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'}
 ...
+-- Checking The Wolf's last messages
+---
+...
 box.select(9, 0, 'The Wolf!', 'Vincent')
 ---
  - 'The Wolf!': {'Vincent', 1, '<ooops>'}
  - 'The Wolf!': {'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.'}
 ...
+-- try to update a nonexistent message
+---
+...
 box.update(9, {'Vincent', 'The Wolf!', 3}, '=p', 3, '<ooops>')
 ---
 ...
+-- try to update patrial defined key
+---
+...
 box.update(9, {'Vincent', 'The Wolf!'}, '=p', 3, '<ooops>')
 ---
 error: 'Invalid key part count in an exact match (expected 3, got 2)'
 ...
+-- try to update by invalid key
+---
+...
 box.update(9, {'The Wolf!', 'Vincent', 1, 'Come again?'}, '=p', 3, '<ooops>')
 ---
 error: 'Invalid key part count in an exact match (expected 3, got 4)'
@@ -244,8 +355,10 @@ box.space[9]:len()
 ---
  - 0
 ...
- A test case for Bug#1051006 Tree iterators return garbage
-if an index is modified between calls
+-- A test case for Bug#1051006 Tree iterators return garbage
+--if an index is modified between calls
+---
+...
 box.space[16]:insert('a', 'a', 'a')
 ---
  - 'a': {'a', 'a'}
@@ -266,72 +379,65 @@ box.space[16]:insert('c', 'c', 'c')
 ---
  - 'c': {'c', 'c'}
 ...
-k,v = box.space[16].index[1]:next(k)
----
-...
-print(v)
----
-'a': {'a', 'a'}
-...
-k,v = box.space[16].index[1]:next(k)
----
-...
-print(v)
+for i = 1, 2 do
+    k,v = box.space[16].index[1]:next(k)
+    print(' - ', v)
+end
 ---
-'b': {'b', 'b'}
+ - 'a': {'a', 'a'}
+ - 'b': {'b', 'b'}
 ...
 box.space[16]:truncate()
 ---
 ...
-print(v)
+v
 ---
-'b': {'b', 'b'}
+ - 'b': {'b', 'b'}
 ...
 collectgarbage('collect')
 ---
  - 0
 ...
-print(v)
+v
 ---
-'b': {'b', 'b'}
+ - 'b': {'b', 'b'}
 ...
 k,v = box.space[16].index[1]:next(k)
 ---
 ...
-print(v)
+v
 ---
-nil
+ - nil
 ...
 collectgarbage('collect')
 ---
  - 0
 ...
-print(v)
+v
 ---
-nil
+ - nil
 ...
-k,v = box.space[16].index[1]:next(k)
+for i = 1, 3 do
+    k,v = box.space[16].index[1]:next(k)
+    print(' - ', v)
+end
 ---
+ - nil
+ - nil
+ - nil
 ...
-print(v)
+-- Bug #1082356
 ---
-nil
 ...
-k,v = box.space[16].index[1]:next(k)
+box.space[19]:insert(1, 1)
 ---
+error: 'Illegal parameters, tuple must have all indexed fields'
 ...
-print(v)
----
-nil
-...
-k,v = box.space[16].index[1]:next(k)
+box.replace_if_exists(19, 1, 1)
 ---
+error: 'Illegal parameters, tuple must have all indexed fields'
 ...
-print(v)
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
+
 ---
-nil
 ...
-insert into t19 values(1, 1)
-An error occurred: ER_ILLEGAL_PARAMS, 'Illegal parameters, tuple must have all indexed fields'
-replace into t19 values(1, 1)
-An error occurred: ER_ILLEGAL_PARAMS, 'Illegal parameters, tuple must have all indexed fields'
diff --git a/test/big/tree_pk_multipart.test b/test/big/tree_pk_multipart.test
index 8df02f155a..8329c9241c 100644
--- a/test/big/tree_pk_multipart.test
+++ b/test/big/tree_pk_multipart.test
@@ -1,145 +1,146 @@
-# encoding: utf-8
-#
-
-#
-# Insert test
-#
-
-sql("insert into t9 values ('Vincent', 'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?')")
-sql("insert into t9 values ('Jules', 'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?')")
-sql("insert into t9 values ('Vincent', 'Jules', 1, 'No man, they got the metric system. They wouldn`t know what the f--k a Quarter Pounder is.')")
-sql("insert into t9 values ('Jules', 'Vincent', 1, 'Then what do they call it?')")
-sql("insert into t9 values ('Vincent', 'Jules', 2, 'They call it a `Royale` with cheese.')")
-sql("insert into t9 values ('Jules', 'Vincent', 2, 'A `Royale` with cheese!')")
-sql("insert into t9 values ('Vincent', 'Jules', 3, 'That`s right.')")
-sql("insert into t9 values ('Jules', 'Vincent', 3, 'What do they call a Big Mac?')")
-sql("insert into t9 values ('Vincent', 'Jules', 4, 'A Big Mac`s a Big Mac, but they call it `Le Big Mac.`')")
-sql("insert into t9 values ('Jules', 'Vincent', 4, '`Le Big Mac!`')")
-sql("insert into t9 values ('Vincent', 'Jules', 5, 'Ha, ha, ha.')")
-sql("insert into t9 values ('Jules', 'Vincent', 5, 'What do they call a `Whopper`?')")
-sql("insert into t9 values ('Vincent', 'Jules', 6, 'I dunno, I didn`t go into Burger King.')")
-
-sql("insert into t9 values ('The Wolf!', 'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.')")
-sql("insert into t9 values ('Vincent', 'The Wolf!', 0, 'A please would be nice.')")
-sql("insert into t9 values ('The Wolf!', 'Vincent', 1, 'Come again?')")
-sql("insert into t9 values ('Vincent', 'The Wolf!', 1, 'I said a please would be nice.')")
-sql("insert into t9 values ('The Wolf!', 'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.')")
-sql("insert into t9 values ('The Wolf!', 'Vincent', 3, 'I don`t mean any disrespect, I just don`t like people barking orders at me.')")
-sql("insert into t9 values ('Vincent', 'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.')")
-
-#
-# Select test
-#
-
-# Select by one entry
-admin("box.select(9, 0, 'Vincent', 'Jules', 0)")
-admin("box.select(9, 0, 'Jules', 'Vincent', 0)")
-admin("box.select(9, 0, 'Vincent', 'Jules', 1)")
-admin("box.select(9, 0, 'Jules', 'Vincent', 1)")
-admin("box.select(9, 0, 'Vincent', 'Jules', 2)")
-admin("box.select(9, 0, 'Jules', 'Vincent', 2)")
-admin("box.select(9, 0, 'Vincent', 'Jules', 3)")
-admin("box.select(9, 0, 'Jules', 'Vincent', 3)")
-admin("box.select(9, 0, 'Vincent', 'Jules', 4)")
-admin("box.select(9, 0, 'Jules', 'Vincent', 4)")
-admin("box.select(9, 0, 'Vincent', 'Jules', 5)")
-admin("box.select(9, 0, 'Jules', 'Vincent', 5)")
-admin("box.select(9, 0, 'Vincent', 'Jules', 6)")
-
-admin("box.select(9, 0, 'The Wolf!', 'Vincent', 0)")
-admin("box.select(9, 0, 'Vincent', 'The Wolf!', 0)")
-admin("box.select(9, 0, 'The Wolf!', 'Vincent', 1)")
-admin("box.select(9, 0, 'Vincent', 'The Wolf!', 1)")
-admin("box.select(9, 0, 'The Wolf!', 'Vincent', 2)")
-admin("box.select(9, 0, 'The Wolf!', 'Vincent', 3)")
-admin("box.select(9, 0, 'Vincent', 'The Wolf!', 2)")
-
-# Select all messages from Vincent to Jules
-admin("box.select(9, 0, 'Vincent', 'Jules')")
-
-# Select all messages from Jules to Vincent
-admin("box.select(9, 0, 'Jules', 'Vincent')")
-
-# Select all messages from Vincent to The Wolf
-admin("box.select(9, 0, 'Vincent', 'The Wolf!')")
-
-# Select all messages from The Wolf to Vincent
-admin("box.select(9, 0, 'The Wolf!', 'Vincent')")
-
-# Select all Vincent messages
-admin("box.select(9, 0, 'Vincent')")
-
-#
-# Delete test
-#
-
-# Delete some messages from the The Wolf and Vincent dialog
-admin("box.delete(9, 'The Wolf!', 'Vincent', 0)")
-admin("box.delete(9, 'The Wolf!', 'Vincent', 3)")
-admin("box.delete(9, 'Vincent', 'The Wolf!', 0)")
-
-admin("box.update(9, {'Vincent', 'The Wolf!', 1}, '=p=p', 0, 'Updated', 4, 'New')")
-admin("box.update(9, {'Updated', 'The Wolf!', 1}, '=p#p', 0, 'Vincent', 4, '')")
-# Checking Vincent's last messages
-admin("box.select(9, 0, 'Vincent', 'The Wolf!')")
-# Checking The Wolf's last messages
-admin("box.select(9, 0, 'The Wolf!', 'Vincent')")
-
-# try to delete nonexistent message
-admin("box.delete(9, 'Vincent', 'The Wolf!', 3)")
-# try to delete patrial defined key
-admin("box.delete(9, 'Vincent', 'The Wolf!')")
-# try to delete by invalid key
-admin("box.delete(9, 'The Wolf!', 'Vincent', 1, 'Come again?')")
-
-#
-# Update test
-#
-admin("box.update(9, {'The Wolf!', 'Vincent', 1}, '=p', 3, '<ooops>')")
-admin("box.update(9, {'Vincent', 'The Wolf!', 1}, '=p', 3, '<ooops>')")
-
-# Checking Vincent's last messages
-admin("box.select(9, 0, 'Vincent', 'The Wolf!')")
-# Checking The Wolf's last messages
-admin("box.select(9, 0, 'The Wolf!', 'Vincent')")
-
-# try to update a nonexistent message
-admin("box.update(9, {'Vincent', 'The Wolf!', 3}, '=p', 3, '<ooops>')")
-# try to update patrial defined key
-admin("box.update(9, {'Vincent', 'The Wolf!'}, '=p', 3, '<ooops>')")
-# try to update by invalid key
-admin("box.update(9, {'The Wolf!', 'Vincent', 1, 'Come again?'}, '=p', 3, '<ooops>')")
-admin("box.space[9]:len()")
-admin("box.space[9]:truncate()")
-admin("box.space[9]:len()")
-
-print """ A test case for Bug#1051006 Tree iterators return garbage
-if an index is modified between calls"""
-
-admin("box.space[16]:insert('a', 'a', 'a')")
-admin("box.space[16]:insert('d', 'd', 'd')")
-admin("box.space[16]:insert('e', 'e', 'e')")
-admin("box.space[16]:insert('b', 'b', 'b')")
-admin("box.space[16]:insert('c', 'c', 'c')")
-admin("k,v = box.space[16].index[1]:next(k)")
-admin("print(v)")
-admin("k,v = box.space[16].index[1]:next(k)")
-admin("print(v)")
-admin("box.space[16]:truncate()")
-admin("print(v)")
-admin("collectgarbage('collect')")
-admin("print(v)")
-admin("k,v = box.space[16].index[1]:next(k)")
-admin("print(v)")
-admin("collectgarbage('collect')")
-admin("print(v)")
-admin("k,v = box.space[16].index[1]:next(k)")
-admin("print(v)")
-admin("k,v = box.space[16].index[1]:next(k)")
-admin("print(v)")
-admin("k,v = box.space[16].index[1]:next(k)")
-admin("print(v)")
-
-# Bug #1082356
-sql("insert into t19 values(1, 1)")
-sql("replace into t19 values(1, 1)")
+--
+-- Insert test
+--;
+
+box.space[9]:insert('Vincent', 'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?');
+box.space[9]:insert('Jules', 'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?');
+box.space[9]:insert('Vincent', 'Jules', 1, 'No man, they got the metric system. They wouldn`t know what the f--k a Quarter Pounder is.');
+box.space[9]:insert('Jules', 'Vincent', 1, 'Then what do they call it?');
+box.space[9]:insert('Vincent', 'Jules', 2, 'They call it a `Royale` with cheese.');
+box.space[9]:insert('Jules', 'Vincent', 2, 'A `Royale` with cheese!');
+box.space[9]:insert('Vincent', 'Jules', 3, 'That`s right.');
+box.space[9]:insert('Jules', 'Vincent', 3, 'What do they call a Big Mac?');
+box.space[9]:insert('Vincent', 'Jules', 4, 'A Big Mac`s a Big Mac, but they call it `Le Big Mac.`');
+box.space[9]:insert('Jules', 'Vincent', 4, '`Le Big Mac!`');
+box.space[9]:insert('Vincent', 'Jules', 5, 'Ha, ha, ha.');
+box.space[9]:insert('Jules', 'Vincent', 5, 'What do they call a `Whopper`?');
+box.space[9]:insert('Vincent', 'Jules', 6, 'I dunno, I didn`t go into Burger King.');
+
+box.space[9]:insert('The Wolf!', 'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.');
+box.space[9]:insert('Vincent', 'The Wolf!', 0, 'A please would be nice.');
+box.space[9]:insert('The Wolf!', 'Vincent', 1, 'Come again?');
+box.space[9]:insert('Vincent', 'The Wolf!', 1, 'I said a please would be nice.');
+box.space[9]:insert('The Wolf!', 'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.');
+box.space[9]:insert('The Wolf!', 'Vincent', 3, 'I don`t mean any disrespect, I just don`t like people barking orders at me.');
+box.space[9]:insert('Vincent', 'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.');
+
+--
+-- Select test
+--;
+
+-- Select by one entry;
+box.select(9, 0, 'Vincent', 'Jules', 0);
+box.select(9, 0, 'Jules', 'Vincent', 0);
+box.select(9, 0, 'Vincent', 'Jules', 1);
+box.select(9, 0, 'Jules', 'Vincent', 1);
+box.select(9, 0, 'Vincent', 'Jules', 2);
+box.select(9, 0, 'Jules', 'Vincent', 2);
+box.select(9, 0, 'Vincent', 'Jules', 3);
+box.select(9, 0, 'Jules', 'Vincent', 3);
+box.select(9, 0, 'Vincent', 'Jules', 4);
+box.select(9, 0, 'Jules', 'Vincent', 4);
+box.select(9, 0, 'Vincent', 'Jules', 5);
+box.select(9, 0, 'Jules', 'Vincent', 5);
+box.select(9, 0, 'Vincent', 'Jules', 6);
+
+box.select(9, 0, 'The Wolf!', 'Vincent', 0);
+box.select(9, 0, 'Vincent', 'The Wolf!', 0);
+box.select(9, 0, 'The Wolf!', 'Vincent', 1);
+box.select(9, 0, 'Vincent', 'The Wolf!', 1);
+box.select(9, 0, 'The Wolf!', 'Vincent', 2);
+box.select(9, 0, 'The Wolf!', 'Vincent', 3);
+box.select(9, 0, 'Vincent', 'The Wolf!', 2);
+
+-- Select all messages from Vincent to Jules;
+box.select(9, 0, 'Vincent', 'Jules');
+
+-- Select all messages from Jules to Vincent;
+box.select(9, 0, 'Jules', 'Vincent');
+
+-- Select all messages from Vincent to The Wolf;
+box.select(9, 0, 'Vincent', 'The Wolf!');
+
+-- Select all messages from The Wolf to Vincent;
+box.select(9, 0, 'The Wolf!', 'Vincent');
+
+-- Select all Vincent messages;
+box.select(9, 0, 'Vincent');
+
+--
+-- Delete test
+--;
+
+-- Delete some messages from the The Wolf and Vincent dialog;
+box.delete(9, 'The Wolf!', 'Vincent', 0);
+box.delete(9, 'The Wolf!', 'Vincent', 3);
+box.delete(9, 'Vincent', 'The Wolf!', 0);
+
+box.update(9, {'Vincent', 'The Wolf!', 1}, '=p=p', 0, 'Updated', 4, 'New');
+box.update(9, {'Updated', 'The Wolf!', 1}, '=p#p', 0, 'Vincent', 4, '');
+-- Checking Vincent's last messages;
+box.select(9, 0, 'Vincent', 'The Wolf!');
+-- Checking The Wolf's last messages;
+box.select(9, 0, 'The Wolf!', 'Vincent');
+
+-- try to delete nonexistent message;
+box.delete(9, 'Vincent', 'The Wolf!', 3);
+-- try to delete patrial defined key;
+box.delete(9, 'Vincent', 'The Wolf!');
+-- try to delete by invalid key;
+box.delete(9, 'The Wolf!', 'Vincent', 1, 'Come again?');
+
+--
+-- Update test
+--;
+box.update(9, {'The Wolf!', 'Vincent', 1}, '=p', 3, '<ooops>');
+box.update(9, {'Vincent', 'The Wolf!', 1}, '=p', 3, '<ooops>');
+
+-- Checking Vincent's last messages;
+box.select(9, 0, 'Vincent', 'The Wolf!');
+-- Checking The Wolf's last messages;
+box.select(9, 0, 'The Wolf!', 'Vincent');
+
+-- try to update a nonexistent message;
+box.update(9, {'Vincent', 'The Wolf!', 3}, '=p', 3, '<ooops>');
+-- try to update patrial defined key;
+box.update(9, {'Vincent', 'The Wolf!'}, '=p', 3, '<ooops>');
+-- try to update by invalid key;
+box.update(9, {'The Wolf!', 'Vincent', 1, 'Come again?'}, '=p', 3, '<ooops>');
+box.space[9]:len();
+box.space[9]:truncate();
+box.space[9]:len();
+
+-- A test case for Bug#1051006 Tree iterators return garbage
+--if an index is modified between calls;
+
+box.space[16]:insert('a', 'a', 'a');
+box.space[16]:insert('d', 'd', 'd');
+box.space[16]:insert('e', 'e', 'e');
+box.space[16]:insert('b', 'b', 'b');
+box.space[16]:insert('c', 'c', 'c');
+
+for i = 1, 2 do
+    k,v = box.space[16].index[1]:next(k)
+    print(' - ', v)
+end;
+
+box.space[16]:truncate();
+v;
+collectgarbage('collect');
+v;
+
+k,v = box.space[16].index[1]:next(k);
+v;
+collectgarbage('collect');
+v;
+
+for i = 1, 3 do
+    k,v = box.space[16].index[1]:next(k)
+    print(' - ', v)
+end;
+
+-- Bug #1082356;
+box.space[19]:insert(1, 1);
+box.replace_if_exists(19, 1, 1);
+
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
diff --git a/test/big/tree_variants.result b/test/big/tree_variants.result
index d29b54249b..02d326d1c8 100644
--- a/test/big/tree_variants.result
+++ b/test/big/tree_variants.result
@@ -1,34 +1,57 @@
-insert into t6 values (0, '00000000', '00000100', 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000 )
-Insert OK, 1 row affected
-insert into t6 values (1, '00000001', '00000200', 'Joe', 'Sixpack', 'Drinks', 'Heineken', 'bar', 2001 )
-Insert OK, 1 row affected
-insert into t6 values (2, '00000002', '00000200', 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002 )
-Insert OK, 1 row affected
-insert into t6 values (3, '00000003', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003 )
-Insert OK, 1 row affected
-insert into t6 values (4, '00000004', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004 )
-Insert OK, 1 row affected
-insert into t6 values (5, '00000005', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005 )
-Insert OK, 1 row affected
-insert into t6 values (6, '00000006', '00000400', 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006 )
-Insert OK, 1 row affected
-insert into t6 values (7, '00000007', '00000400', 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007 )
-Insert OK, 1 row affected
-insert into t6 values (8, '00000008', '00000400', 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008 )
-Insert OK, 1 row affected
-insert into t6 values (9, '00000009', '00000400', 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009 )
-Insert OK, 1 row affected
-select * from t6 where k0 = 1
-Found 1 tuple:
-[1, '00000001', '00000200', 'Joe', 'Sixpack', 'Drinks', 'Heineken', 'bar', 2001]
-select * from t6 where k1 = '00000002'
-Found 1 tuple:
-[2, '00000002', '00000200', 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002]
-select * from t6 where k2 = '00000300'
-Found 3 tuples:
-[3, '00000003', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003]
-[4, '00000004', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004]
-[5, '00000005', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005]
+box.space[6]:insert(0, '00000000', '00000100', 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000)
+---
+ - 0: {3472328296227680304, 3472329395739308080, 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000}
+...
+box.space[6]:insert(1, '00000001', '00000200', 'Joe', 'Sixpack', 'Drinks', 'Heineken', 'bar', 2001)
+---
+ - 1: {3544385890265608240, 3472330495250935856, 'Joe', 'Sixpack', 'Drinks', 7954882400208119112, 'bar', 2001}
+...
+box.space[6]:insert(2, '00000002', '00000200', 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002)
+---
+ - 2: {3616443484303536176, 3472330495250935856, 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002}
+...
+box.space[6]:insert(3, '00000003', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003)
+---
+ - 3: {3688501078341464112, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003}
+...
+box.space[6]:insert(4, '00000004', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004)
+---
+ - 4: {3760558672379392048, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004}
+...
+box.space[6]:insert(5, '00000005', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005)
+---
+ - 5: {3832616266417319984, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005}
+...
+box.space[6]:insert(6, '00000006', '00000400', 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006)
+---
+ - 6: {3904673860455247920, 3472332694274191408, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006}
+...
+box.space[6]:insert(7, '00000007', '00000400', 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007)
+---
+ - 7: {3976731454493175856, 3472332694274191408, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007}
+...
+box.space[6]:insert(8, '00000008', '00000400', 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008)
+---
+ - 8: {4048789048531103792, 3472332694274191408, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008}
+...
+box.space[6]:insert(9, '00000009', '00000400', 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009)
+---
+ - 9: {4120846642569031728, 3472332694274191408, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009}
+...
+box.space[6]:select(0, 1)
+---
+ - 1: {3544385890265608240, 3472330495250935856, 'Joe', 'Sixpack', 'Drinks', 7954882400208119112, 'bar', 2001}
+...
+box.space[6]:select(1,'00000002')
+---
+ - 2: {3616443484303536176, 3472330495250935856, 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002}
+...
+box.space[6]:select(2,'00000300')
+---
+ - 3: {3688501078341464112, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003}
+ - 4: {3760558672379392048, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004}
+ - 5: {3832616266417319984, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005}
+...
 box.space[6]:select(3, 'Joe', 'Sixpack')
 ---
  - 0: {3472328296227680304, 3472329395739308080, 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000}
@@ -53,77 +76,104 @@ box.space[6]:select(4, 'Miller Genuine Draft', 'Drinks')
 ---
  - 5: {3832616266417319984, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005}
 ...
-select * from t6 where k5 = 2007
-Found 1 tuple:
-[7, '00000007', '00000400', 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007]
+box.space[6]:select(5, 2007)
+---
+ - 7: {3976731454493175856, 3472332694274191408, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007}
+...
 box.space[6]:select(6, 'Miller Genuine Draft', 'Drinks')
 ---
  - 5: {3832616266417319984, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005}
 ...
-delete from t6 where k0 = 6
-Delete OK, 1 row affected
-delete from t6 where k0 = 7
-Delete OK, 1 row affected
-delete from t6 where k0 = 8
-Delete OK, 1 row affected
-delete from t6 where k0 = 9
-Delete OK, 1 row affected
-box.insert(6, 6, 6ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006 )
+box.space[6]:delete(6)
+---
+ - 6: {3904673860455247920, 3472332694274191408, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006}
+...
+box.space[6]:delete(7)
+---
+ - 7: {3976731454493175856, 3472332694274191408, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007}
+...
+box.space[6]:delete(8)
+---
+ - 8: {4048789048531103792, 3472332694274191408, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008}
+...
+box.space[6]:delete(9)
+---
+ - 9: {4120846642569031728, 3472332694274191408, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009}
+...
+box.space[6]:insert(6, 6ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006)
 ---
  - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006}
 ...
-box.insert(6, 7, 7ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007 )
+box.space[6]:insert(7, 7ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007)
 ---
  - 7: {7, 400, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007}
 ...
-box.insert(6, 8, 8ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008 )
+box.space[6]:insert(8, 8ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008)
 ---
  - 8: {8, 400, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008}
 ...
-box.insert(6, 9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009 )
+box.space[6]:insert(9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009)
 ---
  - 9: {9, 400, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009}
 ...
-box.select(6, 1, 6ULL)
+box.space[6]:select(1, 6ULL)
 ---
  - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006}
 ...
-box.select(6, 1, 6)
+box.space[6]:select(1, 6)
 ---
  - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006}
 ...
-box.select(6, 2, 400ULL)
+box.space[6]:select(2, 400ULL)
+---
+ - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006}
+ - 7: {7, 400, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007}
+ - 8: {8, 400, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008}
+ - 9: {9, 400, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009}
+...
+box.space[6]:select(2, 400)
 ---
  - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006}
  - 7: {7, 400, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007}
  - 8: {8, 400, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008}
  - 9: {9, 400, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009}
 ...
-box.select(6, 2, 400)
+for k,v in box.space[6]:pairs() do
+    print(' - ', v)
+end
 ---
+ - 0: {3472328296227680304, 3472329395739308080, 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000}
+ - 1: {3544385890265608240, 3472330495250935856, 'Joe', 'Sixpack', 'Drinks', 7954882400208119112, 'bar', 2001}
+ - 2: {3616443484303536176, 3472330495250935856, 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002}
+ - 3: {3688501078341464112, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003}
+ - 4: {3760558672379392048, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004}
+ - 5: {3832616266417319984, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005}
  - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006}
  - 7: {7, 400, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007}
  - 8: {8, 400, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008}
  - 9: {9, 400, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009}
 ...
-for k,v in box.space[6]:pairs() do print(v) end
----
-0: {3472328296227680304, 3472329395739308080, 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000}
-1: {3544385890265608240, 3472330495250935856, 'Joe', 'Sixpack', 'Drinks', 7954882400208119112, 'bar', 2001}
-2: {3616443484303536176, 3472330495250935856, 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002}
-3: {3688501078341464112, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003}
-4: {3760558672379392048, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004}
-5: {3832616266417319984, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005}
-6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006}
-7: {7, 400, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007}
-8: {8, 400, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008}
-9: {9, 400, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009}
-...
-insert into t6 VALUES('', '00000001', '00000002', '', '', '', '', '', 0)
-An error occurred: ER_KEY_FIELD_TYPE, 'Supplied key field type does not match index type: expected NUM'
-insert into t6 VALUES('xxxxxxxx', '00000001', '00000002', '', '', '', '', '', 0)
-An error occurred: ER_KEY_FIELD_TYPE, 'Supplied key field type does not match index type: expected NUM'
-insert into t6 VALUES(1, '', '00000002', '', '', '', '', '', 0)
-An error occurred: ER_KEY_FIELD_TYPE, 'Supplied key field type does not match index type: expected NUM64'
-insert into t6 VALUES(1, 'xxxxxxxxxxx', '00000002', '', '', '', '', '', 0)
-An error occurred: ER_KEY_FIELD_TYPE, 'Supplied key field type does not match index type: expected NUM64'
+-- Test incorrect keys - supplied key field type does not match index type
+-- https://bugs.launchpad.net/tarantool/+bug/1072624
+---
+...
+box.space[6]:insert('', '00000001', '00000002', '', '', '', '', '', 0)
+---
+error: 'Supplied key field type does not match index type: expected NUM'
+...
+box.space[6]:insert('xxxxxxxx', '00000001', '00000002', '', '', '', '', '', 0)
+---
+error: 'Supplied key field type does not match index type: expected NUM'
+...
+box.space[6]:insert(1, '', '00000002', '', '', '', '', '', 0)
+---
+error: 'Supplied key field type does not match index type: expected NUM64'
+...
+box.space[6]:insert(1, 'xxxxxxxxxxx', '00000002', '', '', '', '', '', 0)
+---
+error: 'Supplied key field type does not match index type: expected NUM64'
+...
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
+
+---
+...
diff --git a/test/big/tree_variants.test b/test/big/tree_variants.test
index 21133d6052..b52125d7df 100644
--- a/test/big/tree_variants.test
+++ b/test/big/tree_variants.test
@@ -1,47 +1,48 @@
-# encoding: utf-8
-#
+box.space[6]:insert(0, '00000000', '00000100', 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000);
+box.space[6]:insert(1, '00000001', '00000200', 'Joe', 'Sixpack', 'Drinks', 'Heineken', 'bar', 2001);
+box.space[6]:insert(2, '00000002', '00000200', 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002);
+box.space[6]:insert(3, '00000003', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003);
+box.space[6]:insert(4, '00000004', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004);
+box.space[6]:insert(5, '00000005', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005);
+box.space[6]:insert(6, '00000006', '00000400', 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006);
+box.space[6]:insert(7, '00000007', '00000400', 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007);
+box.space[6]:insert(8, '00000008', '00000400', 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008);
+box.space[6]:insert(9, '00000009', '00000400', 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009);
 
-sql("insert into t6 values (0, '00000000', '00000100', 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000 )")
-sql("insert into t6 values (1, '00000001', '00000200', 'Joe', 'Sixpack', 'Drinks', 'Heineken', 'bar', 2001 )")
-sql("insert into t6 values (2, '00000002', '00000200', 'Joe', 'Sixpack', 'Drinks', 'Carlsberg', 'bar', 2002 )")
-sql("insert into t6 values (3, '00000003', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003 )")
-sql("insert into t6 values (4, '00000004', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004 )")
-sql("insert into t6 values (5, '00000005', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005 )")
-sql("insert into t6 values (6, '00000006', '00000400', 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006 )")
-sql("insert into t6 values (7, '00000007', '00000400', 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007 )")
-sql("insert into t6 values (8, '00000008', '00000400', 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008 )")
-sql("insert into t6 values (9, '00000009', '00000400', 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009 )")
+box.space[6]:select(0, 1);
+box.space[6]:select(1,'00000002');
+box.space[6]:select(2,'00000300');
+box.space[6]:select(3, 'Joe', 'Sixpack');
+box.space[6]:select(3, 'John');
+box.space[6]:select(4, 'A Pipe');
+box.space[6]:select(4, 'Miller Genuine Draft', 'Drinks');
+box.space[6]:select(5, 2007);
+box.space[6]:select(6, 'Miller Genuine Draft', 'Drinks');
 
-sql("select * from t6 where k0 = 1")
-sql("select * from t6 where k1 = '00000002'")
-sql("select * from t6 where k2 = '00000300'")
-admin("box.space[6]:select(3, 'Joe', 'Sixpack')")
-admin("box.space[6]:select(3, 'John')")
-admin("box.space[6]:select(4, 'A Pipe')")
-admin("box.space[6]:select(4, 'Miller Genuine Draft', 'Drinks')")
-sql("select * from t6 where k5 = 2007")
-admin("box.space[6]:select(6, 'Miller Genuine Draft', 'Drinks')")
+box.space[6]:delete(6);
+box.space[6]:delete(7);
+box.space[6]:delete(8);
+box.space[6]:delete(9);
 
-sql("delete from t6 where k0 = 6")
-sql("delete from t6 where k0 = 7")
-sql("delete from t6 where k0 = 8")
-sql("delete from t6 where k0 = 9")
+box.space[6]:insert(6, 6ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006);
+box.space[6]:insert(7, 7ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007);
+box.space[6]:insert(8, 8ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008);
+box.space[6]:insert(9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009);
 
-admin("box.insert(6, 6, 6ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006 )")
-admin("box.insert(6, 7, 7ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007 )")
-admin("box.insert(6, 8, 8ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008 )")
-admin("box.insert(6, 9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009 )")
+box.space[6]:select(1, 6ULL);
+box.space[6]:select(1, 6);
+box.space[6]:select(2, 400ULL);
+box.space[6]:select(2, 400);
 
-admin("box.select(6, 1, 6ULL)")
-admin("box.select(6, 1, 6)")
-admin("box.select(6, 2, 400ULL)")
-admin("box.select(6, 2, 400)")
+for k,v in box.space[6]:pairs() do
+    print(' - ', v)
+end;
 
-admin("for k,v in box.space[6]:pairs() do print(v) end")
+-- Test incorrect keys - supplied key field type does not match index type
+-- https://bugs.launchpad.net/tarantool/+bug/1072624;
+box.space[6]:insert('', '00000001', '00000002', '', '', '', '', '', 0);
+box.space[6]:insert('xxxxxxxx', '00000001', '00000002', '', '', '', '', '', 0);
+box.space[6]:insert(1, '', '00000002', '', '', '', '', '', 0);
+box.space[6]:insert(1, 'xxxxxxxxxxx', '00000002', '', '', '', '', '', 0);
 
-# Test incorrect keys - supplied key field type does not match index type
-# https://bugs.launchpad.net/tarantool/+bug/1072624
-sql("insert into t6 VALUES('', '00000001', '00000002', '', '', '', '', '', 0)")
-sql("insert into t6 VALUES('xxxxxxxx', '00000001', '00000002', '', '', '', '', '', 0)")
-sql("insert into t6 VALUES(1, '', '00000002', '', '', '', '', '', 0)")
-sql("insert into t6 VALUES(1, 'xxxxxxxxxxx', '00000002', '', '', '', '', '', 0)")
+-- vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 syntax=lua
-- 
GitLab